in reply to Re^5: getlogin works on debian but not ubuntu?
in thread getlogin works on debian but not ubuntu?

Looks like an OS or library bug.
$ cat >gl.c #include <unistd.h> #include <stdio.h> int main(void) { puts(getlogin()); return 0; } ---- rintintin ~ $ gcc gl.c ---- rintintin ~ $ ./a.out Segmentation fault (core dumped)
Maybe it's the same thing as this? https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1067779

Replies are listed 'Best First'.
Re^7: getlogin works on debian but not ubuntu?
by mbethke (Hermit) on Jan 07, 2013 at 16:45 UTC
    Maybe it's the same thing as this? https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1067779
    Strange. My netbook has the very same distribution, my /proc/self/loginuid contains UINT_MAX, but stuff still works. strace tells me that instead of reading /proc/self/loginuid (which on some Linuxes such as my Gentoo doesn't even exist) it checks the /proc/self/fd/0 link to find the terminal the program is running on and then checks /var/run/utmpx or /var/run/utmp for the user logged in on that terminal. The weird thing is that there is no trace of getutent() or something in my glibc's getlogin() implementation. I haven't found whether it gets vendor-patched in somewhere or why else that might be.