From e00612c1b723e38225beb0cd4863349b4136aa3b Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Tue, 7 May 2019 13:44:22 +0200 Subject: [PATCH] Update to bash-5.0 patchlevel 7 --- bash-5.0-patch-3.patch | 202 +++++++++++++++++++++++++++++++++++++++++ bash-5.0-patch-4.patch | 42 +++++++++ bash-5.0-patch-5.patch | 102 +++++++++++++++++++++ bash-5.0-patch-6.patch | 39 ++++++++ bash-5.0-patch-7.patch | 51 +++++++++++ bash.spec | 7 +- 6 files changed, 441 insertions(+), 2 deletions(-) create mode 100644 bash-5.0-patch-3.patch create mode 100644 bash-5.0-patch-4.patch create mode 100644 bash-5.0-patch-5.patch create mode 100644 bash-5.0-patch-6.patch create mode 100644 bash-5.0-patch-7.patch diff --git a/bash-5.0-patch-3.patch b/bash-5.0-patch-3.patch new file mode 100644 index 0000000..509f52e --- /dev/null +++ b/bash-5.0-patch-3.patch @@ -0,0 +1,202 @@ +From fcf6ae7d069a64741e9484cf219d7fe95de9e796 Mon Sep 17 00:00:00 2001 +From: Chet Ramey +Date: Tue, 19 Mar 2019 10:05:39 -0400 +Subject: [PATCH] Bash-5.0 patch 3: improvements when globbing directory names + containing backslashes + +--- + bashline.c | 2 +- + lib/glob/glob.c | 25 +++++++++++++++++++++---- + lib/glob/glob.h | 1 + + lib/glob/glob_loop.c | 23 ++++++++++++++++------- + patchlevel.h | 2 +- + pathexp.c | 16 ++++++++++++---- + 6 files changed, 52 insertions(+), 17 deletions(-) + +diff --git a/bashline.c b/bashline.c +index 75e79f1a..824ea9d9 100644 +--- a/bashline.c ++++ b/bashline.c +@@ -3752,7 +3752,7 @@ completion_glob_pattern (string) + continue; + + case '\\': +- if (*string == 0) ++ if (*string++ == 0) + return (0); + } + +diff --git a/lib/glob/glob.c b/lib/glob/glob.c +index 22d90a5c..398253b5 100644 +--- a/lib/glob/glob.c ++++ b/lib/glob/glob.c +@@ -1061,7 +1061,7 @@ glob_filename (pathname, flags) + char *directory_name, *filename, *dname, *fn; + unsigned int directory_len; + int free_dirname; /* flag */ +- int dflags; ++ int dflags, hasglob; + + result = (char **) malloc (sizeof (char *)); + result_size = 1; +@@ -1110,9 +1110,12 @@ glob_filename (pathname, flags) + free_dirname = 1; + } + ++ hasglob = 0; + /* If directory_name contains globbing characters, then we +- have to expand the previous levels. Just recurse. */ +- if (directory_len > 0 && glob_pattern_p (directory_name)) ++ have to expand the previous levels. Just recurse. ++ If glob_pattern_p returns != [0,1] we have a pattern that has backslash ++ quotes but no unquoted glob pattern characters. We dequote it below. */ ++ if (directory_len > 0 && (hasglob = glob_pattern_p (directory_name)) == 1) + { + char **directories, *d, *p; + register unsigned int i; +@@ -1175,7 +1178,7 @@ glob_filename (pathname, flags) + if (d[directory_len - 1] == '/') + d[directory_len - 1] = '\0'; + +- directories = glob_filename (d, dflags); ++ directories = glob_filename (d, dflags|GX_RECURSE); + + if (free_dirname) + { +@@ -1332,6 +1335,20 @@ only_filename: + free (directory_name); + return (NULL); + } ++ /* If we have a directory name with quoted characters, and we are ++ being called recursively to glob the directory portion of a pathname, ++ we need to dequote the directory name before returning it so the ++ caller can read the directory */ ++ if (directory_len > 0 && hasglob == 2 && (flags & GX_RECURSE) != 0) ++ { ++ dequote_pathname (directory_name); ++ directory_len = strlen (directory_name); ++ } ++ ++ /* We could check whether or not the dequoted directory_name is a ++ directory and return it here, returning the original directory_name ++ if not, but we don't do that yet. I'm not sure it matters. */ ++ + /* Handle GX_MARKDIRS here. */ + result[0] = (char *) malloc (directory_len + 1); + if (result[0] == NULL) +diff --git a/lib/glob/glob.h b/lib/glob/glob.h +index b9462333..56ac08ba 100644 +--- a/lib/glob/glob.h ++++ b/lib/glob/glob.h +@@ -30,6 +30,7 @@ + #define GX_NULLDIR 0x100 /* internal -- no directory preceding pattern */ + #define GX_ADDCURDIR 0x200 /* internal -- add passed directory name */ + #define GX_GLOBSTAR 0x400 /* turn on special handling of ** */ ++#define GX_RECURSE 0x800 /* internal -- glob_filename called recursively */ + + extern int glob_pattern_p __P((const char *)); + extern char **glob_vector __P((char *, char *, int)); +diff --git a/lib/glob/glob_loop.c b/lib/glob/glob_loop.c +index 7d6ae211..3a4f4f1e 100644 +--- a/lib/glob/glob_loop.c ++++ b/lib/glob/glob_loop.c +@@ -26,10 +26,10 @@ INTERNAL_GLOB_PATTERN_P (pattern) + { + register const GCHAR *p; + register GCHAR c; +- int bopen; ++ int bopen, bsquote; + + p = pattern; +- bopen = 0; ++ bopen = bsquote = 0; + + while ((c = *p++) != L('\0')) + switch (c) +@@ -55,13 +55,22 @@ INTERNAL_GLOB_PATTERN_P (pattern) + + case L('\\'): + /* Don't let the pattern end in a backslash (GMATCH returns no match +- if the pattern ends in a backslash anyway), but otherwise return 1, +- since the matching engine uses backslash as an escape character +- and it can be removed. */ +- return (*p != L('\0')); ++ if the pattern ends in a backslash anyway), but otherwise note that ++ we have seen this, since the matching engine uses backslash as an ++ escape character and it can be removed. We return 2 later if we ++ have seen only backslash-escaped characters, so interested callers ++ know they can shortcut and just dequote the pathname. */ ++ if (*p != L('\0')) ++ { ++ p++; ++ bsquote = 1; ++ continue; ++ } ++ else /* (*p == L('\0')) */ ++ return 0; + } + +- return 0; ++ return bsquote ? 2 : 0; + } + + #undef INTERNAL_GLOB_PATTERN_P +diff --git a/patchlevel.h b/patchlevel.h +index a988d852..e7e960c1 100644 +--- a/patchlevel.h ++++ b/patchlevel.h +@@ -25,6 +25,6 @@ + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh + looks for to find the patch level (for the sccs version string). */ + +-#define PATCHLEVEL 2 ++#define PATCHLEVEL 3 + + #endif /* _PATCHLEVEL_H_ */ +diff --git a/pathexp.c b/pathexp.c +index b51729a7..c1bf2d89 100644 +--- a/pathexp.c ++++ b/pathexp.c +@@ -65,11 +65,11 @@ unquoted_glob_pattern_p (string) + { + register int c; + char *send; +- int open; ++ int open, bsquote; + + DECLARE_MBSTATE; + +- open = 0; ++ open = bsquote = 0; + send = string + strlen (string); + + while (c = *string++) +@@ -100,7 +100,14 @@ unquoted_glob_pattern_p (string) + can be removed by the matching engine, so we have to run it through + globbing. */ + case '\\': +- return (*string != 0); ++ if (*string != '\0' && *string != '/') ++ { ++ bsquote = 1; ++ string++; ++ continue; ++ } ++ else if (*string == 0) ++ return (0); + + case CTLESC: + if (*string++ == '\0') +@@ -117,7 +124,8 @@ unquoted_glob_pattern_p (string) + ADVANCE_CHAR_P (string, send - string); + #endif + } +- return (0); ++ ++ return (bsquote ? 2 : 0); + } + + /* Return 1 if C is a character that is `special' in a POSIX ERE and needs to +-- +2.17.2 + diff --git a/bash-5.0-patch-4.patch b/bash-5.0-patch-4.patch new file mode 100644 index 0000000..8993833 --- /dev/null +++ b/bash-5.0-patch-4.patch @@ -0,0 +1,42 @@ +From 16c907aa3bb427618733e5a6f2f4e2fc5a3488d3 Mon Sep 17 00:00:00 2001 +From: Chet Ramey +Date: Sat, 20 Apr 2019 14:24:28 -0400 +Subject: [PATCH] Bash-5.0 patch 4: the wait builtin without arguments only + waits for known children the shell started + +--- + jobs.c | 4 +--- + patchlevel.h | 2 +- + 2 files changed, 2 insertions(+), 4 deletions(-) + +diff --git a/jobs.c b/jobs.c +index ce2bdf24..ae3c54c6 100644 +--- a/jobs.c ++++ b/jobs.c +@@ -2488,10 +2488,8 @@ wait_for_background_pids () + r = wait_for (last_procsub_child->pid); + wait_procsubs (); + reap_procsubs (); +-#if 1 ++#if 0 + /* We don't want to wait indefinitely if we have stopped children. */ +- /* XXX - should add a loop that goes through the list of process +- substitutions and waits for each proc in turn before this code. */ + if (any_stopped == 0) + { + /* Check whether or not we have any unreaped children. */ +diff --git a/patchlevel.h b/patchlevel.h +index e7e960c1..c059f0bd 100644 +--- a/patchlevel.h ++++ b/patchlevel.h +@@ -25,6 +25,6 @@ + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh + looks for to find the patch level (for the sccs version string). */ + +-#define PATCHLEVEL 3 ++#define PATCHLEVEL 4 + + #endif /* _PATCHLEVEL_H_ */ +-- +2.17.2 + diff --git a/bash-5.0-patch-5.patch b/bash-5.0-patch-5.patch new file mode 100644 index 0000000..1fb4faf --- /dev/null +++ b/bash-5.0-patch-5.patch @@ -0,0 +1,102 @@ +From 41f5420db7a911fb0833be693205f4db41f05434 Mon Sep 17 00:00:00 2001 +From: Chet Ramey +Date: Sat, 20 Apr 2019 14:25:52 -0400 +Subject: [PATCH] Bash-5.0 patch 5: prevent optimizing forks away too + aggressively + +--- + builtins/evalstring.c | 26 +++++++++++++++++++++++--- + command.h | 1 + + execute_cmd.c | 2 ++ + patchlevel.h | 2 +- + 4 files changed, 27 insertions(+), 4 deletions(-) + +diff --git a/builtins/evalstring.c b/builtins/evalstring.c +index 1496eeec..cadc9bc0 100644 +--- a/builtins/evalstring.c ++++ b/builtins/evalstring.c +@@ -100,12 +100,22 @@ should_suppress_fork (command) + ((command->flags & CMD_INVERT_RETURN) == 0)); + } + ++int ++can_optimize_connection (command) ++ COMMAND *command; ++{ ++ return (*bash_input.location.string == '\0' && ++ (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') && ++ command->value.Connection->second->type == cm_simple); ++} ++ + void + optimize_fork (command) + COMMAND *command; + { + if (command->type == cm_connection && +- (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR) && ++ (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') && ++ (command->value.Connection->second->flags & CMD_TRY_OPTIMIZING) && + should_suppress_fork (command->value.Connection->second)) + { + command->value.Connection->second->flags |= CMD_NO_FORK; +@@ -412,8 +422,18 @@ parse_and_execute (string, from_file, flags) + command->flags |= CMD_NO_FORK; + command->value.Simple->flags |= CMD_NO_FORK; + } +- else if (command->type == cm_connection) +- optimize_fork (command); ++ ++ /* Can't optimize forks out here execept for simple commands. ++ This knows that the parser sets up commands as left-side heavy ++ (&& and || are left-associative) and after the single parse, ++ if we are at the end of the command string, the last in a ++ series of connection commands is ++ command->value.Connection->second. */ ++ else if (command->type == cm_connection && can_optimize_connection (command)) ++ { ++ command->value.Connection->second->flags |= CMD_TRY_OPTIMIZING; ++ command->value.Connection->second->value.Simple->flags |= CMD_TRY_OPTIMIZING; ++ } + #endif /* ONESHOT */ + + /* See if this is a candidate for $( value.Connection->connector == OR_OR) && + (exec_result != EXECUTION_SUCCESS))) + { ++ optimize_fork (command); ++ + second = command->value.Connection->second; + if (ignore_return && second) + second->flags |= CMD_IGNORE_RETURN; +diff --git a/patchlevel.h b/patchlevel.h +index c059f0bd..1bc098b8 100644 +--- a/patchlevel.h ++++ b/patchlevel.h +@@ -25,6 +25,6 @@ + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh + looks for to find the patch level (for the sccs version string). */ + +-#define PATCHLEVEL 4 ++#define PATCHLEVEL 5 + + #endif /* _PATCHLEVEL_H_ */ +-- +2.17.2 + diff --git a/bash-5.0-patch-6.patch b/bash-5.0-patch-6.patch new file mode 100644 index 0000000..bfd8460 --- /dev/null +++ b/bash-5.0-patch-6.patch @@ -0,0 +1,39 @@ +From dfd2cc6ac5558e252af0a7cb829a9629bf782e17 Mon Sep 17 00:00:00 2001 +From: Chet Ramey +Date: Sat, 20 Apr 2019 14:27:00 -0400 +Subject: [PATCH] Bash-5.0 patch 6: allow building with SYSLOG_HISTORY defined + without defining SYSLOG_SHOPT + +--- + builtins/shopt.def | 2 +- + patchlevel.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/builtins/shopt.def b/builtins/shopt.def +index f6dc6f97..1c485361 100644 +--- a/builtins/shopt.def ++++ b/builtins/shopt.def +@@ -122,7 +122,7 @@ extern int assoc_expand_once; + extern int array_expand_once; + #endif + +-#if defined (SYSLOG_HISTORY) && defined (SYSLOG_SHOPT) ++#if defined (SYSLOG_HISTORY) + extern int syslog_history; + #endif + +diff --git a/patchlevel.h b/patchlevel.h +index 1bc098b8..14bff9fc 100644 +--- a/patchlevel.h ++++ b/patchlevel.h +@@ -25,6 +25,6 @@ + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh + looks for to find the patch level (for the sccs version string). */ + +-#define PATCHLEVEL 5 ++#define PATCHLEVEL 6 + + #endif /* _PATCHLEVEL_H_ */ +-- +2.17.2 + diff --git a/bash-5.0-patch-7.patch b/bash-5.0-patch-7.patch new file mode 100644 index 0000000..2a4315e --- /dev/null +++ b/bash-5.0-patch-7.patch @@ -0,0 +1,51 @@ +From 3ba697465bc74fab513a26dea700cc82e9f4724e Mon Sep 17 00:00:00 2001 +From: Chet Ramey +Date: Sat, 20 Apr 2019 14:27:56 -0400 +Subject: [PATCH] Bash-5.0 patch 7: fix exec builtin leaving the terminal in + the wrong process group + +--- + jobs.c | 12 +++++------- + patchlevel.h | 2 +- + 2 files changed, 6 insertions(+), 8 deletions(-) + +diff --git a/jobs.c b/jobs.c +index ae3c54c6..6bc31dca 100644 +--- a/jobs.c ++++ b/jobs.c +@@ -4837,15 +4837,13 @@ void + end_job_control () + { + if (job_control) +- { +- terminate_stopped_jobs (); ++ terminate_stopped_jobs (); + +- if (original_pgrp >= 0) +- give_terminal_to (original_pgrp, 1); +- } ++ if (original_pgrp >= 0 && terminal_pgrp != original_pgrp) ++ give_terminal_to (original_pgrp, 1); + +- if (original_pgrp >= 0) +- setpgid (0, original_pgrp); ++ if (original_pgrp >= 0 && setpgid (0, original_pgrp) == 0) ++ shell_pgrp = original_pgrp; + } + + /* Restart job control by closing shell tty and reinitializing. This is +diff --git a/patchlevel.h b/patchlevel.h +index 14bff9fc..deb9c5b7 100644 +--- a/patchlevel.h ++++ b/patchlevel.h +@@ -25,6 +25,6 @@ + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh + looks for to find the patch level (for the sccs version string). */ + +-#define PATCHLEVEL 6 ++#define PATCHLEVEL 7 + + #endif /* _PATCHLEVEL_H_ */ +-- +2.17.2 + diff --git a/bash.spec b/bash.spec index ce35907..41d53e0 100644 --- a/bash.spec +++ b/bash.spec @@ -1,5 +1,5 @@ #% define beta_tag rc2 -%define patchleveltag .2 +%define patchleveltag .7 %define baseversion 5.0 %bcond_without tests @@ -20,7 +20,7 @@ Source3: dot-bash_logout # Official upstream patches # Patches are converted to apply with '-p1' -%{lua:for i=1,2 do print(string.format("Patch%u: bash-5.0-patch-%u.patch\n", i, i)) end} +%{lua:for i=1,7 do print(string.format("Patch%u: bash-5.0-patch-%u.patch\n", i, i)) end} # Other patches # We don't want to add '/etc:/usr/etc' in standard utils path. @@ -308,6 +308,9 @@ end %{_libdir}/pkgconfig/%{name}.pc %changelog +* Tue May 07 2019 Siteshwar Vashisht - 5.0.7-1 +- Update to bash-5.0 patchlevel 7 + * Thu Feb 14 2019 Siteshwar Vashisht - 5.0.2-1 - Rebase to bash 5.0 Resolves: #1675080