diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2011-12-05 13:11:09 +0100 |
---|---|---|
committer | Benjamin Fleischer <fleiben@gmail.com> | 2012-01-22 11:16:37 +0100 |
commit | 69b2b3cc0e63dd3a1d7181315f09ceb4b57722be (patch) | |
tree | 2caa2f702fb02d699d90d2c41abc148204a82256 /sshfs.c | |
parent | fa9bfc6d08fc01d3ac6ec91bec7cdc102aec2df1 (diff) | |
download | sshfs-69b2b3cc0e63dd3a1d7181315f09ceb4b57722be.tar sshfs-69b2b3cc0e63dd3a1d7181315f09ceb4b57722be.tar.gz sshfs-69b2b3cc0e63dd3a1d7181315f09ceb4b57722be.tar.bz2 sshfs-69b2b3cc0e63dd3a1d7181315f09ceb4b57722be.zip |
Make chown respect the UID mapping policy
Reported and tested by Vivenzio Pagliari
Diffstat (limited to 'sshfs.c')
-rw-r--r-- | sshfs.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -2226,9 +2226,7 @@ static int sshfs_chown(const char *path, uid_t uid, gid_t gid) { int err; struct buffer buf; - buf_init(&buf, 0); - buf_add_path(&buf, path); - buf_add_uint32(&buf, SSH_FILEXFER_ATTR_UIDGID); + #if __APPLE__ if (sshfs.remote_uid_detected) { if (uid == sshfs.local_uid) @@ -2236,7 +2234,14 @@ static int sshfs_chown(const char *path, uid_t uid, gid_t gid) if (gid == sshfs.local_gid) gid = sshfs.remote_gid; } -#endif /* __APPLE__ */ +#else /* !__APPLE__ */ + if (sshfs.remote_uid_detected && uid == sshfs.local_uid) + uid = sshfs.remote_uid; +#endif /* !__APPLE__ */ + + buf_init(&buf, 0); + buf_add_path(&buf, path); + buf_add_uint32(&buf, SSH_FILEXFER_ATTR_UIDGID); buf_add_uint32(&buf, uid); buf_add_uint32(&buf, gid); err = sftp_request(SSH_FXP_SETSTAT, &buf, SSH_FXP_STATUS, NULL); |