Ok, I don't know too much about those functions, but this quick & dirty code seems to work well on Ubuntu (Hardy 8.04):
#include <pwd.h> #include <stdio.h> int main() { struct passwd *uid; uid = getpwuid(geteuid()); printf("user=%s\n", uid->pw_name); } Prints my username correctly. Also prints root if runned with sudo ;-) Le samedi 06 d?cembre 2008 ? 17:31 +0100, Julien BLACHE a ?crit : > Louis Lagendijk <llagendijk-guest at alioth.debian.org> wrote: > > Hi, > > > backend/pixma_bjnp.c pixma_bjnp_private.h > > On Ubuntu getlogin() returns NULL. So we noew first try getlogin() > > and if that fails, we try getenv("USER") and if that fails we use > > a defaul user string > > You want geteuid() + getpwuid() instead of getlogin() which relies on > utmp and thus is unreliable. > > Also, never trust an environment variable. > > JB. > > -- > Julien BLACHE <http://www.jblache.org> > <jb at jblache.org> GPG KeyID 0xF5D65169 >