technion / lol_dht22

A Raspberry Pi DHT22/AM2302 polling application
81 stars 64 forks source link

lockfile.h - add /lock an loldht runs without sudo #16

Closed floriandd2ba closed 5 years ago

floriandd2ba commented 5 years ago

Hi,

please change lockfile.h:

define LOCKFILE "/var/run/lock/dht.lock"

Because with this change, loldht can execute without root-permissions. I thing, this directory has the permission for all users to write a file, not only root.

THX Florian

technion commented 5 years ago

When I last visited this, wiringPi required root permissions to access the GPIO ports.

Has something changed here?

floriandd2ba commented 5 years ago

Hi, i think wiringpi use the suid flag. gpio works without sudo. The gpio command is designed to be installed as a setuid program and called by a normal user without using the sudo command or logging in as root. from http://wiringpi.com/the-gpio-utility/

technion commented 5 years ago

As you point out, the gpio command is setuid root so that it runs without sudo. This is consistent with my understanding that GPIO access requires root access. Our code doesn't execute the gpio command, and similarly requires root access.

jgtaylor commented 5 years ago

root access is required to access /dev/kmem to directly toggle the associated GPIO register(s).

On Tue, Aug 27, 2019 at 6:41 AM Joshua Small notifications@github.com wrote:

As you point out, the gpio command is setuid root so that it runs without sudo. This is consistent with my understanding that GPIO access requires root access. Our code doesn't execute the gpio command, and similarly requires root access.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/technion/lol_dht22/issues/16?email_source=notifications&email_token=ADAQWMCOZDDRHMBJFF6G5TDQGSV57A5CNFSM4IPKPWS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5GOSSY#issuecomment-525134155, or mute the thread https://github.com/notifications/unsubscribe-auth/ADAQWMCUOL2WPFQ3WGWOKJLQGSV57ANCNFSM4IPKPWSQ .

floriandd2ba commented 5 years ago

In DHT22.c ist this flag lock: 0 disables the lockfile (for running as non-root user)\n",argv[0]);

I think this a another workaround for non-Root use

This flag see i After Open this issue

floriandd2ba commented 5 years ago

And with this Chance loldht works for me without sudo now

technion commented 5 years ago

loldht calls wiringPi. As @jgtaylor points out, that call must be done as root.

There's certainly scope for privilege separation regarding the maths done outside the wiringPi calls, but that's out of scope of this issue.