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

Yeah, that works. I wonder if I should file a bug report on this...I'm not convinced I understand what's going on well enough to file a useful one. I assume per's getlogin() is just a wrapper for the C function, so maybe this is a bug in the C libraries in ubuntu precise?
  • Comment on Re^4: getlogin works on debian but not ubuntu?

Replies are listed 'Best First'.
Re^5: getlogin works on debian but not ubuntu?
by mbethke (Hermit) on Jan 07, 2013 at 04:04 UTC
    Works for me even on Ubuntu PP:
    mb@dennis ~ $ perl -E'say getlogin' mb mb@dennis ~ $ cat gl.c #include <unistd.h> #include <stdio.h> int main(void) { puts(getlogin()); return 0; } mb@dennis ~ $ gcc gl.c mb@dennis ~ $ ./a.out mb
      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
        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.