diff options
author | Luca Boccassi <bluca@debian.org> | 2024-07-04 11:23:04 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-07-04 16:43:51 +0200 |
commit | fc9938d6f8e7081df5420bf88bf98f683b1391c0 (patch) | |
tree | e0d466f078d77ee12d8cb145109135354bae3a0d /src | |
parent | Merge pull request #33589 from poettering/file-hiearchy-no-version (diff) | |
download | systemd-fc9938d6f8e7081df5420bf88bf98f683b1391c0.tar.xz systemd-fc9938d6f8e7081df5420bf88bf98f683b1391c0.zip |
sysusers: handle NSS errors gracefully
If the io.systemd.DynamicUser or io.systemd.Machine files exist,
but nothing is listening on them, the nss-systemd module returns
ECONNREFUSED and systemd-sysusers fails to creat the user/group.
This is problematic when ran by packaging scripts, as the package
assumes that after this has run, the user/group exist and can
be used. adduser does not fail in the same situation.
Change sysusers to print a loud warning but otherwise continue
when NSS returns an error.
Diffstat (limited to 'src')
-rw-r--r-- | src/sysusers/sysusers.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index b3fde5097e..da97f333de 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -1042,7 +1042,7 @@ static int uid_is_ok( if (r >= 0) return 0; if (r != -ESRCH) - return r; + log_warning_errno(r, "Unexpected failure while looking up UID '" UID_FMT "' via NSS, assuming it doesn't exist: %m", uid); if (check_with_gid) { r = getgrgid_malloc((gid_t) uid, &g); @@ -1050,7 +1050,7 @@ static int uid_is_ok( if (!streq(g->gr_name, name)) return 0; } else if (r != -ESRCH) - return r; + log_warning_errno(r, "Unexpected failure while looking up GID '" GID_FMT "' via NSS, assuming it doesn't exist: %m", uid); } } @@ -1155,7 +1155,7 @@ static int add_user(Context *c, Item *i) { return 0; } if (r != -ESRCH) - return log_error_errno(r, "Failed to check if user %s already exists: %m", i->name); + log_warning_errno(r, "Unexpected failure while looking up user '%s' via NSS, assuming it doesn't exist: %m", i->name); } /* Try to use the suggested numeric UID */ @@ -1275,14 +1275,14 @@ static int gid_is_ok( if (r >= 0) return 0; if (r != -ESRCH) - return r; + log_warning_errno(r, "Unexpected failure while looking up GID '" GID_FMT "' via NSS, assuming it doesn't exist: %m", gid); if (check_with_uid) { r = getpwuid_malloc(gid, /* ret= */ NULL); if (r >= 0) return 0; if (r != -ESRCH) - return r; + log_warning_errno(r, "Unexpected failure while looking up GID '" GID_FMT "' via NSS, assuming it doesn't exist: %m", gid); } } @@ -1317,7 +1317,7 @@ static int get_gid_by_name( return 0; } if (r != -ESRCH) - return log_error_errno(r, "Failed to check if group %s already exists: %m", name); + log_warning_errno(r, "Unexpected failure while looking up group '%s' via NSS, assuming it doesn't exist: %m", name); } return -ENOENT; |