376
376
error_t parse_opt (int key, char *arg, __attribute__((unused))
377
377
struct argp_state *state) {
378
/* Get the INPUT argument from `argp_parse', which we know is a
379
pointer to our plugin list pointer. */
381
379
case 'g': /* --global-options */
382
380
if (arg != NULL){
493
struct argp argp = { .options = options, .parser = parse_opt,
488
/* This option parser is the same as parse_opt() above, except it
489
ignores everything but the --config-file option. */
490
error_t parse_opt_config_file (int key, char *arg,
491
__attribute__((unused))
492
struct argp_state *state) {
494
case 'g': /* --global-options */
495
case 'e': /* --global-env */
496
case 'o': /* --options-for */
497
case 'f': /* --env-for */
498
case 'd': /* --disable */
499
case 128: /* --plugin-dir */
501
case 129: /* --config-file */
502
argfile = strdup(arg);
507
case 130: /* --userid */
508
case 131: /* --groupid */
509
case 132: /* --debug */
514
return ARGP_ERR_UNKNOWN;
519
struct argp argp = { .options = options,
520
.parser = parse_opt_config_file,
495
522
.doc = "Mandos plugin runner -- Run plugins" };
524
/* Parse using the parse_opt_config_file in order to get the custom
525
config file location, if any. */
526
ret = argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, NULL);
527
if (ret == ARGP_ERR_UNKNOWN){
528
fprintf(stderr, "Unknown error while parsing arguments\n");
529
exitstatus = EXIT_FAILURE;
533
/* Reset to the normal argument parser */
534
argp.parser = parse_opt;
497
536
/* Open the configfile if available */
498
537
if (argfile == NULL){
499
538
conffp = fopen(AFILE, "r");