The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / bash / 0033-patchlevel-33.patch
1 From http://ftp.gnu.org/pub/gnu/bash/bash-4.3-patches/bash43-033
2
3 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
4
5                              BASH PATCH REPORT
6                              =================
7
8 Bash-Release:   4.3
9 Patch-ID:       bash43-033
10
11 Bug-Reported-by:        mickael9@gmail.com, Jan Rome <jan.rome@gmail.com>
12 Bug-Reference-ID:       <20140907224046.382ED3610CC@mickael-laptop.localdomain>,
13                         <540D661D.50908@gmail.com>
14 Bug-Reference-URL:      http://lists.gnu.org/archive/html/bug-bash/2014-09/msg00029.html
15                         http://lists.gnu.org/archive/html/bug-bash/2014-09/msg00030.html
16
17 Bug-Description:
18
19 Bash does not clean up the terminal state in all cases where bash or
20 readline  modifies it and bash is subsequently terminated by a fatal signal.
21 This happens when the `read' builtin modifies the terminal settings, both
22 when readline is active and when it is not.  It occurs most often when a script
23 installs a trap that exits on a signal without re-sending the signal to itself.
24
25 Patch (apply with `patch -p0'):
26
27 *** a/bash-4.3-patched/shell.c  2014-01-14 08:04:32.000000000 -0500
28 --- b/shell.c   2014-12-22 10:27:50.000000000 -0500
29 ***************
30 *** 74,77 ****
31 --- 74,78 ----
32   
33   #if defined (READLINE)
34 + #  include <readline/readline.h>
35   #  include "bashline.h"
36   #endif
37 ***************
38 *** 910,913 ****
39 --- 912,923 ----
40     fflush (stderr);
41   
42 +   /* Clean up the terminal if we are in a state where it's been modified. */
43 + #if defined (READLINE)
44 +   if (RL_ISSTATE (RL_STATE_TERMPREPPED) && rl_deprep_term_function)
45 +     (*rl_deprep_term_function) ();
46 + #endif
47 +   if (read_tty_modified ())
48 +     read_tty_cleanup ();
49
50     /* Do trap[0] if defined.  Allow it to override the exit status
51        passed to us. */
52 *** a/bash-4.3-patched/builtins/read.def        2014-10-01 12:57:38.000000000 -0400
53 --- b/builtins/read.def 2014-12-22 10:48:54.000000000 -0500
54 ***************
55 *** 141,148 ****
56   int sigalrm_seen;
57   
58 ! static int reading;
59   static SigHandler *old_alrm;
60   static unsigned char delim;
61   
62   /* In all cases, SIGALRM just sets a flag that we check periodically.  This
63      avoids problems with the semi-tricky stuff we do with the xfree of
64 --- 141,150 ----
65   int sigalrm_seen;
66   
67 ! static int reading, tty_modified;
68   static SigHandler *old_alrm;
69   static unsigned char delim;
70   
71 + static struct ttsave termsave;
72
73   /* In all cases, SIGALRM just sets a flag that we check periodically.  This
74      avoids problems with the semi-tricky stuff we do with the xfree of
75 ***************
76 *** 189,193 ****
77     SHELL_VAR *var;
78     TTYSTRUCT ttattrs, ttset;
79 -   struct ttsave termsave;
80   #if defined (ARRAY_VARS)
81     WORD_LIST *alist;
82 --- 191,194 ----
83 ***************
84 *** 222,226 ****
85     USE_VAR(lastsig);
86   
87 !   sigalrm_seen = reading = 0;
88   
89     i = 0;              /* Index into the string that we are reading. */
90 --- 223,227 ----
91     USE_VAR(lastsig);
92   
93 !   sigalrm_seen = reading = tty_modified = 0;
94   
95     i = 0;              /* Index into the string that we are reading. */
96 ***************
97 *** 439,442 ****
98 --- 440,445 ----
99           goto assign_vars;
100         }
101 +       if (interactive_shell == 0)
102 +       initialize_terminating_signals ();
103         old_alrm = set_signal_handler (SIGALRM, sigalrm);
104         add_unwind_protect (reset_alarm, (char *)NULL);
105 ***************
106 *** 483,487 ****
107 --- 486,493 ----
108           if (i < 0)
109             sh_ttyerror (1);
110 +         tty_modified = 1;
111           add_unwind_protect ((Function *)ttyrestore, (char *)&termsave);
112 +         if (interactive_shell == 0)
113 +           initialize_terminating_signals ();
114         }
115       }
116 ***************
117 *** 498,502 ****
118 --- 504,511 ----
119         sh_ttyerror (1);
120   
121 +       tty_modified = 1;
122         add_unwind_protect ((Function *)ttyrestore, (char *)&termsave);
123 +       if (interactive_shell == 0)
124 +       initialize_terminating_signals ();
125       }
126   
127 ***************
128 *** 589,592 ****
129 --- 598,603 ----
130           else
131             lastsig = 0;
132 +         if (terminating_signal && tty_modified)
133 +           ttyrestore (&termsave);     /* fix terminal before exiting */
134           CHECK_TERMSIG;
135           eof = 1;
136 ***************
137 *** 979,982 ****
138 --- 990,1007 ----
139   {
140     ttsetattr (ttp->fd, ttp->attrs);
141 +   tty_modified = 0;
142 + }
143
144 + void
145 + read_tty_cleanup ()
146 + {
147 +   if (tty_modified)
148 +     ttyrestore (&termsave);
149 + }
150
151 + int
152 + read_tty_modified ()
153 + {
154 +   return (tty_modified);
155   }
156   
157 *** ./bash-4.3-patched/builtins/common.h        2014-10-01 12:57:47.000000000 -0400
158 --- b/builtins/common.h 2014-12-22 10:10:14.000000000 -0500
159 ***************
160 *** 123,126 ****
161 --- 141,148 ----
162   extern void getopts_reset __P((int));
163   
164 + /* Functions from read.def */
165 + extern void read_tty_cleanup __P((void));
166 + extern int read_tty_modified __P((void));
167
168   /* Functions from set.def */
169   extern int minus_o_option_value __P((char *));
170 *** a/bash-4.3-patched/bashline.c       2014-05-14 09:22:39.000000000 -0400
171 --- b/bashline.c        2014-09-08 11:28:56.000000000 -0400
172 ***************
173 *** 203,206 ****
174 --- 203,207 ----
175   extern int array_needs_making;
176   extern int posixly_correct, no_symbolic_links;
177 + extern int sigalrm_seen;
178   extern char *current_prompt_string, *ps1_prompt;
179   extern STRING_INT_ALIST word_token_alist[];
180 ***************
181 *** 4209,4214 ****
182     /* If we're going to longjmp to top_level, make sure we clean up readline.
183        check_signals will call QUIT, which will eventually longjmp to top_level,
184 !      calling run_interrupt_trap along the way. */
185 !   if (interrupt_state)
186       rl_cleanup_after_signal ();
187     bashline_reset_event_hook ();
188 --- 4262,4268 ----
189     /* If we're going to longjmp to top_level, make sure we clean up readline.
190        check_signals will call QUIT, which will eventually longjmp to top_level,
191 !      calling run_interrupt_trap along the way.  The check for sigalrm_seen is
192 !      to clean up the read builtin's state. */
193 !   if (terminating_signal || interrupt_state || sigalrm_seen)
194       rl_cleanup_after_signal ();
195     bashline_reset_event_hook ();
196 *** a/bash-4.3-patched/sig.c    2014-01-10 15:06:06.000000000 -0500
197 --- b/sig.c     2014-09-08 11:26:33.000000000 -0400
198 ***************
199 *** 533,538 ****
200     /* Set the event hook so readline will call it after the signal handlers
201        finish executing, so if this interrupted character input we can get
202 !      quick response. */
203 !   if (interactive_shell && interactive && no_line_editing == 0)
204       bashline_set_event_hook ();
205   #endif
206 --- 533,540 ----
207     /* Set the event hook so readline will call it after the signal handlers
208        finish executing, so if this interrupted character input we can get
209 !      quick response.  If readline is active or has modified the terminal we
210 !      need to set this no matter what the signal is, though the check for
211 !      RL_STATE_TERMPREPPED is possibly redundant. */
212 !   if (RL_ISSTATE (RL_STATE_SIGHANDLER) || RL_ISSTATE (RL_STATE_TERMPREPPED))
213       bashline_set_event_hook ();
214   #endif
215 *** a/bash-4.3/patchlevel.h     2012-12-29 10:47:57.000000000 -0500
216 --- b/patchlevel.h      2014-03-20 20:01:28.000000000 -0400
217 ***************
218 *** 26,30 ****
219      looks for to find the patch level (for the sccs version string). */
220   
221 ! #define PATCHLEVEL 32
222   
223   #endif /* _PATCHLEVEL_H_ */
224 --- 26,30 ----
225      looks for to find the patch level (for the sccs version string). */
226   
227 ! #define PATCHLEVEL 33
228   
229   #endif /* _PATCHLEVEL_H_ */