You are not logged in.
In C, if you want to stat a symlink you can use the non-dereferencing version of stat, namely lstat.
Is there a non-dereferencing version of the chown system call (i.e. lchown?).
The desired behavior is that of "chmod -h..." from the command-line. If no one has an answer then I will dig through the source of chmod to determine how it works.
What about chmod? Is it even possible to change the permission mode of a symlink? There does not seem to be any non-dereferencing options for the command-line utility.
Thanks.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
man 2 chown shows that there indeed is a lchown system call. Manual for chmod doesn't mention lchmod, it seems to be declared in stat.h, but it's inside __USE_BSD define, not sure how that works. Some info about this: http://lists.gnu.org/archive/html//bug- … 00268.html
Last edited by kaszak696 (2013-02-13 22:04:19)
'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard
Offline
Is there a non-dereferencing version of the chown system call (i.e. lchown?).
Yep, looks that way. There's a man page for it.
lchmod looks like a BSD only thing, though.
EDIT:
Ah, guy above me found it first.
Last edited by AaronBP (2013-02-13 22:07:05)
Offline
man 2 chown shows that there indeed is a lchown system call. Manual for chmod doesn't mention lchmod, it seems to be declared in stat.h, but it's inside __USE_BSD define, not sure how that works. Some info about this: http://lists.gnu.org/archive/html//bug- … 00268.html
lchmod ist defined in unistd.h and is available on BSD as well as Linux (part of X/Open XA UNIX extensions)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
Thanks. I usually refer to the GNU C library documentation and there is no mention of lchown there.
Right now, gnulib has an lchmod replacement which always calls chmod; this will do the wrong thing if it is ever called on a symlink, but is right for everything else.
(emphasis mine)
Wow.
edit: formatting
Last edited by Xyne (2013-02-13 23:12:41)
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Lol. Seems like it would be better to omit lchmod entirely than to provide a version that does the wrong thing in the only possible situation where one might need it.
Offline