case MODE_LIST :
cmnd = "list";
break;
+ case MODE_BACKGROUND :
+ if (Argc == 1)
+ usage(1);
}
/*
exit(1);
}
- if (sudo_mode == MODE_RUN) {
+ if (sudo_mode == MODE_RUN || sudo_mode == MODE_BACKGROUND) {
load_cmnd(); /* load the cmnd global variable */
} else if (sudo_mode == MODE_KILL) {
remove_timestamp(); /* remove the timestamp ticket file */
exit(0);
set_perms(PERM_FULL_ROOT);
#ifndef GPROF
- EXEC(cmnd, &Argv[1]);
+ if (sudo_mode == MODE_BACKGROUND && fork() > 0)
+ exit(0);
+ else
+ EXEC(cmnd, &Argv[1]);
#else
exit(0);
#endif /* GPROF */
static int parse_args()
{
int ret=MODE_RUN; /* what mode is suod to be run in? */
+ int i;
if (Argc < 2) /* no options and no command */
usage(1);
if (Argv[1][0] == '-') {
- if (Argc > 2) /* only one -? option allowed */
- usage(1);
+ if (Argc > 2 && Argv[2][0] == '-')
+ usage(1); /* only one -? option allowed */
if (Argv[1][1] != '\0' && Argv[1][2] != '\0') {
(void) fprintf(stderr, "%s: Please use single character options\n", Argv[0]);
}
switch (Argv[1][1]) {
+ case 'b':
+ ret = MODE_BACKGROUND;
+ /* shift Argv over and adjust Argc */
+ for (i=1; i < Argc; i++) {
+ Argv[i] = Argv[i+1];
+ }
+ Argc--;
+ break;
case 'v':
ret = MODE_VALIDATE;
break;
static void usage(exit_val)
int exit_val;
{
- (void) fprintf(stderr, "usage: %s -V | -h | -l | -v | -k | <command>\n", Argv[0]);
+ (void) fprintf(stderr, "usage: %s -V | -h | -l | -b | -v | -k | <command>\n", Argv[0]);
exit(exit_val);
}