summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2015-12-17 12:50:34 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-12-17 12:53:21 (GMT)
commit0ac42500ecdfe289b44d0d7ac10ff302e48aef5c (patch) (side-by-side diff)
treeff1d0be679e935256167972034b7f88f9157f010
parentf928d00f38cc8a43f31506fadf868ba72ca93b4d (diff)
downloadpies-0ac42500ecdfe289b44d0d7ac10ff302e48aef5c.tar.gz
pies-0ac42500ecdfe289b44d0d7ac10ff302e48aef5c.tar.bz2
Fixes
* src/ctl.c: Make "id" command accessible only to administrators (cmd_id): Print PID. (ctlio_do_command): Reword 510 text. * src/pies.c (config_file): Remove "next" (conf_head, conf_tail): Remove. Use grecs_list instead. All uses changed.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/ctl.c5
-rw-r--r--src/pies.c42
2 files changed, 17 insertions, 30 deletions
diff --git a/src/ctl.c b/src/ctl.c
index f422e4b..bd8fa53 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -141,7 +141,7 @@ static struct ctlio_command cmdtab[] = {
{ "noop", "no operation",
CTL_ALL_STATES, 1, 1, cmd_noop },
{ "id", "identify the instance",
- CTL_AUTHENTICATED_STATE, 1, 1, cmd_id },
+ CTL_ADMIN_STATE, 1, 1, cmd_id },
{ "quit", "quit the session",
CTL_ALL_STATES, 1, 1, cmd_quit },
{ "help", "display help",
@@ -300,7 +300,7 @@ ctlio_do_command (struct ctlio *io)
}
if (!(cmd->states & io->state))
{
- ctlio_reply (io, "510", "command not valid in state");
+ ctlio_reply (io, "510", "permission denied");
return;
}
if (cmd->minargs && io->ws.ws_wordc < cmd->minargs)
@@ -442,6 +442,7 @@ cmd_id (struct ctlio *io, size_t argc, char **argv)
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
ctlio_printf (io, "Binary: %s%s", program_invocation_name, CRLF);
#endif
+ ctlio_printf (io, "PID: %lu%s", (unsigned long) getpid (), CRLF);
ctlio_printf (io, "Instance: %s%s", instance, CRLF);
ctlio_eot (io);
}
diff --git a/src/pies.c b/src/pies.c
index 85d0567..9466aa2 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -63,12 +63,11 @@ struct quoting_options *pp_qopt;
struct config_file
{
- struct config_file *next;
enum config_syntax syntax;
char *name;
};
-static struct config_file *conf_head, *conf_tail;
+struct grecs_list *config_list;
struct config_syntax_descr
{
@@ -101,14 +100,11 @@ void
add_config (enum config_syntax syntax, const char *name)
{
struct config_file *file = xmalloc (sizeof (file[0]));
- file->next = NULL;
file->syntax = syntax;
file->name = xstrdup (name);
- if (conf_tail)
- conf_tail->next = file;
- else
- conf_head = file;
- conf_tail = file;
+ if (!config_list)
+ config_list = grecs_list_create ();
+ grecs_list_append (config_list, file);
}
@@ -2281,7 +2277,7 @@ mkfilename (const char *dir, const char *name, const char *suf)
static void
set_conf_file_names (const char *base)
{
- if (!conf_head)
+ if (!config_list)
{
char *name = mkfilename (SYSCONFDIR, base, ".conf");
add_config (current_syntax, name);
@@ -2308,13 +2304,13 @@ main (int argc, char **argv)
int index;
pid_t pid;
extern char **environ;
- struct config_file *file;
+ struct grecs_list_entry *ep;
set_program_name (argv[0]);
#ifdef ENABLE_NLS
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain ("mailfromd", LOCALEDIR);
+ bindtextdomain ("pies", LOCALEDIR);
textdomain (PACKAGE);
#endif
mf_proctitle_init (argc, argv, environ);
@@ -2358,22 +2354,8 @@ main (int argc, char **argv)
#endif
for (index = 1; index < argc; index++)
{
- if (!strcmp(argv[index], "single") || !strcmp(argv[index], "-s"))
+ if (!strcmp (argv[index], "single") || !strcmp (argv[index], "-s"))
dfl_level = 'S';
-#if 0
- //FIXME
- else if (!strcmp(argv[index], "-a") || !strcmp(argv[index], "auto"))
- putenv("AUTOBOOT=YES");
- else if (!strcmp(argv[index], "-b") ||
- !strcmp(argv[index],"emergency"))
- emerg_shell = 1;
- else if (!strcmp(argv[index], "-z"))
- {
- /* Ignore -z xxx */
- if (argv[index + 1])
- index++;
- }
-#endif
else if (strchr("0123456789sS", argv[index][0]) && !argv[index][1])
{
dfl_level = toupper (argv[index][0]);
@@ -2407,8 +2389,10 @@ main (int argc, char **argv)
if (preprocess_only)
{
- for (file = conf_head; file; file = file->next)
+ for (ep = config_list->head; ep; ep = ep->next)
{
+ struct config_file *file = ep->data;
+
if (file->syntax == CONF_PIES
&& grecs_preproc_run (file->name, grecs_preprocessor))
exit (EX_CONFIG);
@@ -2416,8 +2400,10 @@ main (int argc, char **argv)
exit (0);
}
else
- for (file = conf_head; file; file = file->next)
+ for (ep = config_list->head; ep; ep = ep->next)
{
+ struct config_file *file = ep->data;
+
switch (file->syntax)
{
case CONF_PIES:

Return to:

Send suggestions and report system problems to the System administrator.