LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How do I obtain root thread priority (on non-root user)? (https://www.linuxquestions.org/questions/linux-general-1/how-do-i-obtain-root-thread-priority-on-non-root-user-571616/)

paintballer1016 07-23-2007 09:17 AM

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

XavierP 07-23-2007 09:26 AM

Have you looked at the nice priority or renice?

paintballer1016 07-23-2007 12:42 PM

Can I obtain ROOT priority with nice/renice?

Matir 07-23-2007 01:00 PM

Assuming you are the root user, you can set your process to any priority you desire.

Matir 07-23-2007 01:05 PM

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).

paintballer1016 07-23-2007 01:32 PM

I need a password-free solution to this problem (i.e. with Sudo, its similar to logging in as root). Any other suggestions?

Matir 07-23-2007 01:38 PM

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.

paintballer1016 07-24-2007 01:06 PM

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?

Matir 07-24-2007 01:13 PM

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.

paintballer1016 07-24-2007 01:17 PM

"and then drop permissions to a normal user."

Could you give more detail on how to go about this please?

Matir 07-24-2007 01:28 PM

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).

paintballer1016 07-24-2007 02:02 PM

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.