diff options
author | Matt McCutchen <matt@mattmccutchen.net> | 2010-02-01 13:29:39 -0500 |
---|---|---|
committer | Wayne Davison <wayned@samba.org> | 2010-04-24 09:28:58 -0700 |
commit | 9a54a640f74dcaeb03ef99799a5320b3eb77f7ec (patch) | |
tree | fb3771462e84532dad9390f98aca2090600f9665 | |
parent | 58a79f4b44593996e53a9bfc94b56006ea86c2ec (diff) | |
download | rsync-9a54a640f74dcaeb03ef99799a5320b3eb77f7ec.tar.gz |
Don't set the umask to 0 any more: it's ugly and pointless.
-rw-r--r-- | clientserver.c | 5 | ||||
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | pipe.c | 2 | ||||
-rw-r--r-- | t_stub.c | 1 | ||||
-rw-r--r-- | util.c | 18 |
5 files changed, 8 insertions, 25 deletions
diff --git a/clientserver.c b/clientserver.c index a7996c7f..878254f3 100644 --- a/clientserver.c +++ b/clientserver.c @@ -48,7 +48,6 @@ extern int write_batch; extern int default_af_hint; extern int logfile_format_has_i; extern int logfile_format_has_o_or_i; -extern mode_t orig_umask; extern char *bind_address; extern char *config_file; extern char *logfile_format; @@ -676,7 +675,6 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char if (*lp_prexfer_exec(i) || *lp_postxfer_exec(i)) { int status; - umask(orig_umask); /* For post-xfer exec, fork a new process to run the rsync * daemon while this process waits for the exit status and * runs the indicated command at that point. */ @@ -745,7 +743,6 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char set_blocking(fds[1]); pre_exec_fd = fds[1]; } - umask(0); } #endif @@ -1076,7 +1073,7 @@ static void create_pid_file(void) return; cleanup_set_pid(pid); - if ((fd = do_open(pid_file, O_WRONLY|O_CREAT|O_EXCL, 0666 & ~orig_umask)) == -1) { + if ((fd = do_open(pid_file, O_WRONLY|O_CREAT|O_EXCL, 0666)) == -1) { failure: cleanup_set_pid(0); fprintf(stderr, "failed to create pid file %s: %s\n", pid_file, strerror(errno)); @@ -1521,9 +1521,10 @@ int main(int argc,char *argv[]) exit_cleanup(RERR_SYNTAX); } - /* we set a 0 umask so that correct file permissions can be - * carried across */ - orig_umask = umask(0); + /* Get the umask for use in permission calculations. We no longer set + * it to zero; that is ugly and pointless now that all the callers that + * relied on it have been reeducated to work with default ACLs. */ + umask(orig_umask = umask(0)); #if defined CONFIG_LOCALE && defined HAVE_SETLOCALE setlocale(LC_CTYPE, ""); @@ -27,7 +27,6 @@ extern int am_server; extern int blocking_io; extern int filesfrom_fd; extern int munge_symlinks; -extern mode_t orig_umask; extern char *logfile_name; extern int remote_option_cnt; extern const char **remote_options; @@ -78,7 +77,6 @@ pid_t piped_child(char **command, int *f_in, int *f_out) close(to_child_pipe[0]); if (from_child_pipe[1] != STDOUT_FILENO) close(from_child_pipe[1]); - umask(orig_umask); set_blocking(STDIN_FILENO); if (blocking_io > 0) set_blocking(STDOUT_FILENO); @@ -26,7 +26,6 @@ int module_id = -1; int relative_paths = 0; int module_dirlen = 0; int preserve_xattrs = 0; -mode_t orig_umask = 002; char number_separator = ','; char *partial_dir; char *module_dir; @@ -32,7 +32,6 @@ extern int relative_paths; extern int preserve_xattrs; extern char *module_dir; extern unsigned int module_dirlen; -extern mode_t orig_umask; extern char *partial_dir; extern filter_rule_list daemon_filter_list; @@ -178,18 +177,11 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode) } } -/* This creates a new directory with default permissions. Since there - * might be some directory-default permissions affecting this, we can't - * force the permissions directly using the original umask and mkdir(). */ +/* This creates a new directory with default permissions. Now that we + * leave the original umask set, we can just mkdir with mode 777. */ int mkdir_defmode(char *fname) { - int ret; - - umask(orig_umask); - ret = do_mkdir(fname, ACCESSPERMS); - umask(0); - - return ret; + return do_mkdir(fname, ACCESSPERMS); } /* Create any necessary directories in fname. Any missing directories are @@ -216,8 +208,6 @@ int make_path(char *fname, int flags) } else end = fname + strlen(fname); - umask(orig_umask); /* NOTE: don't return before setting this back to 0! */ - /* Try to find an existing dir, starting from the deepest dir. */ for (p = end; ; ) { if (do_mkdir(fname, ACCESSPERMS) == 0) { @@ -258,8 +248,6 @@ int make_path(char *fname, int flags) ret++; } - umask(0); - if (flags & MKP_DROP_NAME) *end = '/'; |