Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package account-utils for openSUSE:Factory checked in at 2026-11-27 19:44:10 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/account-utils (Old) and /work/SRC/openSUSE:Factory/.account-utils.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "account-utils" Fri Nov 27 19:44:10 2026 rev:13 rq:1401087 version:1.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/account-utils/account-utils.changes 2026-09-11 08:12:47.364401871 +0200 +++ /work/SRC/openSUSE:Factory/.account-utils.new.1340718/account-utils.changes 2026-11-27 19:47:33.645318824 +0100 @@ -1,0 +2,22 @@ +Fri Nov 27 11:19:47 UTC 2026 - Thorsten Kukuk <[email protected]> + +- Update to version 1.5.0: + * Release version 1.5.0 + * CI: add test for issue#43 (subXid) + * Fix reading /etc/subXid with multiple entries (#43) + * newidmapd: use close(TAKE_FD()) + * pam_unix_ng: free the bus error in start_pwaccessd() + * newidmapd: don't close the mapping fd twice + * newidmapd: free the account name in verify_ranges() + * libclient: allow a NULL default in get_logindefs_string() + * libcommon, pwupdd: fix waiting for the password lock + * Fix the InternalError domain name + * varlink: take the event loop for Quit from the connection + * CI: add test case for PR#35 + * newxidmap: return negative errno from get_map_ranges + * pwupdd: send chsh shell warning as notification + * pwupdd: don't probe the file system for unprivileged chsh callers + * pwupdd: fix name of service file + * Fix typo in comment + +------------------------------------------------------------------- Old: ---- account-utils-1.4.0+git20260717.3914e08.tar.xz New: ---- account-utils-1.5.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ account-utils.spec ++++++ --- /var/tmp/diff_new_pack.xbYmdw/_old 2026-11-27 19:47:34.535356734 +0100 +++ /var/tmp/diff_new_pack.xbYmdw/_new 2026-11-27 19:47:34.536356776 +0100 @@ -22,7 +22,7 @@ %define lname libpwaccess0 Name: account-utils -Version: 1.4.0+git20260717.3914e08 +Version: 1.5.0 Release: 0 Summary: Service for authentication and account management License: GPL-2.0-or-later AND BSD-2-Clause AND LGPL-2.1-or-later ++++++ _service ++++++ --- /var/tmp/diff_new_pack.xbYmdw/_old 2026-11-27 19:47:34.602359588 +0100 +++ /var/tmp/diff_new_pack.xbYmdw/_new 2026-11-27 19:47:34.612360014 +0100 @@ -5,7 +5,7 @@ <param name="changesgenerate">enable</param> <param name="filename">account-utils</param> <param name="revision">main</param> - <param name="versionformat">@PARENT_TAG@+git%cd.%h</param> + <param name="versionformat">@PARENT_TAG@+git@TAG_OFFSET@</param> <param name="versionrewrite-pattern">v(.*?)(\+git0)?$</param> </service> <service mode="manual" name="recompress"> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.xbYmdw/_old 2026-11-27 19:47:34.644361377 +0100 +++ /var/tmp/diff_new_pack.xbYmdw/_new 2026-11-27 19:47:34.647361505 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/thkukuk/account-utils.git</param> -<param name="changesrevision">3914e08fba5f2b89644ef34330af96cf85d34098</param></service></servicedata> +<param name="changesrevision">9bf5f29ee8fbe5e38673924b18176a747fe8176a</param></service></servicedata> (No newline at EOF) ++++++ account-utils-1.4.0+git20260717.3914e08.tar.xz -> account-utils-1.5.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/NEWS new/account-utils-1.5.0/NEWS --- old/account-utils-1.4.0+git20260717.3914e08/NEWS 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/NEWS 2026-11-27 12:07:23.000000000 +0100 @@ -4,6 +4,9 @@ Please enter bug reports at https://github.com/thkukuk/account-utils/issues +Version 1.5.0 +* Many bug fixes + Version 1.4.0 * CI: add tests for newuidmap/newgidmap/newidmapd * Add pwaccessd.conf.5, newgidmap, newidmapd and newuidmap manual pages diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/libclient/get_logindefs.c new/account-utils-1.5.0/libclient/get_logindefs.c --- old/account-utils-1.4.0+git20260717.3914e08/libclient/get_logindefs.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/libclient/get_logindefs.c 2026-11-27 12:07:23.000000000 +0100 @@ -45,6 +45,8 @@ return val; } +/* Returns a copy of the value of key, or of def if the key is not set or + login.defs cannot be read. def can be NULL, then NULL is returned. */ char * get_logindefs_string(const char *key, const char *def) { @@ -56,7 +58,7 @@ if (error != ECONF_SUCCESS) { fprintf(stderr, "Cannot parse login.defs: %s\n", econf_errString(error)); - return strdup(def); + return def ? strdup(def) : NULL; } error = econf_getStringValueDef(key_file, NULL, key, &val, def); @@ -65,7 +67,7 @@ if (error != ECONF_NOKEY) fprintf(stderr, "Error reading '%s': %s\n", key, econf_errString(error)); - return strdup(def); + return def ? strdup(def) : NULL; } return val; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/libcommon/files.c new/account-utils-1.5.0/libcommon/files.c --- old/account-utils-1.4.0+git20260717.3914e08/libcommon/files.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/libcommon/files.c 2026-11-27 12:07:23.000000000 +0100 @@ -22,29 +22,26 @@ #define SELINUX_ENABLED 0 #endif -#define MAX_LOCK_RETRIES 300 /* How often should we try to lock password file */ - typedef int (*update_account_file_cb)(FILE*, FILE*, void*); static int lock_db(void) { - int retries = 0; - int r; - - while((r = lckpwdf()) != 0 && retries < MAX_LOCK_RETRIES) - { - usleep(10000); /* 1/100 second */ - ++retries; - } - - if (r < 0) + /* lckpwdf() blocks until it gets the lock or gives up after 15 seconds + itself. Don't retry: the client gives up long before, and we would + apply the change after it has been told that the request failed. + The timeout uses SIGALRM, so a multi-threaded program has to block it + in all threads but the calling one, else it can wait forever. */ + errno = 0; /* lckpwdf() does not always set errno */ + if (lckpwdf() != 0) { - if (retries == MAX_LOCK_RETRIES) + /* EINTR: interrupted by the timeout signal, 0: already locked by + this process. */ + if (errno == 0 || errno == EINTR) return -ENOLCK; - else - return -errno; + return -errno; } + return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/libcommon/read_config.c new/account-utils-1.5.0/libcommon/read_config.c --- old/account-utils-1.4.0+git20260717.3914e08/libcommon/read_config.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/libcommon/read_config.c 2026-11-27 12:07:23.000000000 +0100 @@ -164,7 +164,7 @@ return ECONF_SUCCESS; } -/* we will read everything and only report the firstx error */ +/* we will read everything and only report the first error */ econf_err read_config(const char *name, struct config_t *cfg) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/man/pwupdd.8.xml new/account-utils-1.5.0/man/pwupdd.8.xml --- old/account-utils-1.4.0+git20260717.3914e08/man/pwupdd.8.xml 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/man/pwupdd.8.xml 2026-11-27 12:07:23.000000000 +0100 @@ -9,14 +9,14 @@ <refnamediv> <refname>pwupdd</refname> - <refname>pwupdd.service</refname> + <refname>[email protected]</refname> <refname>pwupdd.socket</refname> <refpurpose>update passwd and shadow entries</refpurpose> </refnamediv> <refsynopsisdiv> <cmdsynopsis> - <command>pwupdd.service</command> + <command>[email protected]</command> </cmdsynopsis> <cmdsynopsis> <command>pwupdd.socket</command> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/meson.build new/account-utils-1.5.0/meson.build --- old/account-utils-1.4.0+git20260717.3914e08/meson.build 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/meson.build 2026-11-27 12:07:23.000000000 +0100 @@ -12,7 +12,7 @@ 'b_lto=true', 'warning_level=2'], license : ['GPL-2.0-or-later', 'LGPL-2.1-or-later'], - version : '1.4.0', + version : '1.5.0', ) distribution = get_option('distribution') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/src/newidmapd.c new/account-utils-1.5.0/src/newidmapd.c --- old/account-utils-1.4.0+git20260717.3914e08/src/newidmapd.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/src/newidmapd.c 2026-11-27 12:07:23.000000000 +0100 @@ -2,10 +2,10 @@ #include "config.h" +#include <ctype.h> #include <pwd.h> #include <getopt.h> #include <syslog.h> -#include <libeconf.h> #include <systemd/sd-daemon.h> #include <systemd/sd-varlink.h> @@ -60,8 +60,153 @@ return proc_dir_fd; } +/* One "owner:start:count" line from /etc/subuid or /etc/subgid that + applies to the user we are checking. */ +struct subid_range { + int64_t start; + int64_t count; +}; + +static void +subid_ranges_freep(struct subid_range **ranges) +{ + *ranges = mfree(*ranges); +} + +/* Read all lines of subid_file whose owner field matches either + "user" (by name) or "uid" (by its decimal string, as allowed by + subuid(5)/subgid(5)) and collect their (start,count) ranges. */ +static int +load_subid_ranges(const char *subid_file, const char *user, uid_t uid, + struct subid_range **rangesp, size_t *nrangesp) +{ + _cleanup_fclose_ FILE *fp = NULL; + _cleanup_free_ char *line = NULL; + size_t linesize = 0; + ssize_t len; + _cleanup_(subid_ranges_freep) struct subid_range *ranges = NULL; + size_t nranges = 0; + char uidstr[32]; + + snprintf(uidstr, sizeof(uidstr), "%u", uid); + + fp = fopen(subid_file, "r"); + if (fp == NULL) + { + log_msg(LOG_ERR, "Cannot open %s: %m", subid_file); + return (errno == ENOENT) ? -ENOENT : -EIO; + } + + while ((len = getline(&line, &linesize, fp)) != -1) + { + char *comment = strchr(line, '#'); + if (comment) + *comment = '\0'; + + char *owner = line; + while (isspace((unsigned char)*owner)) + owner++; + + char *end = owner + strlen(owner); + while (end > owner && isspace((unsigned char)end[-1])) + *--end = '\0'; + + if (*owner == '\0') + continue; + + char *start_str = strchr(owner, ':'); + if (start_str == NULL) + { + log_msg(LOG_ERR, "Invalid line in %s: %s", subid_file, owner); + continue; + } + *start_str++ = '\0'; + + char *count_str = strchr(start_str, ':'); + if (count_str == NULL) + { + log_msg(LOG_ERR, "Invalid line in %s for user %s: %s", subid_file, owner, start_str); + continue; + } + *count_str++ = '\0'; + + if (!streq(owner, user) && !streq(owner, uidstr)) + continue; + + char *ep = NULL; + long long start, count; + + errno = 0; + start = strtoll(start_str, &ep, 10); + if (errno == ERANGE || start < 0 || start > UID_MAX || start_str == ep || *ep != '\0') + { + log_msg(LOG_ERR, "Cannot parse 'start' value (%s,%s,%s)", subid_file, owner, start_str); + continue; + } + errno = 0; + count = strtoll(count_str, &ep, 10); + if (errno == ERANGE || count <= 0 || count >= (UID_MAX - start) || count_str == ep || *ep != '\0') + { + log_msg(LOG_ERR, "Cannot parse 'count' value (%s,%s,%s)", subid_file, owner, count_str); + continue; + } + + struct subid_range *tmp = reallocarray(ranges, nranges + 1, sizeof(*ranges)); + if (tmp == NULL) + { + log_msg(LOG_ERR, "Out of memory!"); + return -ENOMEM; + } + ranges = tmp; + ranges[nranges].start = start; + ranges[nranges].count = count; + nranges++; + + log_msg(LOG_DEBUG, "%s: owner=%s, start=%lli, count=%lli", subid_file, owner, start, count); + } + + *rangesp = TAKE_PTR(ranges); + *nrangesp = nranges; + return 0; +} + +/* Check whether [start, start+count) is fully covered by the collected + subid ranges, stitching together consecutive ranges if necessary - + mirrors shadow's have_range()/find_range(). */ static bool -verify_range(uid_t id, int64_t start, int64_t count, const struct map_range mapping) +have_subid_range(const struct subid_range *ranges, size_t nranges, + int64_t start, int64_t count) +{ + int64_t end = start + count - 1; + + while (true) + { + bool found = false; + + for (size_t i = 0; i < nranges; i++) + { + int64_t first = ranges[i].start; + int64_t last = first + ranges[i].count - 1; + + if (start < first || start > last) + continue; + + found = true; + if (last >= end) + return true; + + start = last + 1; + break; + } + + if (!found) + return false; + } +} + +static bool +verify_range(uid_t id, const struct subid_range *ranges, size_t nranges, + const struct map_range mapping) { if (mapping.count == 0) { @@ -69,6 +214,9 @@ return false; } + if (have_subid_range(ranges, nranges, mapping.lower, mapping.count)) + return true; + /* Allow a process to map its own uid */ if ((mapping.count == 1) && (id == mapping.lower)) { @@ -76,22 +224,8 @@ return true; } - /* first ID outside namespace must be between start and start+count */ - if (mapping.lower < start || mapping.lower >= start+count) - { - if (mapping.lower < start) - log_msg(LOG_ERR, "Error: lower (%lu) < start (%li)", mapping.lower, start); - if (mapping.lower >= start+count) - log_msg(LOG_ERR, "Error:lower (%lu) >= start+count (%li)", mapping.lower, start+count); - return false; - } - - /* last ID outside must be smaller than start+count. - -1 because lower is already the first ID. */ - if ((mapping.lower+mapping.count-1) < (start+count)) - return true; - else - log_msg(LOG_ERR, "Error: mapping.lower+mapping.count-1 < start+count failed"); + log_msg(LOG_ERR, "Error: mapping [%lu-%lu) not covered by any allowed range", + mapping.lower, mapping.lower+mapping.count); return false; } @@ -104,12 +238,10 @@ const char *map) { const char *subid_file = NULL; - _cleanup_(econf_freeFilep) econf_file *econf = NULL; - econf_err error; - char *user; + _cleanup_free_ char *user = NULL; _cleanup_free_ char *pwerror = NULL; - _cleanup_free_ char *val = NULL; - long long start, count; + _cleanup_(subid_ranges_freep) struct subid_range *ranges = NULL; + size_t n_subid_ranges = 0; int r; uid_t id; // can be uid or gid @@ -137,56 +269,16 @@ return -EINVAL; } - error = econf_readFile(&econf, subid_file, ":", "#"); - if (error != ECONF_SUCCESS) - { - log_msg(LOG_ERR, "Cannot open %s: %s", subid_file, econf_errString(error)); - if (error == ECONF_NOFILE) - return -ENOENT; - else - return -EIO; - } - - error = econf_getStringValue(econf, NULL, user, &val); - if (error != ECONF_SUCCESS) - { - if (error == ECONF_NOKEY) - log_msg(LOG_ERR, "Mapping range for user '%s' not found in %s", user, subid_file); - else - log_msg(LOG_ERR, "Error retrieving key '%s': %s", user, econf_errString(error)); - return -ENODATA; - } - - char *cp = strchr(val, ':'); - if (cp == NULL) - { - log_msg(LOG_ERR, "Invalid format for user %s in %s: %s", user, subid_file, val); - return -EINVAL; - } - - *cp++='\0'; - - char *ep = NULL; - errno = 0; - start = strtoll(val, &ep, 10); - if (errno == ERANGE || start < 0 || start > UID_MAX || val == ep || *ep != '\0') - { - log_msg(LOG_ERR, "Cannot parse 'start' value (%s,%s,%s)", subid_file, user, val); - return -EINVAL; - } - errno = 0; - count = strtoll(cp, &ep, 10); - if (errno == ERANGE || count <= 0 || count >= (UID_MAX - start) || cp == ep || *ep != '\0') - { - log_msg(LOG_ERR, "Cannot parse 'count' value (%s,%s,%s)", subid_file, user, cp); - return -EINVAL; - } + r = load_subid_ranges(subid_file, user, uid, &ranges, &n_subid_ranges); + if (r < 0) + return r; - log_msg(LOG_DEBUG, "%s: user=%s, start=%lli, count=%lli", subid_file, user, start, count); + if (n_subid_ranges == 0) + log_msg(LOG_DEBUG, "No entries for user '%s' found in %s", user, subid_file); for (int i = 0; i < nranges; i++) { - if (!verify_range(id, start, count, mappings[i])) + if (!verify_range(id, ranges, n_subid_ranges, mappings[i])) return 1; } @@ -238,7 +330,8 @@ map, strerror(-r)); return r; } - if (close(fd) != 0 && errno != EINTR) + r = close(TAKE_FD(fd)); + if (r != 0 && errno != EINTR) { r = -errno; log_msg(LOG_ERR, "Failed to close '%s': %s", @@ -545,8 +638,6 @@ return r; } - sd_varlink_server_set_userdata(varlink_server, event); - r = sd_varlink_server_attach_event(varlink_server, event, SD_EVENT_PRIORITY_NORMAL); if (r < 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/src/newxidmap.c new/account-utils-1.5.0/src/newxidmap.c --- old/account-utils-1.4.0+git20260717.3914e08/src/newxidmap.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/src/newxidmap.c 2026-11-27 12:07:23.000000000 +0100 @@ -47,7 +47,7 @@ if (errno == ERANGE || argv[j] == ep || *ep != '\0') { fprintf(stderr, "Cannot parse upper argument ('%s')\n", argv[j]); - return EINVAL; + return -EINVAL; } errno = 0; @@ -55,7 +55,7 @@ if (errno == ERANGE || argv[j+1] == ep || *ep != '\0') { fprintf(stderr, "Cannot parse lower argument ('%s')\n", argv[j+1]); - return EINVAL; + return -EINVAL; } errno = 0; @@ -63,7 +63,7 @@ if (errno == ERANGE || argv[j+2] == ep || *ep != '\0') { fprintf(stderr, "Cannot parse count argument ('%s')\n", argv[j+2]); - return EINVAL; + return -EINVAL; } } *res = TAKE_PTR(mappings); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/src/pam_unix_ng-spawn.c new/account-utils-1.5.0/src/pam_unix_ng-spawn.c --- old/account-utils-1.4.0+git20260717.3914e08/src/pam_unix_ng-spawn.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/src/pam_unix_ng-spawn.c 2026-11-27 12:07:23.000000000 +0100 @@ -58,7 +58,7 @@ .finished = 0, .success = 0 }; - sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; _cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL; _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/src/pwupdd.c new/account-utils-1.5.0/src/pwupdd.c --- old/account-utils-1.4.0+git20260717.3914e08/src/pwupdd.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/src/pwupdd.c 2026-11-27 12:07:23.000000000 +0100 @@ -13,6 +13,7 @@ #include <pwd.h> #include <shadow.h> #include <pthread.h> +#include <signal.h> #include <systemd/sd-daemon.h> #include <systemd/sd-varlink.h> #include <systemd/sd-journal.h> @@ -691,6 +692,16 @@ if (uid) return false; } + else if (uid != 0 && !is_known_shell(shell)) + { + /* Don't look at the file system for a path from an unprivileged + caller. We run as root, so access() would reveal if files exist + in directories the caller cannot access. The shell list is + world-readable. */ + if (asprintf(msg, "Error: '%s' is not listed as valid login shell.", shell) < 0) + *msg = NULL; + return false; + } else if (access(shell, F_OK) < 0) { if (asprintf(msg, "%s: '%s' does not exist.", uid?"Error":"Warning", shell) < 0) @@ -809,9 +820,13 @@ SD_JSON_BUILD_PAIR_STRING("ErrorMsg", stroom(msg))); } if (msg) /* ignore if it fails or not */ - sd_varlink_replybo(link, - SD_JSON_BUILD_PAIR_INTEGER("msg_style", PAM_TEXT_INFO), - SD_JSON_BUILD_PAIR_STRING("message", msg)); + { + /* This is only a notification, a reply would end the call. */ + sd_varlink_notifybo(link, + SD_JSON_BUILD_PAIR_INTEGER("msg_style", PAM_TEXT_INFO), + SD_JSON_BUILD_PAIR_STRING("message", msg)); + sd_varlink_flush(link); + } /* Run under the UID of the caller, else pam_unix will not ask for old password and pam_rootok will wrongly match. */ @@ -1404,7 +1419,23 @@ log_msg (LOG_INFO, "Starting pwupdd (%s) %s...", PACKAGE, VERSION); - int r = run_varlink (); + /* The update functions use lckpwdf(), which uses SIGALRM for its timeout. + A process directed signal is delivered to any thread which does not + block it, e.g. to the main thread while a PAM thread waits for the + lock, which then waits forever. Block it here, the threads started + later inherit the mask, and lckpwdf() unblocks it only for the thread + calling it. */ + sigset_t alarm_set; + sigemptyset(&alarm_set); + sigaddset(&alarm_set, SIGALRM); + int r = pthread_sigmask(SIG_BLOCK, &alarm_set, NULL); + if (r != 0) + { + log_msg(LOG_ERR, "Failed to block SIGALRM: %s", strerror(r)); + return 1; + } + + r = run_varlink (); if (r < 0) return -r; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/src/varlink-service-common.c new/account-utils-1.5.0/src/varlink-service-common.c --- old/account-utils-1.4.0+git20260717.3914e08/src/varlink-service-common.c 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/src/varlink-service-common.c 2026-11-27 12:07:23.000000000 +0100 @@ -8,7 +8,6 @@ #include "basics.h" #include "varlink-service-common.h" -#include "context.h" static int log_level = LOG_WARNING; @@ -152,17 +151,38 @@ #endif } +/* Build the "<interface>.InternalError" domain for the interface the + current call came in on, since this method is shared between daemons + that each declare their own InternalError. Falls back to pwaccess's + if the interface can't be determined. */ +static int +vl_method_quit_internal_error(sd_varlink *link) +{ + _cleanup_free_ char *error_domain = NULL; + const char *method = NULL; + const char *dot; + + if (sd_varlink_get_current_method(link, &method) >= 0 && method && + (dot = strrchr(method, '.')) != NULL && + asprintf(&error_domain, "%.*sInternalError", (int)(dot - method + 1), method) < 0) + error_domain = NULL; + + return sd_varlink_errorbo(link, + error_domain ? error_domain : "org.openSUSE.pwaccess.InternalError", + SD_JSON_BUILD_PAIR_BOOLEAN("Success", false)); +} + int vl_method_quit(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t _unused_(flags), - void *userdata) + void _unused_(*userdata)) { static const sd_json_dispatch_field dispatch_table[] = { { "ExitCode", SD_JSON_VARIANT_INTEGER, sd_json_dispatch_int, 0, 0 }, {} }; uid_t peer_uid; - struct context_t *ctx = userdata; + sd_event *loop; int exit_code = 0; int r; @@ -192,13 +212,21 @@ if (exit_code > 0) exit_code = -exit_code; - r = sd_event_exit(ctx->loop, exit_code); + /* Use the event loop of the connection, not userdata: not every daemon + stores a struct context_t there. */ + loop = sd_varlink_get_event(link); + if (loop == NULL) + { + log_msg(LOG_ERR, "Quit request: connection has no event loop"); + return vl_method_quit_internal_error(link); + } + + r = sd_event_exit(loop, exit_code); if (r != 0) { log_msg(LOG_ERR, "Quit request: disabling event loop failed: %s", strerror(-r)); - return sd_varlink_errorbo(link, "org.openSUSE.pwaccess.InternalError", - SD_JSON_BUILD_PAIR_BOOLEAN("Success", false)); + return vl_method_quit_internal_error(link); } return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_BOOLEAN("Success", true)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/account-utils-1.4.0+git20260717.3914e08/tests/ci/test-newidmapd.sh new/account-utils-1.5.0/tests/ci/test-newidmapd.sh --- old/account-utils-1.4.0+git20260717.3914e08/tests/ci/test-newidmapd.sh 2026-07-17 12:00:03.000000000 +0200 +++ new/account-utils-1.5.0/tests/ci/test-newidmapd.sh 2026-11-27 12:07:23.000000000 +0100 @@ -355,6 +355,160 @@ } # --------------------------------------------------------------------------- +# Regression tests for #43: newidmapd ignoring additional /etc/subuid ranges +# of a user, and entries keyed by UID instead of username. +# --------------------------------------------------------------------------- + +test_newuidmap_subuid_multiple_ranges() { + log_test "Testing newuidmap stitches two contiguous /etc/subuid lines for the same user" + + local testuser="newidmap_multirange" + local range1_start=500000 + local range1_count=65536 + local range2_start=$((range1_start + range1_count)) + local range2_count=65536 + create_test_user "$testuser" "TestPass123" + + # Two separate lines for the same user; contiguous, so a request spanning + # both must be accepted by stitching them together. + container_exec bash -c "echo '${testuser}:${range1_start}:${range1_count}' >> /etc/subuid" + container_exec bash -c "echo '${testuser}:${range2_start}:${range2_count}' >> /etc/subuid" + + local pid_file="/tmp/newidmapd_test_multirange_pid" + local pid + pid=$(start_userns_process "$testuser" "$pid_file") + + local combined_count=$((range1_count + range2_count)) + local rc=0 + container_exec_user "$testuser" /usr/bin/bash -c \ + "newuidmap $pid 0 $range1_start $combined_count" || rc=$? + assert_success $rc "newuidmap accepts a range spanning two contiguous /etc/subuid lines for the same user" + + local uid_map + uid_map=$(container_exec cat "/proc/$pid/uid_map") + assert_contains "$uid_map" "$range1_start" "uid_map contains stitched range start $range1_start" + + container_exec /usr/bin/kill "$pid" 2>/dev/null || true + container_exec rm -f "$pid_file" + container_exec bash -c \ + "grep -v '^${testuser}:' /etc/subuid > /etc/subuid.new && \ + cp /etc/subuid.new /etc/subuid && rm /etc/subuid.new" + delete_test_user "$testuser" +} + +test_newuidmap_subuid_noncontiguous_rejected() { + log_test "Testing newuidmap rejects a range spanning a gap between two /etc/subuid lines" + + local testuser="newidmap_gaprange" + local range1_start=600000 + local range1_count=65536 + local range2_start=700000 + local range2_count=65536 + create_test_user "$testuser" "TestPass123" + + container_exec bash -c "echo '${testuser}:${range1_start}:${range1_count}' >> /etc/subuid" + container_exec bash -c "echo '${testuser}:${range2_start}:${range2_count}' >> /etc/subuid" + + local pid_file="/tmp/newidmapd_test_gaprange_pid" + local pid + pid=$(start_userns_process "$testuser" "$pid_file") + + # The first of the two ranges alone must still be accepted on its own... + local rc=0 + container_exec_user "$testuser" /usr/bin/bash -c \ + "newuidmap $pid 0 $range1_start $range1_count" || rc=$? + assert_success $rc "newuidmap accepts the first of two /etc/subuid lines for the user" + + container_exec /usr/bin/kill "$pid" 2>/dev/null || true + container_exec rm -f "$pid_file" + pid=$(start_userns_process "$testuser" "$pid_file") + + # ...but a request spanning the gap between the two lines must be rejected. + rc=0 + local combined_count=$((range2_start + range2_count - range1_start)) + container_exec_user "$testuser" /usr/bin/bash -c \ + "newuidmap $pid 0 $range1_start $combined_count" >/dev/null 2>&1 || rc=$? + assert_failure $rc "newuidmap rejects a range spanning a gap between two /etc/subuid lines" + + container_exec /usr/bin/kill "$pid" 2>/dev/null || true + container_exec rm -f "$pid_file" + container_exec bash -c \ + "grep -v '^${testuser}:' /etc/subuid > /etc/subuid.new && \ + cp /etc/subuid.new /etc/subuid && rm /etc/subuid.new" + delete_test_user "$testuser" +} + +test_newuidmap_subuid_keyed_by_uid() { + log_test "Testing newuidmap honors an /etc/subuid entry keyed by numeric UID" + + local testuser="newidmap_uidkey" + local sub_start=800000 + local sub_count=65536 + create_test_user "$testuser" "TestPass123" + + local uid + uid=$(container_exec id -u "$testuser") + + # Key the entry by the numeric UID instead of the username, as allowed by subuid(5). + container_exec bash -c "echo '${uid}:${sub_start}:${sub_count}' >> /etc/subuid" + + local pid_file="/tmp/newidmapd_test_uidkey_pid" + local pid + pid=$(start_userns_process "$testuser" "$pid_file") + + local rc=0 + container_exec_user "$testuser" /usr/bin/bash -c \ + "newuidmap $pid 0 $sub_start $sub_count" || rc=$? + assert_success $rc "newuidmap accepts a /etc/subuid range keyed by numeric UID" + + local uid_map + uid_map=$(container_exec cat "/proc/$pid/uid_map") + assert_contains "$uid_map" "$sub_start" "uid_map contains UID-keyed range start $sub_start" + + container_exec /usr/bin/kill "$pid" 2>/dev/null || true + container_exec rm -f "$pid_file" + container_exec bash -c \ + "grep -v '^${uid}:' /etc/subuid > /etc/subuid.new && \ + cp /etc/subuid.new /etc/subuid && rm /etc/subuid.new" + delete_test_user "$testuser" +} + +test_newgidmap_subgid_keyed_by_uid() { + log_test "Testing newgidmap honors an /etc/subgid entry keyed by numeric UID" + + local testuser="newidmap_gidkey" + local sub_start=900000 + local sub_count=65536 + create_test_user "$testuser" "TestPass123" + + local uid + uid=$(container_exec id -u "$testuser") + + # /etc/subgid is also keyed by the owning user's UID/name, not by gid. + container_exec bash -c "echo '${uid}:${sub_start}:${sub_count}' >> /etc/subgid" + + local pid_file="/tmp/newidmapd_test_gidkey_pid" + local pid + pid=$(start_userns_process "$testuser" "$pid_file") + + local rc=0 + container_exec_user "$testuser" /usr/bin/bash -c \ + "newgidmap $pid 0 $sub_start $sub_count" || rc=$? + assert_success $rc "newgidmap accepts a /etc/subgid range keyed by numeric UID" + + local gid_map + gid_map=$(container_exec cat "/proc/$pid/gid_map") + assert_contains "$gid_map" "$sub_start" "gid_map contains UID-keyed range start $sub_start" + + container_exec /usr/bin/kill "$pid" 2>/dev/null || true + container_exec rm -f "$pid_file" + container_exec bash -c \ + "grep -v '^${uid}:' /etc/subgid > /etc/subgid.new && \ + cp /etc/subgid.new /etc/subgid && rm /etc/subgid.new" + delete_test_user "$testuser" +} + +# --------------------------------------------------------------------------- # CLI argument validation (no socket connection needed) # --------------------------------------------------------------------------- @@ -397,6 +551,13 @@ rc=0 container_exec newuidmap 1 0 0 >/dev/null 2>&1 || rc=$? assert_failure $rc "newuidmap with incomplete triple exits non-zero" + + # Non-numeric value in a mapping triple (regression test for #32: used to + # crash with a NULL pointer dereference instead of reporting an error) + rc=0 + container_exec newuidmap 1 abc 0 1 >/dev/null 2>&1 || rc=$? + assert_failure $rc "newuidmap with non-numeric mapping value exits non-zero" + assert_not_equals $rc 139 "newuidmap with non-numeric mapping value does not crash (SIGSEGV)" } # --------------------------------------------------------------------------- @@ -423,5 +584,9 @@ run_test test_newgidmap_subgid_range run_test test_newuidmap_wrong_owner run_test test_newuidmap_out_of_range +run_test test_newuidmap_subuid_multiple_ranges +run_test test_newuidmap_subuid_noncontiguous_rejected +run_test test_newuidmap_subuid_keyed_by_uid +run_test test_newgidmap_subgid_keyed_by_uid print_summary
