Previous behaviour: tripectl starts as root, opens logfile, starts tripe
server, drops privileges, logs happily to file, receives signal,
attempts to open new logfile, and fails miserably. It therefore
continues logging to the old logfile, which may well have been deleted
by this point.
New behaviour: fix Debianization to put logs in a /var/log/tripe
directory, and arrange for this to be writable by the tripe user; create
the log file after dropping privileges. If tripectl can't open the log,
it fails, and the tripe server quits due to EOF on stdin.
#include "util.h"
#undef sun
#include "util.h"
#undef sun
+#define IGNORE(x) do if (x); while (0)
/*----- Data structures ---------------------------------------------------*/
/*----- Data structures ---------------------------------------------------*/
#define f_noinput 64u
#define f_warn 128u
#define f_uclose 256u
#define f_noinput 64u
#define f_warn 128u
#define f_uclose 256u
/*----- Main code ---------------------------------------------------------*/
/*----- Main code ---------------------------------------------------------*/
if (!p) {
if (f & f_command)
die(EXIT_FAILURE, "server dropped the connection");
if (!p) {
if (f & f_command)
die(EXIT_FAILURE, "server dropped the connection");
exit(0);
}
q = str_getword(&p);
exit(0);
}
q = str_getword(&p);
die(EXIT_FAILURE, "couldn't set `%s' as current directory: %s",
dir, strerror(errno));
}
die(EXIT_FAILURE, "couldn't set `%s' as current directory: %s",
dir, strerror(errno));
}
- if (logname)
- logfile(logname);
if (!pidfile && (f & f_daemon) && ((f & f_syslog) || logname))
pidfile = "tripectl.pid";
if (pidfile && (pidfp = fopen(pidfile, "w")) == 0) {
if (!pidfile && (f & f_daemon) && ((f & f_syslog) || logname))
pidfile = "tripectl.pid";
if (pidfile && (pidfp = fopen(pidfile, "w")) == 0) {
md[1].cur = pfd[1]; md[1].want = STDOUT_FILENO;
md[2].cur = efd[1]; md[2].want = STDERR_FILENO;
mdup(md, 3);
md[1].cur = pfd[1]; md[1].want = STDOUT_FILENO;
md[2].cur = efd[1]; md[2].want = STDERR_FILENO;
mdup(md, 3);
- if (logfp) fclose(logfp);
if (pidfp) fclose(pidfp);
closelog();
if (f & f_daemon) detachtty();
if (pidfp) fclose(pidfp);
closelog();
if (f & f_daemon) detachtty();
+ f |= f_losing; /* pessimism */
+ if (logname)
+ logfile(logname);
if (f & f_daemon) {
if (daemonize())
die(EXIT_FAILURE, "error becoming daemon: %s", strerror(errno));
if (f & f_daemon) {
if (daemonize())
die(EXIT_FAILURE, "error becoming daemon: %s", strerror(errno));
+tripe (1.0.0pre11~preview) experimental; urgency=low
+
+ * Fix log/permissions foul-up. Move the logs to /var/log/tripe, and
+ arrange for that directory to exist with the correct permissions.
+ Don't try to open the log until after dropping privileges, so as to
+ provide a check that we can reopen them later.
+
+ -- Mark Wooding <mdw@distorted.org.uk> Mon, 27 Jun 2011 09:51:08 +0100
+
tripe (1.0.0pre10) experimental; urgency=low
* Overhaul SLIP error handling.
tripe (1.0.0pre10) experimental; urgency=low
* Overhaul SLIP error handling.
--with-tunnel="$(default_tunnel) slip" \
--with-configdir="/etc/tripe" \
--with-socketdir="/var/run" \
--with-tunnel="$(default_tunnel) slip" \
--with-configdir="/etc/tripe" \
--with-socketdir="/var/run" \
- --with-logfile="/var/log/tripe.log" \
+ --with-logfile="/var/log/tripe/tripe.log" \
--with-pidfile="/var/run/tripectl.pid" \
--with-initconfig="/etc/default/tripe" \
--with-pidfile="/var/run/tripectl.pid" \
--with-initconfig="/etc/default/tripe" \
+ --with-wireshark="/usr/lib/wireshark/libwireshark0/plugins"
###--------------------------------------------------------------------------
### Python.
###--------------------------------------------------------------------------
### Python.
+/var/log/tripe/tripe.log {
--gecos "TrIPE server" \
tripe
--gecos "TrIPE server" \
tripe
+## Create the log directory and an initial logfile.
+if [ ! -d /var/log/tripe ]; then
+ mkdir -m2750 /var/log/tripe
+ chown tripe:adm /var/log/tripe
+fi
+if [ ! -f /var/log/tripe/tripe.log ]; then
+ (umask 027; touch /var/log/tripe/tripe.log)
+ chown tripe:adm /var/log/tripe/tripe.log
+fi
+