From 98439f64664dc73386b34ff410651f4e34f8517c Mon Sep 17 00:00:00 2001 From: Ondrej Vasik Date: Mar 11 2008 16:48:56 +0000 Subject: dd doubleclose + other way to keep user defined LS_COLORS --- diff --git a/coreutils-colorls.csh b/coreutils-colorls.csh index ea2be8b..7a41d8f 100755 --- a/coreutils-colorls.csh +++ b/coreutils-colorls.csh @@ -1,7 +1,7 @@ # color-ls initialization -if ( $?LS_COLORS ) then - if ( "$LS_COLORS" != "" ) then - #do not override user specified LS_COLORS and use them +if ( $?USER_LS_COLORS ) then + if ( "$USER_LS_COLORS" != "" ) then + #When USER_LS_COLORS set, do not override user specified LS_COLORS but use them goto finish endif endif diff --git a/coreutils-colorls.sh b/coreutils-colorls.sh index ed8a365..dbb853c 100755 --- a/coreutils-colorls.sh +++ b/coreutils-colorls.sh @@ -1,7 +1,7 @@ # color-ls initialization -#do not override user LS_COLORS, but use them. -if [ -z "$LS_COLORS" ]; then +#do not override user LS_COLORS, but use them when USER_LS_COLORS is set. +if [ -z "$USER_LS_COLORS" ]; then alias ll='ls -l' 2>/dev/null alias l.='ls -d .*' 2>/dev/null diff --git a/coreutils-dddoubleclose.patch b/coreutils-dddoubleclose.patch new file mode 100644 index 0000000..3e37027 --- /dev/null +++ b/coreutils-dddoubleclose.patch @@ -0,0 +1,45 @@ +diff -urNp coreutils-6.9-orig/src/dd.c coreutils-6.9/src/dd.c +--- coreutils-6.9-orig/src/dd.c ++++ coreutils-6.9/src/dd.c +@@ -391,6 +391,25 @@ static char const ebcdic_to_ascii[] = + '\070', '\071', '\372', '\373', '\374', '\375', '\376', '\377' + }; + ++/* True if we need to close the standard output *stream*. */ ++static bool close_stdout_required = true; ++ ++/* The only reason to close the standard output *stream* is if ++ parse_long_options fails (as it does for --help or --version). ++ In any other case, dd uses only the STDOUT_FILENO file descriptor, ++ and the "cleanup" function calls "close (STDOUT_FILENO)". ++ Closing the file descriptor and then letting the usual atexit-run ++ close_stdout function call "fclose (stdout)" would result in a ++ harmless failure of the close syscall (with errno EBADF). ++ This function serves solely to avoid the unnecessary close_stdout ++ call, once parse_long_options has succeeded. */ ++static void ++maybe_close_stdout (void) ++{ ++ if (close_stdout_required) ++ close_stdout (); ++} ++ + void + usage (int status) + { +@@ -1639,12 +1658,14 @@ main (int argc, char **argv) + textdomain (PACKAGE); + + /* Arrange to close stdout if parse_long_options exits. */ +- atexit (close_stdout); ++ atexit (maybe_close_stdout); + + page_size = getpagesize (); + + parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION, + usage, AUTHORS, (char const *) NULL); ++ close_stdout_required = false; ++ + if (getopt_long (argc, argv, "", NULL, NULL) != -1) + usage (EXIT_FAILURE); + diff --git a/coreutils.spec b/coreutils.spec index 336d1db..da2d9a5 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: The GNU core utilities: a set of tools commonly used in shell scripts Name: coreutils Version: 6.9 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv2+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -21,6 +21,7 @@ Patch1: coreutils-futimens.patch Patch2: coreutils-ls-x.patch Patch3: coreutils-6.9-cp-i-u.patch Patch4: coreutils-6.9-du-ls-upstream.patch +Patch5: coreutils-dddoubleclose.patch # Our patches Patch100: coreutils-chgrp.patch @@ -95,6 +96,7 @@ the old GNU fileutils, sh-utils, and textutils packages. %patch2 -p1 -b .ls-x %patch3 -p1 -b .cp-i-u %patch4 -p1 -b .du-ls +%patch5 -p1 -b .doubleclose # Our patches %patch100 -p1 -b .chgrp @@ -285,6 +287,10 @@ fi /sbin/runuser %changelog +* Tue Mar 11 2008 Ondrej Vasik 6.9-8 +- other way to keep user defined LS_COLORS(#430827) +- fixed harmless double close stdout in dd(#436368) + * Tue Mar 04 2008 Ondrej Vasik 6.9-7 - su-l/runuser-l pam file usage a bit documented(#368721) - added several missing colored TERMS(#239266)