fail if sources are not regular files
authormarc <devnull@localhost>
Mon, 18 May 1998 15:16:16 +0000 (15:16 +0000)
committermarc <devnull@localhost>
Mon, 18 May 1998 15:16:16 +0000 (15:16 +0000)
CVS patchset: 2118
CVS date: 1998/05/18 15:16:16

CHANGES
build/parseSpec.c

diff --git a/CHANGES b/CHANGES
index aa3e8e3..a57154d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2.5 -> 2.5.1:
+       - fail if sources are not regular files
+
 2.4.109 -> 2.5:
        - fixed return code bug in build code
        - do macro expansion before %if processing
index ab197a7..2a6a23d 100644 (file)
@@ -2,6 +2,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/stat.h>
 
 #include "header.h"
 #include "rpmlib.h"
@@ -11,6 +12,7 @@
 #include "read.h"
 #include "misc.h"
 
+static int checkSources(Spec spec);
 static void setStandardMacros(Spec spec, char *arch, char *os);
 
 int parseSpec(Spec *specp, char *specFile, char *buildRoot,
@@ -158,9 +160,52 @@ int parseSpec(Spec *specp, char *specFile, char *buildRoot,
 
     closeSpec(spec);
     *specp = spec;
+
+    if (checkSources(spec)) {
+       freeSpec(spec);
+       return 1;
+    }
+
     return 0;
 }
 
+static int checkSources(Spec spec)
+{
+    struct Source *p;
+    Package pkg;
+    char buf[BUFSIZ];
+    struct stat sb;
+    int res = 0;
+    
+    p = spec->sources;
+    while (p) {
+       sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), p->source);
+       lstat(buf, &sb);
+       if (! S_ISREG(sb.st_mode)) {
+           rpmError(RPMERR_BADSPEC, "Source file not regular: %s", buf);
+           res = 1;
+       }
+       p = p->next;
+    }
+
+    pkg = spec->packages;
+    while (pkg) {
+       p = pkg->icon;
+       while (p) {
+           sprintf(buf, "%s/%s", rpmGetVar(RPMVAR_SOURCEDIR), p->source);
+           lstat(buf, &sb);
+           if (! S_ISREG(sb.st_mode)) {
+               rpmError(RPMERR_BADSPEC, "Source file not regular: %s", buf);
+               res = 1;
+           }
+           p = p->next;
+       }
+       pkg = pkg->next;
+    }
+
+    return res;
+}
+
 static void setStandardMacros(Spec spec, char *arch, char *os)
 {
     char buf[BUFSIZ];