basic: add RuntimeScope enum

In various tools and services we have a per-system and per-user concept.
So far we sometimes used a boolean indicating whether we are in system
mode, or a reversed boolean indicating whether we are in user mode, or
the LookupScope enum used by the lookup path logic.

Let's address that, in introduce a common enum for this, we can use all
across the board.

This is mostly just search/replace, no actual code changes.
This commit is contained in:
Lennart Poettering
2023-03-10 09:47:39 +01:00
parent 5f64d2bf33
commit 4870133bfa
89 changed files with 938 additions and 814 deletions
+43 -14
View File
@@ -269,7 +269,7 @@ int bus_connect_user_systemd(sd_bus **ret_bus) {
int bus_connect_transport(
BusTransport transport,
const char *host,
bool user,
RuntimeScope runtime_scope,
sd_bus **ret) {
_cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
@@ -280,19 +280,28 @@ int bus_connect_transport(
assert(ret);
assert_return((transport == BUS_TRANSPORT_LOCAL) == !host, -EINVAL);
assert_return(transport != BUS_TRANSPORT_REMOTE || !user, -EOPNOTSUPP);
assert_return(transport != BUS_TRANSPORT_REMOTE || runtime_scope == RUNTIME_SCOPE_SYSTEM, -EOPNOTSUPP);
switch (transport) {
case BUS_TRANSPORT_LOCAL:
if (user)
switch (runtime_scope) {
case RUNTIME_SCOPE_USER:
r = sd_bus_default_user(&bus);
else {
break;
case RUNTIME_SCOPE_SYSTEM:
if (sd_booted() <= 0)
/* Print a friendly message when the local system is actually not running systemd as PID 1. */
return log_error_errno(SYNTHETIC_ERRNO(EHOSTDOWN),
"System has not been booted with systemd as init system (PID 1). Can't operate.");
r = sd_bus_default_system(&bus);
break;
default:
assert_not_reached();
}
break;
@@ -301,10 +310,21 @@ int bus_connect_transport(
break;
case BUS_TRANSPORT_MACHINE:
if (user)
switch (runtime_scope) {
case RUNTIME_SCOPE_USER:
r = sd_bus_open_user_machine(&bus, host);
else
break;
case RUNTIME_SCOPE_SYSTEM:
r = sd_bus_open_system_machine(&bus, host);
break;
default:
assert_not_reached();
}
break;
default:
@@ -321,25 +341,34 @@ int bus_connect_transport(
return 0;
}
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus) {
int bus_connect_transport_systemd(BusTransport transport, const char *host, RuntimeScope runtime_scope, sd_bus **bus) {
assert(transport >= 0);
assert(transport < _BUS_TRANSPORT_MAX);
assert(bus);
assert_return((transport == BUS_TRANSPORT_LOCAL) == !host, -EINVAL);
assert_return(transport == BUS_TRANSPORT_LOCAL || !user, -EOPNOTSUPP);
assert_return(transport == BUS_TRANSPORT_LOCAL || runtime_scope == RUNTIME_SCOPE_SYSTEM, -EOPNOTSUPP);
switch (transport) {
case BUS_TRANSPORT_LOCAL:
if (user)
switch (runtime_scope) {
case RUNTIME_SCOPE_USER:
return bus_connect_user_systemd(bus);
if (sd_booted() <= 0)
/* Print a friendly message when the local system is actually not running systemd as PID 1. */
return log_error_errno(SYNTHETIC_ERRNO(EHOSTDOWN),
"System has not been booted with systemd as init system (PID 1). Can't operate.");
return bus_connect_system_systemd(bus);
case RUNTIME_SCOPE_SYSTEM:
if (sd_booted() <= 0)
/* Print a friendly message when the local system is actually not running systemd as PID 1. */
return log_error_errno(SYNTHETIC_ERRNO(EHOSTDOWN),
"System has not been booted with systemd as init system (PID 1). Can't operate.");
return bus_connect_system_systemd(bus);
default:
assert_not_reached();
}
break;
case BUS_TRANSPORT_REMOTE:
return sd_bus_open_system_remote(bus, host);
+3 -2
View File
@@ -11,6 +11,7 @@
#include "errno-util.h"
#include "macro.h"
#include "runtime-scope.h"
#include "string-util.h"
#include "time-util.h"
@@ -36,8 +37,8 @@ int bus_check_peercred(sd_bus *c);
int bus_connect_system_systemd(sd_bus **ret_bus);
int bus_connect_user_systemd(sd_bus **ret_bus);
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus);
int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus);
int bus_connect_transport(BusTransport transport, const char *host, RuntimeScope runtime_scope, sd_bus **bus);
int bus_connect_transport_systemd(BusTransport transport, const char *host, RuntimeScope runtime_scope, sd_bus **bus);
int bus_log_address_error(int r, BusTransport transport);
int bus_log_connect_error(int r, BusTransport transport);
+1 -1
View File
@@ -464,7 +464,7 @@ int show_cgroup_get_path_and_warn(
if (r < 0)
return log_error_errno(r, "Failed to load machine data: %m");
r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, false, &bus);
r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, RUNTIME_SCOPE_SYSTEM, &bus);
if (r < 0)
return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL);
+1 -1
View File
@@ -98,7 +98,7 @@ static int specifier_last_component(char specifier, const void *data, const char
}
int install_name_printf(
LookupScope scope,
RuntimeScope scope,
const InstallInfo *info,
const char *format,
char **ret) {
+1 -1
View File
@@ -5,7 +5,7 @@
#include "unit-name.h"
int install_name_printf(
LookupScope scope,
RuntimeScope scope,
const InstallInfo *info,
const char *format,
char **ret);
+46 -46
View File
@@ -47,7 +47,7 @@ typedef enum SearchFlags {
} SearchFlags;
typedef struct {
LookupScope scope;
RuntimeScope scope;
OrderedHashmap *will_process;
OrderedHashmap *have_processed;
} InstallContext;
@@ -969,7 +969,7 @@ static int find_symlinks(
}
static int find_symlinks_in_scope(
LookupScope scope,
RuntimeScope scope,
const LookupPaths *lp,
const InstallInfo *info,
bool match_name,
@@ -1003,7 +1003,7 @@ static int find_symlinks_in_scope(
}
/* look for global enablement of user units */
if (scope == LOOKUP_SCOPE_USER && path_is_user_config_dir(*p)) {
if (scope == RUNTIME_SCOPE_USER && path_is_user_config_dir(*p)) {
*state = UNIT_FILE_ENABLED;
return 1;
}
@@ -1881,7 +1881,7 @@ int unit_file_verify_alias(
}
static int install_info_symlink_alias(
LookupScope scope,
RuntimeScope scope,
InstallInfo *info,
const LookupPaths *lp,
const char *config_path,
@@ -1933,7 +1933,7 @@ static int install_info_symlink_alias(
}
static int install_info_symlink_wants(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags file_flags,
InstallInfo *info,
const LookupPaths *lp,
@@ -2068,7 +2068,7 @@ static int install_info_symlink_link(
}
static int install_info_apply(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags file_flags,
InstallInfo *info,
const LookupPaths *lp,
@@ -2245,7 +2245,7 @@ static int install_context_mark_for_removal(
}
int unit_file_mask(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names,
@@ -2257,7 +2257,7 @@ int unit_file_mask(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
if (r < 0)
@@ -2290,7 +2290,7 @@ int unit_file_mask(
}
int unit_file_unmask(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names,
@@ -2305,7 +2305,7 @@ int unit_file_unmask(
int r, q;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
if (r < 0)
@@ -2405,7 +2405,7 @@ int unit_file_unmask(
}
int unit_file_link(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **files,
@@ -2419,7 +2419,7 @@ int unit_file_link(
int r, q;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
if (r < 0)
@@ -2513,7 +2513,7 @@ static int path_shall_revert(const LookupPaths *lp, const char *path) {
}
int unit_file_revert(
LookupScope scope,
RuntimeScope scope,
const char *root_dir,
char **names,
InstallChange **changes,
@@ -2669,7 +2669,7 @@ int unit_file_revert(
}
int unit_file_add_dependency(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags file_flags,
const char *root_dir,
char **names,
@@ -2685,7 +2685,7 @@ int unit_file_add_dependency(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(target);
assert(IN_SET(dep, UNIT_WANTS, UNIT_REQUIRES));
@@ -2739,7 +2739,7 @@ int unit_file_add_dependency(
static int do_unit_file_enable(
const LookupPaths *lp,
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *config_path,
char **names_or_paths,
@@ -2770,7 +2770,7 @@ static int do_unit_file_enable(
}
int unit_file_enable(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names_or_paths,
@@ -2781,7 +2781,7 @@ int unit_file_enable(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
if (r < 0)
@@ -2796,7 +2796,7 @@ int unit_file_enable(
static int do_unit_file_disable(
const LookupPaths *lp,
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *config_path,
char **names,
@@ -2838,7 +2838,7 @@ static int do_unit_file_disable(
}
int unit_file_disable(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **files,
@@ -2849,7 +2849,7 @@ int unit_file_disable(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
if (r < 0)
@@ -2863,7 +2863,7 @@ int unit_file_disable(
}
static int normalize_linked_files(
LookupScope scope,
RuntimeScope scope,
const LookupPaths *lp,
char **names_or_paths,
char ***ret_names,
@@ -2921,7 +2921,7 @@ static int normalize_linked_files(
}
int unit_file_reenable(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names_or_paths,
@@ -2933,7 +2933,7 @@ int unit_file_reenable(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
if (r < 0)
@@ -2957,7 +2957,7 @@ int unit_file_reenable(
}
int unit_file_set_default(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
const char *name,
@@ -2971,7 +2971,7 @@ int unit_file_set_default(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(name);
if (unit_name_to_type(name) != UNIT_TARGET) /* this also validates the name */
@@ -2992,7 +2992,7 @@ int unit_file_set_default(
}
int unit_file_get_default(
LookupScope scope,
RuntimeScope scope,
const char *root_dir,
char **name) {
@@ -3003,7 +3003,7 @@ int unit_file_get_default(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(name);
r = lookup_paths_init(&lp, scope, 0, root_dir);
@@ -3027,7 +3027,7 @@ int unit_file_get_default(
}
int unit_file_lookup_state(
LookupScope scope,
RuntimeScope scope,
const LookupPaths *lp,
const char *name,
UnitFileState *ret) {
@@ -3125,7 +3125,7 @@ int unit_file_lookup_state(
}
int unit_file_get_state(
LookupScope scope,
RuntimeScope scope,
const char *root_dir,
const char *name,
UnitFileState *ret) {
@@ -3134,7 +3134,7 @@ int unit_file_get_state(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(name);
r = lookup_paths_init(&lp, scope, 0, root_dir);
@@ -3144,7 +3144,7 @@ int unit_file_get_state(
return unit_file_lookup_state(scope, &lp, name, ret);
}
int unit_file_exists(LookupScope scope, const LookupPaths *lp, const char *name) {
int unit_file_exists(RuntimeScope scope, const LookupPaths *lp, const char *name) {
_cleanup_(install_context_done) InstallContext c = { .scope = scope };
int r;
@@ -3196,17 +3196,17 @@ static int split_pattern_into_name_and_instances(const char *pattern, char **out
return 0;
}
static int presets_find_config(LookupScope scope, const char *root_dir, char ***files) {
static int presets_find_config(RuntimeScope scope, const char *root_dir, char ***files) {
static const char* const system_dirs[] = {CONF_PATHS("systemd/system-preset"), NULL};
static const char* const user_dirs[] = {CONF_PATHS_USR("systemd/user-preset"), NULL};
const char* const* dirs;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
if (scope == LOOKUP_SCOPE_SYSTEM)
if (scope == RUNTIME_SCOPE_SYSTEM)
dirs = system_dirs;
else if (IN_SET(scope, LOOKUP_SCOPE_GLOBAL, LOOKUP_SCOPE_USER))
else if (IN_SET(scope, RUNTIME_SCOPE_GLOBAL, RUNTIME_SCOPE_USER))
dirs = user_dirs;
else
assert_not_reached();
@@ -3214,13 +3214,13 @@ static int presets_find_config(LookupScope scope, const char *root_dir, char ***
return conf_files_list_strv(files, ".preset", root_dir, 0, dirs);
}
static int read_presets(LookupScope scope, const char *root_dir, UnitFilePresets *presets) {
static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePresets *presets) {
_cleanup_(unit_file_presets_freep) UnitFilePresets ps = {};
_cleanup_strv_free_ char **files = NULL;
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(presets);
r = presets_find_config(scope, root_dir, &files);
@@ -3394,7 +3394,7 @@ static int query_presets(const char *name, const UnitFilePresets *presets, char
}
}
int unit_file_query_preset(LookupScope scope, const char *root_dir, const char *name, UnitFilePresets *cached) {
int unit_file_query_preset(RuntimeScope scope, const char *root_dir, const char *name, UnitFilePresets *cached) {
_cleanup_(unit_file_presets_freep) UnitFilePresets tmp = {};
int r;
@@ -3458,7 +3458,7 @@ static int execute_preset(
}
static int preset_prepare_one(
LookupScope scope,
RuntimeScope scope,
InstallContext *plus,
InstallContext *minus,
LookupPaths *lp,
@@ -3511,7 +3511,7 @@ static int preset_prepare_one(
}
int unit_file_preset(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags file_flags,
const char *root_dir,
char **names,
@@ -3526,7 +3526,7 @@ int unit_file_preset(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(mode < _UNIT_FILE_PRESET_MODE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
@@ -3551,7 +3551,7 @@ int unit_file_preset(
}
int unit_file_preset_all(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags file_flags,
const char *root_dir,
UnitFilePresetMode mode,
@@ -3565,7 +3565,7 @@ int unit_file_preset_all(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(mode < _UNIT_FILE_PRESET_MODE_MAX);
r = lookup_paths_init(&lp, scope, 0, root_dir);
@@ -3626,7 +3626,7 @@ Hashmap* unit_file_list_free(Hashmap *h) {
DEFINE_TRIVIAL_CLEANUP_FUNC(UnitFileList*, unit_file_list_free_one);
int unit_file_get_list(
LookupScope scope,
RuntimeScope scope,
const char *root_dir,
Hashmap *h,
char **states,
@@ -3636,7 +3636,7 @@ int unit_file_get_list(
int r;
assert(scope >= 0);
assert(scope < _LOOKUP_SCOPE_MAX);
assert(scope < _RUNTIME_SCOPE_MAX);
assert(h);
r = lookup_paths_init(&lp, scope, 0, root_dir);
+17 -17
View File
@@ -102,28 +102,28 @@ struct InstallInfo {
};
int unit_file_enable(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names_or_paths,
InstallChange **changes,
size_t *n_changes);
int unit_file_disable(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names,
InstallChange **changes,
size_t *n_changes);
int unit_file_reenable(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names_or_paths,
InstallChange **changes,
size_t *n_changes);
int unit_file_preset(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names,
@@ -131,52 +131,52 @@ int unit_file_preset(
InstallChange **changes,
size_t *n_changes);
int unit_file_preset_all(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
UnitFilePresetMode mode,
InstallChange **changes,
size_t *n_changes);
int unit_file_mask(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names,
InstallChange **changes,
size_t *n_changes);
int unit_file_unmask(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names,
InstallChange **changes,
size_t *n_changes);
int unit_file_link(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **files,
InstallChange **changes,
size_t *n_changes);
int unit_file_revert(
LookupScope scope,
RuntimeScope scope,
const char *root_dir,
char **names,
InstallChange **changes,
size_t *n_changes);
int unit_file_set_default(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
const char *name,
InstallChange **changes,
size_t *n_changes);
int unit_file_get_default(
LookupScope scope,
RuntimeScope scope,
const char *root_dir,
char **name);
int unit_file_add_dependency(
LookupScope scope,
RuntimeScope scope,
UnitFileFlags flags,
const char *root_dir,
char **names,
@@ -186,15 +186,15 @@ int unit_file_add_dependency(
size_t *n_changes);
int unit_file_lookup_state(
LookupScope scope,
RuntimeScope scope,
const LookupPaths *paths,
const char *name,
UnitFileState *ret);
int unit_file_get_state(LookupScope scope, const char *root_dir, const char *filename, UnitFileState *ret);
int unit_file_exists(LookupScope scope, const LookupPaths *paths, const char *name);
int unit_file_get_state(RuntimeScope scope, const char *root_dir, const char *filename, UnitFileState *ret);
int unit_file_exists(RuntimeScope scope, const LookupPaths *paths, const char *name);
int unit_file_get_list(LookupScope scope, const char *root_dir, Hashmap *h, char **states, char **patterns);
int unit_file_get_list(RuntimeScope scope, const char *root_dir, Hashmap *h, char **states, char **patterns);
Hashmap* unit_file_list_free(Hashmap *h);
InstallChangeType install_changes_add(InstallChange **changes, size_t *n_changes, InstallChangeType type, const char *path, const char *source);
@@ -217,7 +217,7 @@ typedef struct {
} UnitFilePresets;
void unit_file_presets_freep(UnitFilePresets *p);
int unit_file_query_preset(LookupScope scope, const char *root_dir, const char *name, UnitFilePresets *cached);
int unit_file_query_preset(RuntimeScope scope, const char *root_dir, const char *name, UnitFilePresets *cached);
const char *unit_file_state_to_string(UnitFileState s) _const_;
UnitFileState unit_file_state_from_string(const char *s) _pure_;
+12 -12
View File
@@ -334,15 +334,15 @@ int specifier_os_image_version(char specifier, const void *data, const char *roo
}
int specifier_group_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
LookupScope scope = PTR_TO_INT(data);
RuntimeScope scope = PTR_TO_INT(data);
char *t;
assert(ret);
if (scope == LOOKUP_SCOPE_GLOBAL)
if (scope == RUNTIME_SCOPE_GLOBAL)
return -EINVAL;
t = gid_to_name(scope == LOOKUP_SCOPE_USER ? getgid() : 0);
t = gid_to_name(scope == RUNTIME_SCOPE_USER ? getgid() : 0);
if (!t)
return -ENOMEM;
@@ -351,15 +351,15 @@ int specifier_group_name(char specifier, const void *data, const char *root, con
}
int specifier_group_id(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
LookupScope scope = PTR_TO_INT(data);
RuntimeScope scope = PTR_TO_INT(data);
gid_t gid;
assert(ret);
if (scope == LOOKUP_SCOPE_GLOBAL)
if (scope == RUNTIME_SCOPE_GLOBAL)
return -EINVAL;
gid = scope == LOOKUP_SCOPE_USER ? getgid() : 0;
gid = scope == RUNTIME_SCOPE_USER ? getgid() : 0;
if (asprintf(ret, UID_FMT, gid) < 0)
return -ENOMEM;
@@ -368,16 +368,16 @@ int specifier_group_id(char specifier, const void *data, const char *root, const
}
int specifier_user_name(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
LookupScope scope = PTR_TO_INT(data);
RuntimeScope scope = PTR_TO_INT(data);
uid_t uid;
char *t;
assert(ret);
if (scope == LOOKUP_SCOPE_GLOBAL)
if (scope == RUNTIME_SCOPE_GLOBAL)
return -EINVAL;
uid = scope == LOOKUP_SCOPE_USER ? getuid() : 0;
uid = scope == RUNTIME_SCOPE_USER ? getuid() : 0;
/* If we are UID 0 (root), this will not result in NSS, otherwise it might. This is good, as we want
* to be able to run this in PID 1, where our user ID is 0, but where NSS lookups are not allowed.
@@ -395,15 +395,15 @@ int specifier_user_name(char specifier, const void *data, const char *root, cons
}
int specifier_user_id(char specifier, const void *data, const char *root, const void *userdata, char **ret) {
LookupScope scope = PTR_TO_INT(data);
RuntimeScope scope = PTR_TO_INT(data);
uid_t uid;
assert(ret);
if (scope == LOOKUP_SCOPE_GLOBAL)
if (scope == RUNTIME_SCOPE_GLOBAL)
return -EINVAL;
uid = scope == LOOKUP_SCOPE_USER ? getuid() : 0;
uid = scope == RUNTIME_SCOPE_USER ? getuid() : 0;
if (asprintf(ret, UID_FMT, uid) < 0)
return -ENOMEM;