On Fri, 2014-12-05 at 10:06 +0000, Kaskinen, Tanu wrote:
> On Fri, 2014-12-05 at 06:01 +0000, Zhang, Zhengguang wrote:
> > Hi, All
> > 
> > I have a question about tizen IVI boot user name, in current IVI
> > image, when system boots up, the default login user should be “app”,
> >  but when I try to get the user name by the following code:
> > 
> >          Struct utmpx *utmp;
> > 
> > setutxent();
> > 
> >          utmp = getutxent();
> > 
> >          printf(“user name: %s”, utmp->ut_user);
> > 
> >          endutxent();
> > 
> > I get the user name “reboot” instead of “app”, can anybody help me to
> > clarify what’s wrong with the code above or how to get the user name
> > “app”?
> 
> Note that prior to your message I knew nothing about the utmp file...
> But after reading the man page for seutxent() and getutxent() and
> checking the utmp contents with dump-utmp on my laptop, I'm sure the
> problem is that with setutxent() you set the read pointer to the
> beginning of the file. The utmp file contains many entries, so you get
> just the first one, which happens to be an entry for the "reboot" user,
> which has nothing to do with the current user.
> 
> To get the current user ID, you can use getuid() or geteuid(), whichever
> is more relevant for your purpose. getpwuid() can be used to get the
> user name corresponding to the numeric user ID.

Oops, sorry, I didn't notice this was already answered on the ivi list
(the original message was cross-posted to dev too, and there weren't any
replies on the dev list).

-- 
Tanu
_______________________________________________
IVI mailing list
[email protected]
https://lists.tizen.org/listinfo/ivi

Reply via email to