]> git.ipfire.org Git - pakfire.git/commitdiff
file: Mark files as executable
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Mar 2023 16:51:23 +0000 (16:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 15 Mar 2023 16:52:56 +0000 (16:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/file.c
src/libpakfire/include/pakfire/file.h

index a3b1dc5b32f11f607e157de3f3aa9713092c9264..a5110880ff665e34608ffcf88a00aa24932ef77c 100644 (file)
@@ -1121,11 +1121,15 @@ static int setup_libelf(struct pakfire* pakfire) {
 
 static int pakfire_file_classify_mode(struct pakfire_file* file) {
        // Check for regular files
-       if (S_ISREG(file->st.st_mode))
+       if (S_ISREG(file->st.st_mode)) {
                file->class |= PAKFIRE_FILE_REGULAR;
 
+               // Does the file have executable permissions?
+               if (file->st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))
+                       file->class |= PAKFIRE_FILE_EXECUTABLE;
+
        // Check for directories
-       else if (S_ISDIR(file->st.st_mode))
+       else if (S_ISDIR(file->st.st_mode))
                file->class |= PAKFIRE_FILE_DIRECTORY;
 
        // Check for symlinks
@@ -1179,8 +1183,6 @@ static const struct mimetype {
        const char* mimetype;
        int class;
 } mimetypes[] = {
-       { "application/x-pie-executable", PAKFIRE_FILE_EXECUTABLE },
-       { "application/x-sharedlibary", PAKFIRE_FILE_EXECUTABLE },
        { "text/x-perl", PAKFIRE_FILE_PERL },
        { NULL, 0 },
 };
index 4fc0b23619bb3f26aec3279a21439a824110ba0e..e2fdecff03c525558f9dc66cc070a0f26c7bef11 100644 (file)
@@ -112,9 +112,11 @@ enum pakfire_file_classes {
        PAKFIRE_FILE_FIFO            = (1 << 5),
        PAKFIRE_FILE_SOCKET          = (1 << 6),
 
+       // Is the file executable?
+       PAKFIRE_FILE_EXECUTABLE      = (1 << 7),
+
        // The rest
-       PAKFIRE_FILE_ELF             = (1 << 7),
-       PAKFIRE_FILE_EXECUTABLE      = (1 << 8),
+       PAKFIRE_FILE_ELF             = (1 << 8),
        PAKFIRE_FILE_PKGCONFIG       = (1 << 9),
        PAKFIRE_FILE_PERL            = (1 << 10),
        PAKFIRE_FILE_STATIC_LIBRARY  = (1 << 11),