How do I obtain root thread priority (on non-root user)?
Okay, So I need this program I'm working on to run at the highest possible priority (the threads need to have root-like priority). How does a non-root user go about obtaining root priorities for the threads created in this program? This is to ensure the functionality of the program without the need to login as root every time.
Thanks for any advice or help! -Paintballer1016 |
|
Can I obtain ROOT priority with nice/renice?
|
Assuming you are the root user, you can set your process to any priority you desire.
|
Sorry, I somehow missed the non-root user part. As an unprivileged user, you are unable to set process priority higher than the current process priority. If you need that high priority, start the process as root (perhaps via sudo).
|
I need a password-free solution to this problem (i.e. with Sudo, its similar to logging in as root). Any other suggestions?
|
Set up sudo to not require a password for that command via the NOPASSWD flag in sudoers. You MUST have root privileges to elevate priorities.
|
There is no way to transparently obtain this priority level? The thing is, if I have to execute something (such as using sudo), I might as well be logging in as root. Any thoughts?
|
You are basically looking to circumvent a significant kernel security feature. At *SOME* point, SOME command is getting executed to launch this. Make sure you start it as root, give high priority with nice, and then drop permissions to a normal user.
|
"and then drop permissions to a normal user."
Could you give more detail on how to go about this please? |
I would use setuid(), which takes the user id of the user to switch to. You can obtain the user id from the getpw* family of functions, such as getpwnam(char *name).
|
Again, is there a more permanent option? (transparent)
The less work, the better. |
All times are GMT -5. The time now is 03:41 AM. |