Subject: Re: bug#18386: logname fails with error "logname: no login name" (is there an echo in here)

From: Bernhard Voelker <[email-masked]>
Date: Tue, 02 Sep 2014 12:35:58 +0200

On 09/02/2014 02:06 AM, Linda Walsh wrote:
>>  logname
> logname: no login name

logname(1) works here on a regular openSUSE-13.1 system, and
just calls getlogin(3) to get the information as required:

   $ ltrace logname
   ...
   getlogin()                 = "berny"

which in turn seems to retrieve the information like this:

   $ strace logname
   ...
   open("/proc/self/loginuid", O_RDONLY)   = 3
   read(3, "717", 12)                      = 3
   close(3)                                = 0
   socket(PF_LOCAL, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
   connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = 0
   sendto(3, "\2\0\0\0\v\0\0\0\7\0\0\0passwd\0", 19, MSG_NOSIGNAL, NULL, 0) = 19
   ...

Don't you have /proc mounted?

> Ishtar:/> who -a
> Ishtar:/> who -t
> Ishtar:/> who -u
> Ishtar:/> who -b
> Linux Ishtar 3.16.0-Isht-Van #1 SMP PREEMPT Tue Aug 12 11:11:02 PDT 2014 x86_64 x86_64 x86_64 GNU/Linux
>
> I wonder if the who command's output being broken is related?

Similar for who(1) here:

   $ strace who
   ...
   open("/var/run/utmp", O_RDONLY|O_CLOEXEC) = 3
   ...

> Distro is a 13.1 SuSE base, but wouldn't call it a stock system (still boots w/sysvinit)

It looks like trying to avoid systemd is not that easy ...

Have a nice day,
Berny