]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
- fix build issues on Linux/Hurd 386 65/head
authorErwan MAS <erwan@mas.nom.fr>
Fri, 30 May 2025 17:40:33 +0000 (13:40 -0400)
committerErwan MAS <erwan@mas.nom.fr>
Fri, 30 May 2025 17:40:33 +0000 (13:40 -0400)
 - unit test tests/mlmmj:smtp was incorrect because write_dot send 2 lines

src/mlmmj-list.c
src/mlmmj-maintd.c
src/mlmmj-send.c
src/mlmmj.c
src/send_list.c
src/subscriberfuncs.c
tests/mlmmj.c

index e2a76845f703efd44bf2a0416a54c2a997c32cb9..eca2ec9eed2aa16acbfc94325e03a57855b6aa03 100644 (file)
@@ -28,6 +28,7 @@
 #include <dirent.h>
 #include <string.h>
 #include <err.h>
+#include <sys/stat.h>
 
 #include "mlmmj.h"
 #include "chomp.h"
@@ -54,11 +55,18 @@ dumpcount(int fd, size_t *count)
        FILE *f;
        char *line = NULL;
        size_t linecap = 0;
+       struct stat fst;
 
        f = fdopen(fd, "r");
        if (f == NULL)
                return (-1);
 
+       if (fstat(fd, &fst) == 0) {
+               if (S_ISDIR(fst.st_mode)) {
+                       return(-1);
+               }
+       }
+
        while (getline(&line, &linecap, f) > 0) {
                chomp(line);
                if (count)
index 96d146939360f71f39ee73f018901fcf44693084..62317a0b385432c72ab61787dd0e11284a9095be 100644 (file)
@@ -50,7 +50,7 @@
 #define log(...) dprintf(logfd, __VA_ARGS__);
 #define opendirat(_dirfd, _fd, _dirent, _path) \
        do { \
-               _fd = openat(_dirfd, _path, O_DIRECTORY|O_CLOEXEC); \
+               _fd = openat(_dirfd, _path, O_DIRECTORY|O_CLOEXEC|O_RDONLY); \
                if (_fd == -1 || (_dirent = fdopendir(_fd)) == NULL) { \
                        log(" - Could not open '%s': %s\n", _path, \
                            strerror(errno)); \
@@ -792,7 +792,7 @@ int main(int argc, char **argv)
                        goto mainsleep;
                }
 
-               int dfd = open(dirlists, O_DIRECTORY);
+               int dfd = open(dirlists, O_DIRECTORY|O_RDONLY);
                if (dfd == -1 || (dirp = fdopendir(dfd)) == NULL) {
                        log_err("Could not open the directory containing "
                            "mailing lists (%s): %s", dirlists,
index e8a1007b0cd09723cd0d7809aa44c792bddfd44a..3aa4ccf8bd14866a759eadec0f41d752fc6de0f3 100644 (file)
@@ -485,7 +485,7 @@ int main(int argc, char **argv)
                } else {
                        subddirname = "digesters.d";
                }
-               subdirfd = openat(ml.fd, subddirname, O_DIRECTORY|O_CLOEXEC);
+               subdirfd = openat(ml.fd, subddirname, O_DIRECTORY|O_CLOEXEC|O_RDONLY);
                if (subdirfd == -1 || (subddir = fdopendir(subdirfd)) == NULL) {
                        log_error(LOG_ARGS, "Could not opendir(%s/%s)", ml.dir,
                                            subddirname);
index aa2cc275bef9c894e6d12853fd3e1d214a258e72..eb158c60fa9faa25639615fb55cc55f1ea3139b3 100644 (file)
@@ -272,7 +272,7 @@ open_subscriber_directory(int listfd, enum subtype typesub, const char **subdir)
                *subdir = dir;
        if (dir == NULL)
                return (-1);
-       return (openat(listfd, dir, O_DIRECTORY|O_CLOEXEC));
+       return (openat(listfd, dir, O_DIRECTORY|O_CLOEXEC|O_RDONLY));
 }
 
 bool
index 6b39f0eabc65a2e92d36d143a2cc52b6dca64808..ababcd8647273f1d85284d3699b9f00dee9b304b 100644 (file)
@@ -68,7 +68,7 @@ void rewind_subs_list(void *state)
        struct subs_list_state *s = (struct subs_list_state *)state;
        if (s == NULL) return;
        if (s->dirp != NULL) closedir(s->dirp);
-       s->dfd = openat(s->listfd, s->dirname, O_DIRECTORY|O_CLOEXEC);
+       s->dfd = openat(s->listfd, s->dirname, O_DIRECTORY|O_CLOEXEC|O_RDONLY);
        if (s->dfd == -1 || (s->dirp = fdopendir(s->dfd)) == NULL)
                log_error(LOG_ARGS, "Could not opendir(%s);\n", s->dirname);
        s->used = true;
index 60b9cd6d5d65878a0fe494094cef582a22c5f738..8b9072aeb5be2b62b8ce7e1337a8ca20a1e6669a 100644 (file)
@@ -136,19 +136,19 @@ is_subbed(int listfd, const char *address, bool both)
        enum subtype typesub = SUB_NONE;
        int fd;
 
-       fd = openat(listfd, "subscribers.d", O_DIRECTORY);
+       fd = openat(listfd, "subscribers.d", O_DIRECTORY|O_RDONLY);
        if (fd != -1 && is_subbed_in(fd, "subscribers.d", address)) {
                if (!both) return SUB_NORMAL;
                typesub = SUB_NORMAL;
        }
 
-       fd = openat(listfd, "digesters.d", O_DIRECTORY);
+       fd = openat(listfd, "digesters.d", O_DIRECTORY|O_RDONLY);
        if (fd != -1 && is_subbed_in(fd, "digesters.d", address)) {
                if (typesub == SUB_NORMAL) return SUB_BOTH;
                return SUB_DIGEST;
        }
 
-       fd = openat(listfd, "nomailsubs.d", O_DIRECTORY);
+       fd = openat(listfd, "nomailsubs.d", O_DIRECTORY|O_RDONLY);
        if (fd != -1 && is_subbed_in(fd, "nomailsubs.d", address))
                return SUB_NOMAIL;
 
index 0444f2f5fa98e2633b6ef19a9d9774823e00e635..1cb59bf0f4d31bfeefb5af09f422c079e1a2b0ac 100644 (file)
@@ -956,6 +956,7 @@ ATF_TC_BODY(smtp, tc)
                    "250 2.1.0 Ok\n", /* MAIL FROM */
                    "250 2.1.0 Ok\n", /* RCPT TO */
                    "354 Send message content; end with <CRLF>.<CRLF>\n", /* DATA */
+                   NULL, /* BEFORE DOT */
                    "250 2.1.0 Ok\n", /* DATA */
                    "221 2.0.0 Bye\n", /* QUIT */
                    "250 2.0.0 Ok\n", /* RSET */
@@ -963,7 +964,9 @@ ATF_TC_BODY(smtp, tc)
                dprintf(smtppipe[0], "220 me fake smtp\n");
                for (uint8_t i = 0; i < NELEM(replies); i++) {
                        atf_utils_readline(smtppipe[0]);
-                       dprintf(smtppipe[0], "%s", replies[i]);
+                       if ( replies[i] != NULL ) {
+                               dprintf(smtppipe[0], "%s", replies[i]);
+                       }
                }
                exit (0);
        }