diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2012-12-30 15:36:56 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-01-04 12:29:27 +0200 |
commit | cf14c349fad774e477a80d1c5e6572f21f17ced1 (patch) | |
tree | d8d73b072902cadc5aea5583119ec9e4e8ced2bc /src | |
parent | 64c343ff8f11c8379ec21916ba915a2894495797 (diff) | |
download | pies-cf14c349fad774e477a80d1c5e6572f21f17ced1.tar.gz pies-cf14c349fad774e477a80d1c5e6572f21f17ced1.tar.bz2 |
Initial support for running as init process.
* grecs: Upgrade.
* lib/Makefile.am: Use AM_CPPFLAGS instead of INCLUDES.
* src/Makefile.am: Likewise.
* src/acl.c: Update grecs_keyword definitions.
* src/inetd.c (inetd_conf_file): Bugfix. The ws structure could
be free'd prior to initialization.
* src/pies.c: Update grecs_keyword definitions.
(init_process,initdefault,dfl_level): New globals.
(modetab) <once>: New keyword.
(component_keywords)<runlevels,initdefault>: New keywords.
(main): Initial support for init(8) mode.
* src/pies.h (pies_comp_mode) <pies_comp_exec_once>: New constant.
(component)<runlevels>: New member.
(init_process,console_device,initdefault): New externs.
* src/progman.c (prog_status)<status_finished>: New status.
(prog)<runlevels>: New member.
(progman_running_p): New function.
(prog_start): Special handling for init process mode.
(progman_start): Likewise. Take into account runlevels.
(progman_dump_stats): New flag 'f' for status_finished.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 10 | ||||
-rw-r--r-- | src/acl.c | 4 | ||||
-rw-r--r-- | src/inetd.c | 13 | ||||
-rw-r--r-- | src/pies.c | 509 | ||||
-rw-r--r-- | src/pies.h | 53 | ||||
-rw-r--r-- | src/progman.c | 185 |
6 files changed, 566 insertions, 208 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 455b2c2..44e0a8d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,27 +51,25 @@ EXTRA_DIST = cmdline.opt pp-setup inetd.in SUFFIXES=.opt .c .h .opt.h: $(AM_V_GEN)m4 -s $(top_srcdir)/@GRECS_SUBDIR@/build-aux/getopt.m4 $< > $@ cmdline.h: cmdline.opt -INCLUDES = \ - -I$(top_srcdir)/lib\ - -I$(top_srcdir)/gnu\ - -I$(top_builddir)/gnu\ - @GRECS_INCLUDES@ - LDADD = \ ../lib/libpies.a\ @GRECS_LDADD@\ ../gnu/libgnu.a\ $(MF_PROCTITLE_LIBS) pkgstatedir=$(localstatedir)/pies AM_CPPFLAGS=\ + -I$(top_srcdir)/lib\ + -I$(top_srcdir)/gnu\ + -I$(top_builddir)/gnu\ + @GRECS_INCLUDES@\ -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"\ -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ -DDEFAULT_STATE_DIR=\"$(pkgstatedir)\" AM_YFLAGS=-dvt -pmeta1 @@ -479,18 +479,18 @@ deny_cb (enum grecs_callback_command cmd, } struct grecs_keyword acl_keywords[] = { /* TRANSLATORS: only words within angle brackets are translatable */ { "allow", N_("[all|authenticated|group <grp: list>] [from <addr: list>]"), N_("Allow access"), - grecs_type_string, NULL, 0, + grecs_type_string, GRECS_MULT, NULL, 0, allow_cb }, /* TRANSLATORS: only words within angle brackets are translatable */ { "deny", N_("[all|authenticated|group <grp: list>] [from <addr: list>]"), N_("Deny access"), - grecs_type_string, NULL, 0, + grecs_type_string, GRECS_MULT, NULL, 0, deny_cb }, { NULL } }; diff --git a/src/inetd.c b/src/inetd.c index 1d7798d..febd84e 100644 --- a/src/inetd.c +++ b/src/inetd.c @@ -81,22 +81,24 @@ inetd_conf_file (const char *file) FILE *fp; size_t size = 0; char *buf = NULL; size_t line_no = 0; struct wordsplit ws; char *dfl_address = NULL; + int wsflags; fp = fopen (file, "r"); if (!fp) { logmsg (LOG_ERR, _("cannot open configuration file %s: %s"), file, strerror (errno)); return 1; } + wsflags = WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_WS | WRDSF_SQUEEZE_DELIMS; while (getline (&buf, &size, fp) >= 0) { char *p; struct component *comp; int socket_type; struct pies_url *url; @@ -108,30 +110,25 @@ inetd_conf_file (const char *file) char *address; char *service; size_t len; struct inetd_builtin *builtin; char *tag; - if (line_no) - wordsplit_free (&ws); - line_no++; for (p = buf; *p && c_isblank (*p); p++) ; if (!p || *p == '\n' || *p == '#') continue; - if (wordsplit (p, &ws, - WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_WS | - WRDSF_SQUEEZE_DELIMS)) + if (wordsplit (p, &ws, wsflags)) { logmsg (LOG_ERR, "wordsplit: %s", strerror (errno)); continue; } - + wsflags |= WRDSF_REUSE; if (ws.ws_wordc == 1) { size_t len = strlen (ws.ws_wordv[IFLD_SERVICE]); if (len > 0 && ws.ws_wordv[IFLD_SERVICE][len-1] == ':') { free (dfl_address); @@ -305,13 +302,13 @@ inetd_conf_file (const char *file) } if (progman_lookup_component (comp->tag) == NULL) register_prog (comp); } - if (line_no) + if (wsflags & WRDSF_REUSE) wordsplit_free (&ws); free (dfl_address); free (buf); fclose (fp); return 0; } @@ -23,24 +23,27 @@ int preprocess_only; /* Preprocess config, do nothing more */ int lint_mode; /* Test configuration syntax and exit */ int log_to_stderr_only; /* Use only stderr for logging */ int log_facility = LOG_USER; char *log_tag; struct pies_privs pies_privs; int foreground; +int init_process; enum pies_command { COM_START, COM_RESTART, COM_RELOAD, COM_STATUS, COM_STOP, COM_DUMP_PREREQ, COM_DUMP_DEPMAP }; enum pies_command command; +int initdefault; /* Default runlevel */ +int dfl_level; char *statedir = DEFAULT_STATE_DIR; char *instance; char *pidfile; char *ctlfile; char *statfile; char *qotdfile; @@ -92,14 +95,14 @@ int str_to_config_syntax (const char *str, enum config_syntax *psynt) { struct config_syntax_descr *p; for (p = config_syntax_tab; p->name; p++) if (strcmp (p->name, str) == 0) { - *psynt = p->type; - return 0; + *psynt = p->type; + return 0; } return 1; } void add_config (enum config_syntax syntax, const char *name) @@ -128,13 +131,13 @@ add_pp_option (const char *opt, const char *arg) obstack_1grow (&pp_stk, ' '); obstack_grow (&pp_stk, opt, strlen (opt)); if (arg) { char *qarg; size_t qlen; - + if (!pp_qopt) { pp_qopt = clone_quoting_options (NULL); set_quoting_style (pp_qopt, shell_quoting_style); } qarg = quotearg_alloc_mem (arg, strlen (arg), &qlen, pp_qopt); @@ -155,25 +158,25 @@ stderr_closed_p () return fd <= 2; } int assert_grecs_value_type (grecs_locus_t *locus, - const grecs_value_t *value, int type) + const grecs_value_t *value, int type) { if (GRECS_VALUE_EMPTY_P (value)) { grecs_error (locus, 0, _("expected %s"), - grecs_data_type_string (type)); + grecs_data_type_string (type)); return 1; } if (value->type != type) { grecs_error (locus, 0, _("expected %s, but found %s"), - grecs_data_type_string (type), - grecs_data_type_string (value->type)); + grecs_data_type_string (type), + grecs_data_type_string (value->type)); return 1; } return 0; } int @@ -187,14 +190,14 @@ assert_scalar_stmt (grecs_locus_t *locus, enum grecs_callback_command cmd) return 0; } static int _cb_action (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { enum return_action *pact = varptr; static struct tokendef actab[] = { {"disable", action_disable}, {"restart", action_restart}, {NULL} @@ -216,30 +219,33 @@ _cb_action (enum grecs_callback_command cmd, struct grecs_keyword return_code_keywords[] = { {"action", /* TRANSLATORS: disable and restart are keywords, do not translate them. */ N_("arg: {disable | restart}"), N_("Specifies action to take when a component finishes with this " "return code."), - grecs_type_string, NULL, offsetof (struct component, act_temp.act), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, act_temp.act), _cb_action, }, {"notify", N_("arg: emails"), N_("Notify this address when a component terminates."), - grecs_type_string, NULL, offsetof (struct component, act_temp.addr) + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, act_temp.addr) }, {"message", NULL, N_("Notification message text (with headers)."), - grecs_type_string, NULL, offsetof (struct component, act_temp.message), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, act_temp.message), NULL}, {"exec", NULL, N_("Execute this command."), - grecs_type_string, NULL, - offsetof (struct component, act_temp.command), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, act_temp.command), NULL, }, {NULL} }; #define S(s) { #s, s } @@ -323,15 +329,15 @@ static struct tokendef sig_tokendef[] = { }; #undef S static struct action * create_action (struct component *comp, - grecs_locus_t *locus, - grecs_value_t *val, int argc, - const char *(*getarg) (grecs_value_t *, int, grecs_locus_t *)) + grecs_locus_t *locus, + grecs_value_t *val, int argc, + const char *(*getarg) (grecs_value_t *, int, grecs_locus_t *)) { int i; unsigned *retv; int retc = 0; int allflag = 0; struct action *act; @@ -343,13 +349,13 @@ create_action (struct component *comp, { for (i = 0; i < argc; i++) { unsigned n; const char *arg = getarg (val, i, locus); size_t len = strlen (arg); - + if (isdigit (arg[0])) { char *p; n = strtoul (arg, &p, 0); if (*p) { @@ -378,18 +384,18 @@ create_action (struct component *comp, } else if (strtotok_ci (ex_tokendef, arg, &n)) { grecs_error (locus, 0, _("%s: not a return code"), arg); continue; } - + /* Alles in ordnung */ retv[retc++] = n; } } - + if (retc == 0 && !allflag) { free (retv); return NULL; } @@ -439,15 +445,15 @@ _get_list_arg (grecs_value_t *val, int num, grecs_locus_t *locus) return elt->v.string; return NULL; } static int return_code_section_parser (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, - grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, + grecs_value_t *value, void *cb_data) { struct component *comp = varptr; size_t count; struct action *act; switch (cmd) @@ -455,34 +461,34 @@ return_code_section_parser (enum grecs_callback_command cmd, case grecs_callback_section_begin: if (GRECS_VALUE_EMPTY_P (value)) { grecs_error (locus, 0, _("missing tag")); return 1; } - + switch (value->type) { case GRECS_TYPE_STRING: act = create_action (comp, locus, value, 1, _get_string_arg); break; - + case GRECS_TYPE_ARRAY: act = create_action (comp, locus, value, value->v.arg.c, _get_array_arg); break; - + case GRECS_TYPE_LIST: count = grecs_list_size (value->v.list); act = create_action (comp, locus, value, count, _get_list_arg); } *(struct component **) cb_data = comp; if (!act) return 1; memset (&comp->act_temp, 0, sizeof (comp->act_temp)); break; - + case grecs_callback_section_end: act = comp->act_tail; act->act = comp->act_temp.act; act->addr = comp->act_temp.addr; act->message = comp->act_temp.message; act->command = comp->act_temp.command; @@ -497,13 +503,13 @@ return_code_section_parser (enum grecs_callback_command cmd, static char ** config_array_to_argv (grecs_value_t *val, grecs_locus_t *locus, size_t *pargc) { int i, j; int argc; char **argv; - + argc = val->v.arg.c; argv = xcalloc (argc + 1, sizeof (argv[0])); for (i = j = 0; i < argc; i++) { if (assert_grecs_value_type (locus, val->v.arg.v[i], GRECS_TYPE_STRING) == 0) @@ -514,14 +520,14 @@ config_array_to_argv (grecs_value_t *val, grecs_locus_t *locus, size_t *pargc) *pargc = argc; return argv; } static int _cb_command (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { struct component *comp = varptr; struct wordsplit ws; switch (value->type) { @@ -531,13 +537,13 @@ _cb_command (enum grecs_callback_command cmd, grecs_error (locus, 0, "wordsplit: %s", strerror (errno)); return 1; } comp->argc = ws.ws_wordc; comp->argv = ws.ws_wordv; break; - + case GRECS_TYPE_ARRAY: comp->argv = config_array_to_argv (value, locus, &comp->argc); break; case GRECS_TYPE_LIST: grecs_error (locus, 0, _("unexpected list")); @@ -545,14 +551,14 @@ _cb_command (enum grecs_callback_command cmd, } return 0; } static int _cb_umask (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { mode_t *pmode = varptr; char *p; unsigned long n; if (assert_scalar_stmt (locus, cmd) @@ -567,14 +573,14 @@ _cb_umask (enum grecs_callback_command cmd, *pmode = n; return 0; } static int _cb_env (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { int argc; char **argv; char ***penv = varptr; struct wordsplit ws; @@ -652,14 +658,14 @@ string_to_syslog_facility (const char *key, int *pres) return strtotok_ci (tokdef_fac, key, pres); } static int cb_syslog_facility (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { const char *str; if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) return 1; str = value->v.string; @@ -677,24 +683,24 @@ cb_syslog_facility (enum grecs_callback_command cmd, grecs_error (locus, 0, _("unknown syslog facility `%s'"), str); return 0; } static int _cb_redir (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { struct redirector *rp = varptr; static struct tokendef redirtab[] = { {"null", redir_null}, {"syslog", redir_syslog}, {"file", redir_file}, {NULL} }; int res; - + switch (value->type) { case GRECS_TYPE_STRING: if (strcmp (value->v.string, "null") == 0) { rp->type = redir_null; @@ -705,13 +711,13 @@ _cb_redir (enum grecs_callback_command cmd, { grecs_error (locus, 0, _("unknown syslog priority `%s'"), value->v.string); return 0; } break; - + case GRECS_TYPE_ARRAY: if (assert_grecs_value_type (locus, value->v.arg.v[0], GRECS_TYPE_STRING)) return 0; if (strtotok (redirtab, value->v.arg.v[0]->v.string, &res)) grecs_error (locus, 0, _("%s: unrecognised redirector type"), @@ -725,59 +731,59 @@ _cb_redir (enum grecs_callback_command cmd, grecs_error (locus, 0, _("wrong number of arguments")); return 0; } if (assert_grecs_value_type (locus, value->v.arg.v[1], GRECS_TYPE_STRING)) return 0; - + switch (res) { case redir_null: break; - + case redir_syslog: if (string_to_syslog_priority (value->v.arg.v[1]->v.string, &rp->v.prio)) { grecs_error (locus, 0, _("unknown syslog priority `%s'"), value->v.arg.v[1]->v.string); return 0; } break; - + case redir_file: rp->v.file = xstrdup (value->v.arg.v[1]->v.string); break; } } rp->type = res; } break; - + default: grecs_error (locus, 0, _("unexpected list")); } - + return 0; } static int _cb_url (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { struct pies_url *url; if (assert_scalar_stmt (locus, cmd) || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) return 1; if (pies_url_create (&url, value->v.string)) { grecs_error (locus, 0, _("%s: cannot create URL: %s"), - value->v.string, strerror (errno)); + value->v.string, strerror (errno)); return 0; } *(struct pies_url **) varptr = url; return 0; } @@ -804,14 +810,14 @@ socket_type_to_str (int socket_type, const char **pres) { return toktostr (socktype_xtab, socket_type, pres); } static int _cb_socket_type (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { if (assert_scalar_stmt (locus, cmd) || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) return 1; if (str_to_socket_type (value->v.string, varptr)) @@ -819,24 +825,25 @@ _cb_socket_type (enum grecs_callback_command cmd, return 0; } static struct tokendef modetab[] = { {"exec", pies_comp_exec}, {"wait", pies_comp_exec}, + {"once", pies_comp_once}, {"accept", pies_comp_accept}, {"inetd", pies_comp_inetd}, {"nostartaccept", pies_comp_inetd}, {"pass-fd", pies_comp_pass_fd}, {"pass", pies_comp_pass_fd}, {NULL} }; static int _cb_mode (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { int res; if (assert_scalar_stmt (locus, cmd) || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) return 1; @@ -846,14 +853,14 @@ _cb_mode (enum grecs_callback_command cmd, *(enum pies_comp_mode *) varptr = res; return 0; } static int _cb_limits (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { limits_record_t *plrec = varptr; char *p; if (assert_scalar_stmt (locus, cmd) || assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) @@ -879,13 +886,13 @@ str_to_cf (const char *string, int *flags) { "internal", CF_INTERNAL }, { "sockenv", CF_SOCKENV }, { "resolve", CF_RESOLVE }, { "siggroup", CF_SIGGROUP }, { NULL } }; - + if (len > 2 && memcmp (string, "no", 2) == 0) { neg++; string += 2; } @@ -898,31 +905,31 @@ str_to_cf (const char *string, int *flags) *flags |= mask; return 0; } static int _cb_flags (enum grecs_callback_command cmd, - grecs_locus_t *locus, - void *varptr, grecs_value_t *value, void *cb_data) + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) { int *flags = varptr; - + switch (value->type) { case GRECS_TYPE_STRING: if (str_to_cf (value->v.string, flags)) { grecs_error (locus, 0, _("%s: unrecognised flag"), value->v.string); return 1; } break; - + case GRECS_TYPE_LIST: { struct grecs_list_entry *ep; - + for (ep = value->v.list->head; ep; ep = ep->next) { const grecs_value_t *vp = ep->data; if (assert_grecs_value_type (locus, vp, GRECS_TYPE_STRING)) return 1; if (str_to_cf (vp->v.string, flags)) @@ -931,217 +938,286 @@ _cb_flags (enum grecs_callback_command cmd, vp->v.string); return 1; } } } break; - + case GRECS_TYPE_ARRAY: grecs_error (locus, 0, _("too many arguments")); return 1; } return 0; } +static const char valid_runlevels[] = "0123456Ss"; + +static int +_cb_initdefault (enum grecs_callback_command cmd, + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) +{ + int *val = varptr; + + if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + return 1; + if (strlen (value->v.string) != 1) + { + grecs_error (locus, 0, _("argument must be a single character")); + return 1; + } + if (!strchr (valid_runlevels, value->v.string[0])) + { + grecs_error (locus, 0, _("not a valid runlevel")); + return 1; + } + *val = toupper (value->v.string[0]); + return 0; +} + +static int +_cb_runlevels (enum grecs_callback_command cmd, + grecs_locus_t *locus, + void *varptr, grecs_value_t *value, void *cb_data) +{ + char **sptr = varptr, *p; + + if (assert_grecs_value_type (locus, value, GRECS_TYPE_STRING)) + return 1; + for (p = value->v.string; *p; p++) + { + if (!strchr (valid_runlevels, *p)) + { + grecs_error (locus, 0, _("not a valid runlevel: %c")); + return 1; + } + } + *sptr = grecs_strdup(value->v.string); + for (p = *sptr; *p; p++) + *p = toupper (*p); + return 0; +} struct grecs_keyword component_keywords[] = { {"mode", /* TRANSLATORS: The words between '{' and '}' are keywords, do not translate them. */ N_ ("mode: {exec | wait | accept | inetd | nostartaccept | pass-fd | pass}"), N_("Component execution mode."), - grecs_type_string, NULL, offsetof (struct component, mode), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, mode), _cb_mode, }, {"program", NULL, N_("Full name of the program."), - grecs_type_string, NULL, - offsetof (struct component, program), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, program), NULL, }, {"command", NULL, N_("Command line."), - grecs_type_string, NULL, 0, + grecs_type_string, GRECS_DFLT, + NULL, 0, _cb_command, }, {"prerequisites", N_("list"), N_("List of prerequisites."), - grecs_type_string | GRECS_LIST, NULL, offsetof (struct component, prereq), + grecs_type_string, GRECS_LIST, NULL, offsetof (struct component, prereq), NULL, }, {"dependents", N_("list"), N_("List of components for which this one is a prerequisite."), - grecs_type_string | GRECS_LIST, NULL, offsetof (struct component, depend), + grecs_type_string, GRECS_LIST, NULL, offsetof (struct component, depend), NULL, }, {"flags", N_("list"), N_("List of flags."), - grecs_type_string | GRECS_LIST, NULL, offsetof (struct component, flags), + grecs_type_string, GRECS_LIST, NULL, offsetof (struct component, flags), _cb_flags }, + {"runlevels", + N_("chars"), + N_("Runlevels to start that component in."), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, runlevels), + _cb_runlevels }, {"pass-fd-timeout", NULL, N_("Time to wait for pass-fd socket to become available."), - grecs_type_uint, NULL, - offsetof (struct component, pass_fd_timeout), + grecs_type_uint, GRECS_DFLT, + NULL, offsetof (struct component, pass_fd_timeout), NULL, }, {"max-instances", NULL, N_("Maximum number of running instances."), - grecs_type_size, NULL, - offsetof (struct component, max_instances), + grecs_type_size, GRECS_DFLT, + NULL, offsetof (struct component, max_instances), NULL }, {"max-instances-message", NULL, N_("Text to send back if max-instances is reached (inetd-components only)."), - grecs_type_string, NULL, - offsetof (struct component, max_instances_message), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, max_instances_message), NULL }, {"max-ip-connections", NULL, N_("Maximum number of simultaneous connections per IP address (inetd only)."), - grecs_type_size, NULL, - offsetof (struct component, max_ip_connections), + grecs_type_size, GRECS_DFLT, + NULL, offsetof (struct component, max_ip_connections), NULL }, {"max-ip-connections-message", NULL, N_("Text to send back if max-ip-connections-message is reached (inetd only)."), - grecs_type_string, NULL, - offsetof (struct component, max_ip_connections_message), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, max_ip_connections_message), NULL }, - + {"max-rate", NULL, N_("Maximum number of times an inetd component can be invoked in one minute."), - grecs_type_size, NULL, - offsetof (struct component, max_rate), + grecs_type_size, GRECS_DFLT, + NULL, offsetof (struct component, max_rate), NULL }, {"socket", N_("url: string"), N_("Listen on the given url."), - grecs_type_string, NULL, - offsetof (struct component, socket_url), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, socket_url), _cb_url, }, {"socket-type", /* TRANSLATORS: words after `type:' are keywords. */ N_("type: {stream | dgram | raw | rdm | seqpacket}"), N_("Set socket type."), - grecs_type_int, NULL, - offsetof (struct component, socket_type), + grecs_type_int, GRECS_DFLT, + NULL, offsetof (struct component, socket_type), _cb_socket_type }, {"pass-fd-socket", N_("name"), N_("Pass fd through this socket."), - grecs_type_string, NULL, - offsetof (struct component, pass_fd_socket), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, pass_fd_socket), NULL, }, {"acl", N_("name: string"), N_("Set ACL."), - grecs_type_section, NULL, offsetof (struct component, acl), + grecs_type_section, GRECS_DFLT, + NULL, offsetof (struct component, acl), acl_section_parser, NULL, acl_keywords}, {"access-denied-message", NULL, N_("Text to send back if access is denied (inetd-components only)."), - grecs_type_string, NULL, - offsetof (struct component, access_denied_message), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, access_denied_message), NULL }, {"remove-file", N_("file"), N_("Remove file before starting the component."), - grecs_type_string, NULL, offsetof (struct component, rmfile), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, rmfile), NULL, }, {"facility", N_("arg"), N_("Override default syslog facility for this component."), - grecs_type_string, NULL, offsetof (struct component, facility), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, facility), cb_syslog_facility, }, {"stdout", /* TRANSLATORS: file and syslog are keywords. Do not translate them. */ N_("type: {file | syslog}> <channel: string"), N_("Redirect program's standard output to the given file or " "syslog priority."), - grecs_type_string, NULL, offsetof (struct component, redir[RETR_OUT]), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, redir[RETR_OUT]), _cb_redir, }, {"stderr", /* TRANSLATORS: file and syslog are keywords. Do not translate them. */ N_("type: {file | syslog}> <channel: string"), N_("Redirect program's standard error to the given file or " "syslog priority."), - grecs_type_string, NULL, offsetof (struct component, redir[RETR_ERR]), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, redir[RETR_ERR]), _cb_redir, }, {"user", NULL, N_("Run with this user privileges."), - grecs_type_string, NULL, offsetof (struct component, privs.user), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, privs.user), NULL, }, {"group", NULL, N_("Retain supplementary group."), - grecs_type_string | GRECS_LIST, NULL, offsetof (struct component, - privs.groups), + grecs_type_string, GRECS_LIST, + NULL, offsetof (struct component, privs.groups), NULL, }, {"allgroups", NULL, N_("Retain all supplementary groups of which user is a member."), - grecs_type_bool, NULL, offsetof (struct component, privs.allgroups), + grecs_type_bool, GRECS_DFLT, + NULL, offsetof (struct component, privs.allgroups), NULL, }, {"umask", N_("arg: number"), N_("Force this umask."), - grecs_type_string, NULL, offsetof (struct component, umask), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, umask), _cb_umask, }, {"limits", NULL, N_("Set system limits"), - grecs_type_string, NULL, offsetof (struct component, limits), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, limits), _cb_limits, }, {"env", N_("arg: list"), N_("Set program environment. Argument is a list of assignments " "separated by white space."), - grecs_type_string, NULL, offsetof (struct component, env), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, env), _cb_env, }, {"chdir", N_("dir"), N_("Change to this directory before executing the component."), - grecs_type_string, NULL, offsetof (struct component, dir), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, dir), NULL, }, {"return-code", N_("tag: exit-code-list"), N_("Define what to do when the component finishes."), - grecs_type_section, NULL, 0, + grecs_type_section, GRECS_DFLT, + NULL, 0, return_code_section_parser, NULL, return_code_keywords}, {"service", N_("name"), N_("Service name for inetd component."), - grecs_type_string, NULL, offsetof (struct component, service), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, service), NULL }, {"tcpmux-master", N_("tag"), N_("Tag of master TCPMUX component."), - grecs_type_string, NULL, offsetof (struct component, tcpmux), + grecs_type_string, GRECS_DFLT, + NULL, offsetof (struct component, tcpmux), NULL }, {NULL} }; struct grecs_keyword * find_component_keyword (const char *ident) @@ -1207,13 +1283,13 @@ component_verify (struct component *comp, grecs_locus_t *locus) "%s", _("`internal' used with `command'")); } } else if (!comp->argv) COMPERR (grecs_error, "%s", _("missing command line")); - + if (ISCF_TCPMUX (comp->flags)) { comp->mode = pies_comp_inetd; if ((comp->flags & (CF_TCPMUX | CF_TCPMUXPLUS)) == (CF_TCPMUX | CF_TCPMUXPLUS)) COMPERR (grecs_error, @@ -1231,13 +1307,13 @@ component_verify (struct component *comp, grecs_locus_t *locus) { case pies_comp_exec: if (comp->socket_url) COMPERR (grecs_error, "%s", _("socket ignored: wrong mode")); break; - + case pies_comp_pass_fd: if (!comp->pass_fd_socket) COMPERR (grecs_error, "%s", _("must supply pass-fd-socket in this mode")); else if (comp->pass_fd_socket[0] != '/') { @@ -1250,13 +1326,13 @@ component_verify (struct component *comp, grecs_locus_t *locus) else COMPERR (grecs_error, "%s", _("pass-fd-socket must be an absolute " "file name or chdir must be specified")); } /* Fall through */ - + case pies_comp_accept: if (!comp->socket_url) { COMPERR (grecs_error, "%s", _("socket must be specified in this mode")); /* FIXME: Memory leak */ @@ -1303,21 +1379,21 @@ component_verify (struct component *comp, grecs_locus_t *locus) else if (comp->flags & CF_WAIT) { /* TRANSLATORS: `wait' is a keywords, do not translate. */ COMPERR (grecs_error, "%s", _("wait is useless in this mode")); comp->flags &= ~CF_WAIT; } - + |