complain if spec file is not a regular file
authorroot <devnull@localhost>
Tue, 20 Aug 1996 14:29:41 +0000 (14:29 +0000)
committerroot <devnull@localhost>
Tue, 20 Aug 1996 14:29:41 +0000 (14:29 +0000)
CVS patchset: 970
CVS date: 1996/08/20 14:29:41

rpm.c

diff --git a/rpm.c b/rpm.c
index fea8946..d089e89 100755 (executable)
--- a/rpm.c
+++ b/rpm.c
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <sys/stat.h>
 
 #include "install.h"
 #include "lib/rpmerr.h"
@@ -210,6 +211,7 @@ int build(char *arg, int buildAmount, char *passPhrase,
     Spec s;
     char * specfile;
     int res = 0;
+    struct stat statbuf;
 
     if (arg[0] == '/') {
        specfile = arg;
@@ -221,6 +223,12 @@ int build(char *arg, int buildAmount, char *passPhrase,
        strcat(specfile, arg);
     }
 
+    stat(specfile, &statbuf);
+    if (! S_ISREG(statbuf.st_mode)) {
+       error(RPMERR_BADSPEC, "File is not a regular file: %s\n", specfile);
+       return 1;
+    }
+    
     if (!(f = fopen(specfile, "r"))) {
        fprintf(stderr, _("unable to open: %s\n"), specfile);
        return 1;