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

From: Linda Walsh <[email-masked]>
Date: Wed, 03 Sep 2014 02:06:55 -0700

Bernhard Voelker wrote:
> 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"
----
With the same I get:
  ltrace -f logname|& more
[pid 40807] __libc_start_main(0x4017c0, 1, 0x7fff8b0306f8, 0x4042d0 <unfinished ...>
[pid 40807] strrchr("logname", '/')              = nil
[pid 40807] setlocale(LC_ALL, "")                = 
"LC_CTYPE=en_US.UTF-8;LC_NUMERIC="...
[pid 40807] bindtextdomain("coreutils", "/usr/share/locale") = "/usr/share/locale"
[pid 40807] textdomain("coreutils")              = "coreutils"
[pid 40807] __cxa_atexit(0x401c20, 0, 0, 0x736c6974756572) = 0
[pid 40807] getopt_long(1, 0x7fff8b0306f8, "", 0, nil) = -1
[pid 40807] getlogin()                           = nil
----

> 
> which in turn seems to retrieve the information like this:
> 
>   $ strace logname
>   ...
>   open("/proc/self/loginuid", O_RDONLY)   = 3
----
	I don't have a /proc/self/loginuid

How is it enabled in a vanilla kernel?

>   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?
---
Yup.... mine is stock from kernel.org

I don't recall seeing any option for loginuid.

What module is it?  I probably don't have it mounted.