3 Commits

Author SHA1 Message Date
BritishTeapot
aea6e94ad7 Fixed incorrect database creation flags 2025-04-02 18:56:31 +02:00
BritishTeapot
52fcb4d4e3 Fixed an arbitrary return value in temp permissions init 2025-04-02 18:49:14 +02:00
badbf2ff98 Merge pull request 'setuid' (#7) from setuid into main
Reviewed-on: #7
2025-04-01 19:57:01 +02:00
2 changed files with 6 additions and 3 deletions

View File

@@ -154,8 +154,11 @@ int init_perm_permissions_table(const char *db_filename) {
euid = geteuid();
fprintf(stderr, "Running with uid: %d, gid: %d\n", euid, getegid());
if (sqlite3_open(db_filename, &perm_database)) {
perror("Can't open permanent permissions database:");
if (sqlite3_open_v2(db_filename, &perm_database,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
SQLITE_OPEN_FULLMUTEX,
NULL)) {
perror("Can't open permanent permissions database");
return -1;
}
umask(0);

View File

@@ -75,6 +75,7 @@ unsigned long long get_process_creation_time(pid_t pid) {
int init_temp_permissions_table() {
pthread_mutex_init(&temp_permissions_table_lock, PTHREAD_MUTEX_DEFAULT);
init(&temp_permissions_table);
return 0;
}
/**
@@ -225,7 +226,6 @@ int give_temp_access(const char *filename, struct process_info pi) {
push(&new_permission_entry.allowed_files, strdup(filename));
insert(&temp_permissions_table, pi.PID, new_permission_entry);
printf("temp_permissions_table size: %ld\n", size(&temp_permissions_table));
pthread_mutex_unlock(&temp_permissions_table_lock);
return 0;