From: hildo@ideta.nl (Hildo den Breejen)
Subject: Re: setuid confusion
Date: Fri, 9 Sep 1994 14:17:53 GMT [thread overview]
Message-ID: <Cvv91u.3DE@ideta.nl> (raw)
In-Reply-To: 1994Sep9.052738.18360@lugb.latrobe.edu.au
ccvj@misty.latrobe.edu.au (Vicki Jordan) writes:
>Could someone please tell me how to change a process's uid the right way?
>I need to start as root, change to the uid of the person allocated the
>process and then change back to root. This contrived code illustrates
>the problem and the output my confusion! Running suid root, I get
>different behaviour across Ultrix, AIX and OSF1. It would seem to me
>that AIX and OSF1 are "correct" when run as an individual user, but only
>OSF1 correct when run as root. In partilcuar, I need to get the same
>result from AIX as OSF1 in both the run as user and root cases.
>Is there anyone who doesn't confuse as easily as I do?? If so, please
>enlighten me!
>Thanks.
>--------
>#include <stdio.h>
>#include <sys/types.h>
>main()
>{
> printf("Start - uid is %d and euid is %d \n", getuid(), geteuid());
>/* Change to uid 203 */
> seteuid(203);
> printf("Call seteuid(203) - uid is %d and euid is %d \n", getuid(),geteuid());
> setuid(203);
> printf("Call setuid(203) - uid is %d and euid is %d \n", getuid(),geteuid());
>/* Change back to initial uid 0 */
> seteuid(0);
> printf("Call seteuid(0) - uid is %d and euid is %d \n", getuid(),geteuid());
> setuid(0);
> printf("Call setuid(0) - uid is %d and euid is %d \n", getuid(),geteuid());
>}
>File is suid root.
>Ultrix - run as user 203:
>Start - uid is 203 and euid is 0
>Call seteuid(203) - uid is 203 and euid is 203
>Call setuid(203) - uid is 203 and euid is 203
>Call seteuid(0) - uid is 203 and euid is 203
Obviously, ultrix does not have saved-set-UID (Posix optional)
there's no way you cab regain root privileges.
>Call setuid(0) - uid is 203 and euid is 203
Nope. You don't get root back.
>Aix - run as user 203:
>Start - uid is 203 and euid is 0
>Call seteuid(203) - uid is 203 and euid is 203
>Call setuid(203) - uid is 203 and euid is 203
>Call seteuid(0) - uid is 203 and euid is 0
So AIX does have saved-set-UID. You can retrieve your root privs.
>Call setuid(0) - uid is 0 and euid is 0
Check. You're effectively root now. root can do anything.
>OSF1 - run as user 203
>Start - uid is 203 and euid is 0
>Call seteuid(203) - uid is 203 and euid is 203
>Call setuid(203) - uid is 203 and euid is 203
>Call seteuid(0) - uid is 203 and euid is 0
>Call setuid(0) - uid is 0 and euid is 0
Obviously, OSF has saved-set-UID too.
>Ultrix/AIX - run as root:
>Start - uid is 0 and euid is 0
>Call seteuid(203) - uid is 0 and euid is 0
>Call setuid(203) - uid is 203 and euid is 203
>Call seteuid(0) - uid is 203 and euid is 203
>Call setuid(0) - uid is 203 and euid is 203
AIX obviously does not have'em.
>OSF1 - run as root:
>Start - uid is 0 and euid is 0
>Call seteuid(203) - uid is 0 and euid is 203
>Call setuid(203) - uid is 0 and euid is 203
>Call seteuid(0) - uid is 0 and euid is 0
>Call setuid(0) - uid is 0 and euid is 0
Apparently, OSF1 has saved-set-UID's, but considders root
not to have 'appropriate privileges': a setuid root process can only
do what any user can:
make euid equal to uid or make euid equal to saved-set-UID.
It cannot change it's real UID. (It can in BSD, using setreuid()).
>--
>Vicki Jordan V.Jordan@latrobe.edu.au
>Computing Services phone: +61 03 479 1500
>La Trobe University fax: +61 03 479 1999
>Bundoora Vic 3083 Australia
I am into the UID business myself these days, so I read Posix and Xopen
on this subject.
Both use the phrase 'appropriate privilege', where I would say 'root'.
Their must be some subtle difference. Perhaps someone can explain.
To make it even more complicated: every process in SCO has a login-uid.
Set by the login process, and from that moment on immutable. It's used
for the audit subsystem: every process can be traced back to an account.
Hope this helps...
--
Hildo den Breejen <Hildo.den-Breejen@ideta.nl>
Ideta, 6 Frankemaheerd, 1102 AN Amsterdam, the Netherlands
My opinions are my own, not necessarily my boss's.
Everything's relative - absolutely.
next prev parent reply other threads:[~1994-09-09 14:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-09-09 5:27 setuid confusion Vicki Jordan
1994-09-09 14:17 ` Hildo den Breejen [this message]
1994-09-12 12:18 ` David Boyce
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox