diff --git a/0001-crontab-Fix-backup-failure-when-cache-directory-mis.patch b/0001-crontab-Fix-backup-failure-when-cache-directory-mis.patch new file mode 100644 index 0000000..793b9d3 --- /dev/null +++ b/0001-crontab-Fix-backup-failure-when-cache-directory-mis.patch @@ -0,0 +1,40 @@ +From 8ad9e9179ec806ec1031c94b218ae6ef9dc11c28 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= +Date: Wed, 2 Jul 2025 11:58:41 +0200 +Subject: [PATCH] crontab: Fix backup failure when ~/.cache directory missing + +Create ~/.cache parent directory before creating ~/.cache/crontab backup +directory to prevent "mkdir: No such file or directory" errors when users +edit crontabs and their cache directory doesn't exist. +--- + src/crontab.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/crontab.c b/src/crontab.c +index c11dc81..f6fae67 100644 +--- a/src/crontab.c ++++ b/src/crontab.c +@@ -578,7 +578,20 @@ static int backup_crontab(const char *crontab_path) { + exit(ERROR_EXIT); + } + ++ /* Try to create parent directory if needed */ + if (stat(backup_dir, &sb) < OK && errno == ENOENT) { ++ char *last_slash = strrchr(backup_dir, '/'); ++ if (last_slash && last_slash != backup_dir) { ++ char parent_dir[MAX_FNAME]; ++ size_t parent_len = last_slash - backup_dir; ++ ++ if (parent_len < sizeof(parent_dir)) { ++ strncpy(parent_dir, backup_dir, parent_len); ++ parent_dir[parent_len] = '\0'; ++ mkdir(parent_dir, 0755); ++ } ++ } ++ + if (OK != mkdir(backup_dir, 0755)) { + fprintf(stderr, "%s: ", backup_dir); + perror("mkdir"); +-- +2.50.1 + diff --git a/cronie.spec b/cronie.spec index 13af359..f417e57 100644 --- a/cronie.spec +++ b/cronie.spec @@ -25,6 +25,9 @@ Patch: re-introduce-the-test-for-existence-of-file.patch Patch: fix-range-parsing.patch Patch: move_parsing_code.patch +# https://github.com/cronie-crond/cronie/pull/206 +Patch: 0001-crontab-Fix-backup-failure-when-cache-directory-mis.patch + Requires: dailyjobs %if %{with selinux}