Hi,
 this patch address the problem mentioned here by John Reiser:
https://bugzilla.redhat.com/show_bug.cgi?id=632444 .
Install now checks the $PATH or the path given for the strip
program and turns off the -s option if none is found.

Thanks,
Ondrej.
>From 26a9a711526ad5d387b2341a4b0ef19e405da9b3 Mon Sep 17 00:00:00 2001
From: Ondrej Oprala <[email protected]>
Date: Thu, 21 Feb 2013 16:17:14 +0100
Subject: [PATCH] install: check for the existence of a strip program

* bootstrap.conf: Add findprog to the list of modules.
* src/install.c (main): Check the path for the strip tool if no
explicit strip tool is specified, otherwise check the current directory.
* tests/install/strip-program.sh: Add a test case to exercise
the changes.
---
 bootstrap.conf                 |  1 +
 src/install.c                  | 25 +++++++++++++++++++++++++
 tests/install/strip-program.sh |  8 ++++++++
 3 files changed, 34 insertions(+)

diff --git a/bootstrap.conf b/bootstrap.conf
index bb6c145..59636e9 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -86,6 +86,7 @@ gnulib_modules="
   filemode
   filenamecat
   filevercmp
+  findprog
   fnmatch-gnu
   fopen-safer
   fprintftime
diff --git a/src/install.c b/src/install.c
index 94374df..02d8c47 100644
--- a/src/install.c
+++ b/src/install.c
@@ -20,11 +20,13 @@
 #include <stdio.h>
 #include <getopt.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <signal.h>
 #include <pwd.h>
 #include <grp.h>
 #include <selinux/selinux.h>
 #include <sys/wait.h>
+#include <unistd.h>
 
 #include "system.h"
 #include "backupfile.h"
@@ -32,6 +34,7 @@
 #include "cp-hash.h"
 #include "copy.h"
 #include "filenamecat.h"
+#include "findprog.h"
 #include "full-read.h"
 #include "mkancesdirs.h"
 #include "mkdir-p.h"
@@ -968,6 +971,28 @@ main (int argc, char **argv)
       usage (EXIT_FAILURE);
     }
 
+  if (strip_files)
+    {
+      /* if specified with a path.  */
+      if (strip_program_specified && strchr (strip_program, '/'))
+        {
+          struct stat dst_st;
+          if (lstat (strip_program, &dst_st) == -1)
+            strip_files = false;
+        }
+      else
+        {
+          char *path = (char *)find_in_path (strip_program);
+          if (STREQ (path, strip_program))
+            strip_files = false;
+          else
+            free (path);
+        }
+      if (!strip_files)
+        error (0, 0, _("WARNING: %s not found - ignoring the -s option"),
+              quote (strip_program));
+    }
+
   if (copy_only_if_needed && extra_mode (mode))
     error (0, 0, _("the --compare (-C) option is ignored when you"
                    " specify a mode with non-permission bits"));
diff --git a/tests/install/strip-program.sh b/tests/install/strip-program.sh
index 8950d50..5d7e16b 100755
--- a/tests/install/strip-program.sh
+++ b/tests/install/strip-program.sh
@@ -33,4 +33,12 @@ echo aBc > exp || fail=1
 ginstall src dest -s --strip-program=./b || fail=1
 compare exp dest || fail=1
 
+#check that only stripping fails with a nonexistent strip program specified
+umask 0022
+chmod 600 src
+ginstall src dest -s -m 755 --strip-program=./FOO &>/dev/null || fail=1
+exp_perm='-rwxr-xr-x'
+dest_perm="$(ls -ld dest|cut -b-10)"
+test $exp_perm = $dest_perm || fail=1
+
 Exit $fail
-- 
1.7.11.7

Reply via email to