Skip to content

Commit

Permalink
mxqd: fail with diagnostic if unable to write to log directory
Browse files Browse the repository at this point in the history
Failures of cronolog are not detected by the current code, because
cronologs own stderr goes to /dev/null.

While there are many reasons, why cronolog mail fail, not being able
to write to the log directory altogether is a very prominent one
which is easy to detect beforehand. This may become even more
relevant when we start to support mxqd being run as non-root.
  • Loading branch information
donald committed Oct 9, 2015
1 parent 61065a9 commit 907f222
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ int server_init(struct mxq_server *server, int argc, char *argv[])
setup_stdin("/dev/null");

if (!arg_nolog) {
if (access("/var/log",R_OK|W_OK|X_OK)) {
mx_log_err("MAIN: cant write to /var/log: %m");
exit(EX_IOERR);
}
res = setup_cronolog("/usr/sbin/cronolog", "/var/log/mxqd_log", "/var/log/%Y/mxqd_log-%Y-%m");
if (!res) {
mx_log_err("MAIN: cronolog setup failed. exiting.");
Expand Down

0 comments on commit 907f222

Please sign in to comment.