home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!ut-emx!ibmchs!auschs!awdprime.austin.ibm.com!levell.austin.ibm.com!julie
- From: julie@levell.austin.ibm.com (Julie L. Craft)
- Newsgroups: comp.unix.aix
- Subject: Re: setreuid() broken?
- Message-ID: <1992Jul28.154814.28686@awdprime.austin.ibm.com>
- Date: 28 Jul 92 15:48:14 GMT
- References: <1992Jul23.224104.19277@math.waterloo.edu>
- Sender: news@awdprime.austin.ibm.com (USENET News)
- Organization: IBM, Austin
- Lines: 58
-
- In article <1992Jul23.224104.19277@math.waterloo.edu> gamiddle@math.waterloo.edu (Guy Middleton) writes:
- >Sorry if this has been mentioned here before, but I just started reading this
- >newsgroup. setreuid() doesn't seen to work right:
- >
- ># cat foo.c
- >#include <errno.h>
- >main() {
- > setuid(0);
- > seteuid(0);
- > printf("%d, %d\n", getuid(), geteuid());
- > if (setreuid(-1, 200))
- > printf("errno = %d\n", errno);
- > printf("%d, %d\n", getuid(), geteuid());
- >}
- ># ./a.out
- >0, 0
- >errno = 1
- >0, 0
- >#
- >This is crazy. If my uid and euid are 0, how could I possibly get an
- >EPERM error?
- >Is there any way to get this to do what I expect?
- > -Guy Middleton, University of Waterloo gamiddleton@math.waterloo.edu
- > (+1 519 885 1211 x3472) gamiddleton@math.uwaterloo.ca
-
- AIX doesn't allow you to change the EFFECTIVE unless it is equal
- to the REAL or SAVED.
-
- setreuid There are two cases:
-
- RUID != EUID If EUID specifies either the process' real or saved
- user IDs, the process' effective user ID is set to EUID. Other-
- wise, EPERM is returned.
- ^^^^^
-
- RUID= = EUID If the invoker is the root user, the process' real,
- effective, and saved user IDs are set to EUID. Otherwise, EPERM
- is returned.
-
- The real and effective user ID parameters can have a value of -1.
- If the value is -1, the actual value for that UID is set to the
- corresponding current UID of the process.
-
- If you want to toggle your EFFECTIVE between your REAL and SAVED
- you can use a suid program and then use seteuid().
-
- Of course, this might not be what you want. Let me know if
- if you had something specific in mind. This has been a sticky
- issue lately.
-
- later,
- Julie
-
- --
- *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
- Julie Levell Craft IBM AUSTIN,TX Internet: julie@aixwiz.austin.ibm.com
- IBMNET: JULIEL at AUSVM6 2F-007/903 (512) 838-2677 (Tie 678-2677)
- "I'm not getting defensive!"
-