Subject: cp -p fails to preserve permissions on sshfs

From: Jared Henley <[email-masked]>
Date: Fri, 20 Jul 2012 09:10:31 +1000

These days I'm frequently using sshfs to access a remote server running 
Linux.
I like to use Rox-Filer, which copies files using "cp -p". I always get 
permission
denied errors trying to change ownership, which is expected. But then the
permissions of the copied file are always 600, which causes problems 
since the
files need to be group-readable. The umask on the server is 002.

Below is some test output to demonstrate what happens.

[pe@hope ~]$ sshfs ja@localhost:/home/ja sshfs
ja@localhost's password:
[pe@hope ~]$ touch sshfs/newfile
[pe@hope ~]$ ls -l sshfs/newfile
-rw-rw-r-- 1 ja ja 0 Jul 20 08:35 sshfs/newfile
[pe@hope ~]$ touch newfile2
[pe@hope ~]$ cp -p newfile2 sshfs
cp: failed to preserve ownership for ‘sshfs/newfile2’: Permission denied
[pe@hope ~]$ ls -l sshfs/newfile2
-rw------- 1 ja ja 0 Jul 20 08:36 sshfs/newfile2
[pe@hope ~]$ rm sshfs/newfile2
[pe@hope ~]$ cp newfile2 sshfs
[pe@hope ~]$ ls -l sshfs/newfile2
-rw-rw-r-- 1 ja ja 0 Jul 20 08:37 sshfs/newfile2

Is there some security reason why the permissions fall back to 600 when the
chown fails, or is this a bug?

Jared Henley