Zach Dennis
3/3/2005 4:10:00 PM
ruby@eq.cz wrote:
> Adriano Ferreira wrote:
>
>> Etc.getlogin likely "implements the C library function of the
>> same name, which on most systems returns the current login
>> from /etc/utmp, if any".
>> With a 'su' you changed the real user user id and getlogin() returns
>> the name associated with the current login activity. So as Guy Decoux
>> said it is the expected behaviour and
>> Etc.getpwuid(Process::Sys.geteuid)[:dir]
>> is what you want.
>>
>
> Ok, now I see. 'su -', according to man page, should ``Simulate a full
> login.''. On the other hand, 'getlogin', according to 'Linux
> Programmer's Manual', ``returns a pointer to a string containing the
> name of the user logged in on the controlling terminal of the process''.
>
> 'NetBSD System Calls Manual' is explicit about this behaviour:
> ``The name is normally associated with a login shell at the time a
> session is created, and is inherited by all processes descended from the
> login shell. (This is true even if some of those processes assume
> another user ID, for example when su(1) is used.)''
>
> Thanks for your help, guys, and sorry for the noise.
Not noise, I learned from this. Thanks for posting this to the list so I
could share in reading the replies and reasoning!
Zach