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

commit c2929d087701dd36f84e8ba5e25ba060466c1c2a
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Wed Aug 15 05:10:12 2018 +0200

    libdpkg, dpkg: Use new pager spawning support
    
    Use it instead of open-coding it, or piping it via a shell invocation,
    which required metacharacter escaping.
---
 debian/changelog |  2 ++
 lib/dpkg/file.c  | 19 +++----------------
 src/configure.c  | 19 ++++++++++++-------
 3 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 06462517a..1d46bb361 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -207,6 +207,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
     - libdpkg: Factor out package stanza printing into its own function.
     - libdpkg: Split pager specific code into its own module.
     - libdpkg: Add pager spawning and reaping support.
+    - Use new pager spawning support instead of open-coding it, or piping it
+      via a shell invocation, which required metacharacter escaping.
   * Build system:
     - Set distribution tarball format to ustar, instead of default v7 format.
     - Mark PO4A and POD2MAN as precious variables.
diff --git a/lib/dpkg/file.c b/lib/dpkg/file.c
index c62c3121f..4b3a24fed 100644
--- a/lib/dpkg/file.c
+++ b/lib/dpkg/file.c
@@ -31,8 +31,6 @@
 
 #include <dpkg/dpkg.h>
 #include <dpkg/i18n.h>
-#include <dpkg/subproc.h>
-#include <dpkg/command.h>
 #include <dpkg/pager.h>
 #include <dpkg/fdio.h>
 #include <dpkg/file.h>
@@ -201,22 +199,11 @@ file_lock(int *lockfd, enum file_lock_flags flags, const 
char *filename,
 void
 file_show(const char *filename)
 {
-       pid_t pid;
+       struct pager *pager;
 
        if (filename == NULL)
                internerr("filename is NULL");
 
-       pid = subproc_fork();
-       if (pid == 0) {
-               struct command cmd;
-               const char *pager;
-
-               pager = pager_get_exec();
-
-               command_init(&cmd, pager, _("showing file on pager"));
-               command_add_arg(&cmd, pager);
-               command_add_arg(&cmd, filename);
-               command_exec(&cmd);
-       }
-       subproc_reap(pid, _("showing file on pager"), SUBPROC_NOCHECK);
+       pager = pager_spawn(_("pager to show file"), filename);
+       pager_reap(pager);
 }
diff --git a/src/configure.c b/src/configure.c
index d021e2040..66019071b 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -198,22 +198,27 @@ show_prompt(const char *cfgfile, const char *realold, 
const char *realnew,
 static void
 show_diff(const char *old, const char *new)
 {
+       struct pager *pager;
        pid_t pid;
 
+       pager = pager_spawn(_("conffile difference visualizer"), NULL);
+
        pid = subproc_fork();
        if (!pid) {
                /* Child process. */
-               char cmdbuf[1024];
-
-               sprintf(cmdbuf, DIFF " -Nu %.250s %.250s | %.250s",
-                       str_quote_meta(old), str_quote_meta(new),
-                       pager_get_exec());
-
-               command_shell(cmdbuf, _("conffile difference visualizer"));
+               struct command cmd;
+
+               command_init(&cmd, DIFF, _("conffile difference visualizer"));
+               command_add_arg(&cmd, DIFF);
+               command_add_arg(&cmd, "-Nu");
+               command_add_arg(&cmd, old);
+               command_add_arg(&cmd, new);
+               command_exec(&cmd);
        }
 
        /* Parent process. */
        subproc_reap(pid, _("conffile difference visualizer"), SUBPROC_NOCHECK);
+       pager_reap(pager);
 }
 
 /**

-- 
Dpkg.Org's dpkg

Reply via email to