ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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.
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.