How do I change the user that my c program identifies itself as?
A command-line tool I want to invoke automatically requires to be run as a specific user and won't work otherwise.
I have tried using setuid(0)
but I still don't get the desired results.
The user I want to imitate is not 'root', but a normal unprivileged, shell-less user. I want to be able to run the binary logged in as the user nobody. I was able to concoct a solution as 'root' using:
su -ls /bin/bash -c /binary
(superuser)
However I want to be able to achieve the same logged in as user nobody
Is there something I'm missing?
If anyone could just become root by putting setuid(0);
in their program, Unix would be, well, Windows.
Some thoughts:
sudo
permissions for it and running it via sudo.Given the very basic question you're asking, you should not even attempt to write code that will run as root, so I've omitted any details about how to setup root permissions for your program.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With