Unset DISPLAY in environment.
[rsync.git] / main.c
diff --git a/main.c b/main.c
index 66e5f780ac208d791e61f06c92694264299becf8..15303e5d2a792e552ad961a8ea9ec12869f41459 100644 (file)
--- 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.