GNU bug report logs - #35553
getlogin and getlogin_r fail with error ENXIO

Previous Next

Package: guix;

Reported by: Bruno Haible <bruno <at> clisp.org>

Date: Fri, 3 May 2019 23:04:01 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35553 in the body.
You can then email your comments to 35553 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#35553; Package guix. (Fri, 03 May 2019 23:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Bruno Haible <bruno <at> clisp.org>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Fri, 03 May 2019 23:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Bruno Haible <bruno <at> clisp.org>
To: bug-guix <at> gnu.org
Subject: getlogin and getlogin_r fail with error ENXIO
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





Information forwarded to bug-guix <at> gnu.org:
bug#35553; Package guix. (Sat, 04 May 2019 13:14:01 GMT) Full text and rfc822 format available.

Message #8 received at 35553 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Bruno Haible <bruno <at> clisp.org>, 35553 <at> debbugs.gnu.org
Subject: Re: bug#35553: getlogin and getlogin_r fail with error ENXIO
Date: Sat, 4 May 2019 15:13:10 +0200
[Message part 1 (text/plain, inline)]
http://man7.org/linux/man-pages/man8/pam_loginuid.8.html suggests that we should
use that for all "entry point"s for the user.  I guess we can add it.

Are you logging in using gdm?

We don't refer to pam_loginuid.so anywhere, so it's understandable that
/proc/self/loginuid is not set either.

Apparently, Ubuntu has the following:

/etc/pam.d/common-session-noninteractive:

session [default=1]                     pam_permit.so
session requisite                       pam_deny.so
session required                        pam_permit.so
session required        pam_unix.so 
session optional                        pam_winbind.so 
session required        pam_loginuid.so 

And then they @include the file above in /etc/pam.d/gdm
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#35553; Package guix. (Sat, 04 May 2019 13:27:02 GMT) Full text and rfc822 format available.

Message #11 received at 35553 <at> debbugs.gnu.org (full text, mbox):

From: Bruno Haible <bruno <at> clisp.org>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 35553 <at> debbugs.gnu.org
Subject: Re: bug#35553: getlogin and getlogin_r fail with error ENXIO
Date: Sat, 04 May 2019 15:26:16 +0200
Danny Milosavljevic wrote:
> Are you logging in using gdm?

I'm using the guix-1.0 installation image
(guix-system-vm-image-1.0.0.x86_64-linux). It shows a screen "Logging in..."
for less than one second and then starts the user's desktop immediately.

Bruno





Information forwarded to bug-guix <at> gnu.org:
bug#35553; Package guix. (Tue, 07 May 2019 10:19:02 GMT) Full text and rfc822 format available.

Message #14 received at 35553 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Bruno Haible <bruno <at> clisp.org>
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>, 35553 <at> debbugs.gnu.org
Subject: Re: bug#35553: getlogin and getlogin_r fail with error ENXIO
Date: Tue, 07 May 2019 12:18:09 +0200
[Message part 1 (text/plain, inline)]
Hi Bruno!

Bruno Haible <bruno <at> clisp.org> skribis:

> Danny Milosavljevic wrote:
>> Are you logging in using gdm?
>
> I'm using the guix-1.0 installation image
> (guix-system-vm-image-1.0.0.x86_64-linux). It shows a screen "Logging in..."
> for less than one second and then starts the user's desktop immediately.

This is the VM image (not the installation image), and it uses SLiM:

  https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/system/examples/vm-image.tmpl

Danny wrote:

> We don't refer to pam_loginuid.so anywhere, so it's understandable that
> /proc/self/loginuid is not set either.

Is it the only way to get that done?  (That something has to write some
number to /proc/self/loginuid looks very clunky to me.)

I’ve tested the patch below and confirmed that after logging in at the
tty, running Guile and calling ‘getlogin’ at the REPL now returns the
right thing.

We’d have to do that for all the relevant services (graphical log-in
managers, SSH daemons, anything else?).  Perhaps we can simply add a
keyword to ‘unix-pam-service’ to make it less verbose.

Thoughts?

Thanks for the bug report, Bruno!

Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 952f6f9ab2..30e50f4b9a 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -829,11 +829,18 @@ Return a service that sets up Unicode support in @var{tty} and loads
 (define (login-pam-service config)
   "Return the list of PAM service needed for CONF."
   ;; Let 'login' be known to PAM.
-  (list (unix-pam-service "login"
-                          #:allow-empty-passwords?
-                          (login-configuration-allow-empty-passwords? config)
-                          #:motd
-                          (login-configuration-motd config))))
+  (let ((base (unix-pam-service
+               "login"
+               #:allow-empty-passwords?
+               (login-configuration-allow-empty-passwords? config)
+               #:motd
+               (login-configuration-motd config))))
+    (list (pam-service
+           (inherit base)
+           (session (cons (pam-entry
+                           (control "required")
+                           (module "pam_loginuid.so"))
+                          (pam-service-session base)))))))
 
 (define login-service-type
   (service-type (name 'login)

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Thu, 09 May 2019 10:15:03 GMT) Full text and rfc822 format available.

Notification sent to Bruno Haible <bruno <at> clisp.org>:
bug acknowledged by developer. (Thu, 09 May 2019 10:15:04 GMT) Full text and rfc822 format available.

Message #19 received at 35553-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: Bruno Haible <bruno <at> clisp.org>, 35553-done <at> debbugs.gnu.org
Subject: Re: bug#35553: getlogin and getlogin_r fail with error ENXIO
Date: Thu, 09 May 2019 12:13:54 +0200
Hello,

Danny Milosavljevic <dannym <at> scratchpost.org> scribes:

> We don't refer to pam_loginuid.so anywhere, so it's understandable that
> /proc/self/loginuid is not set either.

I proceeded as discussed:

  https://git.savannah.gnu.org/cgit/guix.git/commit/?id=e6b1a2248ff164e14d1b2f495224faf8a8326142
  https://git.savannah.gnu.org/cgit/guix.git/commit/?id=af55ca481d9e6c1d1e06632f96d550b42f33210f

Thanks,
Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 06 Jun 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 325 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.