Operating System - HP-UX
1835296 Members
2590 Online
110078 Solutions
New Discussion

Gethostbyname fails in NIS+ environment

 
Johan_52
Advisor

Gethostbyname fails in NIS+ environment

Hi All,

If I run a program that calls gethostbyname in a NIS+ environment it correctly returns a pointer to the correct hostent structure if I run the program as root but it returns NULL I run it as a 'normal' user.
I checked with tusc and I see that there is a permission denied error on the open of the file
/var/nis/NIS_SHARED_DIRCACHE
And subsequently on the file
/var/nis/NIS_COLD_START
We changed the security mask to allow everybody to read the files, but still have the same problem. (I tusc I see the files are opened READONLY)

So my questions
- What should be the default security mask for these files
- Why does ping (as a normal user) succeed in retrieving the ip adress and a program calling gethostbyname not
- What else could cause this problem

Any help will be greatly appreciated.

Johan Harmsen
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: Gethostbyname fails in NIS+ environment

Ping works because even when it's run as a non-root user, it's running with the effective UID of 0 because it's a setuid program owned by root.

If it ain't broke, I can fix that.
Ron Kinner
Honored Contributor

Re: Gethostbyname fails in NIS+ environment

Are you running nsd?

http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?nsd+1

mentions that you can set permissions for several files:

mode The mode attribute controls the permissions of the cache files
created by nsd. This should be set to an octal integer value, the
default is 0666 and is modified by the nsd processes umask.

owner
The owner attribute controls the owner of the cache files created by
nsd. This should be set to an integer user ID, and the default is
0.

group
The group attribute controls the group of the cache files created by
nsd. This should be set to an integer group ID and the default is
0.

Ron

Johan_52
Advisor

Re: Gethostbyname fails in NIS+ environment

Thanks for your help !
Turned out that I completely overlooked the obvious (like with ping...). There was no search permission on the /var/nis directory. Just wondering why a default NIS+ installation does not allow this