# move : permission denied



## nORKy (Jan 18, 2012)

I don't undestand this

```
%id
uid=1025(kuthe) gid=100(users) groups=100(users)
%touch /tmp/test
%ls -la /tmp/test
-rw----r--  1 kuthe  wheel  0 18 jan 11:22 /tmp/test
%ls -la /u/kuthe/home/www/img_art/files/
total 6
drwxr-xr-x  2 kuthe  users   3 18 jan 11:21 .
drwxr-xr-x  3 kuthe  users  61 18 jan 11:02 ..
%mv /tmp/test /u/kuthe/home/www/img_art/files/
mv: /u/kuthe/home/www/img_art/files/test: set owner/group (was: 1025/0): Operation not permitted
%
```

it's a zfs filesystem under FreeBSD-8.2-RELEASE

thanks you for your help


----------



## SirDice (Jan 18, 2012)

What are the permissions on /tmp/ itself?

Oh wait, it tries to set the group ownership to wheel. Which you are not allowed to do.


----------



## nORKy (Jan 18, 2012)

tmp is

```
drwxrwxrwt   7 root       wheel     4142 18 jan 13:57 .
```

I don't understand what to do/change


----------



## SirDice (Jan 18, 2012)

Look at the group ownership of the /tmp/test file.

You are not a member of the wheel group and you are therefor not allowed to change the ownership.

When you are moving a file from one filesystem to another it actually does a copy followed by a delete. It cannot change the group ownership to wheel on the copy.


----------



## nORKy (Jan 18, 2012)

yes, /tmp/test's group is wheel. But why? The problem is that there are php applicationss that upload file to /tmp et try to move to their directory. Are permissions of /tmp bad?


----------



## SirDice (Jan 18, 2012)

nORKy said:
			
		

> yes, /tmp/test's group is wheel. But why ??


That's normal, correct behavior. It's because the group on /tmp/ is wheel.



> the problem is that there are php applicationss that upload file to /tmp et try to move to their directory.


One way to solve it is to create a subdirectory in /tmp/ with the correct group and have the application use that.

Another option would require the adjustment of the web application. Instead of moving the file it should use a plain copy and delete.



> are permissions of tmp bad ?


No, they are absolutely correct.


Some background. 
From mv(1)

```
As the rename(2) call does not work across file systems, mv uses cp(1)
     and rm(1) to accomplish the move.  The effect is equivalent to:

           rm -f destination_path && \
           cp -pRP source_file destination && \
           rm -rf source_file
```

It's the -P option to cp(1) that's causing the issue. It tries to preserve the owner, group and permissions of the file.


----------

