From b406c6d12816439ffb5375e2751433bd2aca2e20 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Mon, 27 Apr 2020 09:01:18 +0200 Subject: [PATCH] pid1: make manager_deserialize_{uid,gid}_refs() static No functional change. --- src/core/manager.c | 92 +++++++++++++++++++++++----------------------- src/core/manager.h | 3 -- 2 files changed, 46 insertions(+), 49 deletions(-) diff --git a/src/core/manager.c b/src/core/manager.c index e4bd70d7249..ac5a3b68051 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3427,6 +3427,52 @@ int manager_set_watchdog_overridden(Manager *m, WatchdogType t, usec_t timeout) return 0; } +static void manager_deserialize_uid_refs_one_internal( + Manager *m, + Hashmap** uid_refs, + const char *value) { + + uid_t uid; + uint32_t c; + int r; + + assert(m); + assert(uid_refs); + assert(value); + + r = parse_uid(value, &uid); + if (r < 0 || uid == 0) { + log_debug("Unable to parse UID reference serialization: " UID_FMT, uid); + return; + } + + r = hashmap_ensure_allocated(uid_refs, &trivial_hash_ops); + if (r < 0) { + log_oom(); + return; + } + + c = PTR_TO_UINT32(hashmap_get(*uid_refs, UID_TO_PTR(uid))); + if (c & DESTROY_IPC_FLAG) + return; + + c |= DESTROY_IPC_FLAG; + + r = hashmap_replace(*uid_refs, UID_TO_PTR(uid), UINT32_TO_PTR(c)); + if (r < 0) { + log_debug_errno(r, "Failed to add UID reference entry: %m"); + return; + } +} + +static void manager_deserialize_uid_refs_one(Manager *m, const char *value) { + manager_deserialize_uid_refs_one_internal(m, &m->uid_refs, value); +} + +static void manager_deserialize_gid_refs_one(Manager *m, const char *value) { + manager_deserialize_uid_refs_one_internal(m, &m->gid_refs, value); +} + int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { int r = 0; @@ -4584,52 +4630,6 @@ static void manager_vacuum(Manager *m) { exec_runtime_vacuum(m); } -static void manager_deserialize_uid_refs_one_internal( - Manager *m, - Hashmap** uid_refs, - const char *value) { - - uid_t uid; - uint32_t c; - int r; - - assert(m); - assert(uid_refs); - assert(value); - - r = parse_uid(value, &uid); - if (r < 0 || uid == 0) { - log_debug("Unable to parse UID reference serialization: " UID_FMT, uid); - return; - } - - r = hashmap_ensure_allocated(uid_refs, &trivial_hash_ops); - if (r < 0) { - log_oom(); - return; - } - - c = PTR_TO_UINT32(hashmap_get(*uid_refs, UID_TO_PTR(uid))); - if (c & DESTROY_IPC_FLAG) - return; - - c |= DESTROY_IPC_FLAG; - - r = hashmap_replace(*uid_refs, UID_TO_PTR(uid), UINT32_TO_PTR(c)); - if (r < 0) { - log_debug_errno(r, "Failed to add UID reference entry: %m"); - return; - } -} - -void manager_deserialize_uid_refs_one(Manager *m, const char *value) { - manager_deserialize_uid_refs_one_internal(m, &m->uid_refs, value); -} - -void manager_deserialize_gid_refs_one(Manager *m, const char *value) { - manager_deserialize_uid_refs_one_internal(m, &m->gid_refs, value); -} - int manager_dispatch_user_lookup_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) { struct buffer { uid_t uid; diff --git a/src/core/manager.h b/src/core/manager.h index 80819dbdb15..a29d976eae5 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -529,9 +529,6 @@ int manager_ref_uid(Manager *m, uid_t uid, bool clean_ipc); void manager_unref_gid(Manager *m, gid_t gid, bool destroy_now); int manager_ref_gid(Manager *m, gid_t gid, bool destroy_now); -void manager_deserialize_uid_refs_one(Manager *m, const char *value); -void manager_deserialize_gid_refs_one(Manager *m, const char *value); - char *manager_taint_string(Manager *m); void manager_ref_console(Manager *m);