From rsync-cvs at lists.samba.org Thu May 13 04:41:01 2021 From: rsync-cvs at lists.samba.org (Rsync CVS commit messages) Date: Thu, 13 May 2021 04:41:01 +0000 Subject: [SCM] The rsync repository. - branch master updated Message-ID: The branch, master has been updated via a6bdf313 Unset DISPLAY in environment. via 915685e0 Updated GLIBC check in configure.ac (#175) via 05540220 Fix plural of --group option. from 75158e10 Fix git-set-file-times's handling of staged changed files. https://git.samba.org/?p=rsync.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit a6bdf313f239cabfef445bc3658b79aec8a40c37 Author: Wayne Davison Date: Sat May 1 09:00:03 2021 -0700 Unset DISPLAY in environment. Without a DISPLAY var, ssh won't try to forward X11 when making an ssh connection. This patch also makes use of setenv() and unsetenv() if they are available. commit 915685e01b7c065a56a09cbba9516d3c96f0d744 Author: Bart S Date: Sat May 1 17:23:25 2021 +0200 Updated GLIBC check in configure.ac (#175) The current GLIBC check does not consider we may see glibc 3.0 in the future. commit 05540220a92dd06b62f240f6178921dde5697dd3 Author: Wayne Davison Date: Sat Apr 3 21:09:14 2021 -0700 Fix plural of --group option. ----------------------------------------------------------------------- Summary of changes: clientserver.c | 46 ++++++++++++++++++++++++++++++++++++++++------ configure.ac | 5 +++-- main.c | 22 ++++++++++++++++++++-- rsync.1.md | 4 ++-- 4 files changed, 65 insertions(+), 12 deletions(-) Changeset truncated at 500 lines: diff --git a/clientserver.c b/clientserver.c index 48c15a60..14e3c544 100644 --- a/clientserver.c +++ b/clientserver.c @@ -380,7 +380,7 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char return 0; } -#ifdef HAVE_PUTENV +#if defined HAVE_SETENV || defined HAVE_PUTENV static int read_arg_from_pipe(int fd, char *buf, int limit) { char *bp = buf, *eob = buf + limit - 1; @@ -405,23 +405,57 @@ static int read_arg_from_pipe(int fd, char *buf, int limit) static void set_env_str(const char *var, const char *str) { +#ifdef HAVE_SETENV + if (setenv(var, str, 1) < 0) + out_of_memory("set_env_str"); +#else #ifdef HAVE_PUTENV char *mem; if (asprintf(&mem, "%s=%s", var, str) < 0) out_of_memory("set_env_str"); putenv(mem); +#else + (void)var; + (void)str; +#endif #endif } +#if defined HAVE_SETENV || defined HAVE_PUTENV + +static void set_envN_str(const char *var, int num, const char *str) +{ +#ifdef HAVE_SETENV + char buf[128]; + (void)snprintf(buf, sizeof buf, "%s%d", var, num); + if (setenv(buf, str, 1) < 0) + out_of_memory("set_env_str"); +#else #ifdef HAVE_PUTENV + char *mem; + if (asprintf(&mem, "%s%d=%s", var, num, str) < 0) + out_of_memory("set_envN_str"); + putenv(mem); +#endif +#endif +} + void set_env_num(const char *var, long num) { +#ifdef HAVE_SETENV + char val[64]; + (void)snprintf(val, sizeof val, "%ld", num); + if (setenv(var, val, 1) < 0) + out_of_memory("set_env_str"); +#else +#ifdef HAVE_PUTENV char *mem; if (asprintf(&mem, "%s=%ld", var, num) < 0) out_of_memory("set_env_num"); putenv(mem); -} #endif +#endif +} /* Used for "early exec", "pre-xfer exec", and the "name converter" script. */ static pid_t start_pre_exec(const char *cmd, int *arg_fd_ptr, int *error_fd_ptr) @@ -451,15 +485,13 @@ static pid_t start_pre_exec(const char *cmd, int *arg_fd_ptr, int *error_fd_ptr) set_env_str("RSYNC_REQUEST", buf); for (j = 0; ; j++) { - char *p; len = read_arg_from_pipe(arg_fd, buf, BIGPATHBUFLEN); if (len <= 0) { if (!len) break; _exit(1); } - if (asprintf(&p, "RSYNC_ARG%d=%s", j, buf) >= 0) - putenv(p); + set_envN_str("RSYNC_ARG", j, buf); } dup2(arg_fd, STDIN_FILENO); @@ -490,6 +522,8 @@ static pid_t start_pre_exec(const char *cmd, int *arg_fd_ptr, int *error_fd_ptr) return pid; } +#endif + static void write_pre_exec_args(int write_fd, char *request, char **early_argv, char **argv, int exec_type) { int j = 0; @@ -809,7 +843,7 @@ static int rsync_module(int f_in, int f_out, int i, const char *addr, const char log_init(1); -#ifdef HAVE_PUTENV +#if defined HAVE_SETENV || defined HAVE_PUTENV if ((*lp_early_exec(module_id) || *lp_prexfer_exec(module_id) || *lp_postxfer_exec(module_id) || *lp_name_converter(module_id)) && !getenv("RSYNC_NO_XFER_EXEC")) { diff --git a/configure.ac b/configure.ac index f216c218..5a8d6d06 100644 --- a/configure.ac +++ b/configure.ac @@ -411,7 +411,7 @@ yes # http://www.v6.linux.or.jp/ AC_EGREP_CPP(yes, [ #include -#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)) yes #endif], [ipv6type=$i; @@ -905,7 +905,8 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd chown chmod lchmod mknod mkfifo \ setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \ seteuid strerror putenv iconv_open locale_charset nl_langinfo getxattr \ extattr_get_link sigaction sigprocmask setattrlist getgrouplist \ - initgroups utimensat posix_fallocate attropen setvbuf nanosleep usleep) + initgroups utimensat posix_fallocate attropen setvbuf nanosleep usleep \ + setenv unsetenv) dnl cygwin iconv.h defines iconv_open as libiconv_open if test x"$ac_cv_func_iconv_open" != x"yes"; then diff --git a/main.c b/main.c index 66e5f780..15303e5d 100644 --- a/main.c +++ b/main.c @@ -1567,6 +1567,8 @@ static int start_client(int argc, char *argv[]) #ifdef HAVE_PUTENV if (daemon_connection) set_env_num("RSYNC_PORT", env_port); +#else + (void)env_port; #endif pid = do_cmd(shell_cmd, shell_machine, shell_user, remote_argv, remote_argc, &f_in, &f_out); @@ -1639,7 +1641,6 @@ void remember_children(UNUSED(int val)) #endif } - /** * This routine catches signals and tries to send them to gdb. * @@ -1663,7 +1664,6 @@ const char *get_panic_action(void) return "xterm -display :0 -T Panic -n Panic -e gdb /proc/%d/exe %d"; } - /** * Handle a fatal signal by launching a debugger, controlled by $RSYNC_PANIC_ACTION. * @@ -1687,6 +1687,22 @@ static void rsync_panic_handler(UNUSED(int whatsig)) } #endif +static void unset_env_var(const char *var) +{ +#ifdef HAVE_UNSETENV + unsetenv(var); +#else +#ifdef HAVE_PUTENV + char *mem; + if (asprintf(&mem, "%s=", var) < 0) + out_of_memory("unset_env_var"); + putenv(mem); +#else + (void)var; +#endif +#endif +} + int main(int argc,char *argv[]) { @@ -1724,6 +1740,8 @@ int main(int argc,char *argv[]) our_gid = MY_GID(); am_root = our_uid == ROOT_UID; + unset_env_var("DISPLAY"); + memset(&stats, 0, sizeof(stats)); /* Even a non-daemon runs needs the default config values to be set, e.g. diff --git a/rsync.1.md b/rsync.1.md index 6d79528b..fbbfad22 100644 --- a/rsync.1.md +++ b/rsync.1.md @@ -1416,7 +1416,7 @@ your home directory (remove the '=' for that). This tells the receiving side to attempt super-user activities even if the receiving rsync wasn't run by the super-user. These activities include: preserving users via the `--owner` option, preserving all groups (not just - the current user's groups) via the `--groups` option, and copying devices + the current user's groups) via the `--group` option, and copying devices via the `--devices` option. This is useful for systems that allow such activities without being the super-user, and also for ensuring that you will get errors if the receiving side isn't being run as the super-user. @@ -2630,7 +2630,7 @@ your home directory (remove the '=' for that). For the `--usermap` option to have any effect, the `-o` (`--owner`) option must be used (or implied), and the receiver will need to be running as a super-user (see also the `--fake-super` option). For the `--groupmap` - option to have any effect, the `-g` (`--groups`) option must be used (or + option to have any effect, the `-g` (`--group`) option must be used (or implied), and the receiver will need to have permissions to set that group. If your shell complains about the wildcards, use `--protect-args` (`-s`). -- The rsync repository.