LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-23-2007, 09:17 AM   #1
paintballer1016
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Rep: Reputation: 0
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
 
Old 07-23-2007, 09:26 AM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,174
Blog Entries: 4

Rep: Reputation: 428Reputation: 428Reputation: 428Reputation: 428Reputation: 428
Have you looked at the nice priority or renice?
 
Old 07-23-2007, 12:42 PM   #3
paintballer1016
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Can I obtain ROOT priority with nice/renice?
 
Old 07-23-2007, 01:00 PM   #4
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
Assuming you are the root user, you can set your process to any priority you desire.
 
Old 07-23-2007, 01:05 PM   #5
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
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).
 
Old 07-23-2007, 01:32 PM   #6
paintballer1016
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
I need a password-free solution to this problem (i.e. with Sudo, its similar to logging in as root). Any other suggestions?
 
Old 07-23-2007, 01:38 PM   #7
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
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.
 
Old 07-24-2007, 01:06 PM   #8
paintballer1016
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
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?
 
Old 07-24-2007, 01:13 PM   #9
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
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.
 
Old 07-24-2007, 01:17 PM   #10
paintballer1016
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
"and then drop permissions to a normal user."

Could you give more detail on how to go about this please?
 
Old 07-24-2007, 01:28 PM   #11
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
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).
 
Old 07-24-2007, 02:02 PM   #12
paintballer1016
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Again, is there a more permanent option? (transparent)

The less work, the better.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding root privaliges to user accounts or auto login as root Val-Ent Linux - General 15 03-02-2010 04:27 PM
How could normal user obtain root password or change root password ckamheng Debian 18 02-18-2009 10:28 PM
why lftp command run failed when user isn't root, but ok when logining as root steven_yu Linux - Software 0 06-06-2007 08:36 PM
Scanner to work as USER and not forced as ROOT Root (Suse 9.1) 1kyle Linux - Hardware 0 07-10-2004 08:51 AM
IntelliMouse thumb buttons work as root, broken as non-root user, wheel works always digital vortex Linux - Hardware 7 03-02-2004 04:14 PM


All times are GMT -5. The time now is 01:53 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration