#include "util.h"
#undef sun
+#define IGNORE(x) do if (x); while (0)
/*----- Data structures ---------------------------------------------------*/
#define f_noinput 64u
#define f_warn 128u
#define f_uclose 256u
+#define f_losing 512u
/*----- Main code ---------------------------------------------------------*/
if (!p) {
if (f & f_command)
die(EXIT_FAILURE, "server dropped the connection");
+ f &= ~f_losing;
exit(0);
}
q = str_getword(&p);
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) {
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();
}
}
+ f |= f_losing; /* pessimism */
u_setugid(u, g);
+ if (logname)
+ logfile(logname);
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.
--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-wireshark
+ --with-wireshark="/usr/lib/wireshark/libwireshark0/plugins"
###--------------------------------------------------------------------------
### Python.
-/var/log/tripe.log {
+/var/log/tripe/tripe.log {
rotate 7
weekly
compress
--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
+
#DEBHELPER#