diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-05-26 17:08:38 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-05-26 17:20:36 +0200 |
commit | 2caed041c0b04a993d11d8cf4174a617bf3cf40b (patch) | |
tree | 371220b377ed3ac209f3bd19edab25b08a4eaf83 /src/sysusers/sysusers.c | |
parent | hexdecoct: make return parameters of unbase64mem() and unhexmem() optional (diff) | |
download | systemd-2caed041c0b04a993d11d8cf4174a617bf3cf40b.tar.xz systemd-2caed041c0b04a993d11d8cf4174a617bf3cf40b.zip |
sysusers: add a generic specifier table for common cases
This moves the definition of the specifier table consisting only of
system and /tmp specifiers into generic code so that we can share it.
This patch only adds one user of it for now. Follow-up patches will add
more.
Diffstat (limited to 'src/sysusers/sysusers.c')
-rw-r--r-- | src/sysusers/sysusers.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 5aa3531012..c9eda29b49 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -1466,12 +1466,6 @@ static bool item_equal(Item *a, Item *b) { static int parse_line(const char *fname, unsigned line, const char *buffer) { - static const Specifier specifier_table[] = { - COMMON_SYSTEM_SPECIFIERS, - COMMON_TMP_SPECIFIERS, - {} - }; - _cleanup_free_ char *action = NULL, *name = NULL, *resolved_name = NULL, *id = NULL, *resolved_id = NULL, @@ -1515,7 +1509,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { name = mfree(name); if (name) { - r = specifier_printf(name, NAME_MAX, specifier_table, NULL, &resolved_name); + r = specifier_printf(name, NAME_MAX, system_and_tmp_specifier_table, NULL, &resolved_name); if (r < 0) return log_error_errno(r, "[%s:%u] Failed to replace specifiers in '%s': %m", fname, line, name); @@ -1530,7 +1524,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { id = mfree(id); if (id) { - r = specifier_printf(id, PATH_MAX-1, specifier_table, NULL, &resolved_id); + r = specifier_printf(id, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_id); if (r < 0) return log_error_errno(r, "[%s:%u] Failed to replace specifiers in '%s': %m", fname, line, name); @@ -1541,7 +1535,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { description = mfree(description); if (description) { - r = specifier_printf(description, LONG_LINE_MAX, specifier_table, NULL, &resolved_description); + r = specifier_printf(description, LONG_LINE_MAX, system_and_tmp_specifier_table, NULL, &resolved_description); if (r < 0) return log_error_errno(r, "[%s:%u] Failed to replace specifiers in '%s': %m", fname, line, description); @@ -1557,7 +1551,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { home = mfree(home); if (home) { - r = specifier_printf(home, PATH_MAX-1, specifier_table, NULL, &resolved_home); + r = specifier_printf(home, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_home); if (r < 0) return log_error_errno(r, "[%s:%u] Failed to replace specifiers in '%s': %m", fname, line, home); @@ -1573,7 +1567,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { shell = mfree(shell); if (shell) { - r = specifier_printf(shell, PATH_MAX-1, specifier_table, NULL, &resolved_shell); + r = specifier_printf(shell, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_shell); if (r < 0) return log_error_errno(r, "[%s:%u] Failed to replace specifiers in '%s': %m", fname, line, shell); |