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=fddae6d870dc220d446c5a3c22ed0ae083a5e581 commit fddae6d870dc220d446c5a3c22ed0ae083a5e581 Author: Guillem Jover <[email protected]> AuthorDate: Sat Feb 23 04:47:56 2019 +0100 dpkg: Parse and set new DPKG_FORCE environment variable for subprocesses This will make it possible for third-party tools, and also for other dpkg tools to have access to the force options specified for dpkg. Closes: #666147 --- debian/changelog | 2 ++ man/dpkg.man | 9 +++++++++ src/force.c | 10 ++++++++++ src/main.c | 2 ++ 4 files changed, 23 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6dfe1f6f8..6f3f4cec5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ dpkg (1.19.5) UNRELEASED; urgency=medium * start-stop-daemon: Always refuse to parse a world-writable pidfile, except when that is /dev/null. * dpkg: Print the current set of enabled force options on --force-help. + * dpkg: Parse and set new DPKG_FORCE environment variable for subprocesses. + Closes: #666147 * Documentation: - start-stop-daemon(1): Document behavior of --pidfile security checks. Closes: #921557 diff --git a/man/dpkg.man b/man/dpkg.man index 5e4bc6946..bf56510ed 100644 --- a/man/dpkg.man +++ b/man/dpkg.man @@ -911,6 +911,11 @@ Sets the color mode (since dpkg 1.18.5). The currently accepted values are: \fBauto\fP (default), \fBalways\fP and \fBnever\fP. .TP +.B DPKG_FORCE +Sets the force flags (since dpkg 1.19.5). +When this variable is present, no built-in force defaults will be applied. +If the variable is present but empty, all force flags will be disabled. +.TP .B DPKG_FRONTEND_LOCKED Set by a package manager frontend to notify dpkg that it should not acquire the frontend lock (since dpkg 1.19.1). @@ -941,6 +946,10 @@ Defined by \fBdpkg\fP on the maintainer script environment to indicate the \fBdpkg\fP administrative directory to use (since dpkg 1.16.0). This variable is always set to the current \fB\-\-admindir\fP value. .TP +.B DPKG_FORCE +Defined by \fBdpkg\fP on the subprocesses environment to all the currently +enabled force option names separated by commas (since dpkg 1.19.5). +.TP .B DPKG_SHELL_REASON Defined by \fBdpkg\fP on the shell spawned on the conffile prompt to examine the situation (since dpkg 1.15.6). diff --git a/src/force.c b/src/force.c index 15895faf4..2418bd8ac 100644 --- a/src/force.c +++ b/src/force.c @@ -323,10 +323,20 @@ parse_force(const char *value, bool set) void set_force_default(int mask) { + const char *force_env; const struct forceinfo *fip; force_mask = mask; + /* If we get passed force options from the environment, do not + * initialize from the built-in defaults. */ + force_env = getenv("DPKG_FORCE"); + if (force_env != NULL) { + if (force_env[0] != '\0') + parse_force(force_env, 1); + return; + } + for (fip = forceinfos; fip->name; fip++) if (fip->type == FORCETYPE_ENABLED) set_force(fip->flag); diff --git a/src/main.c b/src/main.c index 6ba5c5090..f78cc4099 100644 --- a/src/main.c +++ b/src/main.c @@ -761,6 +761,8 @@ int main(int argc, const char *const *argv) { ohshite(_("unable to setenv for subprocesses")); if (setenv("DPKG_ROOT", instdir, 1) < 0) ohshite(_("unable to setenv for subprocesses")); + if (setenv("DPKG_FORCE", get_force_string(), 1) < 0) + ohshite(_("unable to setenv for subprocesses")); if (!f_triggers) f_triggers = (cipaction->arg_int == act_triggers && *argv) ? -1 : 1; -- Dpkg.Org's dpkg

