]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Merge branch 'refs/heads/t/exit-hook'
authorAndre Noll <maan@tuebingen.mpg.de>
Fri, 17 Nov 2017 15:41:27 +0000 (16:41 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 17 Nov 2017 15:44:19 +0000 (16:44 +0100)
A fix for a long standing issue with the exit hook.

Cooking for a week.

* refs/heads/t/exit-hook:
  Allow word-splitting for exit hook.

NEWS
dss.c

diff --git a/NEWS b/NEWS
index f103fb497b6ae944827b71827f74a725b6fe2693..09e72093165b72ab94d0484211ad3292895316b5 100644 (file)
--- a/NEWS
+++ b/NEWS
  - New option: --mountpoint. If this option is given, dss aborts if
  no file system is mounted on the destination directory.
 
+ - New option --checksum to let rsync compute checksums occasionally.
+
  - The --no-resume option has been removed.
 
  - The ls subcommand now shows the age of incomplete snapshots rather
  than 0:00.
 
- - New option --checksum to let rsync compute checksums occasionally.
-
  - In run mode, dss no longer exits successfully if another instance
  is already running.
 
- - "make install" will install the executable and the man page.
+ - The command specified as the argument to --exit-hook is now subject
+ to word splitting. Previously, the string was executed as-is.
 
  - Improved error diagnostics for the kill subcommand.
 
  - For all subcommands other than "run", timestamps and function names
  are omitted from the log output.
 
+ - "make install" will install the executable and the man page.
+
  - CFLAGS, CPPFLAGS and LDFLAGS can now be used to override the flags
  of the build system.
 
diff --git a/dss.c b/dss.c
index 24d77eb79dbd2ab0862b2b7012b73babde542c93..d60f00b1cc08f44ac29ae383c71b376f9e9ef49d 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1526,15 +1526,18 @@ out:
 
 static void exit_hook(int exit_code)
 {
-       const char *argv[3];
        pid_t pid;
-
-       argv[0] = OPT_STRING_VAL(DSS, EXIT_HOOK);
-       argv[1] = dss_strerror(-exit_code);
-       argv[2] = NULL;
-
-       DSS_NOTICE_LOG(("executing %s %s\n", argv[0], argv[1]));
-       dss_exec(&pid, argv[0], (char **)argv);
+       char **argv, *tmp = dss_strdup(OPT_STRING_VAL(DSS, EXIT_HOOK));
+       unsigned n = split_args(tmp, &argv, " \t");
+
+       n++;
+       argv = dss_realloc(argv, (n + 1) * sizeof(char *));
+       argv[n - 1] = dss_strdup(dss_strerror(-exit_code));
+       argv[n] = NULL;
+       dss_exec(&pid, argv[0], argv);
+       free(argv[n - 1]);
+       free(argv);
+       free(tmp);
 }
 
 static void lock_dss_or_die(void)