LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   user and group names from uid and gid (https://www.linuxquestions.org/questions/programming-9/user-and-group-names-from-uid-and-gid-558712/)

PatrickNew 06-02-2007 07:57 PM

user and group names from uid and gid
 
The title kinda says it all. I know that stat() in C or C++ will give me, amongst other things, the uid of the owner and the gid of the file. But how do I translate the integer uid into a name? The specific implementation I'm looking at is C++, but C ways of doing this work too.

Thanks.

Tinkster 06-02-2007 08:23 PM

Correlate it by looking it up in /etc/passwd and /etc/group respectively?


Cheers,
Tink

jim mcnamara 06-02-2007 09:08 PM

getgrgid() and getpwuid() for group and user name translation.

PatrickNew 06-02-2007 09:26 PM

Thanks! Just what I was looking for.


All times are GMT -5. The time now is 12:00 AM.