[SCM] The rsync repository. - branch master updated
Rsync CVS commit messages
rsync-cvs at lists.samba.org
Wed Jan 9 21:42:29 UTC 2019
The branch, master has been updated
via 48346c87 Reject --log-file when read-only.
via a0274c08 Improve check for ".." and guard against dash args.
via f627e277 Save each expanded daemon-config string on first use to avoid a new alloc on every use (one that was not freed).
via 0b6cae67 No need to strdup each new section since we stopped using free().
from e5610f18 Avoid a yodl macro warning.
https://git.samba.org/?p=rsync.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 48346c878f03868480c6c8db1f41e69576758ccc
Author: Wayne Davison <wayned at samba.org>
Date: Wed Jan 9 12:15:31 2019 -0800
Reject --log-file when read-only.
commit a0274c08b5b561c489046e835063f1e384bedd9c
Author: Wayne Davison <wayned at samba.org>
Date: Wed Jan 9 11:54:34 2019 -0800
Improve check for ".." and guard against dash args.
commit f627e27749dc03cf3ceeb705b81bc3f0a454731a
Author: Wayne Davison <wayned at samba.org>
Date: Tue Jan 8 20:33:58 2019 -0800
Save each expanded daemon-config string on first use to
avoid a new alloc on every use (one that was not freed).
commit 0b6cae6792439c50718830a2500e7a6ab7c36972
Author: Wayne Davison <wayned at samba.org>
Date: Tue Jan 8 20:30:58 2019 -0800
No need to strdup each new section since we stopped using free().
-----------------------------------------------------------------------
Summary of changes:
loadparm.c | 130 ++++++++++++++++++++++++++++++++++++++++++---------------
support/rrsync | 9 ++--
2 files changed, 103 insertions(+), 36 deletions(-)
Changeset truncated at 500 lines:
diff --git a/loadparm.c b/loadparm.c
index c118bf35..e6dd843c 100644
--- a/loadparm.c
+++ b/loadparm.c
@@ -100,6 +100,15 @@ typedef struct {
char *pid_file;
char *socket_options;
+ /* Each _EXP var tracks if the associated char* var has been expanded yet or not. */
+ BOOL bind_address_EXP;
+ BOOL daemon_chroot_EXP;
+ BOOL daemon_gid_EXP;
+ BOOL daemon_uid_EXP;
+ BOOL motd_file_EXP;
+ BOOL pid_file_EXP;
+ BOOL socket_options_EXP;
+
int listen_backlog;
int rsync_port;
} global_vars;
@@ -135,8 +144,34 @@ typedef struct {
char *syslog_tag;
char *temp_dir;
char *uid;
-/* NOTE: update this macro if the last char* variable changes! */
-#define LOCAL_STRING_COUNT() (offsetof(local_vars, uid) / sizeof (char*) + 1)
+
+ /* Each _EXP var tracks if the associated char* var has been expanded yet or not. */
+ BOOL auth_users_EXP;
+ BOOL charset_EXP;
+ BOOL comment_EXP;
+ BOOL dont_compress_EXP;
+ BOOL exclude_EXP;
+ BOOL exclude_from_EXP;
+ BOOL filter_EXP;
+ BOOL gid_EXP;
+ BOOL hosts_allow_EXP;
+ BOOL hosts_deny_EXP;
+ BOOL include_EXP;
+ BOOL include_from_EXP;
+ BOOL incoming_chmod_EXP;
+ BOOL lock_file_EXP;
+ BOOL log_file_EXP;
+ BOOL log_format_EXP;
+ BOOL name_EXP;
+ BOOL outgoing_chmod_EXP;
+ BOOL path_EXP;
+ BOOL postxfer_exec_EXP;
+ BOOL prexfer_exec_EXP;
+ BOOL refuse_options_EXP;
+ BOOL secrets_file_EXP;
+ BOOL syslog_tag_EXP;
+ BOOL temp_dir_EXP;
+ BOOL uid_EXP;
int max_connections;
int max_verbosity;
@@ -183,6 +218,14 @@ static const all_vars Defaults = {
/* pid_file; */ NULL,
/* socket_options; */ NULL,
+ /* bind_address_EXP; */ False,
+ /* daemon_chroot_EXP; */ False,
+ /* daemon_gid_EXP; */ False,
+ /* daemon_uid_EXP; */ False,
+ /* motd_file_EXP; */ False,
+ /* pid_file_EXP; */ False,
+ /* socket_options_EXP; */ False,
+
/* listen_backlog; */ 5,
/* rsync_port; */ 0,
},
@@ -216,6 +259,33 @@ static const all_vars Defaults = {
/* temp_dir; */ NULL,
/* uid; */ NULL,
+ /* auth_users_EXP; */ False,
+ /* charset_EXP; */ False,
+ /* comment_EXP; */ False,
+ /* dont_compress_EXP; */ False,
+ /* exclude_EXP; */ False,
+ /* exclude_from_EXP; */ False,
+ /* filter_EXP; */ False,
+ /* gid_EXP; */ False,
+ /* hosts_allow_EXP; */ False,
+ /* hosts_deny_EXP; */ False,
+ /* include_EXP; */ False,
+ /* include_from_EXP; */ False,
+ /* incoming_chmod_EXP; */ False,
+ /* lock_file_EXP; */ False,
+ /* log_file_EXP; */ False,
+ /* log_format_EXP; */ False,
+ /* name_EXP; */ False,
+ /* outgoing_chmod_EXP; */ False,
+ /* path_EXP; */ False,
+ /* postxfer_exec_EXP; */ False,
+ /* prexfer_exec_EXP; */ False,
+ /* refuse_options_EXP; */ False,
+ /* secrets_file_EXP; */ False,
+ /* syslog_tag_EXP; */ False,
+ /* temp_dir_EXP; */ False,
+ /* uid_EXP; */ False,
+
/* max_connections; */ 0,
/* max_verbosity; */ 1,
/* syslog_facility; */ LOG_DAEMON,
@@ -391,7 +461,7 @@ static char *expand_vars(char *str)
char *buf, *t, *f;
int bufsize;
- if (strchr(str, '%') == NULL)
+ if (!str || !strchr(str, '%'))
return str;
bufsize = strlen(str) + 2048;
@@ -434,20 +504,23 @@ static char *expand_vars(char *str)
return buf;
}
+/* NOTE: use this function and all the FN_{GLOBAL,LOCAL} ones WITHOUT a trailing semicolon! */
+#define RETURN_EXPANDED(val) {if (!val ## _EXP) {val = expand_vars(val); val ## _EXP = True;} return val ? val : "";}
+
/* In this section all the functions that are used to access the
* parameters from the rest of the program are defined. */
-#define FN_GLOBAL_STRING(fn_name, ptr) \
- char *fn_name(void) {return expand_vars(*(char **)(ptr) ? *(char **)(ptr) : "");}
-#define FN_GLOBAL_BOOL(fn_name, ptr) \
- BOOL fn_name(void) {return *(BOOL *)(ptr);}
-#define FN_GLOBAL_CHAR(fn_name, ptr) \
- char fn_name(void) {return *(char *)(ptr);}
-#define FN_GLOBAL_INTEGER(fn_name, ptr) \
- int fn_name(void) {return *(int *)(ptr);}
+#define FN_GLOBAL_STRING(fn_name, val) \
+ char *fn_name(void) RETURN_EXPANDED(Vars.g.val)
+#define FN_GLOBAL_BOOL(fn_name, val) \
+ BOOL fn_name(void) {return Vars.g.val;}
+#define FN_GLOBAL_CHAR(fn_name, val) \
+ char fn_name(void) {return Vars.g.val;}
+#define FN_GLOBAL_INTEGER(fn_name, val) \
+ int fn_name(void) {return Vars.g.val;}
#define FN_LOCAL_STRING(fn_name, val) \
- char *fn_name(int i) {return expand_vars(LP_SNUM_OK(i) && iSECTION(i).val ? iSECTION(i).val : Vars.l.val ? Vars.l.val : "");}
+ char *fn_name(int i) {if (LP_SNUM_OK(i) && iSECTION(i).val) RETURN_EXPANDED(iSECTION(i).val) else RETURN_EXPANDED(Vars.l.val)}
#define FN_LOCAL_BOOL(fn_name, val) \
BOOL fn_name(int i) {return LP_SNUM_OK(i)? iSECTION(i).val : Vars.l.val;}
#define FN_LOCAL_CHAR(fn_name, val) \
@@ -455,16 +528,16 @@ static char *expand_vars(char *str)
#define FN_LOCAL_INTEGER(fn_name, val) \
int fn_name(int i) {return LP_SNUM_OK(i)? iSECTION(i).val : Vars.l.val;}
-FN_GLOBAL_STRING(lp_bind_address, &Vars.g.bind_address)
-FN_GLOBAL_STRING(lp_daemon_chroot, &Vars.g.daemon_chroot)
-FN_GLOBAL_STRING(lp_daemon_gid, &Vars.g.daemon_gid)
-FN_GLOBAL_STRING(lp_daemon_uid, &Vars.g.daemon_uid)
-FN_GLOBAL_STRING(lp_motd_file, &Vars.g.motd_file)
-FN_GLOBAL_STRING(lp_pid_file, &Vars.g.pid_file)
-FN_GLOBAL_STRING(lp_socket_options, &Vars.g.socket_options)
+FN_GLOBAL_STRING(lp_bind_address, bind_address)
+FN_GLOBAL_STRING(lp_daemon_chroot, daemon_chroot)
+FN_GLOBAL_STRING(lp_daemon_gid, daemon_gid)
+FN_GLOBAL_STRING(lp_daemon_uid, daemon_uid)
+FN_GLOBAL_STRING(lp_motd_file, motd_file)
+FN_GLOBAL_STRING(lp_pid_file, pid_file)
+FN_GLOBAL_STRING(lp_socket_options, socket_options)
-FN_GLOBAL_INTEGER(lp_listen_backlog, &Vars.g.listen_backlog)
-FN_GLOBAL_INTEGER(lp_rsync_port, &Vars.g.rsync_port)
+FN_GLOBAL_INTEGER(lp_listen_backlog, listen_backlog)
+FN_GLOBAL_INTEGER(lp_rsync_port, rsync_port)
FN_LOCAL_STRING(lp_auth_users, auth_users)
FN_LOCAL_STRING(lp_charset, charset)
@@ -525,19 +598,10 @@ static inline void string_set(char **s, const char *v)
out_of_memory("string_set");
}
-/* Copy the local_vars, strdup'ing any strings. NOTE: this depends on
- * the structure starting with a contiguous list of the char* variables,
- * and having an accurate count in the LOCAL_STRING_COUNT() macro. */
+/* Copy local_vars into a new section. No need to strdup since we don't free. */
static void copy_section(local_vars *psectionDest, local_vars *psectionSource)
{
- int count = LOCAL_STRING_COUNT();
- char **strings = (char**)psectionDest;
-
memcpy(psectionDest, psectionSource, sizeof psectionDest[0]);
- while (count--) {
- if (strings[count] && !(strings[count] = strdup(strings[count])))
- out_of_memory("copy_section");
- }
}
/* Initialise a section to the defaults. */
@@ -680,10 +744,10 @@ static BOOL do_parameter(char *parmname, char *parmvalue)
switch (parm_table[parmnum].type) {
case P_PATH:
case P_STRING:
- /* delay expansion of vars */
+ /* delay expansion of %VAR% strings */
break;
default:
- /* expand any %VARS% now */
+ /* expand any %VAR% strings now */
parmvalue = expand_vars(parmvalue);
break;
}
diff --git a/support/rrsync b/support/rrsync
index 9195aa2f..ad4d434b 100644
--- a/support/rrsync
+++ b/support/rrsync
@@ -107,7 +107,7 @@ our %long_opt = (
'link-dest' => 2,
'links' => 0,
'list-only' => 0,
- 'log-file' => 3,
+ 'log-file' => $only eq 'r' ? -1 : 3,
'log-format' => 1,
'max-delete' => 1,
'max-size' => 1,
@@ -207,13 +207,16 @@ while ($command =~ /((?:[^\s\\]+|\\.[^\s\\]*)+)/g) {
s{//+}{/}g;
s{^/}{};
s{^$}{.};
- die "$0: do not use .. in any path!\n" if m{(^|/)\\?\.\\?\.(\\?/|$)};
}
push(@args, bsd_glob($_, GLOB_LIMIT|GLOB_NOCHECK|GLOB_BRACE|GLOB_QUOTE));
}
}
die "$0: invalid rsync-command syntax or options\n" if $in_options;
+if ($subdir ne '/') {
+ die "$0: do not use .. in any path!\n" if grep m{(^|/)\.\.(/|$)}, @args;
+}
+
@args = ( '.' ) if !@args;
if ($write_log) {
@@ -227,7 +230,7 @@ if ($write_log) {
}
# Note: This assumes that the rsync protocol will not be maliciously hijacked.
-exec(RSYNC, @opts, @args) or die "exec(rsync @opts @args) failed: $? $!";
+exec(RSYNC, @opts, '--', @args) or die "exec(rsync @opts -- @args) failed: $? $!";
sub check_arg
{
--
The rsync repository.
More information about the rsync-cvs
mailing list