[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Sat Jul 4 17:31:41 UTC 2020


The branch, master has been updated
       via  f4184849 Use module_id more consistently after it is set.
       via  565cde84 Don't turn off the user's open-noatime unless the module is forcing the value.
       via  f0e670b4 Add "open noatime" module option to rsyncd.conf
      from  ef895177 Fix issue in --compress-level doc.

https://git.samba.org/?p=rsync.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f4184849c44cfb30cb9f77161dd5ff2656877691
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sat Jul 4 10:26:56 2020 -0700

    Use module_id more consistently after it is set.

commit 565cde84a71b212b25289e0e32221a66b3263837
Author: Wayne Davison <wayne at opencoder.net>
Date:   Sat Jul 4 10:23:17 2020 -0700

    Don't turn off the user's open-noatime unless the module is forcing the value.

commit f0e670b4c691c58de3f996f2f18b50a0ee95777a
Author: Paul Slootman <paul at wurtel.net>
Date:   Sat Jul 4 16:28:50 2020 +0200

    Add "open noatime" module option to rsyncd.conf

-----------------------------------------------------------------------

Summary of changes:
 NEWS.md          |  3 +++
 clientserver.c   | 60 +++++++++++++++++++++++++++++++-------------------------
 daemon-parm.awk  |  4 ++--
 daemon-parm.txt  |  6 ++++--
 loadparm.c       | 50 +++++++++++++++++++++++-----------------------
 rsync.h          |  1 +
 rsyncd.conf.5.md | 16 +++++++++++++++
 7 files changed, 83 insertions(+), 57 deletions(-)


Changeset truncated at 500 lines:

diff --git a/NEWS.md b/NEWS.md
index 516c49f9..cb0d5436 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -37,6 +37,9 @@
    also allows you to specify the value via the RSYNC_MAX_ALLOC environment
    variable.
 
+ - Add the "open atime" daemon parameter to allow a daemon to always enable or
+   disable the use of O_NOATIME (the default is to let the user control it).
+
  - The default systemd config was changed to remove the `ProtectHome=on`
    setting since rsync is often used to serve files in /home and /root and this
    seemed a bit too strict.  Feel free to use `systemctl edit rsync` to add
diff --git a/clientserver.c b/clientserver.c
index 57bb1b9a..831c3eab 100644
--- a/clientserver.c
+++ b/clientserver.c
@@ -38,6 +38,7 @@ extern int preserve_xattrs;
 extern int kluge_around_eof;
 extern int daemon_over_rsh;
 extern int munge_symlinks;
+extern int open_noatime;
 extern int sanitize_paths;
 extern int numeric_ids;
 extern int filesfrom_fd;
@@ -695,8 +696,8 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 
 	module_id = i;
 
-	if (lp_transfer_logging(i) && !logfile_format)
-		logfile_format = lp_log_format(i);
+	if (lp_transfer_logging(module_id) && !logfile_format)
+		logfile_format = lp_log_format(module_id);
 	if (log_format_has(logfile_format, 'i'))
 		logfile_format_has_i = 1;
 	if (logfile_format_has_i || log_format_has(logfile_format, 'o'))
@@ -705,7 +706,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 	uid = MY_UID();
 	am_root = (uid == 0);
 
-	p = *lp_uid(i) ? lp_uid(i) : am_root ? NOBODY_USER : NULL;
+	p = *lp_uid(module_id) ? lp_uid(module_id) : am_root ? NOBODY_USER : NULL;
 	if (p) {
 		if (!user_to_uid(p, &uid, True)) {
 			rprintf(FLOG, "Invalid uid %s\n", p);
@@ -716,7 +717,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 	} else
 		set_uid = 0;
 
-	p = *lp_gid(i) ? conf_strtok(lp_gid(i)) : NULL;
+	p = *lp_gid(module_id) ? conf_strtok(lp_gid(module_id)) : NULL;
 	if (p) {
 		/* The "*" gid must be the first item in the list. */
 		if (strcmp(p, "*") == 0) {
@@ -749,7 +750,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 			return -1;
 	}
 
-	module_dir = lp_path(i);
+	module_dir = lp_path(module_id);
 	if (*module_dir == '\0') {
 		rprintf(FLOG, "No path specified for module %s\n", name);
 		io_printf(f_out, "@ERROR: no path setting.\n");
@@ -786,38 +787,38 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 	} else
 		set_filter_dir(module_dir, module_dirlen);
 
-	p = lp_filter(i);
+	p = lp_filter(module_id);
 	parse_filter_str(&daemon_filter_list, p, rule_template(FILTRULE_WORD_SPLIT),
 		XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3);
 
-	p = lp_include_from(i);
+	p = lp_include_from(module_id);
 	parse_filter_file(&daemon_filter_list, p, rule_template(FILTRULE_INCLUDE),
 		XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
 
-	p = lp_include(i);
+	p = lp_include(module_id);
 	parse_filter_str(&daemon_filter_list, p,
 		rule_template(FILTRULE_INCLUDE | FILTRULE_WORD_SPLIT),
 		XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
 
-	p = lp_exclude_from(i);
+	p = lp_exclude_from(module_id);
 	parse_filter_file(&daemon_filter_list, p, rule_template(0),
 		XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
 
-	p = lp_exclude(i);
+	p = lp_exclude(module_id);
 	parse_filter_str(&daemon_filter_list, p, rule_template(FILTRULE_WORD_SPLIT),
 		XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
 
 	log_init(1);
 
 #ifdef HAVE_PUTENV
-	if ((*lp_early_exec(i) || *lp_prexfer_exec(i) || *lp_postxfer_exec(i))
+	if ((*lp_early_exec(module_id) || *lp_prexfer_exec(module_id) || *lp_postxfer_exec(module_id))
 	 && !getenv("RSYNC_NO_XFER_EXEC")) {
 		set_env_num("RSYNC_PID", (long)getpid());
 
 		/* 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. */
-		if (*lp_postxfer_exec(i)) {
+		if (*lp_postxfer_exec(module_id)) {
 			pid_t pid = fork();
 			if (pid < 0) {
 				rsyserr(FLOG, errno, "fork failed");
@@ -837,7 +838,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 				else
 					status = -1;
 				set_env_num("RSYNC_EXIT_STATUS", status);
-				if (shell_exec(lp_postxfer_exec(i)) < 0)
+				if (shell_exec(lp_postxfer_exec(module_id)) < 0)
 					status = -1;
 				_exit(status);
 			}
@@ -845,9 +846,9 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 
 		/* For early exec, fork a child process to run the indicated
 		 * command and wait for it to exit. */
-		if (*lp_early_exec(i)) {
+		if (*lp_early_exec(module_id)) {
 			int arg_fd;
-			pid_t pid = start_pre_exec(lp_early_exec(i), &arg_fd, NULL);
+			pid_t pid = start_pre_exec(lp_early_exec(module_id), &arg_fd, NULL);
 			if (pid == (pid_t)-1) {
 				rsyserr(FLOG, errno, "early exec preparation failed");
 				io_printf(f_out, "@ERROR: early exec preparation failed\n");
@@ -864,8 +865,8 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 		/* For pre-xfer exec, fork a child process to run the indicated
 		 * command, though it first waits for the parent process to
 		 * send us the user's request via a pipe. */
-		if (*lp_prexfer_exec(i)) {
-			pre_exec_pid = start_pre_exec(lp_prexfer_exec(i), &pre_exec_arg_fd, &pre_exec_error_fd);
+		if (*lp_prexfer_exec(module_id)) {
+			pre_exec_pid = start_pre_exec(lp_prexfer_exec(module_id), &pre_exec_arg_fd, &pre_exec_error_fd);
 			if (pre_exec_pid == (pid_t)-1) {
 				rsyserr(FLOG, errno, "pre-xfer exec preparation failed");
 				io_printf(f_out, "@ERROR: pre-xfer exec preparation failed\n");
@@ -906,7 +907,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 	if (module_dirlen || (!use_chroot && !*lp_daemon_chroot()))
 		sanitize_paths = 1;
 
-	if ((munge_symlinks = lp_munge_symlinks(i)) < 0)
+	if ((munge_symlinks = lp_munge_symlinks(module_id)) < 0)
 		munge_symlinks = !use_chroot || module_dirlen;
 	if (munge_symlinks) {
 		STRUCT_STAT st;
@@ -961,8 +962,8 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 		am_root = (our_uid == 0);
 	}
 
-	if (lp_temp_dir(i) && *lp_temp_dir(i)) {
-		tmpdir = lp_temp_dir(i);
+	if (lp_temp_dir(module_id) && *lp_temp_dir(module_id)) {
+		tmpdir = lp_temp_dir(module_id);
 		if (strlen(tmpdir) >= MAXPATHLEN - 10) {
 			rprintf(FLOG,
 				"the 'temp dir' value for %s is WAY too long -- ignoring.\n",
@@ -989,7 +990,12 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 	} else
 		orig_early_argv = NULL;
 
+	/* The default is to use the user's setting unless the module sets True or False. */
+	if (lp_open_noatime(module_id) >= 0)
+		open_noatime = lp_open_noatime(module_id);
+
 	munge_symlinks = save_munge_symlinks; /* The client mustn't control this. */
+
 	if (am_daemon > 0)
 		msgs2stderr = 0; /* A non-rsh-run daemon doesn't have stderr for msgs. */
 
@@ -1008,7 +1014,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 	if (write_batch < 0)
 		dry_run = 1;
 
-	if (lp_fake_super(i)) {
+	if (lp_fake_super(module_id)) {
 		if (preserve_xattrs > 1)
 			preserve_xattrs = 1;
 		am_root = -1;
@@ -1033,7 +1039,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 
 #ifndef DEBUG
 	/* don't allow the logs to be flooded too fast */
-	limit_output_verbosity(lp_max_verbosity(i));
+	limit_output_verbosity(lp_max_verbosity(module_id));
 #endif
 
 	if (protocol_version < 23 && (protocol_version == 22 || am_sender))
@@ -1094,20 +1100,20 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char
 #endif
 
 	if (!numeric_ids
-	 && (use_chroot ? lp_numeric_ids(i) != False : lp_numeric_ids(i) == True))
+	 && (use_chroot ? lp_numeric_ids(module_id) != False : lp_numeric_ids(module_id) == True))
 		numeric_ids = -1; /* Set --numeric-ids w/o breaking protocol. */
 
-	if (lp_timeout(i) && (!io_timeout || lp_timeout(i) < io_timeout))
-		set_io_timeout(lp_timeout(i));
+	if (lp_timeout(module_id) && (!io_timeout || lp_timeout(module_id) < io_timeout))
+		set_io_timeout(lp_timeout(module_id));
 
 	/* If we have some incoming/outgoing chmod changes, append them to
 	 * any user-specified changes (making our changes have priority).
 	 * We also get a pointer to just our changes so that a receiver
 	 * process can use them separately if --perms wasn't specified. */
 	if (am_sender)
-		p = lp_outgoing_chmod(i);
+		p = lp_outgoing_chmod(module_id);
 	else
-		p = lp_incoming_chmod(i);
+		p = lp_incoming_chmod(module_id);
 	if (*p && !(daemon_chmod_modes = parse_chmod(p, &chmod_modes))) {
 		rprintf(FLOG, "Invalid \"%sing chmod\" directive: %s\n",
 			am_sender ? "outgo" : "incom", p);
diff --git a/daemon-parm.awk b/daemon-parm.awk
index c4752c78..dd0eded0 100755
--- a/daemon-parm.awk
+++ b/daemon-parm.awk
@@ -41,7 +41,7 @@ BEGIN {
     next
 }
 
-/^(STRING|CHAR|PATH|INTEGER|ENUM|OCTAL|BOOL|BOOLREV)[ \t]/ {
+/^(STRING|CHAR|PATH|INTEGER|ENUM|OCTAL|BOOL|BOOLREV|BOOL3)[ \t]/ {
     ptype = $1
     name = $2
     $1 = $2 = ""
@@ -59,7 +59,7 @@ BEGIN {
     if (ptype == "STRING" || ptype == "PATH") {
 	atype = "STRING"
 	vtype = "char*"
-    } else if (ptype == "BOOL" || ptype == "BOOLREV") {
+    } else if (ptype ~ /BOOL/) {
 	atype = vtype = "BOOL"
     } else if (ptype == "CHAR") {
 	atype = "CHAR"
diff --git a/daemon-parm.txt b/daemon-parm.txt
index 83ecc980..0f8f01e5 100644
--- a/daemon-parm.txt
+++ b/daemon-parm.txt
@@ -55,11 +55,13 @@ BOOL	forward_lookup		True
 BOOL	ignore_errors		False
 BOOL	ignore_nonreadable	False
 BOOL	list			True
-BOOL	munge_symlinks		(BOOL)-1
-BOOL	numeric_ids		(BOOL)-1
 BOOL	read_only		True
 BOOL	reverse_lookup		True
 BOOL	strict_modes		True
 BOOL	transfer_logging	False
 BOOL	use_chroot		True
 BOOL	write_only		False
+
+BOOL3	munge_symlinks		Unset
+BOOL3	numeric_ids		Unset
+BOOL3	open_noatime		Unset
diff --git a/loadparm.c b/loadparm.c
index 5e532da2..a1d5992d 100644
--- a/loadparm.c
+++ b/loadparm.c
@@ -48,7 +48,6 @@
 extern item_list dparam_list;
 
 #define strequal(a, b) (strcasecmp(a, b)==0)
-#define BOOLSTR(b) ((b) ? "Yes" : "No")
 
 #ifndef LOG_DAEMON
 #define LOG_DAEMON 0
@@ -56,7 +55,7 @@ extern item_list dparam_list;
 
 /* the following are used by loadparm for option lists */
 typedef enum {
-	P_BOOL, P_BOOLREV, P_CHAR, P_INTEGER,
+	P_BOOL, P_BOOLREV, P_BOOL3, P_CHAR, P_INTEGER,
 	P_OCTAL, P_PATH, P_STRING, P_ENUM
 } parm_type;
 
@@ -279,19 +278,14 @@ static void init_section(local_vars *psection)
 	copy_section(psection, &Vars.l);
 }
 
-/* Do a case-insensitive, whitespace-ignoring string compare. */
-static int strwicmp(char *psz1, char *psz2)
+/* Do a case-insensitive, whitespace-ignoring string equality check. */
+static int strwiEQ(char *psz1, char *psz2)
 {
-	/* if BOTH strings are NULL, return TRUE, if ONE is NULL return */
-	/* appropriate value. */
+	/* If one or both strings are NULL, we return equality right away. */
 	if (psz1 == psz2)
-		return 0;
-
-	if (psz1 == NULL)
-		return -1;
-
-	if (psz2 == NULL)
 		return 1;
+	if (psz1 == NULL || psz2 == NULL)
+		return 0;
 
 	/* sync the strings on first non-whitespace */
 	while (1) {
@@ -299,12 +293,14 @@ static int strwicmp(char *psz1, char *psz2)
 			psz1++;
 		while (isSpace(psz2))
 			psz2++;
-		if (toUpper(psz1) != toUpper(psz2) || *psz1 == '\0' || *psz2 == '\0')
+		if (*psz1 == '\0' || *psz2 == '\0')
+			break;
+		if (toUpper(psz1) != toUpper(psz2))
 			break;
 		psz1++;
 		psz2++;
 	}
-	return *psz1 - *psz2;
+	return *psz1 == *psz2;
 }
 
 /* Find a section by name. Otherwise works like get_section. */
@@ -313,7 +309,7 @@ static int getsectionbyname(char *name)
 	int i;
 
 	for (i = section_list.count - 1; i >= 0; i--) {
-		if (strwicmp(iSECTION(i).name, name) == 0)
+		if (strwiEQ(iSECTION(i).name, name))
 			break;
 	}
 
@@ -353,7 +349,7 @@ static int map_parameter(char *parmname)
 		return -1;
 
 	for (iIndex = 0; parm_table[iIndex].label; iIndex++) {
-		if (strwicmp(parm_table[iIndex].label, parmname) == 0)
+		if (strwiEQ(parm_table[iIndex].label, parmname))
 			return iIndex;
 	}
 
@@ -364,16 +360,14 @@ static int map_parameter(char *parmname)
 /* Set a boolean variable from the text value stored in the passed string.
  * Returns True in success, False if the passed string does not correctly
  * represent a boolean. */
-static BOOL set_boolean(BOOL *pb, char *parmvalue)
+static BOOL set_boolean(BOOL *pb, char *parmvalue, int allow_unset)
 {
-	if (strwicmp(parmvalue, "yes") == 0
-	 || strwicmp(parmvalue, "true") == 0
-	 || strwicmp(parmvalue, "1") == 0)
+	if (strwiEQ(parmvalue, "yes") || strwiEQ(parmvalue, "true") || strwiEQ(parmvalue, "1"))
 		*pb = True;
-	else if (strwicmp(parmvalue, "no") == 0
-	      || strwicmp(parmvalue, "False") == 0
-	      || strwicmp(parmvalue, "0") == 0)
+	else if (strwiEQ(parmvalue, "no") || strwiEQ(parmvalue, "false") || strwiEQ(parmvalue, "0"))
 		*pb = False;
+	else if (allow_unset && (strwiEQ(parmvalue, "unset") || strwiEQ(parmvalue, "-1")))
+		*pb = Unset;
 	else {
 		rprintf(FLOG, "Badly formed boolean in configuration file: \"%s\".\n", parmvalue);
 		return False;
@@ -422,11 +416,15 @@ static BOOL do_parameter(char *parmname, char *parmvalue)
 
 	switch (parm_table[parmnum].type) {
 	case P_BOOL:
-		set_boolean(parm_ptr, parmvalue);
+		set_boolean(parm_ptr, parmvalue, False);
+		break;
+
+	case P_BOOL3:
+		set_boolean(parm_ptr, parmvalue, True);
 		break;
 
 	case P_BOOLREV:
-		set_boolean(parm_ptr, parmvalue);
+		set_boolean(parm_ptr, parmvalue, False);
 		*(BOOL *)parm_ptr = ! *(BOOL *)parm_ptr;
 		break;
 
@@ -496,7 +494,7 @@ static BOOL do_section(char *sectionname)
 		return True;
 	}
 
-	isglobal = strwicmp(sectionname, GLOBAL_NAME) == 0;
+	isglobal = strwiEQ(sectionname, GLOBAL_NAME);
 
 	/* At the end of the global section, add any --dparam items. */
 	if (bInGlobalSection && !isglobal) {
diff --git a/rsync.h b/rsync.h
index 2668d670..41c4052b 100644
--- a/rsync.h
+++ b/rsync.h
@@ -20,6 +20,7 @@
 
 #define False 0
 #define True 1
+#define Unset (-1) /* Our BOOL values are always an int. */
 
 #define BLOCK_SIZE 700
 #define RSYNC_RSH_ENV "RSYNC_RSH"
diff --git a/rsyncd.conf.5.md b/rsyncd.conf.5.md
index 4e9da77c..11f77cb0 100644
--- a/rsyncd.conf.5.md
+++ b/rsyncd.conf.5.md
@@ -424,6 +424,22 @@ the values of parameters.  See the GLOBAL PARAMETERS section for more details.
     Helpful hint: you probably want to specify "refuse options = delete" for a
     write-only module.
 
+0.  `open noatime`
+
+    When set to True, this parameter tells the rsync daemon to open files with
+    the O_NOATIME flag
+    (on systems that support it) to avoid changing the access time of the files
+    that are being transferred.  If your OS does not support the O_NOATIME flag
+    then rsync will silently ignore this option.  Note also that some
+    filesystems are mounted to avoid updating the atime on read access even
+    without the O_NOATIME flag being set.
+
+    When set to False, this parameters ensures that files on the server are not
+    opened with O_NOATIME.
+
+    When set to Unset (the default) the user controls the setting via
+    `--open-noatime`.
+
 0.  `list`
 
     This parameter determines whether this module is listed when the client


-- 
The rsync repository.



More information about the rsync-cvs mailing list