Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute without sudo #680

Closed
Baptiste-Garcin opened this issue Aug 13, 2018 · 6 comments
Closed

Execute without sudo #680

Baptiste-Garcin opened this issue Aug 13, 2018 · 6 comments

Comments

@Baptiste-Garcin
Copy link

Hi,

Thanks for this awsome library.

I would like to know if there is a way to run binary without sudo-ing ?

@hzeller
Copy link
Owner

hzeller commented Aug 13, 2018

No, as the hardware needs to be initialized, which only works as root. However, by default the library will switch back the user to a safe default after the initialization, so the root-exposure is short.

If you can't run with sudo, you might try setuid root the binary.

@JokerCatz
Copy link

I tried use C lang create a unix socket server and use Golang send package to C , it only C part need root , and it worked : )

@JokerCatz
Copy link

I upload my C lang server and Golang client here : )

https://gist.github.com/JokerCatz/b39143861480ef174069bc5c718b142c
https://gist.github.com/JokerCatz/9790290776b71f7cff41f7bd060cd83b

@boilerbots
Copy link

There is a solution, I just implemented it.

First open /dev/gpiomem instead of /dev/mem, now you can run without root privileges.

Second thing that requires root is changing the priority level of the scheduler. For this you can simply do sudo setcap 'cap_sys_nice=eip' $@ in the makefile after the final linking.

@hzeller
Copy link
Owner

hzeller commented Jun 9, 2019 via email

@boilerbots
Copy link

On Sat, 8 Jun 2019 at 17:39, boilerbots @.***> wrote: There is a solution, I just implemented it. First open /dev/gpiomem instead of /dev/mem, now you can run without root privileges.
Does it work also with the other parts needed to do hardware pulse output ?
Second thing that requires root is changing the priority level of the
scheduler. For this you can simply do sudo setcap 'cap_sys_nice=eip' $@ in the makefile after the final linking.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <#680?email_source=notifications&email_token=AABCNCOLYWC2G6J7T5DKIZ3PZRGNHA5CNFSM4FPNDEZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXIBGFY#issuecomment-500175639>, or mute the thread https://github.com/notifications/unsubscribe-auth/AABCNCJR5OACCY5AWMXUYELPZRGNHANCNFSM4FPNDEZA .

Good question, I am running with --led-no-hardware-pulse because I am trying to preserve the audio. I suspect it won't but I haven't looked into that.

@hzeller hzeller closed this as completed in 7fdbf1e Jul 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants