]> git.ipfire.org Git - people/ms/dma.git/commitdiff
load_queue: use stat(2) instead of de->d_type
authorSimon Schubert <2@0x2c.org>
Mon, 28 Jun 2010 22:48:52 +0000 (00:48 +0200)
committerSimon Schubert <2@0x2c.org>
Mon, 28 Jun 2010 22:50:32 +0000 (00:50 +0200)
Some filesystems (notably XFS) do not set the d_type field in the dirent
structure.  This prevents dma from delivering any of the queued messages.
Rework the code to use stat() instead.

Submitted-by: Peter Pentchev <roam@ringlet.net> (earlier version)
spool.c

diff --git a/spool.c b/spool.c
index c29b628d6782a74d583dd1bfb6beeb4bd75e1cdb..3f5e4b5f327085e11d4006aa06676f822a1109d4 100644 (file)
--- a/spool.c
+++ b/spool.c
@@ -293,9 +293,7 @@ load_queue(struct queue *queue)
                queuefn = NULL;
                mailfn = NULL;
 
-               /* ignore temp files */
-               if (strncmp(de->d_name, "tmp_", 4) == 0 || de->d_type != DT_REG)
-                       continue;
+               /* ignore non-queue files */
                if (de->d_name[0] != 'Q')
                        continue;
                if (asprintf(&queuefn, "%s/Q%s", config.spooldir, de->d_name + 1) < 0)
@@ -303,6 +301,18 @@ load_queue(struct queue *queue)
                if (asprintf(&mailfn, "%s/M%s", config.spooldir, de->d_name + 1) < 0)
                        goto fail;
 
+               /*
+                * Some file systems don't provide a de->d_type, so we have to
+                * do an explicit stat on the queue file.
+                * Move on if it turns out to be something else than a file.
+                */
+               if (stat(queuefn, &sb) != 0)
+                       goto skip_item;
+               if (!S_ISREG(sb.st_mode)) {
+                       errno = EINVAL;
+                       goto skip_item;
+               }
+
                if (stat(mailfn, &sb) != 0)
                        goto skip_item;