167
167
struct sigaction old_sigchld_action;
168
168
struct sigaction sigchld_action = { .sa_handler = handle_sigchld,
169
169
.sa_flags = SA_NOCLDSTOP };
170
char *plus_options = NULL;
171
char **plus_argv = NULL;
171
173
/* Establish a signal handler */
172
174
sigemptyset(&sigchld_action.sa_mask);
173
175
ret = sigaddset(&sigchld_action.sa_mask, SIGCHLD);
218
220
addargument(getplugin(NULL, plugins), p);
219
221
p = strtok(NULL, ",");
224
226
if (arg != NULL){
225
227
char *name = strtok(arg, ":");
226
228
char *p = strtok(NULL, ":");
228
230
p = strtok(p, ",");
230
232
addargument(getplugin(name, plugins), p);
231
233
p = strtok(NULL, ",");
264
269
plugin *plugin_list = NULL;
266
271
struct argp argp = { .options = options, .parser = parse_opt,
272
.args_doc = "[+PLUS_SEPARATED_OPTIONS]",
268
273
.doc = "Mandos plugin runner -- Run plugins" };
270
275
argp_parse (&argp, argc, argv, 0, 0, &plugin_list);
278
/* This is a mangled argument in the form of
279
"+--option+--other-option=parameter+--yet-another-option", etc */
280
/* Make new argc and argv vars, and call argp_parse() again. */
281
plus_options++; /* skip the first '+' character */
282
const char delims[] = "+";
285
plus_argv = malloc(sizeof(char*) * 2);
286
if(plus_argv == NULL){
288
exitstatus = EXIT_FAILURE;
291
plus_argv[0] = argv[0];
293
arg = strtok(plus_options, delims); /* Get first argument */
296
plus_argv = realloc(plus_argv, sizeof(char *)
297
* ((unsigned int) new_argc + 1));
298
if(plus_argv == NULL){
300
exitstatus = EXIT_FAILURE;
303
plus_argv[new_argc-1] = arg;
304
plus_argv[new_argc] = NULL;
305
arg = strtok(NULL, delims); /* Get next argument */
307
argp_parse (&argp, new_argc, plus_argv, 0, 0, &plugin_list);
273
311
for(plugin *p = plugin_list; p != NULL; p=p->next){
274
312
fprintf(stderr, "Plugin: %s has %d arguments\n",
624
662
/* Restore old signal handler */
625
663
sigaction(SIGCHLD, &old_sigchld_action, NULL);
627
667
/* Free the plugin list */
628
668
for(plugin *next; plugin_list != NULL; plugin_list = next){
629
669
next = plugin_list->next;