A complication here is how you are using the pins. If you use a library that uses
mmap(), neither method here will work for you. I do not know which libraries do not do this -- most of them do. However, you only need to use such a library if you want the web server to be able to set the pull up/down resistors or one of the pi-specific modes. If all you need to do is check/set the state (high/low) or direction (in/out) you can use the
/sys/class/gpio interface directly (i.e., no library), and both these methods will work.
Does gpio-admin do basically the same thing or is there more too it?
It does something pretty similar only on a pin by pin basis; you'll notice it also requires you create a
gpio group and add users to it.
One thing it does which is not possible the other way is allow non-privileged users to manipulate the pull up/down resistors (but you must use
gpio-admin to do so); this is done by setting the the setuid bit on the executable. There is a potential security risk in that it means the program actually runs as root, regardless of who executes it. There is a necessity for such binaries on the system (e.g.,
passwd), but you must take care to ensure that the executable itself is not writable by anyone except root, otherwise they can replace/alter it and use it to do whatever they want. The
make install should do that (which you should run as root or via sudo).
I'm not sure of the route to take
Probably the safest/most paranoid way to allow for this is to export the individual pins and make them owned by the server user, e.g.:
export 26 > /sys/class/gpio/export
chown -R httpd /sys/devices/virtual/gpio/gpio26
You need to use the
devices/virtual path in the second command instead of
chmod (fortunately) will not follow symlinks. The
httpd username is just an example.
That needs to be done root;
/etc/rc.local, if your system has one, is a good place to do this (it will be done at boot by init).
Again, this will only work for manipulating the GPIOs via that interface (which doesn't include stuff like setting the pull up/down resistors). If you need to do something requiring one of the pi-specialized libraries, you will have to use a setuid binary in the manner of