65
65
#include <errno.h> /* errno, EBADF */
67
67
#define BUFFER_SIZE 256
69
#define PDIR "/lib/mandos/plugins.d"
70
#define AFILE "/conf/conf.d/mandos/plugin-runner.conf"
68
#define ARGFILE "/conf/conf.d/mandos/plugin-runner.conf"
72
70
const char *argp_program_version = "plugin-runner 1.0";
73
71
const char *argp_program_bug_address = "<mandos@fukt.bsnet.se>";
319
317
{ .name = "plugin-dir", .key = 128,
320
318
.arg = "DIRECTORY",
321
319
.doc = "Specify a different plugin directory", .group = 2 },
322
{ .name = "config-file", .key = 129,
324
.doc = "Specify a different configuration file", .group = 2 },
325
{ .name = "userid", .key = 130,
326
.arg = "ID", .flags = 0,
327
.doc = "User ID the plugins will run as", .group = 3 },
328
{ .name = "groupid", .key = 131,
329
.arg = "ID", .flags = 0,
330
.doc = "Group ID the plugins will run as", .group = 3 },
331
{ .name = "debug", .key = 132,
332
.doc = "Debug mode", .group = 4 },
320
{ .name = "userid", .key = 129,
321
.arg = "ID", .flags = 0,
322
.doc = "User ID the plugins will run as", .group = 2 },
323
{ .name = "groupid", .key = 130,
324
.arg = "ID", .flags = 0,
325
.doc = "Group ID the plugins will run as", .group = 2 },
326
{ .name = "debug", .key = 131,
327
.doc = "Debug mode", .group = 3 },
422
plugindir = strdup(arg);
423
if(plugindir == NULL){
428
argfile = strdup(arg);
420
uid = (uid_t)strtol(arg, NULL, 10);
434
uid = (uid_t)strtol(arg, NULL, 10);
423
gid = (gid_t)strtol(arg, NULL, 10);
437
gid = (gid_t)strtol(arg, NULL, 10);
442
428
case ARGP_KEY_ARG:
466
if (argfile == NULL){
467
conffp = fopen(AFILE, "r");
469
conffp = fopen(argfile, "r");
452
conffp = fopen(argfile, "r");
472
453
if(conffp != NULL){
473
454
char *org_line = NULL;
474
455
char *p, *arg, *new_arg, *line;