Operating System - HP-UX
1834804 Members
2914 Online
110070 Solutions
New Discussion

Re: Using getpwnam in a NIS+ environment

 
Johan_52
Advisor

Using getpwnam in a NIS+ environment

Hello

I have a program running in a NIS+ environment this program retrieves user information using the getpwnam function. This program fails if it is executed by root (getpwnam returns NULL) but succeeds if it is executed by another user. The user for which the information is retrieved is another than root. The user root is specified in the local /etc/passwd, the user for which the information is retrieved resides in the NIS+ tables. I'm not able to use a debugger to see what happens, but if I run the same program through tusc (also as root) it finds the information for the user. Looks like some bug in my program, but even after looking several hours I'm not able to find it. So I thought I might just ask whether somebody has seen such behaviour before.

All help will be greatly appreciated

Thanks

Johan
2 REPLIES 2
Johan_52
Advisor

Re: Using getpwnam in a NIS+ environment

Some more information, the problem only occurs if the program has the setuid bit set
If the owner of the program is 'johan' and the program is executed by root, getpwnam("johan") will fail (errno set to Permission denied).
For any user other than root there is no problem.

Any ideas ?
Shannon Petry
Honored Contributor

Re: Using getpwnam in a NIS+ environment

Try tossing an echo of your credentials before you are using getpwnam.

Are you running this suid/sgid?

Regards,
Shannon
Microsoft. When do you want a virus today?