diff --git a/mksh-36-alias.patch b/mksh-36-alias.patch new file mode 100644 index 0000000..8b52ce5 --- /dev/null +++ b/mksh-36-alias.patch @@ -0,0 +1,95 @@ +Patch by Thorsten Glaser for mksh <= 36, to solve +some kind of "bug" resulting in command hang in mksh and also high +cpu workload. For more information, please have a look to Red Hat +Bugzilla ID #474115. And this patch is already in upstream version +control system and will be included in upstream's next release. + +--- mksh-36/check.t 2008-10-24 23:36:05.000000000 +0200 ++++ mksh-36/check.t.alias 2008-12-02 22:36:13.000000000 +0100 +@@ -7,7 +7,7 @@ + # http://www.research.att.com/~gsf/public/ifs.sh + + expected-stdout: +- @(#)MIRBSD KSH R36 2008/10/24 ++ @(#)MIRBSD KSH R36 2008/10/24 RedHat-1 + description: + Check version of shell. + stdin: +@@ -151,6 +151,20 @@ + hi + there + --- ++name: alias-9 ++description: ++ Check that recursion is detected/avoided in aliases. ++time-limit: 3 ++stdin: ++ echo -n >tf ++ alias ls=ls ++ ls ++ echo $(ls) ++ exit 0 ++expected-stdout: ++ tf ++ tf ++--- + name: arith-lazy-1 + description: + Check that only one side of ternary operator is evaluated +--- mksh-36/lex.c 2008-10-10 23:31:05.000000000 +0200 ++++ mksh-36/lex.c.alias 2008-12-02 22:33:53.000000000 +0100 +@@ -904,16 +904,24 @@ + /* prefer functions over aliases */ + ktdelete(p); + else { +- Source *s; ++ Source *s = source; + +- for (s = source; s->type == SALIAS; s = s->next) ++ while (s->flags & SF_HASALIAS) + if (s->u.tblp == p) + return LWORD; ++ else ++ s = s->next; + /* push alias expansion */ + s = pushs(SALIAS, source->areap); + s->start = s->str = p->val.s; + s->u.tblp = p; ++ s->flags |= SF_HASALIAS; + s->next = source; ++ if (source->type == SEOF) { ++ /* prevent infinite recursion at EOS */ ++ source->u.tblp = p; ++ source->flags |= SF_HASALIAS; ++ } + source = s; + afree(yylval.cp, ATEMP); + goto Again; +--- mksh-36/sh.h 2008-10-24 23:36:06.000000000 +0200 ++++ mksh-36/sh.h.alias 2008-12-02 22:35:27.000000000 +0100 +@@ -102,7 +102,7 @@ + #ifdef EXTERN + __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.245 2008/10/24 21:35:43 tg Exp $"); + #endif +-#define MKSH_VERSION "R36 2008/10/24" ++#define MKSH_VERSION "R36 2008/10/24 RedHat-1" + + #ifndef MKSH_INCLUDES_ONLY + +@@ -1117,7 +1117,7 @@ + union { + const char **strv; /* string [] */ + struct shf *shf; /* shell file */ +- struct tbl *tblp; /* alias (SALIAS) */ ++ struct tbl *tblp; /* alias (SF_HASALIAS) */ + char *freeme; /* also for SREREAD */ + } u; + int line; /* line number */ +@@ -1148,6 +1148,7 @@ + #define SF_ALIASEND BIT(2) /* faking space at end of alias */ + #define SF_TTY BIT(3) /* type == SSTDIN & it is a tty */ + #define SF_FIRST BIT(4) /* initial state (to ignore UTF-8 BOM) */ ++#define SF_HASALIAS BIT(5) /* u.tblp valid (SALIAS, SEOF) */ + + typedef union { + int i; diff --git a/mksh.spec b/mksh.spec index 84955f0..ee6f62e 100644 --- a/mksh.spec +++ b/mksh.spec @@ -9,6 +9,7 @@ Group: System Environment/Shells URL: http://www.mirbsd.de/%{name}/ Source0: http://www.mirbsd.org/MirOS/dist/mir/%{name}/%{name}-R%{version}.cpio.gz Source1: http://www.mirbsd.org/MirOS/dist/hosted/other/arc4random.c +Patch: mksh-36-alias.patch Requires(post): grep Requires(postun): coreutils, grep BuildRequires: util-linux, ed @@ -28,6 +29,7 @@ bourne shell replacement, pdksh successor and an alternative to the C shell. gzip -dc %{SOURCE0} | cpio -imd mv %{name}/* . && rm -rf %{name} cp -f %{SOURCE1} . +%patch -p1 -b .alias %build CFLAGS="$RPM_OPT_FLAGS" sh Build.sh -r -j @@ -71,6 +73,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/%{name}.1* %changelog +* Tue Dec 02 2008 Robert Scheck 36-2 +- Upstream patch for command hang/high cpu workload (#474115) + * Sat Oct 25 2008 Robert Scheck 36-1 - Upgrade to 36