1834156 Members
2975 Online
110064 Solutions
New Discussion

chmod on symbolic links

 
SOLVED
Go to solution
Xavier Gutierrez_2
Frequent Advisor

chmod on symbolic links

Hi folks.

I just found that on our HPUX servers (no matter what version) I can change ownership of symlinks but not the permissions (i.e, I can't chmod them)

Do I have to remove the link, change my umask and create it again to overcome this? I can't believe...


Thanks in advance,

Xavier.
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: chmod on symbolic links

The mode (what you call permissions) of the symbolic link are ignored; only the underlying mode of the file pointed to matters. However, if this really bugs you there is an undocumented system call, lchmod() which will alter the mode of the symlink. The attached C source, lchmod.c will do this for you.

It's intentionally written in K&C C so even the Bundled C compiler will compile it although you can easily convert iy to ANSI C, if you like.

Compile it like this:
cc lchmod.c -o lchmod

use it like this:
lchmod 1750 slink1 [slink2 slink3 ...]

Note: lchmod only understands octal modes but if you want to convert it to also understand symbolic modes then knock yourself out.

If it ain't broke, I can fix that.
Xavier Gutierrez_2
Frequent Advisor

Re: chmod on symbolic links

Thanks a lot!