summaryrefslogtreecommitdiff
path: root/src/irmd/reg/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irmd/reg/proc.c')
-rw-r--r--src/irmd/reg/proc.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/irmd/reg/proc.c b/src/irmd/reg/proc.c
index 9bbdf0eb..8a7e24c9 100644
--- a/src/irmd/reg/proc.c
+++ b/src/irmd/reg/proc.c
@@ -1,5 +1,5 @@
/*
- * Ouroboros - Copyright (C) 2016 - 2024
+ * Ouroboros - Copyright (C) 2016 - 2026
*
* The IPC Resource Manager - Registry - Processes
*
@@ -25,6 +25,7 @@
#define OUROBOROS_PREFIX "reg/proc"
#include <ouroboros/logs.h>
+#include <ouroboros/utils.h>
#include "proc.h"
@@ -54,12 +55,11 @@ static void __reg_proc_clear_names(struct reg_proc * proc)
assert(proc != NULL);
- list_for_each_safe(p, h, &proc->names) {
+ llist_for_each_safe(p, h, &proc->names) {
struct name_entry * entry;
entry = list_entry(p, struct name_entry, next);
- list_del(&entry->next);
+ llist_del(&entry->next, &proc->names);
__free_name_entry(entry);
- proc->n_names--;
}
}
@@ -75,17 +75,18 @@ struct reg_proc * reg_proc_create(const struct proc_info * info)
goto fail_malloc;
}
- proc->set = shm_flow_set_create(info->pid);
+ memset(proc, 0, sizeof(*proc));
+
+ proc->set = ssm_flow_set_create(info->pid);
if (proc->set == NULL) {
log_err("Failed to create flow set for %d.", info->pid);
goto fail_set;
}
list_head_init(&proc->next);
- list_head_init(&proc->names);
+ llist_init(&proc->names);
proc->info = *info;
- proc->n_names = 0;
return proc;
@@ -99,15 +100,13 @@ void reg_proc_destroy(struct reg_proc * proc)
{
assert(proc != NULL);
- shm_flow_set_destroy(proc->set);
+ ssm_flow_set_destroy(proc->set);
__reg_proc_clear_names(proc);
assert(list_is_empty(&proc->next));
- assert(proc->n_names == 0);
-
- assert(list_is_empty(&proc->names));
+ assert(llist_is_empty(&proc->names));
free(proc);
}
@@ -117,7 +116,7 @@ static struct name_entry * __reg_proc_get_name(const struct reg_proc * proc,
{
struct list_head * p;
- list_for_each(p, &proc->names) {
+ llist_for_each(p, &proc->names) {
struct name_entry * entry;
entry = list_entry(p, struct name_entry, next);
if (strcmp(entry->name, name) == 0)
@@ -146,9 +145,7 @@ int reg_proc_add_name(struct reg_proc * proc,
goto fail_name;
}
- list_add(&entry->next, &proc->names);
-
- proc->n_names++;
+ llist_add(&entry->next, &proc->names);
return 0;
@@ -167,12 +164,10 @@ void reg_proc_del_name(struct reg_proc * proc,
if(entry == NULL)
return;
- list_del(&entry->next);
+ llist_del(&entry->next, &proc->names);
__free_name_entry(entry);
- proc->n_names--;
-
assert(__reg_proc_get_name(proc, name) == NULL);
}
@@ -181,3 +176,10 @@ bool reg_proc_has_name(const struct reg_proc * proc,
{
return __reg_proc_get_name(proc, name) != NULL;
}
+
+bool reg_proc_is_privileged(const struct reg_proc * proc)
+{
+ assert(proc != NULL);
+
+ return is_ouroboros_member_uid(proc->info.uid);
+}