aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-10-12 21:14:00 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-10-12 21:14:00 +0300
commitaf04ed630f18e9003756317cc627a11084d0d59a (patch)
tree828cf1fc2c326842777942441c14e853d9894cc7 /src
parent989a5bbb74c3620abaa2191ce2c4f8d5968dbf0a (diff)
downloadpies-af04ed630f18e9003756317cc627a11084d0d59a.tar.gz
pies-af04ed630f18e9003756317cc627a11084d0d59a.tar.bz2
Do not require Mailutils. Provide missing functions.
* Makefile.am (ACLOCAL_AMFLAGS): Add grecs/am * bootstrap.conf: Skip po. Initialize submodule. * configure.ac: Mailutils no longer needed. (AC_CONFIG_FILES): Add new subdirs. * gnulib.modules: Add more modules. Arrange entries alphabetically. * lib/Makefile.am: Rename library to libpies. * lib/libpies.h (mf_privs) (switch_to_privs, get_user_groups) (mf_priv_setup, mf_epriv_setup): Move to src/pies.h (config_array_to_argv, config_array_to_string) (config_cb_timeout): Remove. (tokendef): New struct. (strtotok_len, strtotok_len_ci) (strtotok, strtotok_ci, toktostr): New prototypes. * lib/nls.c: Remove call to mu_init_nls. * src/acl.c: New file. * src/addrfmt.c: New file. * src/diag.c: New file. * src/meta.c: New file. * src/url.c: New file. * src/userprivs.c: New file. * src/acl.h: New file. * src/pp-setup: New file. * src/Makefile.am (pies_SOURCES): Add acl.c, addrfmt.c, diag.c, meta.c, url.c, userprivs.c. (noinst_HEADERS): Add acl.h. (inc_DATA): Add pp-setup. * src/limits.c, src/meta1gram.y, src/meta1lex.h, src/meta1lex.l, src/pies.c, src/pies.h, src/progman.c, src/socket.c, src/userprivs.c: Remove calls to functions from Mailutils.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am34
-rw-r--r--src/depmap.c18
-rw-r--r--src/limits.c27
-rw-r--r--src/meta1gram.y395
-rw-r--r--src/meta1lex.h14
-rw-r--r--src/meta1lex.l83
-rw-r--r--src/pies.c1614
-rw-r--r--src/pies.h133
-rw-r--r--src/progman.c557
-rw-r--r--src/socket.c197
10 files changed, 1684 insertions, 1388 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 52648c8..c0c3b8a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,31 +1,38 @@
-# This file is part of mailfrom filter.
+# This file is part of Pies.
# Copyright (C) 2008, 2009 Sergey Poznyakoff
#
-# This program is free software; you can redistribute it and/or modify
+# Pies is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
-# This program is distributed in the hope that it will be useful,
+# Pies is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with Pies. If not, see <http://www.gnu.org/licenses/>. */
sbin_PROGRAMS = pies
pies_SOURCES = \
+ acl.c\
+ addrfmt.c\
depmap.c\
+ diag.c\
limits.c\
+ meta.c\
meta1gram.y\
meta1lex.l\
pies.c\
progman.c\
- socket.c
+ socket.c\
+ url.c\
+ userprivs.c
noinst_HEADERS = \
+ acl.h\
meta1gram.h\
meta1lex.h\
pies.h
@@ -38,20 +45,25 @@ DISTCLEANFILES = pies.rc
meta1lex.c: meta1gram.h
+incdir=$(pkgdatadir)/$(VERSION)/include
+inc_DATA = pp-setup
+
INCLUDES = \
- $(MAILUTILS_INCLUDES)\
- $(MU_COMMON_INCLUDES)\
-I$(top_srcdir)/lib\
- -I$(top_srcdir)/gnu
+ -I$(top_srcdir)/gnu\
+ -I$(top_srcdir)/grecs/src
LDADD = \
- ../lib/libmf.a\
+ ../lib/libpies.a\
+ ../grecs/src/libgrecs.a\
../gnu/libgnu.a\
- $(MAILUTILS_LIBS)\
$(MF_PROCTITLE_LIBS)
AM_CPPFLAGS=-DSYSCONFDIR=\"$(sysconfdir)\"\
- -DSTATEDIR=\"$(localstatedir)\"
+ -DSTATEDIR=\"$(localstatedir)\"\
+ -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)"\
+ -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\
+ -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"
AM_YFLAGS=-dvt -pmeta1
AM_LFLAGS=-dvp -Pmeta1 -olex.yy.c
diff --git a/src/depmap.c b/src/depmap.c
index 76b492f..8a2772f 100644
--- a/src/depmap.c
+++ b/src/depmap.c
@@ -1,18 +1,18 @@
-/* This file is part of Mailfromd.
- Copyright (C) 2008 Sergey Poznyakoff
+/* This file is part of Pies.
+ Copyright (C) 2008, 2009 Sergey Poznyakoff
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 3 of the License, or (at your
- option) any later version.
+ Pies is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
- This program is distributed in the hope that it will be useful,
+ Pies is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License along
- with this program. If not, see <http://www.gnu.org/licenses/>. */
+ You should have received a copy of the GNU General Public License
+ along with Pies. If not, see <http://www.gnu.org/licenses/>. */
#include "pies.h"
diff --git a/src/limits.c b/src/limits.c
index 90d6459..3d430af 100644
--- a/src/limits.c
+++ b/src/limits.c
@@ -1,18 +1,18 @@
-/* This file is part of Mailfromd.
- Copyright (C) 2008 Sergey Poznyakoff
+/* This file is part of Pies.
+ Copyright (C) 2008, 2009 Sergey Poznyakoff
- This program is free software; you can redistribute it and/or modify
+ Pies is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
- This program is distributed in the hope that it will be useful,
+ Pies is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with Pies. If not, see <http://www.gnu.org/licenses/>. */
#include <pies.h>
@@ -50,15 +50,14 @@ do_set_limit (int rlimit, rlim_t limit)
{
struct rlimit rlim;
- MU_DEBUG2 (pies_debug, MU_DEBUG_TRACE1,
- "Setting limit %d to %lu\n", rlimit, (unsigned long) limit);
+ debug (1, ("setting limit %d to %lu", rlimit, (unsigned long) limit));
rlim.rlim_cur = limit;
rlim.rlim_max = limit;
if (setrlimit(rlimit, &rlim))
{
- mu_diag_output (MU_DIAG_NOTICE, _("error setting limit: %s"),
- mu_strerror (errno));
+ logmsg (LOG_NOTICE, _("error setting limit: %s"),
+ strerror (errno));
return 1;
}
return 0;
@@ -67,11 +66,11 @@ do_set_limit (int rlimit, rlim_t limit)
static int
set_prio (int prio)
{
- MU_DEBUG1 (pies_debug, MU_DEBUG_TRACE2, "Setting priority to %d\n", prio);
+ debug (2, ("Setting priority to %d", prio));
if (setpriority (PRIO_PROCESS, 0, prio))
{
- mu_diag_output (MU_DIAG_NOTICE, _("error setting priority: %s"),
- mu_strerror (errno));
+ logmsg (LOG_NOTICE, _("error setting priority: %s"),
+ strerror (errno));
return 1;
}
return 0;
@@ -81,7 +80,7 @@ set_prio (int prio)
static int
check_logins (const char *name, int limit)
{
- mu_diag_output (MU_DIAG_NOTICE, _("L limit is not implemented"));
+ logmsg (LOG_NOTICE, _("L limit is not implemented"));
return 0;
}
@@ -93,7 +92,7 @@ set_limits (const char *name, struct limits_rec *lrec)
if (!lrec)
return 0;
- MU_DEBUG1 (pies_debug, MU_DEBUG_TRACE2, "Setting limits for %s\n", name);
+ debug (2, ("setting limits for %s", name));
#if defined(RLIMIT_AS)
if (lrec->set & SET_LIMIT_AS)
diff --git a/src/meta1gram.y b/src/meta1gram.y
index 4966634..db92d61 100644
--- a/src/meta1gram.y
+++ b/src/meta1gram.y
@@ -1,6 +1,6 @@
%{
-/* MeTA1 configuration parser for Mailfromd.
- Copyright (C) 2008 Sergey Poznyakoff
+/* MeTA1 configuration parser for Pies.
+ Copyright (C) 2008, 2009 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,99 +22,98 @@
#include "pies.h"
#include "meta1lex.h"
-/* FIXME: Use mu_opool_alloc? */
-static mu_config_value_t *
-create_value (int type)
+#define META1_QUEUE_DIR() \
+ (meta1_queue_dir ? meta1_queue_dir : "/var/spool/meta1")
+
+enum meta1_stmt_type
+{
+ meta1_simple,
+ meta1_block
+};
+
+struct meta1_stmt
+{
+ struct meta1_stmt *next;
+ grecs_locus_t locus;
+ enum meta1_stmt_type type;
+ const char *ident;
+ union
+ {
+ grecs_value_t *value;
+ struct meta1_stmt *list;
+ } v;
+};
+
+struct meta1_stmt *
+meta1_stmt_create (enum meta1_stmt_type type, const char *ident)
{
- mu_config_value_t *val = mu_alloc (sizeof (*val));
- val->type = type;
- return val;
+ struct meta1_stmt *p = xmalloc (sizeof (*p));
+ p->next = NULL;
+ p->type = type;
+ p->ident = ident;
+ p->locus = meta1_locus;
+ return p;
}
-static mu_config_value_t *
-config_value_dup (mu_config_value_t *src)
+static struct meta1_stmt *
+_reverse (struct meta1_stmt *list, struct meta1_stmt **root)
{
- if (!src)
- return NULL;
- else
+ struct meta1_stmt *next;
+
+ if (list->next == NULL)
{
- mu_config_value_t *val = mu_alloc (sizeof (*val));
- *val = *src;
- return val;
+ *root = list;
+ return list;
}
+ next = _reverse (list->next, root);
+ next->next = list;
+ list->next = NULL;
+ return list;
}
-
-static mu_cfg_node_t *
-alloc_node (enum mu_cfg_node_type type, mu_cfg_locus_t *loc,
- const char *tag, mu_config_value_t *label,
- mu_cfg_node_t *node)
+
+static struct meta1_stmt *
+reverse (struct meta1_stmt *in)
{
- char *p;
- mu_cfg_node_t *np;
- size_t size = sizeof *np + strlen (tag) + 1;
- np = mu_alloc (size);
- np->type = type;
- np->locus = *loc;
- p = (char*) (np + 1);
- np->tag = p;
- strcpy (p, tag);
- np->label = label;
- np->node = node;
- np->next = NULL;
- return np;
+ struct meta1_stmt *root;
+ if (!in)
+ return in;
+ _reverse (in, &root);
+ return root;
}
-static mu_cfg_node_t *translate_component (mu_cfg_node_t *);
-
-mu_cfg_node_t *meta1_parse_head;
-
+static void meta1_translate (struct meta1_stmt *);
%}
%union {
- mu_cfg_node_t node;
- mu_cfg_node_t *pnode;
- mu_config_value_t *value;
- struct { mu_cfg_node_t *head, *tail; } nodelist;
char *string;
- unsigned long number;
- mu_list_t list;
+ gl_list_t list;
+ grecs_value_t *value;
+ struct meta1_stmt *stmt;
}
%token <string> META1_IDENT META1_STRING META1_NUMBER
-
-%type <nodelist> stmtlist
-%type <pnode> stmt simple block
-%type <list> slist list values
+%type <list> slist values list
+%type <value> value
%type <string> string ident
-%type <value> value
-
+%type <stmt> stmtlist stmt simple block
%%
input : stmtlist
{
- mu_cfg_node_t *node;
- meta1_parse_head = NULL;
- for (node = $1.head; node; node = node->next)
- {
- mu_cfg_node_t *new_node = translate_component (node);
- if (new_node)
- {
- new_node->next = meta1_parse_head;
- meta1_parse_head = new_node;
- }
- }
+ struct meta1_stmt *stmt;
+ for (stmt = $1; stmt; stmt = stmt->next)
+ meta1_translate (stmt);
}
;
stmtlist: stmt
{
- $$.head = $$.tail = $1;
+ $$ = $1;
}
| stmtlist stmt
{
- $$ = $1;
- $$.tail->next = $2;
- $$.tail = $2;
+ $2->next = $1;
+ $$ = $2;
}
;
@@ -124,18 +123,15 @@ stmt : simple
simple : ident '=' value opt_sc
{
- $$ = alloc_node (mu_cfg_node_param, &meta1_locus,
- $1, $3,
- NULL);
+ $$ = meta1_stmt_create (meta1_simple, $1);
+ $$->v.value = $3;
}
;
block : ident tag '{' stmtlist '}' opt_sc
- {
- /* FIXME: tag is currently ignored */
- $$ = alloc_node (mu_cfg_node_tag, &meta1_locus,
- $1, NULL,
- $4.head);
+ {
+ $$ = meta1_stmt_create (meta1_block, $1);
+ $$->v.list = reverse ($4);
}
;
@@ -148,49 +144,50 @@ ident : META1_IDENT
value : string
{
- $$ = create_value (MU_CFG_STRING);
+ $$ = xmalloc (sizeof (*$$));
+ $$->type = GRECS_TYPE_STRING;
$$->v.string = $1;
}
| list
{
- $$ = create_value (MU_CFG_LIST);
+ $$ = xmalloc (sizeof (*$$));
+ $$->type = GRECS_TYPE_LIST;
$$->v.list = $1;
}
| META1_NUMBER
{
- $$ = create_value (MU_CFG_STRING);
+ $$ = xmalloc (sizeof (*$$));
+ $$->type = GRECS_TYPE_STRING;
$$->v.string = $1;
- }
+ }
;
string : META1_IDENT
| slist
{
- mu_iterator_t itr;
- mu_list_get_iterator ($1, &itr);
+ const void *p;
+ gl_list_iterator_t itr = gl_list_iterator ($1);
meta1_line_begin ();
- for (mu_iterator_first (itr);
- !mu_iterator_is_done (itr); mu_iterator_next (itr))
- {
- char *p;
- mu_iterator_current (itr, (void**)&p);
- meta1_line_add (p, strlen (p));
- }
+ while (gl_list_iterator_next (&itr, &p, NULL))
+ meta1_line_add (p, strlen (p));
+ gl_list_iterator_free (&itr);
$$ = meta1_line_finish ();
- mu_iterator_destroy (&itr);
- mu_list_destroy (&$1);
}
;
slist : META1_STRING
{
- mu_list_create (&$$);
- mu_list_append ($$, $1);
+ $$ = gl_list_create_empty (&gl_linked_list_implementation,
+ NULL,
+ NULL,
+ NULL,
+ true);
+ gl_list_add_last ($$, $1);
}
| slist META1_STRING
{
- mu_list_append ($1, $2);
+ gl_list_add_last ($1, $2);
$$ = $1;
}
;
@@ -207,12 +204,16 @@ list : '{' values '}'
values : value
{
- mu_list_create (&$$);
- mu_list_append ($$, $1);
+ $$ = gl_list_create_empty (&gl_linked_list_implementation,
+ NULL,
+ NULL,
+ NULL,
+ true);
+ gl_list_add_last ($$, $1);
}
| values ',' value
{
- mu_list_append ($1, $3);
+ gl_list_add_last ($1, $3);
$$ = $1;
}
;
@@ -232,19 +233,27 @@ yyerror (char *s)
void
meta1_parser_set_debug ()
{
- mu_log_level_t lev = mu_global_debug_level ("meta1");
- if (lev & MU_DEBUG_LEVEL_MASK (MU_DEBUG_TRACE6))
- yydebug = 1;
+ char *p = getenv ("META1_DEBUG_YACC");
+ yydebug = p && (*p - '0') > 0;
}
+static struct meta1_stmt *
+find_stmt (struct meta1_stmt *stmt, const char *ident)
+{
+ for (; stmt; stmt = stmt->next)
+ if (strcmp (stmt->ident, ident) == 0)
+ break;
+ return stmt;
+}
+
+
struct node_trans
{
char *name;
char *new_name;
- mu_cfg_node_t *(*fun) (const char *, mu_cfg_node_t *);
+ int (*xlat) (struct meta1_stmt *stmt, struct component *comp);
};
-
static struct node_trans *
find_node_trans (struct node_trans *tab, const char *name)
{
@@ -254,54 +263,43 @@ find_node_trans (struct node_trans *tab, const char *name)
return NULL;
}
-static mu_cfg_node_t *
-find_node (mu_cfg_node_t *list, const char *name)
-{
- for (; list; list = list->next)
- {
- if (strcmp (list->tag, name) == 0)
- return list;
- }
- return NULL;
-}
-
-static mu_cfg_node_t *
-xlat_listen_socket (const char *name, mu_cfg_node_t *src)
+static int
+xlat_listen_socket (struct meta1_stmt *stmt, struct component *comp)
{
- mu_cfg_node_t *p;
- mu_config_value_t *val;
+ struct meta1_stmt *p;
+ grecs_value_t *val;
+ p = find_stmt (stmt->v.list, "type");
+ if (!p || !p->v.value || p->v.value->type != GRECS_TYPE_STRING)
+ return 1;
meta1_line_begin ();
- p = find_node (src->node, "type");
- if (!p || !p->label || p->label->type != MU_CFG_STRING)
- return NULL;
- meta1_line_add (p->label->v.string, strlen (p->label->v.string));
+ meta1_line_add (p->v.value->v.string, strlen (p->v.value->v.string));
meta1_line_add ("://", 3);
- if (strcmp (p->label->v.string, "inet") == 0)
+ if (strcmp (p->v.value->v.string, "inet") == 0)
{
const char *addr;
- p = find_node (src->node, "address");
+ p = find_stmt (stmt->v.list, "address");
if (p)
{
- if (p->label->type != MU_CFG_STRING)
- return NULL;
- addr = p->label->v.string;
+ if (p->v.value->type != GRECS_TYPE_STRING)
+ return 1;
+ addr = p->v.value->v.string;
}
else
addr = "0.0.0.0";
meta1_line_add (addr, strlen (addr));
meta1_line_add (":", 1);
- p = find_node (src->node, "port");
- if (p->label->type != MU_CFG_STRING)
- return NULL;
- meta1_line_add (p->label->v.string, strlen (p->label->v.string));
+ p = find_stmt (stmt->v.list, "port");
+ if (p->v.value->type != GRECS_TYPE_STRING)
+ return 1;
+ meta1_line_add (p->v.value->v.string, strlen (p->v.value->v.string));
}
- else if (strcmp (p->label->v.string, "unix") == 0)
+ else if (strcmp (p->v.value->v.string, "unix") == 0)
{
- p = find_node (src->node, "path");
- if (!p || p->label->type != MU_CFG_STRING)
- return NULL;
- meta1_line_add (p->label->v.string, strlen (p->label->v.string));
+ p = find_stmt (stmt->v.list, "path");
+ if (!p || p->v.value->type != GRECS_TYPE_STRING)
+ return 1;
+ meta1_line_add (p->v.value->v.string, strlen (p->v.value->v.string));
/* FIXME: Other substatements:
listen_socket {
type=unix;
@@ -312,11 +310,15 @@ xlat_listen_socket (const char *name, mu_cfg_node_t *src)
}
*/
}
- val = create_value (MU_CFG_STRING);
+ val = xmalloc (sizeof (*val));
+ val->type = GRECS_TYPE_STRING;
val->v.string = meta1_line_finish ();
- return alloc_node (mu_cfg_node_param, &src->locus, "socket", val, NULL);
+ stmt->type = meta1_simple;
+ stmt->v.value = val;
+ return 0;
}
+
static struct node_trans root_node_trans[] = {
{ "listen_socket", "socket", xlat_listen_socket },
{ "start_action", "mode" },
@@ -328,112 +330,45 @@ static struct node_trans root_node_trans[] = {
{ NULL }
};
-static mu_cfg_node_t *
-create_string_node (const char *tag, const char *str, mu_cfg_locus_t *locus)
+static void
+meta1_translate_stmt (struct meta1_stmt *stmt, struct component *comp)
{
- mu_config_value_t *val = create_value (MU_CFG_STRING);
+ struct grecs_keyword *kwp;
- val->v.string = meta1_string (str, strlen (str));
- return alloc_node (mu_cfg_node_param, locus, tag, val, NULL);
-}
-
-static mu_cfg_node_t *
-create_redir_node (const char *tag, const char *dir,
- const char *name, mu_cfg_locus_t *locus)
-{
- mu_config_value_t *val = create_value (MU_CFG_ARRAY);
- val->v.arg.c = 2;
- val->v.arg.v = mu_alloc (2 * sizeof (val->v.arg.v[0]));
+ struct node_trans *nt = find_node_trans (root_node_trans, stmt->ident);
+ if (!nt)
+ return;
- val->v.arg.v[1].type = MU_CFG_STRING;
- val->v.arg.v[0].v.string = meta1_string ("file", 4);
+ kwp = find_component_keyword (nt->new_name);
+ if (!kwp)
+ abort ();
- val->v.arg.v[1].type = MU_CFG_STRING;
- meta1_line_begin ();
- meta1_line_add (dir, strlen (dir));
- meta1_line_add ("/", 1);
- meta1_line_add (name, strlen (name));
- meta1_line_add (".log", 4);
- val->v.arg.v[1].v.string = meta1_line_finish ();
+ if (nt->xlat && nt->xlat (stmt, comp))
+ return;
- return alloc_node (mu_cfg_node_param, locus, tag, val, NULL);
+ grecs_process_ident (kwp, stmt->v.value, comp, &stmt->locus);
}
-static mu_cfg_node_t *
-translate_node (mu_cfg_node_t *src)
+static void
+meta1_translate (struct meta1_stmt *stmt)
{
- mu_cfg_node_t *dst = NULL;
- struct node_trans *nt = find_node_trans (root_node_trans, src->tag);
+ struct component *comp;
+ struct meta1_stmt *p;
- if (nt)
- {
- if (nt->fun)
- dst = nt->fun (nt->new_name, src);
- else
- dst = alloc_node (mu_cfg_node_param, &src->locus,
- nt->new_name, config_value_dup (src->label),
- NULL);
- }
- return dst;
-}
-
-#define META1_QUEUE_DIR() \
- (meta1_queue_dir ? meta1_queue_dir : "/var/spool/meta1")
-
-static mu_cfg_node_t *
-translate_node_list (mu_cfg_node_t *src, const char *name)
-{
- mu_cfg_node_t *head = NULL, *tail = NULL;
- mu_cfg_locus_t *locus = &src->locus;
+ if (stmt->type != meta1_block)
+ return;
- for (; src; src = src->next)
- {
- mu_cfg_node_t *dst = translate_node (src);
- if (dst)
- {
- if (tail)
- tail->next = dst;
- else
- head = dst;
- tail = dst;
- }
- }
- if (head)
+ comp = component_create (stmt->ident);
+ for (p = stmt->v.list; p; p = p->next)
{
- /* Add common statements: */
- mu_cfg_node_t *node;
-
- node = create_string_node ("allgroups", "yes", locus);
- tail->next = node;
- tail = node;
-
- node = create_string_node ("chdir", META1_QUEUE_DIR (), locus);
- tail->next = node;
- tail = node;
-
- node = create_redir_node ("stderr", META1_QUEUE_DIR (), name, locus);
- tail->next = node;
- tail = node;
-
- node = create_string_node ("settle-timeout", "1", locus);
- tail->next = node;
- tail = node;
+ meta1_translate_stmt (p, comp);
}
- return head;
+ comp->privs.allgroups = 1;
+ comp->dir = META1_QUEUE_DIR ();
+ comp->settle_timeout = 1;
+ comp->redir[RETR_ERR].type = redir_file;
+ comp->redir[RETR_ERR].v.file = xasprintf ("%s/%s.log",
+ META1_QUEUE_DIR (),
+ comp->tag);
+ component_finish (comp, &stmt->locus);
}
-
-static mu_cfg_node_t *
-translate_component (mu_cfg_node_t *src)
-{
- mu_cfg_node_t *dst = NULL;
- if (src->type == mu_cfg_node_tag)
- {
- mu_config_value_t *val = create_value (MU_CFG_STRING);
- val->v.string = meta1_string (src->tag, strlen (src->tag));
- dst = alloc_node (mu_cfg_node_tag, &src->locus,
- "component", val,
- translate_node_list (src->node, val->v.string));
- }
- return dst;
-}
-
diff --git a/src/meta1lex.h b/src/meta1lex.h
index 8db32f9..035204b 100644
--- a/src/meta1lex.h
+++ b/src/meta1lex.h
@@ -1,23 +1,21 @@
-/* This file is part of Mailfromd.
- Copyright (C) 2008 Sergey Poznyakoff
+/* This file is part of Pies.
+ Copyright (C) 2009, 2009 Sergey Poznyakoff
- This program is free software; you can redistribute it and/or modify
+ Pies is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
- This program is distributed in the hope that it will be useful,
+ Pies is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with Pies. If not, see <http://www.gnu.org/licenses/>. */
-extern mu_cfg_locus_t meta1_locus;
+extern grecs_locus_t meta1_locus;
extern size_t meta1_error_count;
-extern mu_cfg_node_t *meta1_parse_head;
-extern mu_cfg_tree_t *meta1_parse_tree;
extern char *meta1_queue_dir;
char *meta1_string (const char *str, size_t len);
diff --git a/src/meta1lex.l b/src/meta1lex.l
index 312a1fd..0f08d87 100644
--- a/src/meta1lex.l
+++ b/src/meta1lex.l
@@ -1,6 +1,6 @@
%{
-/* MeTA1 configuration lexer for Mailfromd.
- Copyright (C) 2008 Sergey Poznyakoff
+/* MeTA1 configuration lexer for Pies.
+ Copyright (C) 2008, 2009 Sergey Poznyakoff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,9 +22,10 @@
#include "meta1gram.h"
#include "meta1lex.h"
-mu_cfg_locus_t meta1_locus;
+grecs_locus_t meta1_locus;
size_t meta1_error_count;
-mu_opool_t meta1_pool;
+struct obstack meta1_stk;
+int meta1_stk_init;
char *meta1_queue_dir;
#define yylval meta1lval
@@ -98,7 +99,22 @@ yywrap ()
void
meta1_line_add (const char *text, size_t len)
{
- mu_opool_append (meta1_pool, text, len);
+ obstack_grow (&meta1_stk, text, len);
+}
+
+static char quote_transtab[] = "\\\\\"\"a\ab\bf\fn\nr\rt\tv\v";
+
+static int
+unescape_char (int c)
+{
+ char *p;
+
+ for (p = quote_transtab; *p; p += 2)
+ {
+ if (*p == c)
+ return p[1];
+ }
+ return c;
}
static void
@@ -110,17 +126,17 @@ unescape_to_line (int c)
t = '\v';
else
{
- t = mu_argcv_unquote_char (c);
+ t = unescape_char (c);
if (t == c && t != '\\' && t != '\"')
meta1_parse_error (_("unknown escape sequence '\\%c'"), c);
}
- mu_opool_append_char (meta1_pool, t);
+ obstack_1grow (&meta1_stk, t);
}
void
meta1_line_add_unescape_last (const char *text, size_t len)
{
- mu_opool_append (meta1_pool, text, len - 2);
+ obstack_grow (&meta1_stk, text, len - 2);
unescape_to_line (text[len - 1]);
}
@@ -129,24 +145,25 @@ meta1_line_add_unescape_hex (const char *text, size_t len)
{
for (; text[len-1] != 'x' && len > 0; len--)
;
- mu_opool_append (meta1_pool, text, len - 2);
- mu_opool_append_char (meta1_pool, (char) strtoul (text + len, NULL, 16));
+ obstack_grow (&meta1_stk, text, len - 2);
+ obstack_1grow (&meta1_stk, (char) strtoul (text + len, NULL, 16));
}
void
meta1_line_begin ()
{
- if (!meta1_pool)
- mu_opool_create (&meta1_pool, 1);
- else
- mu_opool_clear (meta1_pool);
+ if (!meta1_stk_init)
+ {
+ obstack_init (&meta1_stk);
+ meta1_stk_init = 1;
+ }
}
char *
meta1_line_finish ()
{
- mu_opool_append_char (meta1_pool, 0);
- return mu_opool_finish (meta1_pool, NULL);
+ obstack_1grow (&meta1_stk, 0);
+ return obstack_finish (&meta1_stk);
}
char *
@@ -161,34 +178,23 @@ void
meta1_parse_error (const char *fmt, ...)
{
va_list ap;
- mu_debug_t debug;
- mu_diag_get_debug (&debug);
- mu_debug_printf (debug, 0, "%s:%lu: ", meta1_locus.file,
+ logmsg_printf (LOG_ERR, "%s:%lu: ", meta1_locus.file,
(unsigned long) meta1_locus.line);
va_start (ap, fmt);
- mu_debug_vprintf (debug, 0, fmt, ap);
- mu_debug_printf (debug, 0, "\n");
+ logmsg_vprintf (LOG_ERR, fmt, ap);
va_end (ap);
+ logmsg_printf (LOG_ERR, "\n");
meta1_error_count++;
}
void
meta1_lexer_set_debug ()
{
- mu_log_level_t lev = mu_global_debug_level ("meta1");
- yy_flex_debug = (lev & MU_DEBUG_LEVEL_MASK (MU_DEBUG_TRACE7));
+ char *p = getenv ("META1_DEBUG_LEX");
+ yy_flex_debug = p && (*p - '0') > 0;
}
-static int
-_cfg_default_printer (void *unused, mu_log_level_t level, const char *str)
-{
- fprintf (stderr, "%s", str);
- return 0;
-}
-
-mu_cfg_tree_t *meta1_parse_tree;
-
/* Parse MeTA1 configuration file `name'. Populate `meta1_parse_tree' with
the parse tree. */
int
@@ -200,7 +206,8 @@ meta1_config_parse (const char *name)
fp = fopen (name, "r");
if (!fp)
{
- mu_error (_("%s: cannot open file: %s"), name, mu_strerror (errno));
+ logmsg (LOG_ERR,
+ _("%s: cannot open file: %s"), name, strerror (errno));
return 1;
}
meta1_locus.file = meta1_string (name, strlen (name));
@@ -213,16 +220,6 @@ meta1_config_parse (const char *name)
fclose (fp);
if (meta1_error_count)
rc = 1;
- if (rc == 0)
- {
- meta1_parse_tree = mu_alloc (sizeof (*meta1_parse_tree));
- mu_debug_create (&meta1_parse_tree->debug, NULL);
- mu_debug_set_print (meta1_parse_tree->debug, _cfg_default_printer, NULL);
- mu_debug_set_level (meta1_parse_tree->debug,
- mu_global_debug_level ("meta1"));
- meta1_parse_tree->node = meta1_parse_head;
- meta1_parse_tree->pool = meta1_pool;
- }
return rc;
}
diff --git a/src/pies.c b/src/pies.c
index 10862c2..f36c21f 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -1,27 +1,29 @@
-/* This file is part of Mailfromd.
+/* This file is part of Pies.
Copyright (C) 2008, 2009 Sergey Poznyakoff
- This program is free software; you can redistribute it and/or modify
+ Pies is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
- This program is distributed in the hope that it will be useful,
+ Pies is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with Pies. If not, see <http://www.gnu.org/licenses/>. */
#include "pies.h"
#include "meta1lex.h"
-int log_to_stderr; /* Use stderr for logging */
-char *log_tag; /* override mu_log_tag */
-mu_log_level_t debug_level;
-mu_debug_t pies_debug;
-struct mf_privs pies_privs;
+char *conffile = SYSCONFDIR "/pies.conf";
+int preprocess_only; /* Preprocess config, do nothing more */
+int lint_mode; /* Test configuration syntax and exit */
+int log_to_stderr; /* Use stderr for logging */
+int log_facility = LOG_USER;
+char *log_tag;
+struct pies_privs pies_privs;
int foreground;
int command;
char *pidfile = STATEDIR "/pies.pid";
@@ -29,34 +31,21 @@ char *ctlfile = STATEDIR "/pies.ctl";
char *statfile = STATEDIR "/pies.stat";
mode_t pies_umask = 0;
unsigned long shutdown_timeout = 5;
-mu_acl_t pies_acl;
+pies_acl_t pies_acl;
limits_record_t pies_limits;
int force_option;
-
+
/* Logging */
void
log_setup (int want_stderr)
{
- mu_debug_t debug;
-
- mu_diag_get_debug (&debug);
-
- if (log_tag)
- mu_log_tag = log_tag;
-
if (!want_stderr)
- {
- openlog (MU_LOG_TAG (), LOG_PID, mu_log_facility);
- mu_debug_set_print (debug, mu_diag_syslog_printer, NULL);
- mu_debug_default_printer = mu_debug_syslog_printer;
- }
- else
- mu_debug_default_printer = mu_debug_stderr_printer;
+ openlog (log_tag, LOG_PID, log_facility);
}
-
+
static int
-stderr_closed_p()
+stderr_closed_p ()
{
int fd = dup (0);
if (fd < 0)
@@ -64,77 +53,90 @@ stderr_closed_p()
close (fd);
return fd <= 2;
}
-
-static int
-_cb_action (mu_debug_t debug, void *data, mu_config_value_t *arg)
+
+int
+assert_grecs_value_type (grecs_locus_t * locus,
+ const grecs_value_t * value, int type)
{
- enum return_action *pact = data;
- static struct mu_kwd actab[] = {
- { "disable", action_disable },
- { "restart", action_restart },
- { NULL }
- };
- int res;
-
- if (mu_cfg_assert_value_type (arg, MU_CFG_STRING, debug))
- return 1;
- if (m