Mailinglist Archive: opensuse (626 mails)

< Previous Next >
Re: [opensuse] 'mv' a read-only directory doesn't work...why not?
man 2 rename
/EACCES

09.11.2018 19:23, Linda Walsh пишет:
I had two items in dir 'a', file1 and dir1 (empty)
I have full rwx access to 'a' (and am owner):
dir a:
drwxrwxrwx  3 law  lawgroup   29 Nov  9 07:59 ./
dr-xr-xr-x  2 law  lawgroup    6 Nov  9 07:25 dir1/
-r--r--r--  1 law  lawgroup    0 Nov  9 07:25 file1

dir b:
drwxrwxrwx  2 law  lawgroup    6 Nov  9 07:59 ./

try to move everything in 'a' to 'b':

 mv a/* b/
mv: cannot move 'a/dir1' to 'b/dir1': Permission denied

I know this is basic unix/linux 101, but I need some review:

Permissions of parent allow things to transfer in and out of
the parent, right?

The settings on file1 and dir1 for 'read-only' should affect
the file and the directory, right?

So why is moving 'dir1' from 'a' to 'b' disallowed?  Shouldn't
the move only look at the rw permissions on 'a' and 'b'?

To "emphasize the point":  1) I can do a 'cp -a a/dir1 b/' which works. 
Since they are
  on the same device, even hardlinks will be duplicated.
2) I can then follow-up with 'rmdir a/dir1', which also
  works (no warning like when removing a file):
 > rm a/file1
 rm: remove write-protected regular empty file 'a/file1'?

I.e. the exact same actions 'mv' would do if I was copying
between devices.

So could someone explain why move doesn't use the parent
directory permissions?  I don't remember this being standard
unix behavior...??

FWIW, tested on xfs file system on:
4.19.0-Ish-Van #4 SMP Wed Oct 31 03:59:49 PDT 2018
2.6.31.14-0.8-default #1 SMP 2011-04-06 18:09:24 +0200



--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
References