aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-10-15 16:21:32 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-10-15 16:21:32 +0300
commitb713e2208519e7cba1c779cbd9387137eb101e5e (patch)
treec1245c09d9cffa5d74ec8961ed0ffd820f0bd23e /src
parent9dbe6b40d07df41255f0c8fda6895000b7c7e1a6 (diff)
downloadpies-b713e2208519e7cba1c779cbd9387137eb101e5e.tar.gz
pies-b713e2208519e7cba1c779cbd9387137eb101e5e.tar.bz2
Various fixes.
* README: Fix typo. * doc/usr-acl.texi: New file. * doc/Makefile.am (pies_TEXINFOS): Remove pies.texi, add usr-acl.texi (check-config, check-sub-config): Handle @deffnx * doc/pies.texi: Update. * src/Makefile.am (AM_CPPFLAGS): Remove superfluous defs, use ../gnu/configmake.h instead * src/acl.c (_acl_common_section_parser): Handle tag, depending on the value of `flag' parameter. Avoid coredumping on NULL pacl. (acl_section_parser, defacl_section_parser): Update calls to _acl_common_section_parser. * src/pies.c (STATEDIR): Replace with LOCALSTATEDIR. (GRECS_VALUE_IS_EMPTY): New define (possibly belongs to grecs more than to pies). (assert_grecs_value_type) (return_code_section_parser): Use GRECS_VALUE_IS_EMPTY to check for empty value. (_get_array_arg): Bugfix. (component_keywords, pies_keywords): Add missing docstrings. * src/progman.c (TYPE_RETR): Rename to TYPE_REDIRECTOR. All uses updated.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/acl.c42
-rw-r--r--src/pies.c43
-rw-r--r--src/progman.c10
4 files changed, 67 insertions, 31 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 970a8b3..78b55c1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,8 +55,7 @@ LDADD = \
../gnu/libgnu.a\
$(MF_PROCTITLE_LIBS)
-AM_CPPFLAGS=-DSYSCONFDIR=\"$(sysconfdir)\"\
- -DSTATEDIR=\"$(localstatedir)\"\
+AM_CPPFLAGS=\
-DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"\
-DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\
-DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"
diff --git a/src/acl.c b/src/acl.c
index ad3ea1d..c78dc61 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -360,16 +360,22 @@ parse_acl_line (grecs_locus_t *locus, int allow, pies_acl_t acl,
return 0;
}
+#define ACL_TAG_NONE 0
+#define ACL_TAG_IGNORE 1
+#define ACL_TAG_OPTIONAL 2
+#define ACL_TAG_REQUIRED 3
+
int
_acl_common_section_parser (enum grecs_callback_command cmd,
grecs_locus_t *locus,
grecs_value_t *value,
pies_acl_t *pacl,
- int need_tag)
+ int flag)
{
pies_acl_t acl;
grecs_locus_t defn_loc;
const char *tag = NULL;
+ int has_value = 0;
switch (cmd)
{
@@ -381,9 +387,26 @@ _acl_common_section_parser (enum grecs_callback_command cmd,
grecs_error (locus, 0, _("ACL name must be a string"));
return 1;
}
- tag = value->v.string;
+ has_value = value->v.string != NULL;
+ }
+ if (has_value)
+ {
+ switch (flag)
+ {
+ case ACL_TAG_NONE:
+ grecs_error (locus, 0, _("ACL name is not expected"));
+ return 1;
+
+ case ACL_TAG_IGNORE:
+ grecs_warning (locus, 0, _("ACL name is ignored"));
+ break;
+
+ case ACL_TAG_OPTIONAL:
+ case ACL_TAG_REQUIRED:
+ tag = value->v.string;
+ }
}
- else if (need_tag)
+ else if (flag == ACL_TAG_REQUIRED)
{
grecs_error (locus, 0, _("missing ACL name"));
return 1;
@@ -398,7 +421,8 @@ _acl_common_section_parser (enum grecs_callback_command cmd,
_("location of the previous definition"));
return 1;
}
- *pacl = acl;
+ if (pacl)
+ *pacl = acl;
break;
case grecs_callback_section_end:
@@ -415,9 +439,11 @@ acl_section_parser (enum grecs_callback_command cmd,
grecs_value_t *value,
void *cb_data)
{
- if (_acl_common_section_parser (cmd, locus, value, varptr, 1) == 0)
+ int rc = _acl_common_section_parser (cmd, locus, value, varptr,
+ ACL_TAG_NONE);
+ if (rc == 0)
*(void**)cb_data = *(pies_acl_t*)varptr;
- return 0;
+ return rc;
}
int
@@ -427,8 +453,8 @@ defacl_section_parser (enum grecs_callback_command cmd,
grecs_value_t *value,
void *cb_data)
{
- _acl_common_section_parser (cmd, locus, value, cb_data, 0);
- return 0;
+ return _acl_common_section_parser (cmd, locus, value, cb_data,
+ ACL_TAG_REQUIRED);
}
static int
diff --git a/src/pies.c b/src/pies.c
index d7d4ae1..d4a8013 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -28,9 +28,9 @@ char *log_tag;
struct pies_privs pies_privs;
int foreground;
int command;
-char *pidfile = STATEDIR "/pies.pid";
-char *ctlfile = STATEDIR "/pies.ctl";
-char *statfile = STATEDIR "/pies.stat";
+char *pidfile = LOCALSTATEDIR "/pies.pid";
+char *ctlfile = LOCALSTATEDIR "/pies.ctl";
+char *statfile = LOCALSTATEDIR "/pies.stat";
mode_t pies_umask = 0;
unsigned long shutdown_timeout = 5;
pies_acl_t pies_acl;
@@ -62,11 +62,20 @@ stderr_closed_p ()
}
+#define GRECS_VALUE_IS_EMPTY(val) \
+ (!(val) || ((val)->type == GRECS_TYPE_STRING && !(val)->v.string))
+
int
assert_grecs_value_type (grecs_locus_t * locus,
const grecs_value_t * value, int type)
{
- if (!value || value->type != type)
+ if (GRECS_VALUE_IS_EMPTY (value))
+ {
+ grecs_error (locus, 0, _("expected %s"),
+ 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),
@@ -320,7 +329,8 @@ _get_array_arg (grecs_value_t * val, int num, grecs_locus_t * locus)
{
if (num < val->v.arg.c)
{
- if (assert_grecs_value_type (locus, val, GRECS_TYPE_STRING) == 0)
+ if (assert_grecs_value_type (locus, &val->v.arg.v[num],
+ GRECS_TYPE_STRING) == 0)
return val->v.arg.v[num].v.string;
}
return NULL;
@@ -352,7 +362,7 @@ return_code_section_parser (enum grecs_callback_command cmd,
switch (cmd)
{
case grecs_callback_section_begin:
- if (!value)
+ if (GRECS_VALUE_IS_EMPTY (value))
{
grecs_error (locus, 0, _("missing tag"));
return 1;
@@ -873,7 +883,7 @@ struct grecs_keyword component_keywords[] = {
},
{"return-code",
N_("<tag: exit-code-list>"),
- NULL, /* FIXME: Docstring? */
+ N_("Define what to do when the component finishes."),
grecs_type_section, NULL, 0,
return_code_section_parser, NULL, return_code_keywords},
{NULL}
@@ -1054,8 +1064,10 @@ static struct grecs_keyword syslog_kw[] = {
grecs_type_string, &log_facility, 0, cb_syslog_facility},
{"tag", N_("string"), N_("Tag syslog messages with this string"),
grecs_type_string, &log_tag},
-# if 0
- {"print-priority", N_("arg"), N_("Prefix each message with its priority"),
+#if 0
+ /* This is reserved for future use */
+ {
+ "print-priority", N_("arg"), N_("Prefix each message with its priority"),
grecs_type_bool, &syslog_include_prio},
#endif
{NULL},
@@ -1076,10 +1088,9 @@ _cm_include_meta1 (enum grecs_callback_command cmd,
}
struct grecs_keyword pies_keywords[] = {
- /* FIXME */
{"component",
N_("<tag: string>"),
- NULL, /* FIXME: Docstring */
+ N_("Define a component"),
grecs_type_section, NULL, 0,
component_section_parser, NULL, component_keywords},
{"syslog",
@@ -1121,7 +1132,7 @@ struct grecs_keyword pies_keywords[] = {
{"group",
NULL,
N_("Retain supplementary group."),
- grecs_type_string | GRECS_LIST, /*FIXME*/ &pies_privs.groups, 0,
+ grecs_type_string | GRECS_LIST, &pies_privs.groups, 0,
NULL,
},
{"allgroups",
@@ -1149,13 +1160,13 @@ struct grecs_keyword pies_keywords[] = {
},
{"return-code",
N_("<tag: exit-code-list>"),
- NULL, /* FIXME: Docstring? */
+ N_("Define what to do when the component finishes."),
grecs_type_section, &default_component, 0,
return_code_section_parser, NULL, return_code_keywords},
{"acl",
N_("name: string"),
N_("Set global ACL."),
- grecs_type_section, NULL, 0,
+ grecs_type_section, &pies_acl, 0,
acl_section_parser, NULL, acl_keywords},
{"defacl",
N_("name: string"),
@@ -1170,7 +1181,7 @@ struct grecs_keyword pies_keywords[] = {
},
{"meta1-queue-dir",
NULL,
- N_("Set name of MeTA1 queue directory (default /var/spool/meta1)."),
+ N_("Set the name of MeTA1 queue directory (default /var/spool/meta1)."),
grecs_type_string, &meta1_queue_dir, 0,
NULL,
},
@@ -1586,7 +1597,7 @@ pies_status ()
logmsg (LOG_INFO,
_("pies is not running, but a pidfile "
"is found (pid %lu)"), (unsigned long) pid);
- return 1; /* FIXME: hm? */
+ return 1;
case pies_status_noresp:
logmsg (LOG_INFO,
diff --git a/src/progman.c b/src/progman.c
index e420e85..7438837 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -16,8 +16,8 @@
#include "pies.h"
-#define TYPE_COMPONENT 0
-#define TYPE_RETR 1
+#define TYPE_COMPONENT 0
+#define TYPE_REDIRECTOR 1
enum prog_status
{
@@ -169,7 +169,7 @@ destroy_prog (struct prog **pp)
case TYPE_COMPONENT:
break;
- case TYPE_RETR:
+ case TYPE_REDIRECTOR:
{
struct prog *master = p->v.r.master;
if (p == master->v.p.redir[0])
@@ -205,7 +205,7 @@ register_redir (int type, struct prog *master)
struct prog *pp = xzalloc (sizeof (*pp) + strlen (tag) + 1 +
2 * sizeof (char**));
- pp->type = TYPE_RETR;
+ pp->type = TYPE_REDIRECTOR;
pstr = (char *) (pp + 1);
pp->tag = pstr;
strcpy (pp->tag, tag);
@@ -1807,7 +1807,7 @@ progman_dump_stats (const char *filename)
fputc ('\n', fp);
break;
- case TYPE_RETR:
+ case TYPE_REDIRECTOR:
fprintf (fp, _("redirector %s %lu\n"), prog->tag,
(unsigned long) prog->pid);
}

Return to:

Send suggestions and report system problems to the System administrator.