Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!texbell!merch!cpe!hal6000!iv From: iv@hal6000.UUCP Newsgroups: comp.unix.xenix Subject: Re: <28@van-bc.UUCP> Message-ID: <-1087513@hal6000> Date: 16 Oct 89 17:01:00 GMT References: <28@van-bc.UUCP> Lines: 57 Nf-ID: #R:van-bc.UUCP:28:hal6000:-1087513:000:2035 Nf-From: hal6000.UUCP!iv Oct 16 12:01:00 1989 /* Written 10:24 am Oct 10, 1989 by van-bc!skl in comp.unix.xenix */ | ------------------- "setuid() in Xenix 2.3.2" ------------------- | | Could some setuid() or Xenix expert please help? | I [ . . . ] need to imitate the seteuid() calls in the code with setuid()'s, | since Xenix doesn't have seteuid(). | | What I need: | | - Start with euid(root). | - ... | - Switch to euid(arbitrary_uid). | - ... | - Revert back to euid(root). | - ... Your basic problem is that setuid() will act differently depending on whether you are root or not. Here's more-or-less how System V setuid() works: if (effective-uid != 0 && (requested-uid == real-uid || requested-uid == remembered-set_uid)) { effective-uid = requested-uid; } else if (effective-uid == 0) { real-uid = requested-uid; effective-uid = requested-uid; remembered-uid = requested-uid; /* Bye-bye privs! */ } else return (EPERM); So, though XENIX would accomodate you if you were using just two UIDs, the fact you wish to be many users via root spells doom for this technique. The only way to do what you wish here is to fork sub-processes, setuid(user) there and exit when done with that user. (I know, I know, oooh, ick!) | Thank you very much for your help. | -- | Samuel Lam or {uunet,ubc-cs}!wimsey.bc.ca!skl Oh, did I help? :-) ---- IV (aka John Elliott IV) Domain: iv@hal6000.Tandy.COM Tandy Systems Software UUCP: ...!texbell!letni!hal6000!iv 900 Two Tandy Center or: ...!decvax!microsoft!trsvax!hal6000!iv Fort Worth, TX 76102 Phone: 817/390-2701; 9:30am-6:00pm CST, M-F [This information was provided by an individual and is not nor should be construed as being provided by Radio Shack or Tandy Corporation. Radio Shack and/or Tandy Corporation have no obligation to support the information provided. I don't think they even know what UNIX is any- more anyway ("Is that like DOS 4.0?"). *sigh* The author will, however, cheerfully accept mail.]