LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 02-13-2010, 10:58 AM   #1
Gruik
LQ Newbie
 
Registered: Sep 2006
Location: France (33)
Distribution: Arch
Posts: 10

Rep: Reputation: 0
About real UID and forking


Hi,

I'm thinking of designing a software that may need to change the current user to a normal user if run as root. But from what i've read, you can still switch back to root if you were root in the first place (meaning, the real UID is 0). I'd like to make this impossible.
I think the solution is forking but i'd like you to confirm this.

My question is, does the real UID of the children is the effective UID of the parent at the time the fork is done?
My manual lists what's inherited from the parent but doesn't states this.

I'd like an answer about Linux kernel and about Unices in general (i'd like to make it at least POSIX-portable)

Many thanks
 
Old 02-13-2010, 12:02 PM   #2
hostmaster
Member
 
Registered: Feb 2007
Posts: 55

Rep: Reputation: 17
Change User ID

You can change Effective User ID, Real user ID and Saved Userd ID simultaneously using setuid() system call so it cannot switch back to root. (Only root is allowed). Check man setuid()
 
Old 02-13-2010, 01:10 PM   #3
Gruik
LQ Newbie
 
Registered: Sep 2006
Location: France (33)
Distribution: Arch
Posts: 10

Original Poster
Rep: Reputation: 0
Oh okay.
Actually, i thought that in most implementations, setuid() was like seteuid() (which doesn't change the real uid) -- i read somewhere something like that, but i misunderstood i think.

After trying on my Linux system, it's right, you can't change back effective or real user to root after setuid() has been called with a non root user -- no need to fork
 
  


Reply



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
Real uid and effective uid palisetty_suman Linux - Newbie 2 02-15-2009 12:59 PM
Effective UID and real UID Milosevic Linux - General 1 01-06-2007 03:01 PM
Effective UID and Real UID Milosevic Linux - Newbie 1 01-06-2007 10:41 AM
FREEBSD5.3 platform: PHP setcookie() successful, but $uid = $_COOKIE['uid']; fail tclwp Programming 1 03-30-2005 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:31 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration