aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am40
-rw-r--r--NEWS8
-rw-r--r--bootstrap.conf9
-rw-r--r--configure.ac9
-rw-r--r--gnulib.modules3
m---------grecs0
-rw-r--r--lib/libpies.h6
-rw-r--r--src/.gitignore1
-rw-r--r--src/Makefile.am17
-rw-r--r--src/acl.c198
-rw-r--r--src/acl.h4
-rw-r--r--src/cmdline.opt193
-rw-r--r--src/diag.c40
-rw-r--r--src/inetd.c18
-rw-r--r--src/meta1gram.y43
-rw-r--r--src/meta1lex.h3
-rw-r--r--src/meta1lex.l55
-rw-r--r--src/pies.c319
-rw-r--r--src/pies.h12
-rw-r--r--src/progman.c76
-rw-r--r--src/userprivs.c49
21 files changed, 545 insertions, 558 deletions
diff --git a/Makefile.am b/Makefile.am
index b3c49a2..de4bf81 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,8 +1,8 @@
# This file is part of GNU Pies.
-# Copyright (C) 2008, 2009, 2010 Sergey Poznyakoff
+# Copyright (C) 2008, 2009, 2010, 2011 Sergey Poznyakoff
#
# GNU 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.
#
@@ -31,40 +31,22 @@ dist-hook:
alpha:
$(MAKE) dist distdir=$(PACKAGE)-$(VERSION)-`date +"%Y%m%d"`
alphacheck:
$(MAKE) distcheck distdir=$(PACKAGE)-$(VERSION)-`date +"%Y%m%d"`
-# Define the following variables in order to use the ChangeLog rule below:
-# prev_change_log [optional] Name of the previous ChangeLog file.
-# gen_start_date [optional] Start ChangeLog from this date.
-# changelog_dir [mandatory] Directory where to create ChangeLog
+# Name of the previous ChangeLog file.
prev_change_log = ChangeLog.mfd
+# Start Git ChangeLog from this date.
gen_start_date = 2009-09-04
-changelog_dir = .
.PHONY: ChangeLog
ChangeLog:
- @if test -d .git; then \
- cmd=$(top_srcdir)/build-aux/gitlog-to-changelog; \
- if test -n "$(gen_start_date)"; then \
- cmd="$$cmd --since=\"$(gen_start_date)\""; \
- fi; \
- $$cmd --format='%s%n%n%b%n' | \
- sed '/<unknown>$$/d' | fmt -s > $(changelog_dir)/cl-t; \
- if test -n "$(prev_change_log)" && test -f "$(prev_change_log)"; \
- then \
- echo "" >> $(changelog_dir)/cl-t; \
- cat "$(prev_change_log)" | \
- sed '/^Local Variables:/,/^End:/d' >> $(changelog_dir)/cl-t; \
- fi; \
- echo "Local Variables:" >> $(changelog_dir)/cl-t; \
- echo "mode: change-log" >> $(changelog_dir)/cl-t; \
- echo "version-control: never" >> $(changelog_dir)/cl-t; \
- echo "buffer-read-only: t" >> $(changelog_dir)/cl-t; \
- echo "End:" >> $(changelog_dir)/cl-t; \
- echo "" >> $(changelog_dir)/cl-t; \
- sed -n '1,/^[^#]/s/^#//p' $(top_srcdir)/Makefile.am \
- >> $(changelog_dir)/cl-t; \
- rm -f $(changelog_dir)/ChangeLog; \
- mv $(changelog_dir)/cl-t $(changelog_dir)/ChangeLog; \
+ $(AM_V_GEN)if test -d .git; then \
+ git log --pretty='format:%ct %an <%ae>%n%n%s%n%n%b%n' | \
+ awk -f $(top_srcdir)/@GRECS_SUBDIR@/build-aux/git2chg.awk \
+ -vsince=\"$(gen_start_date)\" -vappend=\"$(prev_change_log)\" \
+ > ChangeLog.tmp; \
+ cmp ChangeLog ChangeLog.tmp > /dev/null 2>&1 || \
+ mv ChangeLog.tmp ChangeLog; \
+ rm -f ChangeLog.tmp; \
fi
diff --git a/NEWS b/NEWS
index d4b2392..9bc6609 100644
--- a/NEWS
+++ b/NEWS
@@ -1,14 +1,16 @@
-GNU Pies NEWS -- history of user-visible changes. 2009-12-11
-Copyright (C) 2009, 2010 Sergey Poznyakoff
+GNU Pies NEWS -- history of user-visible changes. 2011-10-23
+Copyright (C) 2009, 2010, 2011 Sergey Poznyakoff
See the end of file for copying conditions.
Please send Pies bug reports to <bug-pies@gnu.org> or
<bug-pies@gnu.org.ua>
+Version 1.2.90 (Git)
+
Version 1.2, 2009-12-11
* First release as a GNU package.
* Full inetd support
@@ -69,13 +71,13 @@ First stand-alone release. Previous versions were released as
part of Mailfromd (http://mailfromd.software.gnu.org.ua).
=========================================================================
Copyright information:
-Copyright (C) 2009 Sergey Poznyakoff
+Copyright (C) 2009, 2010, 2011 Sergey Poznyakoff
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
copyright notice and this permission notice are preserved,
thus giving the recipient permission to redistribute in turn.
diff --git a/bootstrap.conf b/bootstrap.conf
index 364978b..492aa78 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -1,8 +1,8 @@
# Bootstrap configuration for GNU Pies. -*- shell-script -*-
-# Copyright (C) 2008, 2009, 2010 Sergey Poznyakoff
+# Copyright (C) 2008, 2009, 2010, 2011 Sergey Poznyakoff
#
# GNU 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.
#
@@ -28,17 +28,18 @@ MODAVOID="xalloc-die openat-die"
if [ -n "$MODAVOID" ]; then
gnulib_tool_option_extras="`echo $MODAVOID | sed 's/\([^ ][^ ]*\)/--avoid &/g'`"
fi
# gnulib modules used by this package.
-gnulib_modules=`grep -h '^[^#]' gnulib.modules grecs/gnulib.modules | sort | uniq`
+gnulib_modules=`grep -h '^[^#]' gnulib.modules | sort | uniq`
NLS_MARKERS="\
- mu_error:1"
-
+ mu_error:1\
+ grecs_error:3\
+ grecs_warning:3"
# Additional xgettext options to use. Use "\\\newline" to break lines.
if [ -n "$NLS_MARKERS" ]; then
XGETTEXT_OPTIONS="$XGETTEXT_OPTIONS "`echo $NLS_MARKERS | tr ' ' '\n' | sed 's/.*/ --flag=&:pass-c-format\\\\\\\\\\\\/'`"
"
fi
diff --git a/configure.ac b/configure.ac
index a8848dd..0c1d2b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
# This file is part of GNU Pies. -*- autoconf -*-
-# Copyright (C) 2009, 2010 Sergey Poznyakoff
+# Copyright (C) 2009, 2010, 2011 Sergey Poznyakoff
#
# GNU 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.
#
@@ -12,13 +12,13 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Pies. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ([2.63])
-AC_INIT([GNU Pies], [1.2], [bug-pies@gnu.org.ua])
+AC_INIT([GNU Pies], [1.2.90], [bug-pies@gnu.org.ua])
AC_CONFIG_SRCDIR([src/pies.h])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.11 gnits tar-ustar dist-bzip2 std-options silent-rules])
# Enable silent rules by default:
@@ -54,13 +54,14 @@ AC_FUNC_FORK
AC_CHECK_FUNCS([alarm dup2 gethostbyname memmove memset select setenv socket strchr strcspn strtol strtoul sysconf getdtablesize vsyslog])
# Gnulib
gl_INIT
# Grecs
-GRECS_SETUP
+GRECS_SETUP([grecs],[tests git2chg getopt])
+GRECS_HOST_PROJECT_INCLUDES='-I$(top_srcdir)/gnu -I$(top_builddir)/gnu'
# Test for setproctitle
MF_PROCTITLE
# Gettext.
AM_ICONV
@@ -82,13 +83,11 @@ AH_BOTTOM([
])
IMPRIMATUR_INIT
AC_CONFIG_FILES([Makefile
gnu/Makefile
- grecs/Makefile
- grecs/src/Makefile
lib/Makefile
src/Makefile
doc/Makefile
po/Makefile.in])
AC_OUTPUT
diff --git a/gnulib.modules b/gnulib.modules
index d62e1a3..1e01a93 100644
--- a/gnulib.modules
+++ b/gnulib.modules
@@ -1,15 +1,14 @@
# List of gnulib modules needed for Pies.
# A module name per line. Empty lines and comments are ignored.
-argp
c-ctype
c-strcase
+configmake
fprintftime
gettext
-gitlog-to-changelog
inttostr
inttypes
obstack
progname
quotearg
sysexits
diff --git a/grecs b/grecs
-Subproject edcc575bcdc9e50bdb79f422ad0f11dc79f3eaa
+Subproject a52ab6c6c38e1dca047ada4d60249fb323942f0
diff --git a/lib/libpies.h b/lib/libpies.h
index 04910d5..d071846 100644
--- a/lib/libpies.h
+++ b/lib/libpies.h
@@ -1,8 +1,8 @@
/* This file is part of GNU Pies.
- Copyright (C) 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 2009, 2010, 2011 Sergey Poznyakoff
GNU 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.
@@ -16,16 +16,12 @@
#include <unistd.h>
#include <stdlib.h>
#include <gettext.h>
-#define _(String) gettext(String)
-#define N_(String) String
-
-
#if defined HAVE_SYSCONF && defined _SC_OPEN_MAX
# define getmaxfd() sysconf(_SC_OPEN_MAX)
#elif defined (HAVE_GETDTABLESIZE)
# define getmaxfd() getdtablesize()
#else
# define getmaxfd() 256
diff --git a/src/.gitignore b/src/.gitignore
index 18a7111..4ad4290 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,6 +1,7 @@
+cmdline.h
inetd
meta1gram.c
meta1gram.h
meta1gram.output
meta1lex.c
pies
diff --git a/src/Makefile.am b/src/Makefile.am
index 19c6483..455b2c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,8 +1,8 @@
# This file is part of GNU Pies.
-# Copyright (C) 2008, 2009, 2010 Sergey Poznyakoff
+# Copyright (C) 2008, 2009, 2010, 2011 Sergey Poznyakoff
#
# GNU 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.
#
@@ -32,31 +32,40 @@ pies_SOURCES = \
socket.c\
url.c\
userprivs.c
noinst_HEADERS = \
acl.h\
+ cmdline.h\
meta1gram.h\
meta1lex.h\
pies.h
meta1lex.c: meta1gram.h
+BUILT_SOURCES=cmdline.h
+
incdir=$(pkgdatadir)/$(VERSION)/include
inc_DATA = pp-setup
-EXTRA_DIST = pp-setup inetd.in
+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\
- -I$(top_srcdir)/grecs/src
+ @GRECS_INCLUDES@
LDADD = \
../lib/libpies.a\
- ../grecs/src/libgrecs.a\
+ @GRECS_LDADD@\
../gnu/libgnu.a\
$(MF_PROCTITLE_LIBS)
pkgstatedir=$(localstatedir)/pies
AM_CPPFLAGS=\
diff --git a/src/acl.c b/src/acl.c
index a0ee85e..dc459f5 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -1,8 +1,8 @@
/* This file is part of GNU Pies
- Copyright (C) 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 2009, 2010, 2011 Sergey Poznyakoff
GNU 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.
@@ -22,13 +22,12 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
-#include <hash.h>
struct pies_sockaddr
{
unsigned netmask;
int salen;
struct sockaddr sa;
@@ -37,41 +36,45 @@ struct pies_sockaddr
struct acl_entry
{
grecs_locus_t locus;
int allow;
int authenticated;
pies_acl_t acl;
- gl_list_t groups;
- gl_list_t sockaddrs;
+ struct grecs_list *groups;
+ struct grecs_list *sockaddrs;
};
struct pies_acl
{
char *name;
grecs_locus_t locus;
- gl_list_t list;
+ struct grecs_list *list;
};
/* ACL creation */
pies_acl_t
pies_acl_create (const char *name, grecs_locus_t *locus)
{
pies_acl_t acl = xmalloc (sizeof (acl[0]));
acl->name = name ? xstrdup (name) : NULL;
acl->locus = *locus;
- acl->list = gl_list_create_empty(&gl_linked_list_implementation,
- NULL,
- NULL,
- NULL,
- false);
+ acl->list = grecs_list_create ();
return acl;
}
+void
+pies_acl_free (pies_acl_t acl)
+{
+ free (acl->name);
+ grecs_list_free (acl->list);
+ free (acl);
+}
+
static struct pies_sockaddr *
create_acl_sockaddr (int family, int len)
{
struct pies_sockaddr *p = xzalloc (sizeof (*p));
p->salen = len;
p->sa.sa_family = family;
@@ -186,60 +189,55 @@ _parse_sockaddr (struct acl_entry *entry, const grecs_value_t *value)
return 1;
}
}
else
sptr->netmask = 0xfffffffful;
}
- gl_list_add_last (entry->sockaddrs, sptr);
+ grecs_list_append (entry->sockaddrs, sptr);
return 0;
}
static int
-_parse_from (struct acl_entry *entry, size_t argc, const grecs_value_t *argv)
+_parse_from (struct acl_entry *entry, size_t argc, grecs_value_t **argv)
{
if (argc == 0)
return 0;
- else if (argv->type == GRECS_TYPE_LIST)
+ else if (argv[0]->type == GRECS_TYPE_LIST)
{
grecs_error (&entry->locus, 0, _("expected `from', but found list"));
return 1;
}
- else if (strcmp (argv->v.string, "from"))
+ else if (strcmp (argv[0]->v.string, "from"))
{
grecs_error (&entry->locus, 0, _("expected `from', but found `%s'"),
- argv->v.string);
+ argv[0]->v.string);
return 1;
}
argc--;
argv++;
if (argc == 0)
{
grecs_error (&entry->locus, 0,
_("unexpected end of statement after `from'"));
return 1;
}
- entry->sockaddrs = gl_list_create_empty(&gl_linked_list_implementation,
- NULL,
- NULL,
- NULL,
- false);
- if (argv->type == GRECS_TYPE_STRING)
+ entry->sockaddrs = grecs_list_create ();
+ if (argv[0]->type == GRECS_TYPE_STRING)
{
- if (_parse_sockaddr (entry, argv))
+ if (_parse_sockaddr (entry, argv[0]))
return 1;
}
else
{
- gl_list_iterator_t itr = gl_list_iterator (argv->v.list);
- const void *p;
int rc = 0;
- while (gl_list_iterator_next (&itr, &p, NULL))
- rc += _parse_sockaddr (entry, (const grecs_value_t*) p);
- gl_list_iterator_free (&itr);
+ struct grecs_list_entry *ep;
+
+ for (ep = argv[0]->v.list->head; ep; ep = ep->next)
+ rc += _parse_sockaddr (entry, (const grecs_value_t*) ep->data);
if (rc)
return rc;
}
if (argc - 1)
{
@@ -247,84 +245,80 @@ _parse_from (struct acl_entry *entry, size_t argc, const grecs_value_t *argv)
return 1;
}
return 0;
}
static int
-_parse_sub_acl (struct acl_entry *entry, size_t argc, grecs_value_t *argv)
+_parse_sub_acl (struct acl_entry *entry, size_t argc, grecs_value_t **argv)
{
if (argc == 0)
return 0;
- if (strcmp (argv->v.string, "acl") == 0)
+ if (strcmp (argv[0]->v.string, "acl") == 0)
{
argc--;
argv++;
if (argc == 0)
{
grecs_error (&entry->locus, 0,
_("expected ACL name, but found end of statement"));
return 1;
}
- if (argv->type != GRECS_TYPE_STRING)
+ if (argv[0]->type != GRECS_TYPE_STRING)
{
grecs_error (&entry->locus, 0,
_("expected string, but found list"));
return 1;
}
- entry->acl = pies_acl_lookup (argv->v.string);
+ entry->acl = pies_acl_lookup (argv[0]->v.string);
if (!entry->acl)
{
grecs_error (&entry->locus, 0, _("ACL not defined: `%s'"),
- argv->v.string);
+ argv[0]->v.string);
return 1;
}
argc--;
argv++;
}
return _parse_from (entry, argc, argv);
}
static int
-_parse_group (struct acl_entry *entry, size_t argc, grecs_value_t * argv)
+_parse_group (struct acl_entry *entry, size_t argc, grecs_value_t **argv)
{
- if (strcmp (argv->v.string, "group") == 0)
+ if (strcmp (argv[0]->v.string, "group") == 0)
{
argc--;
argv++;
if (argc == 0)
{
grecs_error (&entry->locus, 0,
_("expected group list, but found end of statement"));
return 1;
}
- if (argv->type == GRECS_TYPE_STRING)
+ if (argv[0]->type == GRECS_TYPE_STRING)
{
- entry->groups = gl_list_create_empty(&gl_linked_list_implementation,
- NULL,
- NULL,
- NULL,
- false);
- gl_list_add_last (entry->groups, (void *) argv->v.string);
+ entry->groups = grecs_list_create ();
+ grecs_list_append (entry->groups, xstrdup (argv[0]->v.string));
}
else
- entry->groups = argv->v.list;
+ entry->groups = argv[0]->v.list;
argc--;
argv++;
}
return _parse_sub_acl (entry, argc, argv);
}
static int
-_parse_acl (struct acl_entry *entry, size_t argc, grecs_value_t *argv)
+_parse_acl (struct acl_entry *entry, size_t argc, grecs_value_t **argv)
{
- if (assert_grecs_value_type (&entry->locus, argv, GRECS_TYPE_STRING))
+ if (assert_grecs_value_type (&entry->locus, argv[0], GRECS_TYPE_STRING))
return 1;
- else if (_parse_token (entry, argv) == 0)
+ else if (_parse_token (entry, argv[0]) == 0)
return _parse_sub_acl (entry, argc - 1, argv + 1);
else
return _parse_group (entry, argc, argv);
}
int
@@ -353,13 +347,13 @@ parse_acl_line (grecs_locus_t *locus, int allow, pies_acl_t acl,
break;
case GRECS_TYPE_LIST:
grecs_error (locus, 0, _("unexpected list"));
return 1;
}
- gl_list_add_last (acl->list, entry);
+ grecs_list_append (acl->list, entry);
return 0;
}
#define ACL_TAG_NONE 0
#define ACL_TAG_IGNORE 1
#define ACL_TAG_OPTIONAL 2
@@ -370,13 +364,12 @@ _acl_common_section_parser (enum grecs_callback_command cmd,
grecs_locus_t *locus,
grecs_value_t *value,
pies_acl_t *pacl,
int flag)
{
pies_acl_t acl;
- grecs_locus_t defn_loc;
const char *tag = NULL;
int has_value = 0;
switch (cmd)
{
case grecs_callback_section_begin:
@@ -409,21 +402,14 @@ _acl_common_section_parser (enum grecs_callback_command cmd,
else if (flag == ACL_TAG_REQUIRED)
{
grecs_error (locus, 0, _("missing ACL name"));
return 1;
}
acl = pies_acl_create (tag, locus);
- if (tag && pies_acl_install (acl, &defn_loc))
- {
- grecs_error (locus, 0,
- _("redefinition of ACL %s"),
- value->v.string);
- grecs_error (&defn_loc, 0,
- _("location of the previous definition"));
+ if (tag && (acl = pies_acl_install (acl)) == NULL)
return 1;
- }
if (pacl)
*pacl = acl;
break;
case grecs_callback_section_end:
case grecs_callback_set_value:
@@ -567,47 +553,45 @@ _acl_check (struct acl_entry *ent, struct acl_input *input)
if (!result)
return result;
}
if (ent->groups)
{
- const void *p;
- gl_list_iterator_t itr = gl_list_iterator (ent->groups);
- while (result && gl_list_iterator_next (&itr, &p, NULL))
- result = match_group (input->groups, p);
- gl_list_iterator_free (&itr);
+ struct grecs_list_entry *ep;
+
+ for (ep = ent->groups->head; result && ep; ep = ep->next)
+ result = match_group (input->groups, ep->data);
if (!result)
return result;
}
result = pies_acl_check (ent->acl, input, 1);
if (!result)
return result;
if (ent->sockaddrs)
{
- const void *p;
- gl_list_iterator_t itr = gl_list_iterator (ent->sockaddrs);
+ struct grecs_list_entry *ep;
+
result = 0;
- while (gl_list_iterator_next (&itr, &p, NULL))
+ for (ep = ent->sockaddrs->head; ep; ep = ep->next)
{
- result = _check_sockaddr ((struct pies_sockaddr *)p, input);
+ result = _check_sockaddr ((struct pies_sockaddr *)ep->data, input);
if (result)
break;
}
- gl_list_iterator_free (&itr);
}
return result;
}
static int
_acl_check_cb (struct acl_entry *ent, struct acl_input *input, int *pres)
{
int result = _acl_check (ent, input);
- debug (1, ("%s:%d: %s", ent->locus.file, ent->locus.line,
+ debug (1, ("%s:%d: %s", ent->locus.beg.file, ent->locus.beg.line,
/* TRANSLATORS: `MATCHES' is the verb `match' in 2nd person.
E.g., in French: CONCORD AVEC */
result ? _("MATCHES") : _("does not match")));
if (result)
{
@@ -619,67 +603,101 @@ _acl_check_cb (struct acl_entry *ent, struct acl_input *input, int *pres)
int
pies_acl_check (pies_acl_t acl, struct acl_input *input, int result)
{
if (acl)
{
- const void *p;
- gl_list_iterator_t itr = gl_list_iterator (acl->list);
- while (gl_list_iterator_next (&itr, &p, NULL)
- && !_acl_check_cb ((struct acl_entry *)p, input, &result))
- ;
- gl_list_iterator_free (&itr);
+ struct grecs_list_entry *ep;
+
+ for (ep = acl->list->head; ep; ep = ep->next)
+ if (_acl_check_cb ((struct acl_entry *)ep->data, input, &result))
+ break;
}
return result;
}
/* Hash table */
-static Hash_table *acl_table;
+static struct grecs_symtab *acl_table;
/* Calculate the hash of a string. */
-static size_t
-acl_hasher (void const *data, size_t n_buckets)
+static unsigned
+acl_hasher (void *data, unsigned long n_buckets)
{
const struct pies_acl *p = data;
- return hash_string (p->name, n_buckets);
+ return grecs_hash_string (p->name, n_buckets);
}
/* Compare two strings for equality. */
-static bool
+static int
acl_compare (void const *data1, void const *data2)
{
const struct pies_acl *p1 = data1;
const struct pies_acl *p2 = data2;
- return strcasecmp (p1->name, p2->name) == 0;
+ return strcasecmp (p1->name, p2->name);
}
-int
-pies_acl_install (pies_acl_t acl, grecs_locus_t * locus)
+static int
+acl_copy (void *a, void *b)
+{
+ const struct pies_acl *pb = b;
+
+ memcpy (a, b, sizeof (struct pies_acl));
+ memset (b, 0, sizeof (struct pies_acl));
+ return 0;
+}
+
+static void
+acl_free_entry (void *p)
+{
+ pies_acl_free (p);
+}
+
+pies_acl_t
+pies_acl_install (pies_acl_t acl)
{
pies_acl_t ret;
- if (!((acl_table
- || (acl_table = hash_initialize (0, 0,
+ int install = 1;
+
+ if (!acl_table)
+ {
+ acl_table = grecs_symtab_create(sizeof (struct pies_acl),
acl_hasher,
- acl_compare, 0)))
- && (ret = hash_insert (acl_table, acl))))
+ acl_compare,
+ acl_copy,
+ NULL,
+ acl_free_entry);
+ if (!acl_table)
xalloc_die ();
+ }
+
+ ret = grecs_symtab_lookup_or_install (acl_table, acl, &install);
- if (ret != acl)
+ if (!ret)
{
- if (locus)
- *locus = ret->locus;
- return 1;
+ logmsg (LOG_ERR, _("cannot install acl: %s"), strerror (errno));
+ exit (1);
}
- return 0;
+
+ if (!install)
+ {
+ grecs_error (&acl->locus, 0,
+ _("redefinition of ACL %s"),
+ ret->name);
+ grecs_error (&ret->locus, 0,
+ _("location of the previous definition"));
+ ret = NULL;
+ }
+ pies_acl_free (acl);
+ return ret;
}
pies_acl_t
pies_acl_lookup (const char *name)
{
struct pies_acl samp;
if (!acl_table)
return NULL;
samp.name = (char *) name;
- return hash_lookup (acl_table, &samp);
+ return grecs_symtab_lookup_or_install (acl_table, &samp, NULL);
}
diff --git a/src/acl.h b/src/acl.h
index 65dcf40..c8e4d07 100644
--- a/src/acl.h
+++ b/src/acl.h
@@ -1,8 +1,8 @@
/* This file is part of GNU Pies
- Copyright (C) 2009, 2010 Sergey Poznyakoff
+ Copyright (C) 2009, 2010, 2011 Sergey Poznyakoff
GNU 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.
@@ -27,13 +27,13 @@ struct acl_input
pies_acl_t pies_acl_create (const char *name, grecs_locus_t *locus);
int pies_acl_check (pies_acl_t acl, struct acl_input *input, int result);
int parse_acl_line (grecs_locus_t *locus, int allow, pies_acl_t acl,
grecs_value_t *value);
pies_acl_t pies_acl_lookup (const char *name);
-int pies_acl_install (pies_acl_t acl, grecs_locus_t * locus);
+pies_acl_t pies_acl_install (pies_acl_t acl);
int assert_grecs_value_type (grecs_locus_t *locus,
const grecs_value_t *value, int type);
extern struct grecs_keyword acl_keywords[];
extern int acl_section_parser (enum grecs_callback_command cmd,
diff --git a/src/cmdline.opt b/src/cmdline.opt
new file mode 100644
index 0000000..31fcf20
--- /dev/null
+++ b/src/cmdline.opt
@@ -0,0 +1,193 @@
+/* This file is part of GNU Pies. -*- c -*-
+ Copyright (C) 2008, 2009, 2010, 2011 Sergey Poznyakoff
+
+ GNU 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.
+
+ GNU 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 GNU Pies. If not, see <http://www.gnu.org/licenses/>. */
+
+OPTIONS_BEGIN("pies",
+ [<process invocation and execution supervisor>],
+ [<>],
+ [<gnu>],
+ [<copyright_year=2011>],
+ [<copyright_holder=Sergey Poznyakoff>])
+
+GROUP(Operation Mode)
+
+OPTION(config-file,c,FILE,
+ [<use FILE instead of the default configuration>])
+BEGIN
+ add_config (current_syntax, optarg);
+END
+
+OPTION(config-help,,,
+ [<show configuration file summary>])
+BEGIN
+ config_help ();
+ exit (0);
+END
+
+OPTION(,E,,
+ [<preprocess config and exit>])
+BEGIN
+ preprocess_only = 1;
+END
+
+OPTION(force,,,
+ [<force startup even if another instance may be running>])
+BEGIN
+ force_option = 1;
+END
+
+OPTION(foreground,,,
+ [<remain in foreground>])
+BEGIN
+ log_to_stderr_only = 1;
+ foreground = 1;
+END
+
+OPTION(inetd,i,,
+ [<run in inetd mode>])
+BEGIN
+ if (!instance)
+ instance = "inetd";
+ current_syntax = CONF_INETD;
+ inetd_mode = 1;
+END
+
+OPTION(instance,,NAME,
+ [<set instance name>])
+BEGIN
+ instance = optarg;
+END
+
+OPTION(rate,,NUMBER,
+ [<set default maximum rate for inetd-style components>])
+BEGIN
+ char *p;
+ default_max_rate = strtoul (optarg, &p, 10);
+ if (*p)
+ {
+ logmsg (LOG_ERR, _("not a number: %s"), optarg);
+ exit (EX_USAGE);
+ }
+END
+
+OPTION(stderr,,,
+ [<log to stderr>])
+BEGIN
+ log_to_stderr_only = 1;
+END
+
+OPTION(syntax,,[<{pies|inetd|meta1}>],
+ [<expect configuration files in the given syntax>])
+BEGIN
+ if (str_to_config_syntax (optarg, &current_syntax))
+ {
+ logmsg (LOG_ERR, _("unknown syntax type: %s"), optarg);
+ exit (EX_USAGE);
+ }
+END
+
+OPTION(syslog,,,
+ [<log to syslog>])
+BEGIN
+ log_to_stderr_only = 0;
+END
+
+OPTION(lint,t,,
+ [<parse configuration file and exit>])
+BEGIN
+ log_to_stderr_only = 1;
+ lint_mode = 1;
+END
+
+GROUP(Preprocessor)
+
+OPTION(define,D,[<NAME[=VALUE]>],
+ [<define a preprocessor symbol NAME as having VALUE or empty>])
+BEGIN
+ add_pp_option ("-D", optarg);
+END
+
+OPTION(undefine,U,NAME,
+ [<undefine a preprocessor symbol NAME>])
+BEGIN
+ add_pp_option ("-U", optarg);
+END
+
+GROUP(Component Management)
+
+OPTION(reload,r,,
+ [<reload the running instance of pies>])
+ALIAS(hup)
+BEGIN
+ log_to_stderr_only = 1;
+ command = COM_RELOAD;
+END
+
+OPTION(restart-component,R,,
+ [<restart components named in the command line>])
+BEGIN
+ log_to_stderr_only = 1;
+ command = COM_RESTART;
+END
+
+OPTION(status,s,,
+ [<display info about the running instance>])
+BEGIN
+ log_to_stderr_only = 1;
+ command = COM_STATUS;
+END
+
+OPTION(stop,S,,
+ [<stop the running instance>])
+BEGIN
+ log_to_stderr_only = 1;
+ command = COM_STOP;
+END
+
+GROUP(Debugging and Additional Diagnostics)
+
+OPTION(dump-depmap,,,
+ [<dump dependency map>])
+BEGIN
+ log_to_stderr_only = 1;
+ command = COM_DUMP_DEPMAP;
+END
+
+OPTION(dump-prereq,,,
+ [<dump prerequisite charts>])