Home
Sign Up
Sign In
V2EX
›
问与答
关于获取 unix 系统的用户 id
vc131874
·
May 11, 2020
· 1761 views
This topic created in 2213 days ago, the information mentioned may be changed or developed.
如果程序通过管理员身份运行,函数 getuid()获取到的是 0,也就是 root 用户的 uid,但是我想要获取登录用户的 uid,有什么好的方式吗?比如我的登陆用户是 xx,我的程序需要管理员权限运行 sudo ./test ,在 test 程序中怎么获取 xx 的 uid 。
uid
获取
test
管理员
2 replies
•
2020-05-11 12:58:26 +08:00
1
crab
May 11, 2020
https://stackoverflow.com/questions/10272784/how-do-i-get-the-users-real-uid-if-the-program-is-run-with-sudo
2
vc131874
OP
May 11, 2020
@
crab
感谢回复
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Solana
·
3253 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms ·
UTC 14:09
·
PVG 22:09
·
LAX 07:09
·
JFK 10:09
♥ Do have faith in what you're doing.
❯