1827472 Members
2044 Online
109965 Solutions
New Discussion

Re: getprpwuid weird???

 
Charlie123
Frequent Advisor

getprpwuid weird???

Hi Gurus,
I have a program calling these:
.............
uid = getuid();
getprpwuid(uid);
.............
when I run it after I logged in, getpwpwuid retuned OK. But if I put this program in the last field of /etc/passwd entry, I used the same account to log in, getprpwuid returns NULL.

Any help?
Thanks a lot.
Charlie
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: getprpwuid weird???

I suspect the problem is that your process does not have permission to access the tcb database. What is the effective UID of the process?
If it ain't broke, I can fix that.
Charlie123
Frequent Advisor

Re: getprpwuid weird???

Thanks. the effective process UID is the same as the UID of the user to attempt to log in.
while getprpwuid gave NULL, the errrno was some times 0, sometimes 2.
A. Clay Stephenson
Acclaimed Contributor

Re: getprpwuid weird???

You will not be able to retrieve anything from the tcb database unless the effective UID of the process is zero.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: getprpwuid weird???

As a regular user, the only way that you will be able to use getprpwuid() is to make your program a setuid root program which means you will have to do an explicit setuid(0) inside your program AND the setuid bit (04000) must be set on the executable AND the executable must be owned by root.

If it ain't broke, I can fix that.