Subject: bug#35553: getlogin and getlogin_r fail with error ENXIO

From: Bruno Haible <[email-masked]>
Date: Sat, 04 May 2019 01:03:37 +0200

Hi,

Running the guix-1.0 installation image
(guix-system-vm-image-1.0.0.x86_64-linux) in qemu, I find that the
glibc functions getlogin() and getlogin_r() fail with error ENXIO.

Using the gnulib programs test-getlogin and test-getlogin_r I can see
that the program is reading the contents of the file /proc/self/loginuid
and its contents is "4294967295". Indeed, the file
glibc/sysdeps/unix/sysv/linux/getlogin_r.c contains this code:

  /* If there is no login uid, linux sets /proc/self/loginid to the sentinel
     value of, (uid_t) -1, so check if that value is set and return early to
     avoid making unneeded nss lookups. */
  if (uid == (uid_t) -1)
    {
      __set_errno (ENXIO);
      return ENXIO;
    }

Is it the xfce4 desktop which is not setting a loginuid? Or is it the lack
of a login screen?

It's the first Linux distro I've seen where getlogin() and getlogin_r()
fail when the user is running a normal desktop environment.

Bruno