Bug 476026 - POSIX function getlogin() returns null for an existing user
Summary: POSIX function getlogin() returns null for an existing user
Status: RESOLVED NORESPONSE
Alias: None
Product: openSUSE 11.1
Classification: openSUSE
Component: Development (show other bugs)
Version: Final
Hardware: x86 openSUSE 11.1
: P5 - None : Normal with 1 vote (vote)
Target Milestone: ---
Assignee: Petr Baudis
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-15 23:33 UTC by Joe LaFata
Modified: 2010-01-19 02:03 UTC (History)
2 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.