From: Baptiste Daroussin Date: Thu, 27 Oct 2022 09:26:41 +0000 (+0200) Subject: mlmmj-maintd: reduce noise in logging if the log file cannot be created X-Git-Tag: RELEASE_1_4_0a1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e412bd29cb636d43258692a2fb36e62d04c1f9c0;p=thirdparty%2Fmlmmj.git mlmmj-maintd: reduce noise in logging if the log file cannot be created While here add a unit test --- diff --git a/src/mlmmj-maintd.c b/src/mlmmj-maintd.c index 3509468f..454a9594 100644 --- a/src/mlmmj-maintd.c +++ b/src/mlmmj-maintd.c @@ -781,7 +781,7 @@ void do_maintenance(int listfd, const char *listdir, const char *mlmmjsend, logfd = openat(listfd, logname, O_WRONLY|O_EXCL|O_CREAT, S_IRUSR|S_IWUSR); if(logfd == -1) { - log_error(LOG_ARGS, "Could not open %s", logname); + log_err("Could not open %s: %s", logname, strerror(errno)); free(logname); return; } diff --git a/tests/mlmmj-maintd.sh b/tests/mlmmj-maintd.sh index 9133dd07..2d73a006 100755 --- a/tests/mlmmj-maintd.sh +++ b/tests/mlmmj-maintd.sh @@ -74,6 +74,9 @@ basics_body() atf_check -s exit:0 -o "inline:$helptxt" $mlmmjmaintd -h echo test@mlmmjtest > lists/ml/control/listaddress atf_check -s exit:1 -e match:"Could not open the directory containing mailing lists.*: No such file or directory" $mlmmjmaintd -F -d nonexisting + chmod -w lists/ml + atf_check -s exit:0 -e match:"Could not open maintdlog.* Permission denied" $mlmmjmaintd -F -L lists/ml + chmod +w lists/ml atf_check -s exit:0 $mlmmjmaintd -L lists/ml -F output="Starting maintenance run at