Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Permissions issue?

Thu Aug 09, 2018 3:25 pm

I think I have a "permissions" issue.

I created a new user... I didn't want to do everything in user pi, that being an intruder's first port of call. My "alternate user" will be, I hope, as powerful, mostly, so LIMITED protection, I know. But maybe "a hassle too far" for the intruder.

I then installed Lazarus on my system, as my alt user, let's call it "xyz".

And, because that was the advice, added that user as follows...

sudo adduser pi gpio
sudo adduser pi i2c
sudo adduser pi spi

I then tried to use the "basic"/ "recommended" approach to accessing the Pi's GPIO pins under Lazarus...

http://wiki.freepascal.org/Lazarus_on_R ... are_access

... which involves what appear to be, nominally, writes to files...

fileDesc := fpopen('/sys/class/gpio/gpio17/value', O_WrOnly);
gReturnCode := fpwrite(fileDesc, PIN_ON[0], 1);

... but the call to fpopen returned an error code which I've yet to fully decode, but the bottom line was that my attempt to "open the file" failed.

===
So! That's where I am. (Please let's not get too much into the pros and cons of the alternate user?) Any thoughts on the best (other) places to put my energies in hopes of finding what's blocking my path to success?

I half understand that the Raspbian file system has a wondrously complex (I mean that as praise!) system of permissions. Am I right in thinking that what a user can do depends on lots of things? Who "owns" the directory/ file concerned, for instance. On what user is asking to do things. On what groups that user belongs to.

If a GROUP has the right permission, and a user is a member of that group, the user has permission?

Do permissions get inherited by subordinate folders? (I.e. if I have write permission for the GPIO folder, do I have write permission for files in folders INSIDE gpio?

I'm not too lazy to read... any suggestions for good tutorials on permissions will be eagerly pursued.
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

k-pi
Posts: 930
Joined: Sun Feb 12, 2017 1:46 pm
Location: Upper Hale, Surrey, UK.

Re: Permissions issue?

Thu Aug 09, 2018 6:47 pm

Adding a new user to a RPi isn't as easy as a normal Linux, from what I have read, you need to make sure your new user is a member of all the groups that pi is a member of. If you enter 'groups' in a terminal as the pi user, it will show you the groups your new user needs to be a member of.

Here's a nudge on your journey to understanding 'permissions'.
https://www.linux.com/learn/understandi ... ermissions

Sheepdog
Posts: 16
Joined: Sun Aug 21, 2016 7:44 pm

Re: Permissions issue?

Fri Aug 10, 2018 2:25 am

k-pi... very helpful...thank you. I hadn't known how to find out what groups pi was part of. And the article very clear, very helpful.

Your encouragement gave me the energy to struggle on. First I found http://www.auctoris.co.uk/2012/07/19/gp ... pberry-pi/... a good discussion of setting/ clearing GPIO pins from the CLI

.. and it worked, and I could see the connection between that and the by Lazarus approach I was attempting... the "basic" approach set out at http://wiki.freepascal.org/Lazarus_on_R ... are_access

Then found a long discussion, very germane to my experiences at https://forum.lazarus.freepascal.org/in ... ic=39177.0

Well down that was "the answer" to what had scuppered my attempts. A sleep(1000); in the FormActivate handler, just after the

Code: Select all

fileDesc := fpopen('/sys/class/gpio/export', O_WrOnly);
    gReturnCode := fpwrite(fileDesc, PIN_17[0], 2);
... does the trick! Hurrah. So though I probably had enough permissions already. "fixing" the rest of my alternate, non-"pi", user is something I am glad of, and the article helped. Between them, I felt energized to tackle the problem again, and get to the "make it work" part. So now I can toggle an LED's state. Will mastering reading a pin configured for input take as long. Please no!
New to Pi and Linux generally... old to computers. Using Raspbian 9 (Stretch) on a Pi 3 B (ver 1.2), apt-get update, apt-get upgrade at least as recently as 5 Aug 2018

k-pi
Posts: 930
Joined: Sun Feb 12, 2017 1:46 pm
Location: Upper Hale, Surrey, UK.

Re: Permissions issue?

Fri Aug 10, 2018 9:23 am

You're welcome - I only use my RPi as desktop substitute, so the rest of it goes over my head, but glad you're on your way. ;)

Return to “Beginners”