Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* setuid confusion
@ 1994-09-09  5:27 Vicki Jordan
  1994-09-09 14:17 ` Hildo den Breejen
  0 siblings, 1 reply; 3+ messages in thread
From: Vicki Jordan @ 1994-09-09  5:27 UTC (permalink / raw)


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 
Call setuid(0)    - uid is 203 and euid is 203 

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 
Call setuid(0)    - uid is 0 and euid is 0 

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 

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 

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 

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: setuid confusion
  1994-09-09  5:27 setuid confusion Vicki Jordan
@ 1994-09-09 14:17 ` Hildo den Breejen
  1994-09-12 12:18   ` David Boyce
  0 siblings, 1 reply; 3+ messages in thread
From: Hildo den Breejen @ 1994-09-09 14:17 UTC (permalink / raw)


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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: setuid confusion
  1994-09-09 14:17 ` Hildo den Breejen
@ 1994-09-12 12:18   ` David Boyce
  0 siblings, 0 replies; 3+ messages in thread
From: David Boyce @ 1994-09-12 12:18 UTC (permalink / raw)


In article <Cvv91u.3DE@ideta.nl> hildo@ideta.nl (Hildo den Breejen) writes:
> 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.

This is because POSIX is allowing for the possibility of so-called
secure configurations.  Traditional Unix-like security has various
holes and so more secure configurations with names like C2 and B1 have
been defined in standards documents.  These configurations allow for
more gradations in privilege than "root" and "non-root".  What this
adds up to is that on a normal configuration, "appropriate privilege"
and "root" are synonymous.  When configured for security, however,
there may be a distinction.
-- 
David Boyce	dsb@world.std.com	508-370-7375


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1994-09-12 12:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-09-09  5:27 setuid confusion Vicki Jordan
1994-09-09 14:17 ` Hildo den Breejen
1994-09-12 12:18   ` David Boyce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox