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=e566532b04c4d263001f798b4cea3488be00400c

commit e566532b04c4d263001f798b4cea3488be00400c
Author: Guillem Jover <[email protected]>
AuthorDate: Sat Feb 23 04:47:12 2019 +0100

    dpkg: Print the current set of enabled force options on --force-help
    
    This will make it possible to reason more easily about what is
    getting enabled.
---
 debian/changelog |  1 +
 src/force.c      | 25 +++++++++++++++++++++++++
 src/force.h      |  2 ++
 3 files changed, 28 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 2b13af898..28b884502 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,7 @@ dpkg (1.19.5) UNRELEASED; urgency=medium
     use errno for error reporting or not.
   * 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.
   * Documentation:
     - start-stop-daemon(1): Document behavior of --pidfile security checks.
       Closes: #921557
diff --git a/src/force.c b/src/force.c
index 13c53f3d6..f3e4d902d 100644
--- a/src/force.c
+++ b/src/force.c
@@ -217,6 +217,25 @@ static const struct forceinfo {
        }
 };
 
+char *
+get_force_string(void)
+{
+       const struct forceinfo *fip;
+       struct varbuf vb = VARBUF_INIT;
+
+       for (fip = forceinfos; fip->name; fip++) {
+               if (fip->opt == NULL || !*fip->opt)
+                       continue;
+
+               if (vb.used)
+                       varbuf_add_char(&vb, ',');
+               varbuf_add_str(&vb, fip->name);
+       }
+       varbuf_end_str(&vb);
+
+       return varbuf_detach(&vb);
+}
+
 static inline void
 print_forceinfo_line(int type, const char *name, const char *desc)
 {
@@ -260,6 +279,12 @@ set_force(const struct cmdinfo *cip, const char *value)
 "WARNING - use of options marked [!] can seriously damage your installation.\n"
 "Forcing options marked [*] are enabled by default.\n"));
                m_output(stdout, _("<standard output>"));
+
+               printf(_(
+"\n"
+"Currently enabled options:\n"
+" %s\n"), get_force_string());
+
                exit(0);
        }
 
diff --git a/src/force.h b/src/force.h
index 2e9a84d9e..769163bd6 100644
--- a/src/force.h
+++ b/src/force.h
@@ -50,6 +50,8 @@ extern int fc_removereinstreq;
 extern int fc_script_chrootless;
 extern int fc_unsafe_io;
 
+char *
+get_force_string(void);
 void
 set_force(const struct cmdinfo *cip, const char *value);
 

-- 
Dpkg.Org's dpkg

Reply via email to