From 69b2b3cc0e63dd3a1d7181315f09ceb4b57722be Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 5 Dec 2011 13:11:09 +0100 Subject: Make chown respect the UID mapping policy Reported and tested by Vivenzio Pagliari --- ChangeLog | 5 +++++ sshfs.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f11917..9b3fb9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-25 Miklos Szeredi + + * Make chown respect the UID mapping policy. Reported and tested + by Vivenzio Pagliari + 2011-11-16 Miklos Szeredi * Submit max 32k reads and writes to the sftp server. Also don't diff --git a/sshfs.c b/sshfs.c index 89b3974..62fadff 100644 --- a/sshfs.c +++ b/sshfs.c @@ -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); -- cgit v1.2.3