install: do proper cleanup when strip fails (O.Oprala, B.Voekler, #632444)
This commit is contained in:
parent
bdd83b2e69
commit
bad02099bd
81
coreutils-8.21-install-strip.patch
Normal file
81
coreutils-8.21-install-strip.patch
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
From 3a20f6888575be7059e9acac07d397009e98c213 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ondrej Oprala <ooprala@redhat.com>
|
||||||
|
Date: Fri, 22 Feb 2013 12:48:57 +0000
|
||||||
|
Subject: install: cleanup properly if the strip program failed for any reason
|
||||||
|
|
||||||
|
* src/install.c (strip): Indicate failure with a return code instead
|
||||||
|
of terminating the program.
|
||||||
|
(install_file_in_file): Handle strip's return code and unlink the
|
||||||
|
created file if necessary.
|
||||||
|
* tests/install/strip-program.sh: Add a test to cover the changes.
|
||||||
|
---
|
||||||
|
diff --git a/src/install.c b/src/install.c
|
||||||
|
index 94374df..a5ed7a8 100644
|
||||||
|
--- a/src/install.c
|
||||||
|
+++ b/src/install.c
|
||||||
|
@@ -515,16 +515,17 @@ change_timestamps (struct stat const *src_sb, char const *dest)
|
||||||
|
magic numbers vary so much from system to system that making
|
||||||
|
it portable would be very difficult. Not worth the effort. */
|
||||||
|
|
||||||
|
-static void
|
||||||
|
+static bool
|
||||||
|
strip (char const *name)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
+ bool ok = false;
|
||||||
|
pid_t pid = fork ();
|
||||||
|
|
||||||
|
switch (pid)
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
- error (EXIT_FAILURE, errno, _("fork system call failed"));
|
||||||
|
+ error (0, errno, _("fork system call failed"));
|
||||||
|
break;
|
||||||
|
case 0: /* Child. */
|
||||||
|
execlp (strip_program, strip_program, name, NULL);
|
||||||
|
@@ -532,11 +533,14 @@ strip (char const *name)
|
||||||
|
break;
|
||||||
|
default: /* Parent. */
|
||||||
|
if (waitpid (pid, &status, 0) < 0)
|
||||||
|
- error (EXIT_FAILURE, errno, _("waiting for strip"));
|
||||||
|
+ error (0, errno, _("waiting for strip"));
|
||||||
|
else if (! WIFEXITED (status) || WEXITSTATUS (status))
|
||||||
|
- error (EXIT_FAILURE, 0, _("strip process terminated abnormally"));
|
||||||
|
+ error (0, 0, _("strip process terminated abnormally"));
|
||||||
|
+ else
|
||||||
|
+ ok = true; /* strip succeeded */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
+ return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the user and group ownership of the files to install. */
|
||||||
|
@@ -681,7 +685,12 @@ install_file_in_file (const char *from, const char *to,
|
||||||
|
if (! copy_file (from, to, x))
|
||||||
|
return false;
|
||||||
|
if (strip_files)
|
||||||
|
- strip (to);
|
||||||
|
+ if (! strip (to))
|
||||||
|
+ {
|
||||||
|
+ if (unlink (to) != 0) /* Cleanup. */
|
||||||
|
+ error (EXIT_FAILURE, errno, _("cannot unlink %s"), to);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
if (x->preserve_timestamps && (strip_files || ! S_ISREG (from_sb.st_mode))
|
||||||
|
&& ! change_timestamps (&from_sb, to))
|
||||||
|
return false;
|
||||||
|
diff --git a/tests/install/strip-program.sh b/tests/install/strip-program.sh
|
||||||
|
index 8950d50..5d65373 100755
|
||||||
|
--- a/tests/install/strip-program.sh
|
||||||
|
+++ b/tests/install/strip-program.sh
|
||||||
|
@@ -33,4 +33,8 @@ echo aBc > exp || fail=1
|
||||||
|
ginstall src dest -s --strip-program=./b || fail=1
|
||||||
|
compare exp dest || fail=1
|
||||||
|
|
||||||
|
+# Check that install cleans up properly if strip fails.
|
||||||
|
+ginstall src dest2 -s --strip-program=./FOO && fail=1
|
||||||
|
+test -e dest2 && fail=1
|
||||||
|
+
|
||||||
|
Exit $fail
|
||||||
|
--
|
||||||
|
cgit v0.9.0.2
|
@ -1,7 +1,7 @@
|
|||||||
Summary: A set of basic GNU tools commonly used in shell scripts
|
Summary: A set of basic GNU tools commonly used in shell scripts
|
||||||
Name: coreutils
|
Name: coreutils
|
||||||
Version: 8.21
|
Version: 8.21
|
||||||
Release: 5%{?dist}
|
Release: 6%{?dist}
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
Url: http://www.gnu.org/software/coreutils/
|
Url: http://www.gnu.org/software/coreutils/
|
||||||
@ -14,6 +14,7 @@ Source105: coreutils-colorls.sh
|
|||||||
Source106: coreutils-colorls.csh
|
Source106: coreutils-colorls.csh
|
||||||
|
|
||||||
# From upstream
|
# From upstream
|
||||||
|
Patch1: coreutils-8.21-install-strip.patch
|
||||||
|
|
||||||
# Our patches
|
# Our patches
|
||||||
#general patch to workaround koji build system issues
|
#general patch to workaround koji build system issues
|
||||||
@ -126,6 +127,7 @@ the old GNU fileutils, sh-utils, and textutils packages.
|
|||||||
%setup -q
|
%setup -q
|
||||||
|
|
||||||
# From upstream
|
# From upstream
|
||||||
|
%patch1 -p1 -b .strip
|
||||||
|
|
||||||
# Our patches
|
# Our patches
|
||||||
%patch100 -p1 -b .configure
|
%patch100 -p1 -b .configure
|
||||||
@ -376,7 +378,11 @@ fi
|
|||||||
%{_sbindir}/chroot
|
%{_sbindir}/chroot
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Wed Feb 20 2013 Ondrej Vasik <ovasik@redhat.com> 8.21-4
|
* Sat Feb 23 2013 Ondrej Vasik <ovasik@redhat.com> 8.21-6
|
||||||
|
- install: do proper cleanup when strip fails
|
||||||
|
(O.Oprala, B.Voekler, #632444)
|
||||||
|
|
||||||
|
* Wed Feb 20 2013 Ondrej Vasik <ovasik@redhat.com> 8.21-5
|
||||||
- fix multibyte issue in unexpand(by R.Kollar, #821262)
|
- fix multibyte issue in unexpand(by R.Kollar, #821262)
|
||||||
|
|
||||||
* Mon Feb 18 2013 Ondrej Oprala <ooprala@redhat.com> 8.21-4
|
* Mon Feb 18 2013 Ondrej Oprala <ooprala@redhat.com> 8.21-4
|
||||||
|
Loading…
Reference in New Issue
Block a user