#include <archive_entry.h>
#include <pakfire/archive.h>
+#include <pakfire/fhs.h>
#include <pakfire/file.h>
#include <pakfire/linter.h>
#include <pakfire/logging.h>
return 0;
}
+static int pakfire_linter_lint_fhs(
+ struct pakfire_linter* linter, struct pakfire_file* file) {
+ int r;
+
+ // Checking against FHS
+ r = pakfire_fhs_check_file(linter->ctx, file);
+ if (r < 0)
+ return r;
+
+ const char* path = pakfire_file_get_path(file);
+
+ // File must not exist
+ if (r & PAKFIRE_FHS_MUSTNOTEXIST) {
+ r = pakfire_linter_error(linter, "FHS: %s must not exist", path);
+ if (r < 0)
+ return r;
+ }
+
+ if (r & PAKFIRE_FHS_UNAME_MISMATCH) {
+ r = pakfire_linter_error(linter, "FHS: Invalid user for %s", path);
+ if (r < 0)
+ return r;
+ }
+
+ if (r & PAKFIRE_FHS_GNAME_MISMATCH) {
+ r = pakfire_linter_error(linter, "FHS: Invalid group for %s", path);
+ if (r < 0)
+ return r;
+ }
+
+ if (r & PAKFIRE_FHS_PERMS_MISMATCH) {
+ r = pakfire_linter_error(linter, "FHS: Invalid permissions for %s", path);
+ if (r < 0)
+ return r;
+ }
+
+ if (r & PAKFIRE_FHS_WORLDWRITABLE) {
+ r = pakfire_linter_error(linter, "FHS: %s is world-writable", path);
+ if (r < 0)
+ return r;
+ }
+
+ if (r & PAKFIRE_FHS_NOEXEC) {
+ r = pakfire_linter_error(linter, "FHS: %s is executable", path);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
static int pakfire_linter_payload(struct pakfire_archive* archive,
struct archive* a, struct archive_entry* e, void* data) {
struct pakfire_linter* linter = data;
CTX_DEBUG(linter->ctx, "Linting %s...\n", pakfire_file_get_path(file));
+ if (!pakfire_package_is_source(linter->pkg)) {
+ // Checking against FHS
+ r = pakfire_linter_lint_fhs(linter, file);
+ if (r < 0)
+ goto ERROR;
+ }
+
ERROR:
if (file)
pakfire_file_unref(file);