I am trying to execute a C program from multiple users and trying to login as other user within the program to access a file. But I am getting error
setuid: Operation not permitted
Can I do something such I needn't to use sudo every time? Like, giving full access to the program to use setuid as it wants without calling sudo everytime?
Depending on the system, and your privileges in it, you might be able to change the owner or group of the program to one that has privileges to setuid, and then set the setuid or setgid mode on the executable via chmod:
chgrp wheel my-awesome-program
chmod g+s my-awesome-program
or
chown superduperuser my-awesome-program
chmod u+s my-awesome-program
Please be aware that by doing so, you create a potential security hole. If someone can overwrite your program, they could use it to gain privileges. Do this with caution.
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