From 923524951aa3c138d67f7a848baeef3bcc1bae34 Mon Sep 17 00:00:00 2001 From: Paul Chitescu Date: Tue, 8 Dec 2009 14:10:01 +0200 Subject: [PATCH] server: Only check if permission bits changed before calling fchmod(). --- server/change.c | 2 +- server/file.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/change.c b/server/change.c index 7ef456f4dad..11b4729436a 100644 --- a/server/change.c +++ b/server/change.c @@ -376,7 +376,7 @@ static int dir_set_sd( struct object *obj, const struct security_descriptor *sd, mode = st.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXG); mode |= sd_to_mode( sd, owner ); - if (st.st_mode != mode && fchmod( unix_fd, mode ) == -1) + if (((st.st_mode ^ mode) & (S_IRWXU|S_IRWXG|S_IRWXO)) && fchmod( unix_fd, mode ) == -1) { file_set_error(); return 0; diff --git a/server/file.c b/server/file.c index 3e09ddd216f..5db64cdf8cc 100644 --- a/server/file.c +++ b/server/file.c @@ -560,7 +560,7 @@ static int file_set_sd( struct object *obj, const struct security_descriptor *sd mode = st.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXG); mode |= sd_to_mode( sd, owner ); - if (st.st_mode != mode && fchmod( unix_fd, mode ) == -1) + if (((st.st_mode ^ mode) & (S_IRWXU|S_IRWXG|S_IRWXO)) && fchmod( unix_fd, mode ) == -1) { file_set_error(); return 0;