if (r < 0)
goto ERROR;
}
+
+ // Invalid capabilities
+ if (file->issues & PAKFIRE_FILE_INVALID_CAPS) {
+ r = asprintf(&buffer, "%s [INVALID-CAPS]", buffer);
+ if (r < 0)
+ goto ERROR;
+ }
}
return buffer;
file->st.st_mode |= ~S_IFMT & perms;
}
+static int pakfire_file_is_executable(struct pakfire_file* file) {
+ return file->st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH);
+}
+
PAKFIRE_EXPORT time_t pakfire_file_get_ctime(struct pakfire_file* file) {
return file->st.st_ctime;
}
return pakfire_file_open_elf(file, __pakfire_file_check_runpath, NULL);
}
+static int pakfire_file_check_capabilities(struct pakfire_file* file) {
+ // Files cannot have capabilities but not be executable
+ if (!pakfire_file_is_executable(file) && pakfire_file_has_caps(file))
+ file->issues |= PAKFIRE_FILE_INVALID_CAPS;
+
+ return 0;
+}
+
+
int pakfire_file_check(struct pakfire_file* file, int* issues) {
int r;
if (r)
file->issues |= PAKFIRE_FILE_FHS_ERROR;
+ // Perform capability check
+ r = pakfire_file_check_capabilities(file);
+ if (r)
+ return r;
+
// Do not perform the following checks on firmware
if (pakfire_file_matches_class(file, PAKFIRE_FILE_FIRMWARE))
goto DONE;
PAKFIRE_FILE_EXECSTACK = (1 << 4),
PAKFIRE_FILE_NO_RELRO = (1 << 5),
PAKFIRE_FILE_HAS_RUNPATH = (1 << 6),
+ PAKFIRE_FILE_INVALID_CAPS = (1 << 7),
};
int pakfire_file_check(struct pakfire_file* file, int* issues);