Detect and error out non-directory being specified as one in spec
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 25 Apr 2013 07:07:41 +0000 (10:07 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 7 Jun 2013 09:25:16 +0000 (12:25 +0300)
- Previously rpmbuild silently ignored %dir (and trailing slash)
  on eg regular files and symlinks and just packaged whatever was
  on disk. If the packager specifies something as a directory, ensure
  it actually is one and error out otherwise to guard against eg
  upstream unexpectly changing a directory to something else.
(cherry picked from commit f9f74db13e3bd94debcd7c33194e27649e5adfca)

build/files.c

index 90c8b70..bb00476 100644 (file)
@@ -1358,6 +1358,12 @@ static rpmRC addFile(FileList fl, const char * diskPath,
        }
     }
 
+    /* Error out when a non-directory is specified as one in spec */
+    if (fl->cur.isDir && !S_ISDIR(statp->st_mode)) {
+       rpmlog(RPMLOG_ERR, _("Not a directory: %s\n"), diskPath);
+       goto exit;
+    }
+
     /* Don't recurse into explicit %dir, don't double-recurse from fts */
     if ((fl->cur.isDir != 1) && (statp == &statbuf) && S_ISDIR(statp->st_mode)) {
        return recurseDir(fl, diskPath);