The branch, master has been updated via feb2fff8 Put the optimizations into their own list. via 7d30490e Simplify the daemon parameter definitions via 317beebe Avoid crash of transfer logging w/default log format. via 7a413c97 Avoid strdup redefinition warning. from 5be73632 Avoid bloating the src-dir scan.
https://git.samba.org/?p=rsync.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit feb2fff894fff1509fd132bbe80f123d28fcea72 Author: Wayne Davison <wa...@opencoder.net> Date: Tue Jun 30 19:11:28 2020 -0700 Put the optimizations into their own list. commit 7d30490ef4ff30746e09d3919c304d6f0bce2d42 Author: Wayne Davison <wa...@opencoder.net> Date: Tue Jun 30 18:16:55 2020 -0700 Simplify the daemon parameter definitions The code now derives all the struct defines, default value assignments, parser-param defines, and lp_foo() accessor functions from a single list of daemon parameters. commit 317beebef8b0f60eb36255b35cbea71c84f6ac38 Author: Wayne Davison <wa...@opencoder.net> Date: Tue Jun 30 12:02:48 2020 -0700 Avoid crash of transfer logging w/default log format. commit 7a413c972246250a8fc8302548489c031de3b0c1 Author: Wayne Davison <wa...@opencoder.net> Date: Tue Jun 30 08:27:20 2020 -0700 Avoid strdup redefinition warning. ----------------------------------------------------------------------- Summary of changes: .gitignore | 1 + Makefile.in | 9 +- NEWS.md | 8 ++ daemon-parm.awk | 114 +++++++++++++++ daemon-parm.txt | 65 +++++++++ loadparm.c | 398 ++++------------------------------------------------ options.c | 36 ++--- rsync.1.md | 3 - rsync.h | 1 + testsuite/rsync.fns | 6 +- 10 files changed, 245 insertions(+), 396 deletions(-) create mode 100755 daemon-parm.awk create mode 100644 daemon-parm.txt Changeset truncated at 500 lines: diff --git a/.gitignore b/.gitignore index 5817ccd5..b8e90ca4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ aclocal.m4 /help-rsync*.h /default-cvsignore.h /default-dont-compress.h +/daemon-parm.h /.md2man-works /autom4te*.cache /confdefs.h diff --git a/Makefile.in b/Makefile.in index f5c788db..672fcc47 100644 --- a/Makefile.in +++ b/Makefile.in @@ -101,7 +101,7 @@ $(CHECK_OBJS): $(HEADERS) tls.o xattrs.o: lib/sysxattrs.h options.o: latest-year.h help-rsync.h help-rsyncd.h exclude.o: default-cvsignore.h -loadparm.o: default-dont-compress.h +loadparm.o: default-dont-compress.h daemon-parm.h flist.o: rounding.h @@ -111,6 +111,9 @@ default-cvsignore.h default-dont-compress.h: rsync.1.md define-from-md.awk help-rsync.h help-rsyncd.h: rsync.1.md help-from-md.awk $(AWK) -f $(srcdir)/help-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md +daemon-parm.h: daemon-parm.txt daemon-parm.awk + $(AWK) -f $(srcdir)/daemon-parm.awk $(srcdir)/daemon-parm.txt + rounding.h: rounding.c rsync.h proto.h @for r in 0 1 3; do \ if $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o rounding -DEXTRA_ROUNDING=$$r -I. $(srcdir)/rounding.c >rounding.out 2>&1; then \ @@ -228,8 +231,8 @@ proto: proto.h-tstamp proto.h: proto.h-tstamp @if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi -proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h - $(AWK) -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c +proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c config.h daemon-parm.h + $(AWK) -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c daemon-parm.h .PHONY: man man: rsync.1 rsync-ssl.1 rsyncd.conf.5 diff --git a/NEWS.md b/NEWS.md index 8d35e252..2b192b38 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,9 @@ Protocol: 31 (unchanged) ### BUG FIXES: + - Avoid a crash when a daemon module enables `transfer logging` without + setting a `log format` value. + - Fixed installing rsync-ssl script from an alternate build dir. - Fixed the updating of configure.sh from an alternate build dir. @@ -40,6 +43,8 @@ Protocol: 31 (unchanged) die when out of memory. This eliminated some caller-side check-and-die code and added some missing sanity-checking of allocations. + - Put optimizations into their own list in the `--version` output. + - Improved the man page a bit more. ### PACKAGING RELATED: @@ -58,6 +63,9 @@ Protocol: 31 (unchanged) - Moved the version number out of configure.ac into its own version.h file so that we don't need to reconfigure just because the version number changes. + - Moved the daemon parameter list into daemon-parm.txt so that an awk script + can create the interrelated structs and accessors that loadparm.c needs. + ------------------------------------------------------------------------------ <a name="3.2.1"></a> diff --git a/daemon-parm.awk b/daemon-parm.awk new file mode 100755 index 00000000..efc15474 --- /dev/null +++ b/daemon-parm.awk @@ -0,0 +1,114 @@ +#!/usr/bin/awk -f + +# The caller must pass arg: daemon-parm.txt +# The resulting code is output into daemon-parm.h + +BEGIN { + heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from a list of values in " ARGV[1] "! */" + sect = psect = defines = accessors = prior_ptype = "" + values = "\nstatic const all_vars Defaults = {\n { /* Globals: */\n" + params = "\nstatic struct parm_struct parm_table[] = {" + exp_line = "\n/********** EXP **********/\n" + tdstruct = "typedef struct {" +} + +/^\s*$/ { next } +/^#/ { next } + +/^Globals:/ { + if (defines != "") { + print "The Globals section must come first!" + defines = "" + exit + } + defines = tdstruct + exps = exp_values = exp_line + sect = "GLOBAL" + psect = ", P_GLOBAL, &Vars.g." + next +} + +/^Locals:/ { + if (sect == "") { + print "The Locals section must come after the Globals!" + exit + } + defines = defines exps "} global_vars;\n\n" tdstruct + values = values exp_values "\n }, { /* Locals: */\n" + exps = exp_values = exp_line + sect = "LOCAL" + psect = ", P_LOCAL, &Vars.l." + next +} + +/^(STRING|PATH|INTEGER|ENUM|BOOL)/ { + ptype = $1 + name = $2 + $1 = $2 = "" + sub(/^[ \t]+/, "") + + if (ptype != prior_ptype) { + defines = defines "\n/********** " ptype " **********/\n" + values = values "\n/********** " ptype " **********/\n" + params = params "\n" + accessors = accessors "\n" + prior_ptype = ptype + } + + if (ptype == "STRING" || ptype == "PATH") { + atype = "STRING" + vtype = "char*" + } else if (ptype == "BOOL") { + atype = vtype = "BOOL" + } else { + atype = "INTEGER" + vtype = "int" + } + + # We have 2 variables that don't match their conf string. Oh well... + if (name == "bind_address") + spname = "address" + else if (name == "rsync_port") + spname = "port" + else { + spname = name + gsub(/_/, " ", spname) + gsub(/-/, "", name) + } + + if (ptype == "ENUM") + enum = "enum_" name + else + enum = "NULL" + + defines = defines "\t" vtype " " name ";\n" + values = values "\t" $0 ", /* " name " */\n" + params = params " {\"" spname "\", P_" ptype psect name ", " enum ", 0},\n" + accessors = accessors "FN_" sect "_" atype "(lp_" name ", " name ")\n" + + if (vtype == "char*") { + exps = exps "\tBOOL " name "_EXP;\n" + exp_values = exp_values "\tFalse, /* " name "_EXP */\n" + } + + next +} + +/./ { + print "Extraneous line:" $0 + defines = "" + exit +} + +END { + if (sect != "" && defines != "") { + defines = defines exps "} local_vars;\n\n" + defines = defines tdstruct "\n\tglobal_vars g;\n\tlocal_vars l;\n} all_vars;\n" + values = values exp_values "\n }\n};\n\nstatic all_vars Vars;\n" + params = params "\n {NULL, P_BOOL, P_NONE, NULL, NULL, 0}\n};\n" + print heading "\n\n" defines values params accessors > "daemon-parm.h" + } else { + print "Failed to parse the data in " ARGV[1] + exit 1 + } +} diff --git a/daemon-parm.txt b/daemon-parm.txt new file mode 100644 index 00000000..36ae5115 --- /dev/null +++ b/daemon-parm.txt @@ -0,0 +1,65 @@ +Globals: ================================================================ + +STRING bind_address NULL +STRING daemon_chroot NULL +STRING daemon_gid NULL +STRING daemon_uid NULL +STRING motd_file NULL +STRING pid_file NULL +STRING socket_options NULL + +INTEGER listen_backlog 5 +INTEGER rsync_port 0 + +BOOL proxy_protocol False + +Locals: ================================================================= + +STRING auth_users NULL +STRING charset NULL +STRING comment NULL +STRING dont_compress DEFAULT_DONT_COMPRESS +STRING early_exec NULL +STRING exclude NULL +STRING exclude_from NULL +STRING filter NULL +STRING gid NULL +STRING hosts_allow NULL +STRING hosts_deny NULL +STRING include NULL +STRING include_from NULL +STRING incoming_chmod NULL +STRING lock_file DEFAULT_LOCK_FILE +STRING log_file NULL +STRING log_format "%o %h [%a] %m (%u) %f %l" +STRING name NULL +STRING outgoing_chmod NULL +STRING post-xfer_exec NULL +STRING pre-xfer_exec NULL +STRING refuse_options NULL +STRING secrets_file NULL +STRING syslog_tag "rsyncd" +STRING uid NULL + +PATH path NULL +PATH temp_dir NULL + +INTEGER max_connections 0 +INTEGER max_verbosity 1 +INTEGER timeout 0 + +ENUM syslog_facility LOG_DAEMON + +BOOL fake_super False +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 diff --git a/loadparm.c b/loadparm.c index 819888c5..5e532da2 100644 --- a/loadparm.c +++ b/loadparm.c @@ -87,234 +87,6 @@ struct parm_struct { #define LP_SNUM_OK(i) ((i) >= 0 && (i) < (int)section_list.count) #define SECTION_PTR(s, p) (((char*)(s)) + (ptrdiff_t)(((char*)(p))-(char*)&Vars.l)) -/* This structure describes global (ie., server-wide) parameters. */ -typedef struct { - char *bind_address; - char *daemon_chroot; - char *daemon_gid; - char *daemon_uid; - char *motd_file; - 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; - - BOOL proxy_protocol; -} global_vars; - -/* This structure describes a single section. Their order must match the - * initializers below, which you can accomplish by keeping each sub-section - * sorted. (e.g. in vim, just visually select each subsection and use !sort.) - * NOTE: the char* variables MUST all remain at the start of the struct! */ -typedef struct { - char *auth_users; - char *charset; - char *comment; - char *dont_compress; - char *early_exec; - char *exclude; - char *exclude_from; - char *filter; - char *gid; - char *hosts_allow; - char *hosts_deny; - char *include; - char *include_from; - char *incoming_chmod; - char *lock_file; - char *log_file; - char *log_format; - char *name; - char *outgoing_chmod; - char *path; - char *postxfer_exec; - char *prexfer_exec; - char *refuse_options; - char *secrets_file; - char *syslog_tag; - char *temp_dir; - char *uid; - - /* 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 early_exec_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; - int syslog_facility; - int timeout; - - BOOL fake_super; - BOOL forward_lookup; - BOOL ignore_errors; - BOOL ignore_nonreadable; - BOOL list; - BOOL munge_symlinks; - BOOL numeric_ids; - BOOL read_only; - BOOL reverse_lookup; - BOOL strict_modes; - BOOL transfer_logging; - BOOL use_chroot; - BOOL write_only; -} local_vars; - -/* This structure describes the global variables (g) as well as the globally - * specified values of the local variables (l), which are used when modules - * don't specify their own values. */ -typedef struct { - global_vars g; - local_vars l; -} all_vars; - -/* The application defaults for all the variables. "Defaults" is - * used to re-initialize "Vars" before each config-file read. - * - * In order to keep these sorted in the same way as the structure - * above, use the variable name in the leading comment, including a - * trailing ';' (to avoid a sorting problem with trailing digits). */ -static const all_vars Defaults = { - /* ==== global_vars ==== */ - { - /* bind_address; */ NULL, - /* daemon_chroot; */ NULL, - /* daemon_gid; */ NULL, - /* daemon_uid; */ NULL, - /* motd_file; */ NULL, - /* 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, - - /* proxy_protocol; */ False, - }, - - /* ==== local_vars ==== */ - { - /* auth_users; */ NULL, - /* charset; */ NULL, - /* comment; */ NULL, - /* dont_compress; */ DEFAULT_DONT_COMPRESS, - /* early_exec; */ NULL, - /* exclude; */ NULL, - /* exclude_from; */ NULL, - /* filter; */ NULL, - /* gid; */ NULL, - /* hosts_allow; */ NULL, - /* hosts_deny; */ NULL, - /* include; */ NULL, - /* include_from; */ NULL, - /* incoming_chmod; */ NULL, - /* lock_file; */ DEFAULT_LOCK_FILE, - /* log_file; */ NULL, - /* log_format; */ "%o %h [%a] %m (%u) %f %l", - /* name; */ NULL, - /* outgoing_chmod; */ NULL, - /* path; */ NULL, - /* postxfer_exec; */ NULL, - /* prexfer_exec; */ NULL, - /* refuse_options; */ NULL, - /* secrets_file; */ NULL, - /* syslog_tag; */ "rsyncd", - /* temp_dir; */ NULL, - /* uid; */ NULL, - - /* auth_users_EXP; */ False, - /* charset_EXP; */ False, - /* comment_EXP; */ False, - /* dont_compress_EXP; */ False, - /* early_exec_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, - /* timeout; */ 0, - - /* fake_super; */ False, - /* forward_lookup; */ True, - /* ignore_errors; */ False, - /* ignore_nonreadable; */ False, - /* list; */ True, - /* munge_symlinks; */ (BOOL)-1, - /* numeric_ids; */ (BOOL)-1, - /* read_only; */ True, - /* reverse_lookup; */ True, - /* strict_modes; */ True, - /* transfer_logging; */ False, - /* use_chroot; */ True, - /* write_only; */ False, -- The rsync repository. _______________________________________________ rsync-cvs mailing list rsync-cvs@lists.samba.org https://lists.samba.org/mailman/listinfo/rsync-cvs