-   Programming (
-   -   Symbolic Links Permissions Unique Problem! (

tliggins 02-20-2011 10:55 AM

Symbolic Links Permissions Unique Problem!
I hope this is the correct place to post this request.
Is it possible to change permissions on symbolic links using the c programming language or any other for that matter? Now, I know what you are thinking, so let me provide some background. I know permission are meaningless. I know that typically permissions are set to 777.
The project that I am working on does the following. On HPUX systems, a c binary recreates missing links from a stored image of the filesystem, if they are missing. The problem is that the permissions are 700 when the links are restored (should be 777). The c method to restore the symbolic links is "symlink()" which takes as its argument the target and linkname. The client wants 777 on the links. I do not know why the permissions are different.
I would like to know if I can change permissions on the link by code, changing the mode?
Is this a bug somewhere in HPUX 10,x and 11.x os or "symlink" c library method, who knows? There are groups of nodes running HPUX, for example groupA, groupB etc. The problems appears in groupA but not in groupB. Seems the nodes are configured differently. While I would love to know if this is a configuration issue, it appears that way to me, there would be little I could do about it. Politics you know, but that's okay, in time someone would listen. Any input either way would be appreciated.

Thanks TL

ntubski 02-20-2011 01:07 PM

It's not possible to change the permissions on a symbolic link and it shouldn't be possible to create a symlink with less than 777 permissions, this sounds like a bug.

If the path given to chmod() contains a symbolic link as the last
element, this link is traversed and path name resolution continues.
chmod() changes the access mode of the symbolic link's target, rather
than the access mode of the link.


tliggins 02-21-2011 12:56 AM

Thanks for the quick response “ntubski”!

Agreed, one should not be able to / cannot change the permissions on symbolic links.
I have searched for days to determine if the link permissions could be reset to its default value of 777 by creating a program to do it. This simply does not appear to be the case.
I can surmise that the system kernel has the ultimate say when it comes to permissions and symbolic links, correct? If there is any supporting documentation (POSIX) available stating this to be the definitive case please point me in their direction. There are a number of high ranking IT people (programmers and system admins) that believe this can be done. I would need to convince them otherwise.

From what I have read, BSD and some flavors of HPUX have the ability (lchmod)to change permissions on the symbolic links themselves. The permissions are still ignored and do not matter. I would think that this must be supported by THEIR operating system kernels and are non POSIX compliant on this matter.

Thanks again,

ntubski 02-21-2011 11:30 AM

I searched around for lchmod and it looks like it's an undocumented system call on HPUX, so I suppose you can just try writing a program to use it and see if it works.

All times are GMT -5. The time now is 08:31 AM.