Package: cron Version: 3.0pl1-200ubuntu1 Severity: normal Tags: patch X-Debbugs-Cc: [email protected]
Dear Maintainer, When orphaned crontabs exist, cron adds them to the orphans list without checking if they are already present. When the list grows sufficiently large, it can cause delayed jobs and excessive nss requests. The attached patch adds a check for whether an entry is already present in the list before adding it, which prevents the list from growing over time.
Origin: vendor, https://git.almalinux.org/rpms/cronie/src/commit/847f386cc7baa45e9eec46fe2c294a838922a9de/cronie-1.4.12-refresh-users.patch Reviewed-by: Willow Carlson-Huber <[email protected]> Description: Prevent adding duplicate orphans to the orphans list. Previously, the orphans list would grow whenever the database reloaded while orphans were present, eventually resulting in cron hammering nss-systemd with requests and delaying jobs. Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/cron/+bug/2174449 --- a/database.c +++ b/database.c @@ -617,10 +617,41 @@ } } +static int +find_orphan(const char *uname, const char *fname, const char *tabname) { + orphan *o; + + for (o = orphans; o != NULL; o = o->next) { + if (uname && o->uname) { + if (strcmp(uname, o->uname) != 0) + continue; + } else if (uname != o->uname) + continue; + + if (fname && o->fname) { + if (strcmp(fname, o->fname) != 0) + continue; + } else if (fname != o->fname) + continue; + + if (tabname && o->tabname) { + if (strcmp(tabname, o->tabname) != 0) + continue; + } else if (tabname != o->tabname) + continue; + return 1; + } + + return 0; +} + static void add_orphan(const char *uname, const char *fname, const char *tabname) { orphan *o; + if (find_orphan(uname, fname, tabname)) + return; + o = calloc(1, sizeof(*o)); if (o == NULL) return;

