Browse Source

dpkg: Search for debsig-verify in PATH instead of using an absolute path

Check that the command exists in the PATH before using it. This makes it
future proof, and friendlier to other systems that might not be using
the same filesystem layout.

It also makes it possible to use a local debsig-verify in a path such as
/usr/local/bin.
Guillem Jover 11 years ago
parent
commit
94e11e11b5
3 changed files with 6 additions and 4 deletions
  1. 1 0
      debian/changelog
  2. 1 1
      lib/dpkg/dpkg.h
  3. 4 3
      src/unpack.c

+ 1 - 0
debian/changelog

@@ -43,6 +43,7 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
     Closes: #719845
     Closes: #719845
     - Use it with dpkg --recursive option.
     - Use it with dpkg --recursive option.
   * Unify start-stop-daemon --help output with the rest of the tools.
   * Unify start-stop-daemon --help output with the rest of the tools.
+  * Search for debsig-verify in PATH instead of using an absolute path.
   * Portability:
   * Portability:
     - Move DPKG_ADMINDIR environment variable name out from update-alternatives
     - Move DPKG_ADMINDIR environment variable name out from update-alternatives
       code, to make life easier for non-dpkg-based systems.
       code, to make life easier for non-dpkg-based systems.

+ 1 - 1
lib/dpkg/dpkg.h

@@ -104,7 +104,7 @@ DPKG_BEGIN_DECLS
 #define DPKGSTAT	"dpkg-statoverride"
 #define DPKGSTAT	"dpkg-statoverride"
 #define DPKGTRIGGER	"dpkg-trigger"
 #define DPKGTRIGGER	"dpkg-trigger"
 #define DPKG		"dpkg"
 #define DPKG		"dpkg"
-#define DEBSIGVERIFY	"/usr/bin/debsig-verify"
+#define DEBSIGVERIFY	"debsig-verify"
 
 
 #define RM		"rm"
 #define RM		"rm"
 #define CAT		"cat"
 #define CAT		"cat"

+ 4 - 3
src/unpack.c

@@ -129,17 +129,18 @@ deb_reassemble(const char **filename, const char **pfilename)
 static void
 static void
 deb_verify(const char *filename)
 deb_verify(const char *filename)
 {
 {
-  struct stat stab;
   pid_t pid;
   pid_t pid;
 
 
-  if (stat(DEBSIGVERIFY, &stab) < 0)
+  /* We have to check on every unpack, in case the debsig-verify package
+   * gets installed or removed. */
+  if (!find_command(DEBSIGVERIFY))
     return;
     return;
 
 
   printf(_("Authenticating %s ...\n"), filename);
   printf(_("Authenticating %s ...\n"), filename);
   fflush(stdout);
   fflush(stdout);
   pid = subproc_fork();
   pid = subproc_fork();
   if (!pid) {
   if (!pid) {
-    execl(DEBSIGVERIFY, DEBSIGVERIFY, "-q", filename, NULL);
+    execlp(DEBSIGVERIFY, DEBSIGVERIFY, "-q", filename, NULL);
     ohshite(_("unable to execute %s (%s)"),
     ohshite(_("unable to execute %s (%s)"),
             _("package signature verification"), DEBSIGVERIFY);
             _("package signature verification"), DEBSIGVERIFY);
   } else {
   } else {