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.

> Who is the “reboot” user?

I don't know.

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

Reply via email to