Is there a C function which returns the user-name for the user id?
Thanks, Marc
Thanks, Marc
marc> Is there a C function which returns the user-name for the user id?
getpwuid()
--
Andrew.
comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
or <URL: http://www.whitefang.com/unix/>
>Thanks, Marc
Someone is borrowing my UNIX programming book so I can't tell you for
sure, but I do believe it exists.
------
Remove "nospam" to respond via email.
Matt
------
- These views are my own, not necessarily those of my company.
> marc> Is there a C function which returns the user-name for the user id?
> getpwuid()
> --
> Andrew.
Ok, getpwuid(uid)->pw_name returns the /etc/passwd user and the
shadow password can also be determined by getspnam but what if you
are connected to NIS/YP-Server or other name services? Is there
a portable way to get the user-name on HP-UX, Solaris, Linux?
E.g. on HP-UX / SCO you need to use different commands (FAQ).
May be I should look in the 'id' command, but I don't have the
sources. However, I hope that your mentioned method works
for most cases. What Unix book would you recommend here?
Thanks a lot for you perfect help!
Yours, Marc Dzaebel
>> marc> Is there a C function which returns the user-name for the user id?
>> getpwuid()
>> --
>> Andrew.
>Hi Andrew, (hi Mattryan)
>Ok, getpwuid(uid)->pw_name returns the /etc/passwd user and the
>shadow password can also be determined by getspnam but what if you
>are connected to NIS/YP-Server or other name services? Is there
>a portable way to get the user-name on HP-UX, Solaris, Linux?
>E.g. on HP-UX / SCO you need to use different commands (FAQ).
>May be I should look in the 'id' command, but I don't have the
>sources. However, I hope that your mentioned method works
>for most cases. What Unix book would you recommend here?
>Thanks a lot for you perfect help!
>Yours, Marc Dzaebel
Matt
------
- These views are my own, not necessarily those of my company.
Adel.
Quote:> Thanks, Marc
> > Ok, getpwuid(uid)->pw_name returns the /etc/passwd user and the
> > shadow password can also be determined by getspnam but what if you
> > are connected to NIS/YP-Server or other name services? Is there
> > a portable way to get the user-name on HP-UX, Solaris, Linux?
> I can't say for all the flavors you mention, but getpwuid() on Solaris
> will automatically use NIS if /etc/nsswitch.conf is properly set.
> ron
> ----------------------------------------------------------------------
> Ron Klatchko - Senior Software Engineer
> UCSF Library and Center for Knowledge Management
Thanks for your answer,
Marc Dzaebel
1. how to user C language to convert a known user id to a user name
Hi Everyone,
I am writing a progam that can find information for a file by using
stat() func. Although I can get user id and group id from this
function.I am trying to find if there's a function in C that can help
convert a known user id to a user name in Linux OS?And how to convert
a known group id to the group name? If there is no such a function,
can I write one and how to do it?
Thanks a lot!
David
2. disconnecting from the internet...computer grinds to a halt
3. How to change a users name (r->connection->user) in a module
4. problem with Solaris7 modload(1M)
6. monitoring network performance
7. user id vs effective user id
9. ps -ef loses user ID -> login name
10. Qube3 user administration - length of user name > 12
11. scoadmin -> Account Manager -> Users -> Add New Users breaks /etc/password symlink
12. How to prevent two concurrent users with the same user ID/Password