Programmatically getting UID and GID from username in Unix?

后端 未结 5 2034
别那么骄傲
别那么骄傲 2020-12-10 12:11

I\'m trying to use setuid() and setgid() to set the respective id\'s of a program to drop privileges down from root, but to use them I need to know the uid and gid of the us

5条回答
  •  独厮守ぢ
    2020-12-10 13:15

    You want to use the getpw* family of system calls, generally in pwd.h. It's essentially a C-level interface to the information in /etc/passwd.

提交回复
热议问题