[NTLUG:Discuss] Is there a way to change permissions of a link

Jeremy Blosser jblosser at firinn.org
Wed Nov 1 16:33:04 CST 2000


Neil Aggarwal [neil at JAMMConsulting.com] wrote:
> I have several symbolic links set-up for a user of mine.
> They point to some files in the same directory.
> 
> I want him to be able to copy new files into the targets
> of the links, but I dont want him to over-write the links
> themselves.
> 
> Unfortunately, the links are mode 777.
> 
> How do I change the mode of the links without affecting the
> targets?

A lot of people have given most of the answer to this question; the part I
haven't seen mentioned yet that you may need is that since the perms on the
symlink don't matter, what *does* matter is the perms on the directory.

If you don't want him to be able to change what the links point to (which
is what I assume you mean by "I don't want him to over-write the links
themselves"), then make sure he doesn't have write access to the directory
in question.  Write access to a directory controls who can affect the
directory contents; ie, add and remove files.  As long as he has execute
permission to the directory and write permission to the individual files,
he'll be able to change the contents of the files:

% ls -la
drwxr-xr-x   2 root     root         4096 Nov  1 16:41 .
lrwxrwxrwx   1 root     root            3 Nov  1 16:41 bar -> foo
-rw-rw-rw-   1 root     root            4 Nov  1 16:43 baz
-rw-rw-rw-   1 root     root            2 Nov  1 16:43 foo

% rm bar
rm: cannot unlink `bar': Permission denied
% ln -sf baz bar
ln: cannot remove `bar': Permission denied

% cat foo
a
% cat baz
xyz
% cp baz foo
% cat foo
xyz

-- 
Jeremy Blosser   |   jblosser at firinn.org   |   http://jblosser.firinn.org/
-----------------+-------------------------+------------------------------
the crises posed a question / just beneath the skin
the virtue in my veins replied / that quitters never win



More information about the Discuss mailing list