On 05/11/2026 05:56, Collin Funk wrote:
diff --git a/NEWS b/NEWS
index ae5c8e32a..14b1206dc 100644
--- a/NEWS
+++ b/NEWS
@@ -95,6 +95,14 @@ GNU coreutils NEWS -*-
outline -*-
before invoking 'strip' instead of using a umask of zero.
[This bug was present in "the beginning".]
+ 'install -D --strip' runs the strip program from the current working directory
+ when the source and destination are absolute paths. Previously, it would run
+ the strip program from the parent directory of the destination file, which
+ could lead to executing the incorrect program if the PATH environment
variable
+ was set to an empty string or a relative file name was given to the
+ --strip-program option.
+ [bug introduced in coreutils-6.2]
That was a bit confusing to me, also $PATH only needs to have an empty entry,
not be fully empty. I'd go with this:
'install -D --strip' now runs the strip program based in the initial working
directory, even when the source and destination are absolute paths.
Previously, it would run the strip program from the parent directory of the
destination file, which could execute the incorrect program if $PATH allowed
the current directory, or --strip-program specified a relative path.
[bug introduced in coreutils-6.2]
diff --git a/src/install.c b/src/install.c
index ffe2aee27..13621574c 100644
--- a/src/install.c
+++ b/src/install.c
@@ -762,9 +762,14 @@ static bool
mkancesdirs_safe_wd (char const *from, char *to, struct cp_options *x,
bool save_always)
{
+ /* Check whether we have to save the current working directory.
+ When using --strip, we must save the current working directory
+ since STRIP_PROGRAM may be relative or $PATH may be set to an
+ empty string, meaning STRIP_PROGRAM may be found and executed
+ in the current working directory. */
bool save_working_directory =
- save_always
- || ! (IS_ABSOLUTE_FILE_NAME (from) && IS_ABSOLUTE_FILE_NAME (to));
+ (save_always || strip_files
+ || ! (IS_ABSOLUTE_FILE_NAME (from) && IS_ABSOLUTE_FILE_NAME (to)));
I was wondering why this didn't do:
(strip_files && !IS_ABSOLUTE_FILE_NAME (split_program))
Though I suppose an absolute split program could load
config files or whatever relative to the current dir,
so it's more consistent to always run strip from the initial dir.
The comment doesn't mention any of that, and only stated
the obvious to me, so therefore I'd replace the 5 line comment like:
diff --git a/src/install.c b/src/install.c
index 13621574c..06a51e5b2 100644
--- a/src/install.c
+++ b/src/install.c
@@ -762,13 +762,8 @@ static bool
mkancesdirs_safe_wd (char const *from, char *to, struct cp_options *x,
bool save_always)
{
- /* Check whether we have to save the current working directory.
- When using --strip, we must save the current working directory
- since STRIP_PROGRAM may be relative or $PATH may be set to an
- empty string, meaning STRIP_PROGRAM may be found and executed
- in the current working directory. */
bool save_working_directory =
- (save_always || strip_files
+ (save_always || strip_files /* strip may be, or access relative files. */
|| ! (IS_ABSOLUTE_FILE_NAME (from) && IS_ABSOLUTE_FILE_NAME (to)));
struct savewd wd;
cheers,
Padraig