'Operation not permitted' but file copied anyway...?

Status
Not open for further replies.

guermantes

Patron
Joined
Sep 27, 2017
Messages
213
What just happened here ? I create 1002.txt and then, as root, move it but get "operation not permitted". I thought root could do anything. And the file ends up fully readable in the destination all the same.
Was this some ACLS trying to be applied and not succeeding, thus retaining 'simple' permissions (775)?

Code:
[root@freenas /mnt/TANK/peterstuff]# find / -user 1002 > 1002.txt      

[root@freenas /mnt/TANK/peterstuff]# ls -la                                                                                        
total 21587                                                                                                                        
drwxrwxr-x+  2 linux_user  linux_user         8 Dec 10 19:22 .                                                                    
drwxrwxr-x+ 14 linux_user  linux_user        15 Dec 10 11:26 ..                                                                    
-rwxrwxr-x+  1 root        linux_user  41428081 Dec 10 19:30 1002.txt                                                              

[root@freenas /mnt/TANK/peterstuff]# mv 1002.txt ../home/peter/                                                                    
mv: ../home/peter/1002.txt: set mode (was: 0775): Operation not permitted                                                          

[root@freenas /mnt/TANK/peterstuff]# ls -la ../home/peter                                                                          
total 3396900                                                                                                                      
drwxrwxr-x+ 14 peter  peter              28 Dec 10 19:36 .                                                                        
drwxrwxr-x+  9 root   wheel              10 Oct 23 14:40 ..                                                                        
-rwxrwxr-x+  1 root   linux_user   41428081 Dec 10 19:30 1002.txt                                                                  
drwxrwxr-x+  3 peter  peter               3 Jul 11 22:43 data                                                                      
drwxrwxr-x+  4 peter  peter              14 Nov  9 09:42 Documents                                                                
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
If the file copied to the new location, but still exists in the original location, the "operation not permitted" was likely due to not being able to delete the source file. The copy happens first, then the delete. There are some reasons why even root would not be allowed to delete a file. You might still have a process accessing the file.
Was the file still in the source location after the attempt to move it?
 

guermantes

Patron
Joined
Sep 27, 2017
Messages
213
Thanks @Chris Moore (no, the file did not remain in source location) and @Jurgen Segaert
I would actually be happy to let this puppy rest with the excuse "it's ACLs playing tricks on me", but couldn't resist running the same commands again and also checking ACLs and they seem to travel along nicely with the file itself. I don't know what to make of this, but accept being beaten by the ACLs at this game (at this stage).

Code:
root@freenas:/mnt/TANK/peterstuff # find / -user 1002 > 1002new.txt

root@freenas:/mnt/TANK/peterstuff # getfacl 1002new.txt
# file: 1002new.txt
# owner: root
# group: linux_user
            owner@:rwxpDdaARWcCos:------I:allow
            group@:rwxpDdaARWcCos:------I:allow
         everyone@:r-x---a-R-c---:------I:allow

root@freenas:/mnt/TANK/peterstuff # mv 1002new.txt /mnt/TANK/home/peter/
mv: /mnt/TANK/home/peter/1002new.txt: set mode (was: 0775): Operation not permitted

root@freenas:/mnt/TANK/peterstuff # ls -la
total 4775
drwxrwxr-x+  2 linux_user  linux_user         7 Dec 10 21:40 .
drwxrwxr-x+ 14 linux_user  linux_user        15 Dec 10 11:26 ..
-rwxrwxr-x+  1 linux_user  linux_user      1136 Oct 30 23:29 cron-logs.sh
-rwxrwxr-x+  1 root        linux_user  12177811 Nov 24 03:14 rsync-backup.log
-rwxrwxr-x+  1 root        linux_user    381060 Dec 10 01:45 rsync-foto.log
-rwxrwxr-x+  1 root        linux_user  19767970 Dec 10 01:31 rsync-hibou.log
-rwxrwxr-x+  1 root        linux_user    935982 Dec 10 01:15 rsync-home.log

root@freenas:/mnt/TANK/peterstuff # ls -la /mnt/TANK/home/peter/1002new.txt
-rwxrwxr-x+ 1 root  linux_user  41427970 Dec 10 21:37 /mnt/TANK/home/peter/1002new.txt

root@freenas:/mnt/TANK/peterstuff # getfacl /mnt/TANK/home/peter/1002new.txt
# file: /mnt/TANK/home/peter/1002new.txt
# owner: root
# group: linux_user
            owner@:rwxpDdaARWcCos:------I:allow
            group@:rwxpDdaARWcCos:------I:allow
         everyone@:r-x---a-R-c---:------I:allow
 
Status
Not open for further replies.
Top