]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-maintd: reduce noise in logging if the log file cannot be created
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 27 Oct 2022 09:26:41 +0000 (11:26 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 27 Oct 2022 09:26:41 +0000 (11:26 +0200)
While here add a unit test

src/mlmmj-maintd.c
tests/mlmmj-maintd.sh

index 3509468f2e6b83d49b70a0a430075a0a7f6ff023..454a959458984ab4c9222f3f95f27819bffe5af1 100644 (file)
@@ -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;
        }
index 9133dd07fc821315849593b899d50d2b360b69b9..2d73a006f029bc71af68fd0afd05d15883e214cc 100755 (executable)
@@ -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