编程方式正从用户名UID和GID在Unix中? [英] Programatically getting UID and GID from username in Unix?
本文介绍了编程方式正从用户名UID和GID在Unix中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用的setuid()和setgid()设置程序的各自的ID从根本放弃特权下来,而是利用他们,我需要知道我要改变用户的UID和GID到
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 user I want to change to.
有一个系统调用来做到这一点?我不想硬code或从/ etc / passwd文件解析。
Is there a system call to do this? I don't want to hardcode it or parse from /etc/passwd .
另外,我想这样做编程,而不是使用:
Also I'd like to do this programatically rather than using:
ID -u用户名
任何帮助将大大AP preciated
Any help would be greatly appreciated
推荐答案
有一个看 getpwnam()和 getgrnam()功能。
这篇关于编程方式正从用户名UID和GID在Unix中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文