Bug 476026

Summary: POSIX function getlogin() returns null for an existing user
Product: [openSUSE] openSUSE 11.1 Reporter: Joe LaFata <qbproger>
Component: DevelopmentAssignee: Petr Baudis <pbaudis>
Status: RESOLVED NORESPONSE QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: pth, qbproger
Version: Final   
Target Milestone: ---   
Hardware: x86   
OS: openSUSE 11.1   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Joe LaFata 2009-02-15 23:33:00 UTC
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009012700 SUSE/3.0.6-0.1.2 Firefox/3.0.6

In C the posix function getlogin() is returning null.

perror is saying something about 'file not found'

Reproducible: Always

Steps to Reproduce:
here is code to reproduce the problem:
#include <unistd.h>
#include <stdio.h>

int main() {
  char* login = getlogin();
  if (login != NULL) {
    printf("login not null [login=%s]\n", login);
  } else {
    perror("getlogin failed");
  }
  return 0;
}
Actual Results:  
null

Expected Results:  
my username
Comment 1 Joe LaFata 2009-02-15 23:42:10 UTC
this may or may not be related, but I just noticed the "logname" command returns "logname: no login name"
Comment 2 Philipp Thomas 2009-02-16 11:37:23 UTC
The POSIX standard says:

Upon successful completion, getlogin ( ) shall return a pointer to the login name or a null pointer if the user’s login name cannot be found. Otherwise, it shall return a null pointer and set errno to
indicate the error.

So the result of the getlogin call is correct. The question is, why getlogin can't find your login name. What is the output of calling id?
Comment 3 Joe LaFata 2009-02-16 22:10:48 UTC
the output from running 'id' on the command line:

qbproger@linux-3r1v:~> id
uid=1000(qbproger) gid=100(users) groups=16(dialout),33(video),100(users)
Comment 4 Petr Baudis 2009-11-14 10:57:32 UTC
I'm sorry I couldn't get to this bug earlier due to my workload. Does this still happen to you? Can you please try to strace your program and post the output?
Comment 5 Joe LaFata 2009-11-14 13:42:21 UTC
I'm on ubuntu now (but plan on moving back to openSuSE now that 11.2 is out), and the computer that had the problem doesn't work anymore.  When I switch back to opensuse (within 2 or 3 weeks), I can test it again, but it is different hardware.
Comment 6 Petr Baudis 2010-01-19 02:03:24 UTC
Thank you for your time anyway, please reopen if you will still want to investigate the issue.