/*
Maps the file into memory
*/
-static int pakfire_linter_file_map(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_map(pakfire_linter_file* lfile) {
// Store the length
lfile->length = lseek(lfile->fd, 0, SEEK_END);
if (lfile->length <= 0)
return 0;
}
-static void pakfire_linter_file_free(struct pakfire_linter_file* lfile) {
+static void pakfire_linter_file_free(pakfire_linter_file* lfile) {
int r;
if (lfile->elf)
free(lfile);
}
-int pakfire_linter_file_create(struct pakfire_linter_file** lfile,
+int pakfire_linter_file_create(pakfire_linter_file** lfile,
pakfire_ctx* ctx, struct pakfire_linter* linter, pakfire_file* file, int fd) {
- struct pakfire_linter_file* l = NULL;
+ pakfire_linter_file* l = NULL;
int r = 0;
// Check input
}
-struct pakfire_linter_file* pakfire_linter_file_ref(struct pakfire_linter_file* lfile) {
+pakfire_linter_file* pakfire_linter_file_ref(pakfire_linter_file* lfile) {
++lfile->nrefs;
return lfile;
}
-struct pakfire_linter_file* pakfire_linter_file_unref(struct pakfire_linter_file* lfile) {
+pakfire_linter_file* pakfire_linter_file_unref(pakfire_linter_file* lfile) {
if (--lfile->nrefs > 0)
return lfile;
return NULL;
}
-static int pakfire_linter_file_check_caps(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_caps(pakfire_linter_file* lfile) {
// Files cannot have capabilities but not be executable
if (!pakfire_file_is_executable(lfile->file) && pakfire_file_has_caps(lfile->file))
return pakfire_linter_file_error(lfile, "File has capabilities but is not executable");
#define pakfire_linter_file_get_script_interpreter(lfile, interpreter) \
__pakfire_linter_file_get_script_interpreter(lfile, interpreter, sizeof(interpreter))
-static int __pakfire_linter_file_get_script_interpreter(struct pakfire_linter_file* lfile,
+static int __pakfire_linter_file_get_script_interpreter(pakfire_linter_file* lfile,
char* interpreter, size_t length) {
char shebang[PATH_MAX];
char* eol = NULL;
return 0;
}
-static int pakfire_linter_check_script_interpreter(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_check_script_interpreter(pakfire_linter_file* lfile) {
char interpreter[PATH_MAX];
int r;
return 0;
}
-static int pakfire_linter_file_check_pie(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_pie(pakfire_linter_file* lfile) {
if (!pakfire_elf_is_pie(lfile->elf))
return pakfire_linter_file_error(lfile, "Missing PIE");
return 0;
}
-static int pakfire_linter_file_check_ssp(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_ssp(pakfire_linter_file* lfile) {
// This check will be skipped for these files
static const char* whitelist[] = {
// Runtime Linker
return 0;
}
-static int pakfire_linter_file_check_execstack(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_execstack(pakfire_linter_file* lfile) {
if (pakfire_elf_has_execstack(lfile->elf))
return pakfire_linter_file_error(lfile, "Executable Stack");
return 0;
}
-static int pakfire_linter_file_check_relro(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_relro(pakfire_linter_file* lfile) {
// If the file is fully RELRO, everything is good
if (pakfire_elf_is_fully_relro(lfile->elf))
return 0;
return pakfire_linter_file_error(lfile, "Is not RELRO");
}
-static int pakfire_linter_file_check_runpath(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_runpath(pakfire_linter_file* lfile) {
char** runpaths = NULL;
int r;
return r;
}
-static int pakfire_linter_file_check_cf_protection(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_cf_protection(pakfire_linter_file* lfile) {
int r;
// Fetch if CF Protection has been enabled
return 0;
}
-static int pakfire_linter_file_is_stripped(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_is_stripped(pakfire_linter_file* lfile) {
switch (pakfire_elf_type(lfile->elf)) {
// Do not check Relocatable Objects
case ET_REL:
return 0;
}
-static int pakfire_linter_file_has_debuglink(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_has_debuglink(pakfire_linter_file* lfile) {
const char* debuglink = NULL;
// Fetch the debug link
return 0;
}
-static int pakfire_linter_file_has_build_id(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_has_build_id(pakfire_linter_file* lfile) {
const char* build_id = NULL;
// Fetch the build ID
}
// Checks if files in /usr/lib/debug are correct
-static int pakfire_linter_file_check_debug(struct pakfire_linter_file* lfile) {
+static int pakfire_linter_file_check_debug(pakfire_linter_file* lfile) {
// Fail if this file is not an ELF file
if (!lfile->elf)
return pakfire_linter_file_error(lfile, "File is not in ELF format");
return 0;
}
-int pakfire_linter_file_lint(struct pakfire_linter_file* lfile) {
+int pakfire_linter_file_lint(pakfire_linter_file* lfile) {
int r = 0;
// Check capabilities
#ifndef PAKFIRE_LINTER_FILE_H
#define PAKFIRE_LINTER_FILE_H
-struct pakfire_linter_file;
+typedef struct pakfire_linter_file pakfire_linter_file;
#include <pakfire/ctx.h>
#include <pakfire/file.h>
#include <pakfire/linter.h>
-int pakfire_linter_file_create(struct pakfire_linter_file** lfile,
+int pakfire_linter_file_create(pakfire_linter_file** lfile,
pakfire_ctx* ctx, struct pakfire_linter* linter, pakfire_file* file, int fd);
-struct pakfire_linter_file* pakfire_linter_file_ref(struct pakfire_linter_file* lfile);
-struct pakfire_linter_file* pakfire_linter_file_unref(struct pakfire_linter_file* lfile);
+pakfire_linter_file* pakfire_linter_file_ref(pakfire_linter_file* lfile);
+pakfire_linter_file* pakfire_linter_file_unref(pakfire_linter_file* lfile);
-int pakfire_linter_file_lint(struct pakfire_linter_file* lfile);
+int pakfire_linter_file_lint(pakfire_linter_file* lfile);
#endif /* PAKFIRE_LINTER_FILE_H */
static int pakfire_linter_payload(
struct pakfire_linter* linter, pakfire_file* file, struct archive* a) {
- struct pakfire_linter_file* lfile = NULL;
+ pakfire_linter_file* lfile = NULL;
int fd = -EBADF;
int r;
return 0;
}
-static int pakfire_linter_file(pakfire_archive* archive,
+static int pakfire_linter_lint_file(pakfire_archive* archive,
struct archive* a, struct archive_entry* e, void* data) {
struct pakfire_linter* linter = data;
pakfire_file* file = NULL;
return r;
// Lint the payload
- r = pakfire_archive_walk_payload(linter->archive, pakfire_linter_file, linter);
+ r = pakfire_archive_walk_payload(linter->archive, pakfire_linter_lint_file, linter);
if (r < 0)
return r;