Commit 9a54a640 authored by Matt McCutchen's avatar Matt McCutchen Committed by Wayne Davison

Don't set the umask to 0 any more: it's ugly and pointless.

parent 58a79f4b
...@@ -48,7 +48,6 @@ extern int write_batch; ...@@ -48,7 +48,6 @@ extern int write_batch;
extern int default_af_hint; extern int default_af_hint;
extern int logfile_format_has_i; extern int logfile_format_has_i;
extern int logfile_format_has_o_or_i; extern int logfile_format_has_o_or_i;
extern mode_t orig_umask;
extern char *bind_address; extern char *bind_address;
extern char *config_file; extern char *config_file;
extern char *logfile_format; 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 ...@@ -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)) { if (*lp_prexfer_exec(i) || *lp_postxfer_exec(i)) {
int status; int status;
umask(orig_umask);
/* For post-xfer exec, fork a new process to run the rsync /* For post-xfer exec, fork a new process to run the rsync
* daemon while this process waits for the exit status and * daemon while this process waits for the exit status and
* runs the indicated command at that point. */ * 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 ...@@ -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]); set_blocking(fds[1]);
pre_exec_fd = fds[1]; pre_exec_fd = fds[1];
} }
umask(0);
} }
#endif #endif
...@@ -1076,7 +1073,7 @@ static void create_pid_file(void) ...@@ -1076,7 +1073,7 @@ static void create_pid_file(void)
return; return;
cleanup_set_pid(pid); 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: failure:
cleanup_set_pid(0); cleanup_set_pid(0);
fprintf(stderr, "failed to create pid file %s: %s\n", pid_file, strerror(errno)); fprintf(stderr, "failed to create pid file %s: %s\n", pid_file, strerror(errno));
......
...@@ -1521,9 +1521,10 @@ int main(int argc,char *argv[]) ...@@ -1521,9 +1521,10 @@ int main(int argc,char *argv[])
exit_cleanup(RERR_SYNTAX); exit_cleanup(RERR_SYNTAX);
} }
/* we set a 0 umask so that correct file permissions can be /* Get the umask for use in permission calculations. We no longer set
* carried across */ * it to zero; that is ugly and pointless now that all the callers that
orig_umask = umask(0); * relied on it have been reeducated to work with default ACLs. */
umask(orig_umask = umask(0));
#if defined CONFIG_LOCALE && defined HAVE_SETLOCALE #if defined CONFIG_LOCALE && defined HAVE_SETLOCALE
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
......
...@@ -27,7 +27,6 @@ extern int am_server; ...@@ -27,7 +27,6 @@ extern int am_server;
extern int blocking_io; extern int blocking_io;
extern int filesfrom_fd; extern int filesfrom_fd;
extern int munge_symlinks; extern int munge_symlinks;
extern mode_t orig_umask;
extern char *logfile_name; extern char *logfile_name;
extern int remote_option_cnt; extern int remote_option_cnt;
extern const char **remote_options; extern const char **remote_options;
...@@ -78,7 +77,6 @@ pid_t piped_child(char **command, int *f_in, int *f_out) ...@@ -78,7 +77,6 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
close(to_child_pipe[0]); close(to_child_pipe[0]);
if (from_child_pipe[1] != STDOUT_FILENO) if (from_child_pipe[1] != STDOUT_FILENO)
close(from_child_pipe[1]); close(from_child_pipe[1]);
umask(orig_umask);
set_blocking(STDIN_FILENO); set_blocking(STDIN_FILENO);
if (blocking_io > 0) if (blocking_io > 0)
set_blocking(STDOUT_FILENO); set_blocking(STDOUT_FILENO);
......
...@@ -26,7 +26,6 @@ int module_id = -1; ...@@ -26,7 +26,6 @@ int module_id = -1;
int relative_paths = 0; int relative_paths = 0;
int module_dirlen = 0; int module_dirlen = 0;
int preserve_xattrs = 0; int preserve_xattrs = 0;
mode_t orig_umask = 002;
char number_separator = ','; char number_separator = ',';
char *partial_dir; char *partial_dir;
char *module_dir; char *module_dir;
......
...@@ -32,7 +32,6 @@ extern int relative_paths; ...@@ -32,7 +32,6 @@ extern int relative_paths;
extern int preserve_xattrs; extern int preserve_xattrs;
extern char *module_dir; extern char *module_dir;
extern unsigned int module_dirlen; extern unsigned int module_dirlen;
extern mode_t orig_umask;
extern char *partial_dir; extern char *partial_dir;
extern filter_rule_list daemon_filter_list; 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) ...@@ -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 /* This creates a new directory with default permissions. Now that we
* might be some directory-default permissions affecting this, we can't * leave the original umask set, we can just mkdir with mode 777. */
* force the permissions directly using the original umask and mkdir(). */
int mkdir_defmode(char *fname) int mkdir_defmode(char *fname)
{ {
int ret; return do_mkdir(fname, ACCESSPERMS);
umask(orig_umask);
ret = do_mkdir(fname, ACCESSPERMS);
umask(0);
return ret;
} }
/* Create any necessary directories in fname. Any missing directories are /* Create any necessary directories in fname. Any missing directories are
...@@ -216,8 +208,6 @@ int make_path(char *fname, int flags) ...@@ -216,8 +208,6 @@ int make_path(char *fname, int flags)
} else } else
end = fname + strlen(fname); 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. */ /* Try to find an existing dir, starting from the deepest dir. */
for (p = end; ; ) { for (p = end; ; ) {
if (do_mkdir(fname, ACCESSPERMS) == 0) { if (do_mkdir(fname, ACCESSPERMS) == 0) {
...@@ -258,8 +248,6 @@ int make_path(char *fname, int flags) ...@@ -258,8 +248,6 @@ int make_path(char *fname, int flags)
ret++; ret++;
} }
umask(0);
if (flags & MKP_DROP_NAME) if (flags & MKP_DROP_NAME)
*end = '/'; *end = '/';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment