Subject: bug#11150: getlogin test failure

From: Matt Burgess <[email-masked]>
Date: Sun, 01 Apr 2012 23:34:51 +0100

Hi,

The coreutils-8.16 release brought in the getlogin gnulib module.

When running through the testsuite, test-getlogin.c fails for me on a
GNU/Linux system.  There are a couple of different failure scenarios:

1) If I 'make' as my normal user account, then run "su nobody
-s /bin/bash -c 'make check'", then the assertion at line 61 (ASSERT
(strcmp (buf, name) == 0);) fails because buf=="mylogin" and
name=="nobody".  If you're wondering why I would do something like that,
it's because it's a slightly simplified form of my usual build method:

sudo su -
FORCE_UNSAFE_CONFIGURE=1 ./configure
make
make check-root
chown -R nobody .
su nobody -s /bin/bash -c 'make check'

2) Under my non-simplified build method, using an automated build tool,
the assertion at line 43 fails.  Debugging this shows that getlogin(3)
returns ENOENT which isn't handled by the assertion.  That behaviour is
documented at http://man7.org/linux/man-pages/man3/getlogin.3.html.

However, the trivial patch to handle that case too just results in the
very next assert failing (line 47: ASSERT (! isatty (0));).

I'm still trying to figure out what's causing isatty(0) to return 0, and
suspect the automated build tool I'm using; so far I've been unable to
reproduce this via manually-invoked builds.  I'll post again if I can
reproduce it.

Thanks,

Matt.