getuid() and geteuid() on Ultrix 2.0 (The Reason)

Brian Wallis brw at jim.odr.oz
Wed Nov 2 14:32:19 AEST 1988


 In article <579 at jim.odr.oz> brw at jim.odr.oz (Brian Wallis (me)) writes:
>
>On Ultrix 2.0 on our MicroVax II, the system calls getuid() and
>geteuid() both seem to return the same uid no matter what you have
>su'd to. ie. If I su to 'local' and run a simple program that prints
>both uid's as returned by getuid and geteuid I get the uid of local
>from both whereas I thought I should get the uid of me ('brw') from
>getuid(). Here is tmp.c and the results...
 
   [rest deleted]

Ok, Ok, maybe I didn't look far enough (although our manual entry for
'su' doesn't actually mention that both the uid and euid are set) (and
thanks to all who replied).

  A bit of background. The reason I wanted this was due to running
emacs while su'd to another user (local, our local utility source
container) and wanting to use MY .emacs file. I thought that
(user-uid) or (user-login-name) as opposed to (user-real-uid) and
(user-real-login-name) would tell me who I was logged in as. In fact
the help for the function user-real-login-name is:
> user-real-login-name:
> Return the name of the user's real uid, as a string.
> Differs from user-login-name when running under su.
which misled me. 

  I am currently using a re-definition of user-real-login-name:
> (defun user-real-login-name ()
> "A kludge for the real thing, since getuid() is wrong on Ultrix 2.0"
>   (interactive)
>   (substring (getenv "MAIL")
>	     (string-match "[^/]+$" (getenv "MAIL")) nil))
which is kludgy but works for the people who su to local around here!

What is a better way of doing this?

-- 
Brian Wallis (brw at jim.odr.oz)		    O'Dowd Research P/L.
	(03) 562-0100 Fax: (03) 562-0616,
	Telex: Jacobs Radio (Bayswater) 152093



More information about the Comp.unix.wizards mailing list