diff options
author | Guillem Jover <guillem@debian.org> | 2018-08-15 05:10:12 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2018-08-30 03:14:08 +0200 |
commit | c2929d087701dd36f84e8ba5e25ba060466c1c2a (patch) | |
tree | e3abf5cc55c4228ece239c846a90af2994b9c074 | |
parent | 3b8cd0ea54e2027fd7c972e3edcbbc8bb43afa52 (diff) | |
download | dpkg-c2929d087701dd36f84e8ba5e25ba060466c1c2a.tar.gz |
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.
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | lib/dpkg/file.c | 19 | ||||
-rw-r--r-- | 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); } /** |