Hello, all

i have encountered a bit unexpected and counter-intuitive behaviour of ln
and wonder if it is OK:
to require _write_ permission on the _source_ file while creating a hardlink to.

here is a shell session:

$ ls -l

drwxr-xr-x  1 sad  sad    - 0 Aug 25 14:48 dir1/
drwxrwxr-x  1 sad  emilk  - 0 Aug 25 14:50 dir2/

dir2 is supposed to be written by user emilk and is empty


$ ls -l dir1

-rw-r--r--  2 sad  emilk  - 6 Aug 25 14:45 file1


now switch to the user "emilk" and try to create a hardlink

$ su emilk
$ ln dir1/file1 dir2/file1

ln: ./dir2/file1: Permission denied


now change the singe perm

$ sudo chmod g+w dir1/file1
$ ls -l dir1

-rw-rw-r--  2 sad  emilk  - 6 Aug 25 14:45 file1


$ su emilk
$ ln dir1/file1 dir2/file1
$ ls -l dir2

-rw-rw-r--  2 sad  emilk  - 6 Aug 25 14:45 file1

It worked.
And it is confusing, since actually i have only written to dir2, keeping the _source_ file INTACT.


Any comments?
thnx.

Reply via email to