[sane-devel] [sane-commit] CVS update of sane-backends (3 files)
Nicolas Martin
nicolas.martin at freesurf.fr
Sat Dec 6 17:39:20 UTC 2008
Same on Ubuntu:
$ ./getlgn
method 1 getuid : user=nicolas
method 2 geteuid: user=nicolas
$ sudo ./getlgn
[sudo] password for nicolas:
method 1 getuid : user=root
method 2 geteuid: user=root
?
Le samedi 06 décembre 2008 à 18:27 +0100, E. MARC a écrit :
> Le samedi 6 décembre 2008, à 18:10, Julien BLACHE a écrit :
> > Nicolas Martin <nicolas.martin at freesurf.fr> wrote:
> >
> > Hi,
> >
> > > struct passwd *uid;
> > > uid = getpwuid(geteuid());
> > > printf("user=%s\n", uid->pw_name);
> > >
> > > Prints my username correctly. Also prints root if runned with sudo ;-)
> >
> > Yep, use getuid() instead of geteuid() if you want to avoid that.
> On debian, I get same result with both functions:
>
> #include <pwd.h>
> #include <stdio.h>
>
> int main()
> {
> struct passwd *uid;
> uid = getpwuid(getuid());
> printf("method 1 getuid : user=%s\n", uid->pw_name);
> uid = getpwuid(geteuid());
> printf("method 2 geteuid: user=%s\n", uid->pw_name);
> }
>
> erwan at PC1:~$ ./myname
> method 1 getuid : user=erwan
> method 2 geteuid: user=erwan
>
> erwan at PC1:~$ sudo ./myname
> method 1 getuid : user=root
> method 2 geteuid: user=root
>
> Is there a bug?
>
> EM
>
> > Also, you want some error checking in there... :)
> >
> > JB.
> >
> > --
> > Julien BLACHE <http://www.jblache.org>
> > <jb at jblache.org> GPG KeyID 0xF5D65169
>
>
More information about the sane-devel
mailing list