This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch master in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=244dec2a9c3f6e9e3fcec1d7ef34f72cda013121 commit 244dec2a9c3f6e9e3fcec1d7ef34f72cda013121 (HEAD -> master) Author: Guillem Jover <[email protected]> AuthorDate: Sat Jun 27 16:07:35 2020 +0200 u-a: Create log directory if missing This will help with installation bootstrapping when dpkg has not yet been unpacked, or when using chroot style installations. Otherwise on normal operation this should never trigger. --- debian/changelog | 1 + utils/update-alternatives.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/debian/changelog b/debian/changelog index 5e8b25b48..da4740c40 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ dpkg (1.20.2) UNRELEASED; urgency=medium * update-alternatives: Create alternatives directory (/etc/alternatives) if it is missing, to help with installation bootstrapping. Reported by Johannes Schauer <[email protected]>. + * update-alternatives: Create the log directory if it is missing. * Code internals: - update-alternatives: Move log_msg() after make_path() so that we can use the latter. diff --git a/utils/update-alternatives.c b/utils/update-alternatives.c index 098ddefc5..71e4879d6 100644 --- a/utils/update-alternatives.c +++ b/utils/update-alternatives.c @@ -502,6 +502,16 @@ log_msg(const char *fmt, ...) if (fh_log == NULL) { fh_log = fopen(log_file, "a"); + if (fh_log == NULL && errno == ENOENT) { + char *log_dir = xdirname(log_file); + + if (make_path(log_dir, 0755) < 0) + syserr(_("cannot create log directory '%s'"), + log_dir); + free(log_dir); + + fh_log = fopen(log_file, "a"); + } if (fh_log == NULL && errno != EACCES) syserr(_("cannot append to '%s'"), log_file); } -- Dpkg.Org's dpkg

