[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-301-g8c5a7
From: |
Mats Erik Andersson |
Subject: |
[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-301-g8c5a700 |
Date: |
Thu, 30 May 2013 00:04:51 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".
The branch, master has been updated
via 8c5a7001976fad8e0786691f8ccf45467fbf414e (commit)
via d6dbed51be6650c560c2872711991090fbff3d0b (commit)
from a3508ed9308e61b5998af03b40183725d66fe9b1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=8c5a7001976fad8e0786691f8ccf45467fbf414e
commit 8c5a7001976fad8e0786691f8ccf45467fbf414e
Author: Mats Erik Andersson <address@hidden>
Date: Wed May 29 22:11:05 2013 +0200
tests: Directory loading in syslogd.
diff --git a/ChangeLog b/ChangeLog
index 51f661b..56c6266 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2013-05-29 Mats Erik Andersson <address@hidden>
+ tests: Directory loading in syslogd.
+
+ * tests/syslogd.sh (CONFD): New variable.
+ (IU_OPTIONS): Add directory setting `--rcdir'.
+ <reloaded configuration>: Move directive for
+ severity `debug' to a file in $CONFD.
+
+ * src/syslogd.c (main) <NoDetach>: Mention the
+ process ID when telling about debug signal USR1.
+
+2013-05-29 Mats Erik Andersson <address@hidden>
+
syslogd: Load configuration from directory.
Code suggested by Guillem Jover <address@hidden>
<http://lists.gnu.org/archive/html/bug-inetutils/2009-12/msg00054.html>.
diff --git a/NEWS b/NEWS
index fd76abb..ffa031e 100644
--- a/NEWS
+++ b/NEWS
@@ -60,6 +60,9 @@ Messages can be logged to specific files according to the name
of the submitting program, on the tag attached to the message.
The mechanism is patterned on an established BSD feature.
+Support loading of multiple configuration files located in a
+single directory. New switches `-D/--rcdir'.
+
* telnet
New switch `-k/--realm'.
diff --git a/src/syslogd.c b/src/syslogd.c
index 46e5109..75a5083 100644
--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -681,7 +681,8 @@ main (int argc, char *argv[])
if (NoDetach)
{
dbg_output = 1;
- dbg_printf ("Debugging disabled, send SIGUSR1 to turn on debugging.\n");
+ dbg_printf ("Debugging is disabled. Send SIGUSR1 to PID=%d "
+ "to turn on debugging.\n", (int) getpid ());
dbg_output = 0;
}
diff --git a/tests/syslogd.sh b/tests/syslogd.sh
index 8fb5053..93ad0a1 100755
--- a/tests/syslogd.sh
+++ b/tests/syslogd.sh
@@ -139,13 +139,16 @@ elif expr X"$IU_TESTDIR" : X"\.\{1,2\}/\{0,1\}$"
>/dev/null; then
exit 77
fi
-# The SYSLOG daemon uses four files.
+# The SYSLOG daemon uses four files and one directory.
#
CONF="$IU_TESTDIR"/syslog.conf
+CONFD="$IU_TESTDIR"/syslog.d
PID="$IU_TESTDIR"/syslogd.pid
OUT="$IU_TESTDIR"/messages
: ${SOCKET:=$IU_TESTDIR/log}
+mkdir -p "$CONFD"
+
# Are we able to write in IU_TESTDIR?
# This could happen with preset IU_TESTDIR.
#
@@ -345,7 +348,7 @@ fi
# building the desired option list.
#
## Base configuration.
-IU_OPTIONS="--rcfile='$CONF' --pidfile='$PID'"
+IU_OPTIONS="--rcfile='$CONF' --rcdir='$CONFD' --pidfile='$PID'"
if $do_unix_socket; then
IU_OPTIONS="$IU_OPTIONS --socket='$SOCKET'"
else
@@ -440,6 +443,9 @@ OUT_DEBUG="$IU_TESTDIR"/debug.log
cat > "$CONF" <<-EOT
*.* $OUT
user.info $OUT_USER
+EOT
+
+cat > "$CONFD/debug" <<-EOT
*.=debug $OUT_DEBUG
EOT
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=d6dbed51be6650c560c2872711991090fbff3d0b
commit d6dbed51be6650c560c2872711991090fbff3d0b
Author: Mats Erik Andersson <address@hidden>
Date: Wed May 29 21:56:10 2013 +0200
syslogd: Load configuration from directory.
Based on a patch suggested by Guillem Jover.
diff --git a/ChangeLog b/ChangeLog
index 0d83bea..51f661b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2013-05-29 Mats Erik Andersson <address@hidden>
+ syslogd: Load configuration from directory.
+ Code suggested by Guillem Jover <address@hidden>
+ <http://lists.gnu.org/archive/html/bug-inetutils/2009-12/msg00054.html>.
+ Minor changes with failure tracking.
+
+ * paths (PATH_LOGCONFD): New variable.
+ * src/Makefile.am (AM_CPPFLAGS): Add $(PATHDEF_LOGCONFD).
+ * src/syslogd.c: Include <dirent.h>.
+ (ConfDir): New variable.
+ (argp_options): New option `-D/--rcdir'.
+ (parse_opt) <'D'>: New case.
+ (load_confdir): New function.
+ (init): New variable RET. Call load_confdir(),
+ making sure that failures are reported.
+
+2013-05-29 Mats Erik Andersson <address@hidden>
+
syslogd: Refactor loading of configuration file.
Code outlined by Guillem Jover <address@hidden>
<http://lists.gnu.org/archive/html/bug-inetutils/2009-12/msg00053.html>.
diff --git a/doc/inetutils.texi b/doc/inetutils.texi
index a39e400..13bdbee 100644
--- a/doc/inetutils.texi
+++ b/doc/inetutils.texi
@@ -3274,6 +3274,12 @@ syslogd address@hidden@dots{}
@opindex --rcfile
Override configuration (the default file is @file{/etc/syslog.conf}).
address@hidden -D @var{dir}
address@hidden address@hidden
address@hidden -D
address@hidden --rcdir
+Override configuration directory (the default is @file{/etc/syslog.d}).
+
@item address@hidden
@opindex --pidfile
Override pidfile (the default file is @file{/var/run/syslogd.pid}).
diff --git a/paths b/paths
index 8808b49..70c0f57 100644
--- a/paths
+++ b/paths
@@ -91,6 +91,7 @@ PATH_LASTLOG <utmp.h> $(localstatedir)/log/lastlog
search:lastlog:/var/log:/var/
PATH_LOG <syslog.h> /dev/log
PATH_KLOG <syslog.h> /dev/klog no
PATH_LOGCONF $(sysconfdir)/syslog.conf
+PATH_LOGCONFD $(sysconfdir)/syslog.d
PATH_LOGIN x $(bindir)/login search:login
PATH_LOGPID $(localstatedir)/run/syslog.pid
PATH_NOLOGIN $(sysconfdir)/nologin
diff --git a/src/Makefile.am b/src/Makefile.am
index 8b84d7b..826af4c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,7 +27,7 @@ AM_CPPFLAGS = \
$(PATHDEF_BSHELL) $(PATHDEF_CONSOLE) $(PATHDEF_CP) \
$(PATHDEF_DEFPATH) $(PATHDEF_DEV) $(PATHDEF_INETDCONF) \
$(PATHDEF_INETDDIR) $(PATHDEF_INETDPID) $(PATHDEF_KLOG) \
- $(PATHDEF_LOG) $(PATHDEF_LOGCONF) \
+ $(PATHDEF_LOG) $(PATHDEF_LOGCONF) $(PATHDEF_LOGCONFD) \
$(PATHDEF_LOGIN) $(PATHDEF_LOGPID) $(PATHDEF_NOLOGIN) \
$(PATHDEF_RLOGIN) $(PATHDEF_RSH) $(PATHDEF_TTY) $(PATHDEF_TTY_PFX) \
$(PATHDEF_UTMP) $(PATHDEF_UTMPX) $(PATHDEF_UUCICO)
diff --git a/src/syslogd.c b/src/syslogd.c
index 18a3e41..46e5109 100644
--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -105,6 +105,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <dirent.h>
#include <unistd.h>
#include <stdarg.h>
@@ -137,6 +138,7 @@ int facilities_seen;
char *selector; /* Program origin to select. */
const char *ConfFile = PATH_LOGCONF; /* Default Configuration file. */
+const char *ConfDir = PATH_LOGCONFD; /* Default Configuration directory. */
const char *PidFile = PATH_LOGPID; /* Default path to tuck pid. */
char ctty[] = PATH_CONSOLE; /* Default console to send message info. */
@@ -259,6 +261,7 @@ void domark (int);
void find_inet_port (const char *);
void fprintlog (struct filed *, const char *, int, const char *);
static int load_conffile (const char *, struct filed **);
+static int load_confdir (const char *, struct filed **);
void init (int);
void logerror (const char *);
void logmsg (int, const char *, const char *, int);
@@ -358,6 +361,8 @@ static struct argp_option argp_options[] = {
{"rcfile", 'f', "FILE", 0, "override configuration file (default: "
PATH_LOGCONF ")",
GRP+1},
+ {"rcdir", 'D', "DIR", 0, "override configuration directory (default: "
+ PATH_LOGCONFD ")", GRP+1},
{"socket", 'p', "FILE", 0, "override default unix domain socket " PATH_LOG,
GRP+1},
{"sync", 'S', NULL, 0, "force a file sync on every line", GRP+1},
@@ -449,6 +454,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
ConfFile = arg;
break;
+ case 'D':
+ ConfDir = arg;
+ break;
+
case 'p':
funix[0].name = arg;
funix[0].fd = -1;
@@ -1797,6 +1806,9 @@ die (int signo)
exit (EXIT_SUCCESS);
}
+/*
+ * Return zero on error.
+ */
static int
load_conffile (const char *filename, struct filed **nextp)
{
@@ -1989,11 +2001,62 @@ load_conffile (const char *filename, struct filed
**nextp)
return 1;
}
+/*
+ * Return zero on error.
+ */
+static int
+load_confdir (const char *dirname, struct filed **nextp)
+{
+ int rc = 0, found = 0;
+ struct dirent *dent;
+ DIR *dir;
+
+ dir = opendir (dirname);
+ if (dir == NULL)
+ {
+ dbg_printf ("cannot open %s\n", dirname);
+ return 1; /* Acceptable deviation. */
+ }
+
+ while ((dent = readdir (dir)) != NULL)
+ {
+ struct stat st;
+ char *file;
+
+ if (asprintf (&file, "%s/%s", dirname, dent->d_name) < 0)
+ {
+ dbg_printf ("cannot allocate space for configuration filename\n");
+ return 0;
+ }
+
+ if (stat (file, &st) != 0)
+ {
+ dbg_printf ("cannot stat file configuration file\n");
+ continue;
+ }
+
+
+ if (S_ISREG(st.st_mode))
+ {
+ found++;
+ rc += load_conffile (file, nextp);
+ }
+
+ free (file);
+ }
+
+ closedir (dir);
+
+ /* An empty directory is acceptable.
+ */
+ return (found ? rc : 1);
+}
+
/* INIT -- Initialize syslogd from configuration table. */
void
init (int signo _GL_UNUSED_PARAMETER)
{
- int rc;
+ int rc, ret;
struct filed *f, *next, **nextp;
dbg_printf ("init\n");
@@ -2040,6 +2103,10 @@ init (int signo _GL_UNUSED_PARAMETER)
rc = load_conffile (ConfFile, nextp);
+ ret = load_confdir (ConfDir, nextp);
+ if (!ret)
+ rc = 0; /* Some allocation errors were found. */
+
Initialized = 1;
if (Debug)
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 29 +++++++++++++++++++++
NEWS | 3 ++
doc/inetutils.texi | 6 ++++
paths | 1 +
src/Makefile.am | 2 +-
src/syslogd.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++-
tests/syslogd.sh | 10 ++++++-
7 files changed, 118 insertions(+), 5 deletions(-)
hooks/post-receive
--
GNU Inetutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-301-g8c5a700,
Mats Erik Andersson <=