Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've got a problem with UNIX permissions : I'm working under Debian Squeeze, and one of my scripts, run by www-data, needs to move a file, 23550.zip, placed in the home directory of another user, autodo, to a subdirectory in this user's home (/home/autodo/.processed) to mark it as already processed.

I tried to change the group ownership of /home/autodo, /home/autodo/23550.zip and /home/autodo/.processed to the group www-data to allow the www-data user to move this file, but it still fails saying Permission denied, as you can see below (as I'm French, I translated french messages back to English, although I can't be sure the translation is the one displayed in English version of these commands) :

sh-4.1$ ls -lah /home/autodo
total 27M
drwxr-xr-x  3 autodo www-data 4,0K  9 janv. 15:17 .
drwxr-xr-x 88 root   root     4,0K  8 janv. 15:21 ..
-rwxr-xr-x  1 autodo ftpusers 4,8K  5 sept. 23:14 19236.zip
-rwxr-xr-x  1 autodo www-data  26M  9 janv. 14:26 23550.zip
-rwxr-xr-x  1 autodo ftpusers 2,3K  6 janv. 20:44 3194.zip
-rwxr-xr-x  1 autodo ftpusers 1,1M  5 sept. 23:38 53274.zip
-rwxr-xr-x  1 autodo ftpusers  585  6 sept. 00:50 70069.zip
-rwxr-xr-x  1 autodo ftpusers  220 16 nov.  15:10 .bash_logout
-rwxr-xr-x  1 autodo ftpusers 3,2K 16 nov.  15:10 .bashrc
drwxr-xr-x  2 autodo www-data 4,0K  9 janv. 15:16 .processed
-rwxr-xr-x  1 autodo ftpusers  675 16 nov.  15:10 .profile
sh-4.1$ ls -lah /home/autodo/.processed
total 66M
drwxr-xr-x 2 autodo www-data 4,0K  9 janv. 15:16 .
drwxr-xr-x 3 autodo www-data 4,0K  9 janv. 15:17 ..
-rwxr-xr-x 1 autodo ftpusers 3,8K  8 janv. 22:42 100583.zip
-rwxr-xr-x 1 autodo ftpusers 1,7K  9 janv. 02:48 12211.zip
-rwxr-xr-x 1 autodo ftpusers 2,2K  8 janv. 22:43 166273.zip
-rwxr-xr-x 1 autodo ftpusers 424K  8 janv. 22:52 193894.zip
-rwxr-xr-x 1 autodo ftpusers 1,2M  9 janv. 01:13 20662.zip
-rwxr-xr-x 1 autodo ftpusers  59M  9 janv. 00:43 22352.zip
-rwxr-xr-x 1 autodo ftpusers 1,2M  8 janv. 22:42 23704.zip
-rwxr-xr-x 1 autodo ftpusers 214K  9 janv. 02:34 24704.zip
-rwxr-xr-x 1 autodo ftpusers  632  9 janv. 01:17 26360.zip
-rwxr-xr-x 1 autodo ftpusers 2,8K  9 janv. 01:03 31795.zip
-rwxr-xr-x 1 autodo ftpusers 106K  9 janv. 00:11 31797.zip
-rwxr-xr-x 1 autodo ftpusers 413K  9 janv. 00:44 31799.zip
-rwxr-xr-x 1 autodo ftpusers 4,4K  8 janv. 22:30 31803.zip
-rwxr-xr-x 1 autodo ftpusers 2,3K  5 janv. 21:19 3194.zip
-rwxr-xr-x 1 autodo ftpusers  13K  8 janv. 23:33 5705.zip
-rwxr-xr-x 1 autodo ftpusers 2,8K  8 janv. 22:19 5858.zip
-rwxr-xr-x 1 autodo ftpusers  86K  9 janv. 04:34 604.zip
-rwxr-xr-x 1 autodo ftpusers 2,6M  9 janv. 03:34 7091.zip
-rwxr-xr-x 1 autodo ftpusers 3,4K  8 janv. 21:25 7878.zip
-rwxr-xr-x 1 autodo ftpusers 752K  9 janv. 03:37 8127.zip
-rwxr-xr-x 1 autodo ftpusers 6,1K  8 janv. 22:01 84846.zip
-rwxr-xr-x 1 autodo ftpusers 358K  9 janv. 02:42 989.zip
sh-4.1$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data),2000(ftpusers)
sh-4.1$ mv /home/autodo/23550.zip /home/autodo/.processed/
mv: unable to move « /home/autodo/23550.zip » to « /home/autodo/.processed/23550.zip »: Permission denied

I also tried to setgid this user's directory, but it also failed with the same Permission denied, and to adduser www-data ftpusers, but it still failed with the same error.

I have to admit that I'm lost; I always thought that the permissions of a group owning a file meant the same than the owner ones, but this problem contradicts this, and I can't think that there can be such a bug in the Linux kernel, so I have to had missed something, but where, dammit!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

since a mv is modifying both the "to directory" and the "from directory" you need write permissions on the files you are moving as well as the directories you are moving to/from.

chmod -R g+w /home/autodo/

this will recursively add write permissions for group for everything under /home/autodo

share|improve this answer
    
Naaah... I'm so stupid. How could I let pass such an evident error? As we say here, Oh, le con!. –  Penegal Jan 9 '13 at 15:08
    
@Penegal glad to help. –  h3rrmiller Jan 9 '13 at 15:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.