};
enum signalsexitspecials { se_number=-100, se_numbernocore, se_highbit, se_stdout };
-enum overridetypes { ot_none, ot_string, ot_file };
+enum overridetypes { ot_none, ot_string, ot_file, ot_builtin };
struct constkeyvaluepair { const char *key, *value; };
static const char *serviceuser;
static uid_t serviceuid, myuid;
static struct fdsetupstate *fdsetup;
-static int fdsetupsize, builtin;
+static int fdsetupsize;
static struct constkeyvaluepair *defvararray;
static int defvaravail, defvarused;
static unsigned long timeout;
hidecwd=1;
}
-static void of_builtin(const struct optioninfo *oip, const char *value, char *key) {
- builtin=1;
-}
-
static void of_help(const struct optioninfo *oip, const char *value, char *key) {
usage();
exit(0);
exit(0);
}
+static void of_builtin(const struct optioninfo *oip, const char *value, char *key) {
+ overridetype= ot_builtin;
+}
+
static void of_override(const struct optioninfo *oip, const char *value, char *key) {
overridetype= ot_string;
overridevalue= value;
}
}
}
- if (builtin) {
+ if (overridetype == ot_builtin) {
serviceuser= "-";
} else {
if (!*argpp) usageerror("no service user given after options");
serviceuser= *argpp++;
}
- if (!*argpp) usageerror(builtin ?
+ if (!*argpp) usageerror(overridetype == ot_builtin ?
"no service name given after options and service user" :
"no builtin service given after options");
ovused= -1;
ovbuf= 0;
break;
+ case ot_builtin:
+ l= strlen(argv[0]);
+ if (l >= MAX_OVERRIDE_LEN-20)
+ miscerror("builtin service string is too long (%d, max is %d)",
+ l,MAX_OVERRIDE_LEN-21);
+ l+= 20;
+ ovbuf= xmalloc(l);
+ snprintf(ovbuf,l,"execute-builtin %s\n",argv[0]);
+ ovused= strlen(ovbuf);
+ break;
case ot_string:
l= strlen(overridevalue);
if (l >= MAX_OVERRIDE_LEN)
miscerror("override string is too long (%d, max is %d)",l,MAX_OVERRIDE_LEN-1);
ovbuf= xmalloc(l+2);
- strcpy(ovbuf,overridevalue);
- strcat(ovbuf,"\n");
+ snprintf(ovbuf,l+2,"%s\n",overridevalue);
ovused= l+1;
break;
case ot_file: