From: Michael Tremer Date: Wed, 15 Mar 2023 16:51:23 +0000 (+0000) Subject: file: Mark files as executable X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72a36c9d2b5c9838e83e78cb41ac0cd96aaeeff6;p=people%2Fstevee%2Fpakfire.git file: Mark files as executable Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index a3b1dc5b..a5110880 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -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 }, }; diff --git a/src/libpakfire/include/pakfire/file.h b/src/libpakfire/include/pakfire/file.h index 4fc0b236..e2fdecff 100644 --- a/src/libpakfire/include/pakfire/file.h +++ b/src/libpakfire/include/pakfire/file.h @@ -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),