1 A crude attempt to add two new daemon module options:
6 The pre-exec command runs prior to the chroot() (if enabled) as the daemon user.
8 The post-exec command runs inside any chroot() as the module user.
10 You'll want to run "make proto" after applying this patch.
12 --- orig/cleanup.c 2005-03-05 18:58:38
13 +++ cleanup.c 2005-06-10 21:32:40
18 +extern int am_daemon;
19 +extern int am_sender;
20 +extern int am_generator;
22 extern int keep_partial;
23 extern int log_got_error;
24 +extern int module_id;
25 extern char *partial_dir;
28 @@ -152,6 +156,16 @@ void _exit_cleanup(int code, const char
29 ocode, safe_fname(file), line, code);
32 + if (am_daemon && (am_sender || am_generator)) {
33 + char *p = lp_post_exec(module_id);
36 + if (asprintf(&arg, "RSYNC_EXIT_STATUS=%d", code) == 0)
37 + putenv(arg); /* XXX Need configure support? */
38 + system(p); /* XXX Check for errors */
45 --- orig/clientserver.c 2005-06-10 21:33:27
46 +++ clientserver.c 2005-06-10 21:25:25
47 @@ -347,6 +347,10 @@ static int rsync_module(int f_in, int f_
53 + system(p); /* XXX Check for errors */
57 * XXX: The 'use chroot' flag is a fairly reliable
58 --- orig/loadparm.c 2005-06-10 21:33:28
59 +++ loadparm.c 2005-06-10 21:25:25
60 @@ -140,6 +140,8 @@ typedef struct
69 @@ -175,6 +177,8 @@ static service sDefault =
70 "%o %h [%a] %m (%u) %f %l", /* log format */
71 NULL, /* refuse options */
72 "*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz", /* dont compress */
73 + NULL, /* pre_exec */
74 + NULL, /* post_exec */
76 0, /* max connections */
77 1, /* max verbosity */
78 @@ -298,6 +302,8 @@ static struct parm_struct parm_table[] =
79 {"log format", P_STRING, P_LOCAL, &sDefault.log_format, NULL, 0},
80 {"refuse options", P_STRING, P_LOCAL, &sDefault.refuse_options,NULL, 0},
81 {"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress,NULL, 0},
82 + {"pre-exec", P_STRING, P_LOCAL, &sDefault.pre_exec, NULL, 0},
83 + {"post-exec", P_STRING, P_LOCAL, &sDefault.post_exec, NULL, 0},
84 {NULL, P_BOOL, P_NONE, NULL, NULL, 0}
87 @@ -379,6 +385,8 @@ FN_LOCAL_STRING(lp_include_from, include
88 FN_LOCAL_STRING(lp_log_format, log_format)
89 FN_LOCAL_STRING(lp_refuse_options, refuse_options)
90 FN_LOCAL_STRING(lp_dont_compress, dont_compress)
91 +FN_LOCAL_STRING(lp_pre_exec, pre_exec)
92 +FN_LOCAL_STRING(lp_post_exec, post_exec)
93 FN_LOCAL_INTEGER(lp_timeout, timeout)
94 FN_LOCAL_INTEGER(lp_max_connections, max_connections)
95 FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity)