From a60a2493b195e3c37441248e729c5c332049cf9b08c89b3817431252c774136e Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Fri, 20 Jan 2012 17:45:26 +0000 Subject: [PATCH 1/4] . OBS-URL: https://build.opensuse.org/package/show/shells/ksh?expand=0&rev=79 --- INIT.2011-06-30.tar.bz2 | 3 - INIT.2012-01-01.tar.bz2 | 3 + ast-ksh.2011-06-30.tar.bz2 | 3 - ast-ksh.2012-01-01.tar.bz2 | 3 + ast-msgcc.2011-06-30.tar.bz2 | 3 - ast-msgcc.2012-01-01.tar.bz2 | 3 + check-build.sh | 11 +++ ksh.changes | 82 +++++++++++++++++++ ksh.spec | 93 ++++++++++++++++------ ksh93-aso.dif | 118 ++++++++++++++++++++++++++++ ksh93-heredoc.dif | 77 +++--------------- ksh93-ia64.dif | 31 +++++++- ksh93-reg.dif | 24 ++---- ksh93-shift_ijs.dif | 6 +- ksh93-suid_exec.dif | 30 +++---- ksh93-vm.dif | 59 ++++++++++++++ ksh93.dif | 11 +++ leak1.sh | 2 +- leak2.sh | 2 +- rpmlintrc | 6 ++ sigexec.c | 15 ++++ workaround-stupid-build-system.diff | 34 ++++---- 22 files changed, 462 insertions(+), 157 deletions(-) delete mode 100644 INIT.2011-06-30.tar.bz2 create mode 100644 INIT.2012-01-01.tar.bz2 delete mode 100644 ast-ksh.2011-06-30.tar.bz2 create mode 100644 ast-ksh.2012-01-01.tar.bz2 delete mode 100644 ast-msgcc.2011-06-30.tar.bz2 create mode 100644 ast-msgcc.2012-01-01.tar.bz2 create mode 100644 check-build.sh create mode 100644 ksh93-aso.dif create mode 100644 ksh93-vm.dif diff --git a/INIT.2011-06-30.tar.bz2 b/INIT.2011-06-30.tar.bz2 deleted file mode 100644 index 7f1d64e..0000000 --- a/INIT.2011-06-30.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fb28fef39dc8545d03f8fc4d20b490f94a85267f17a77583e428bd83c3c2935f -size 294704 diff --git a/INIT.2012-01-01.tar.bz2 b/INIT.2012-01-01.tar.bz2 new file mode 100644 index 0000000..79f9a4b --- /dev/null +++ b/INIT.2012-01-01.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:654c2f7b3a3166142b47bf60f108b732024c2c7c1bdffc044582f250a0600926 +size 296293 diff --git a/ast-ksh.2011-06-30.tar.bz2 b/ast-ksh.2011-06-30.tar.bz2 deleted file mode 100644 index 987d826..0000000 --- a/ast-ksh.2011-06-30.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a1e5670ef12985f90d6564da14a8c274ea71c5b9559d90466c5475ee4c25cd98 -size 1544488 diff --git a/ast-ksh.2012-01-01.tar.bz2 b/ast-ksh.2012-01-01.tar.bz2 new file mode 100644 index 0000000..93ddd16 --- /dev/null +++ b/ast-ksh.2012-01-01.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4620fbd035d3c85d80a1bc8559e464111ebac9fe6beec06fb44d5c8ced20f416 +size 1571615 diff --git a/ast-msgcc.2011-06-30.tar.bz2 b/ast-msgcc.2011-06-30.tar.bz2 deleted file mode 100644 index 037bb97..0000000 --- a/ast-msgcc.2011-06-30.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c89ca42d226367d087870f7a4f5712a52cc1bfb79d103ed40b85ca3ac0d0afbb -size 129233 diff --git a/ast-msgcc.2012-01-01.tar.bz2 b/ast-msgcc.2012-01-01.tar.bz2 new file mode 100644 index 0000000..2ad6fa9 --- /dev/null +++ b/ast-msgcc.2012-01-01.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:60572e0165faf8bc54ace6e0d3930a52c51b71ea600dae2ee551d017dcf6de6e +size 129201 diff --git a/check-build.sh b/check-build.sh new file mode 100644 index 0000000..50df5c8 --- /dev/null +++ b/check-build.sh @@ -0,0 +1,11 @@ +#!/bin/bash +test $(ulimit -l) -lt 64 && exit 1 +test $(ulimit -s) -lt 8192 && exit 1 +if test $(getconf LONG_BIT) -le 32 ; then + test $(ulimit -m) -lt 6852272 && exit 1 + test $(ulimit -v) -lt 5010688 && exit 1 +else + test $(ulimit -m) -lt 10471232 && exit 1 + test $(ulimit -v) -lt 6683794 && exit 1 +fi +exit 0 diff --git a/ksh.changes b/ksh.changes index 216a45b..841d4f2 100644 --- a/ksh.changes +++ b/ksh.changes @@ -1,3 +1,85 @@ +------------------------------------------------------------------- +Fri Jan 20 14:49:47 UTC 2012 - werner@suse.de + +- Update to 2012-01-01 of ksh93u+ which includes some of our patches + 12-01-01 A timing problem with >; has been fixed. + 12-01-01 A macro expansion memory leak has been fixed. + 11-12-26 A bug in array assignments of the form arr=( $arr[i] ...) in which + arr was not unset before the assignment has been fixed. + 11-12-20 A number of code changes were made based on the results of errors + indicated by static code analysis. + 11-12-13 In vi edit mode a lteral can now be entered by preceding it + with a backshash. + 11-12-13 When tab is entered for completion after a ' or ", the ' and " + characters are no longer deleted. + 11-12-07 A bug in which a program in the current direcotry with a . in the + name could fail to execute when both PATH and FPATH end with :. has + been fixed. + 11-12-07 I fixed a bug in which a variable expansion in a large here-document + could be expanded to a null string. + 11-12-06 An optimization to read was added in the case the the read command + was redirected from a file. + 11-12-06 Changes were made to make the line limit for read unlimited by + default. + 11-12-05 A bug in which unsetting an array variable did not completely clear + the variable in some cases has been fixed. + 11-12-02 +The printf alternative character # when applied to the %q format will + quote argument in a form suitable for a field in a .csv format file. + 11-12-02 +A -S option was added to read to be able to read .csv format files. + 11-11-28 A bug in which redirection of standard error in a function called from + command substitution caused standard error to be lost has ben fixed. + 11-11-21 [[ (-n foo) ]] no longer requires a space before (. + 11-11-11 The readonly attribute for a variable now applies to compound + assignments to that variable. + 11-11-07 Changes were made to reduce the stack size to allow deeper function + recursion. + 11-10-10 +Added alternate flag to printf %H for encoding of URI's. + 11-10-10 A bug which could lead to a core dump when the shell was invoked + with more than twenty five open files has been fixed. + 11-10-06 A bug in the scoping of name references in functions called by other + functions has been fixed. + 11-10-05 A bug in which wait on a pid may return the exit status of an + earlier background job with that pid instead has been fixed. + 11-09-22 A bug in which a read timed out with TMOUT did not always restore + the terminal state has been fixed. + 11-09-21 An optimization that allowed the last command in a script to use + the same process id as the script has been eliminated. + 11-09-21 Added letoctal option that enables the let command to recognize + octal constants starting with 0. + 11-09-20 A bug in which ${var.} could cause a core dump has been fixed. + 11-09-20 A bug with SHOPT_EDPREDICT when neither vi or emacs was enabled for + lines beginning with # when in a multibyte locale has been fixed. + 11-09-20 A bug in emacs edit mode with SHOPT_EDPREDICT that would cause + history searches matching comments lines to generate predictions + has been fixed. Only user typed comment lines generate predictions. + 11-09-20 A bug in emacs edit mode with a search that matches a comment line + that could cause a core dump has been fixed. + 11-09-16 A bug in which a command name ending in .. could cause the shell to + abort has been fixed. + 11-09-16 The characters ! + - % and @ in file names are no longer escaped with + file name completion. + 11-09-13 The let command no longer treats numbers starting with 0 as octal + constants. + 11-09-08 A bug in which printf "%R" could cause a core dump for invalid shell + patterns has been fixed. + 11-08-09 With set -u, ${var#pattern} reported that var was unset for special + variables. + 11-08-03 A bug in which the shell did not preserve the exit status for a + coprocess has been fixed. + 11-08-02 A bug in the saving and restoring of IFS in command substitution that + cause case a core dump has been fixed. + 11-07-21 Modified the 10-08-27 bug fix so that background jobs started in for + and while loops created interactively generate completion messages. + 11-07-20 I fixed a bug in here documents in which multi-byte characters that + crossed buffer boundaries were not processed correctly. +- Extend workaround for bug in glibc with signbit() macro that is that + the inlined part for long doubles does not work on IA64 +- Extend check for __sync_fetch_and_add gcc builtins for uint64_t, uint16_t, + and uint8_t to avoid those functions is missed in gcc from older SLES versions +- Avoid to have to large default mimimum region size at an initial memory mapping +- Avoid MAP_FIXED on IA-64 and S/390x, use MAP_32BIT +- Avoid compiler options which increase the risk of memory leaks + ------------------------------------------------------------------- Sun Dec 4 23:00:26 UTC 2011 - agraf@suse.com diff --git a/ksh.spec b/ksh.spec index 555d419..6c12d1a 100644 --- a/ksh.spec +++ b/ksh.spec @@ -1,7 +1,7 @@ # # spec file for package ksh # -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,6 +26,13 @@ BuildRequires: bind-libs libbz2-devel %if %suse_version > 1120 BuildRequires: update-alternatives %endif +# /bin/ex and /bin/ed required for build +BuildRequires: ed +%if %suse_version > 1020 +BuildRequires: vim-base +%else +BuildRequires: vim +%endif Url: http://www.research.att.com/~gsf/download/ License: CPL-1.0 Group: System/Shells @@ -40,9 +47,9 @@ Version: 93u Release: 1 Summary: Korn Shell BuildRoot: %{_tmppath}/%{name}-%{version}-build -Source: INIT.2011-06-30.tar.bz2 -Source1: ast-ksh.2011-06-30.tar.bz2 -Source2: ast-msgcc.2011-06-30.tar.bz2 +Source: INIT.2012-01-01.tar.bz2 +Source1: ast-ksh.2012-01-01.tar.bz2 +Source2: ast-msgcc.2012-01-01.tar.bz2 Source3: CPL Source10: leak1.sh Source11: leak2.sh @@ -71,6 +78,8 @@ Patch16: ksh93-gcc.dif Patch17: ksh93-heredoc.dif Patch18: ksh93-jobs.dif Patch19: ksh93-reg.dif +Patch20: ksh93-aso.dif +Patch21: ksh93-vm.dif Patch42: ksh-locale.patch %global use_suid_exe 0 %global use_locale 0 @@ -143,6 +152,10 @@ find share/ -type d -a -empty | xargs -r rm -vrf %patch17 %patch18 %patch19 +%patch20 +%patch21 +find -type f -a -name Mamfile | \ + xargs sed -ri '/exec.*-I-D/{s@(-I)(-D)([^0]*)(0[^[:blank:]]+)@\1\3@}' %build AR="ar" @@ -153,12 +166,24 @@ find share/ -type d -a -empty | xargs -r rm -vrf SUSE_ASNEEDED=0 export AR CC PATH LANG TMPDIR SUSE_ASNEEDED # + # Remove optimizer which cause runtime leaks in ksh + # + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-funwind-tables/}" + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-fasynchronous-unwind-tables/}" + # + # Check for a clean signal environment for runtime tests + # + ps s $$ 1>&2 typeset -i IGNORED=0x$(ps --no-headers -o ignored $$) - typeset -i SIGPIPE=0x1000 - if ((IGNORED & SIGPIPE)) ; then + typeset -i SIGMASK=0x0 + + let "SIGMASK|=(1<<($(kill -l PIPE)-1))" + let "SIGMASK|=(1<<($(kill -l URG) -1))" + let "SIGMASK|=(1<<($(kill -l XFSZ)-1))" + + if ((IGNORED & SIGMASK)) ; then # Warn and show signal state of this working shell - echo Warning: signal SIGPIPE is ignored by this shell 1>&2 - ps s $$ 1>&2 + echo Warning: signals are ignored by this shell 1>&2 echo Warning: try to solve this 1>&2 ${CC:-gcc} ${RPM_OPT_FLAGS} -o sigexec %{S:42} for fd in /proc/$$/fd/*; do @@ -167,6 +192,7 @@ find share/ -type d -a -empty | xargs -r rm -vrf set -- $(readlink $fd) exec -a $SHELL ./sigexec $SHELL ${1+"$@"} fi + ps s $$ 1>&2 nobuiltin=${TMPDIR:-/tmp}/nobuiltin set -C (cat<<-EOF @@ -202,21 +228,20 @@ find share/ -type d -a -empty | xargs -r rm -vrf case "${!var}" in *${flag}*) return esac + set -o noclobber case "$flag" in -Wl,*) - set -o noclobber - echo 'int main () { return 0; }' > ldtest.c - if ${CC:-gcc} -Werror $RPM_OPT_FLAGS $flag -o /dev/null -xc ldtest.c > /dev/null 2>&1 ; then + if echo 'int main () { return 0; }' | \ + ${CC:-gcc} -Werror $flag -o /dev/null -xc - > /dev/null 2>&1 ; then eval $var=\${$var:+\$$var\ }$flag fi - set +o noclobber - rm -f ldtest.c ;; *) - if ${CC:-gcc} -Werror $RPM_OPT_FLAGS $flag -S -o /dev/null -xc /dev/null > /dev/null 2>&1 ; then + if ${CC:-gcc} -Werror $flag -S -o /dev/null -xc /dev/null > /dev/null 2>&1 ; then eval $var=\${$var:+\$$var\ }$flag fi esac + set +o noclobber } # # If _you_ are knowing how to fix this in the autogenerated @@ -255,31 +280,39 @@ find share/ -type d -a -empty | xargs -r rm -vrf LARGEFILE="$(getconf LFS_CFLAGS)" case "$RPM_ARCH" in i[3456]86) - RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O2} -m32" + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O2}" + cflags -m32 RPM_OPT_FLAGS HOSTTYPE=linux.i386 ;; x86_64) - RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O2} -m64" + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O2}" + cflags -m64 RPM_OPT_FLAGS HOSTTYPE=linux.i386-64 ;; ia64) RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O}" + cflags -mlp64 RPM_OPT_FLAGS + cflags -mno-volatile-asm-stop RPM_OPT_FLAGS HOSTTYPE=linux.ia64 ;; s390) - RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O} -m31" + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O}" + cflags -m31 RPM_OPT_FLAGS HOSTTYPE=linux.s390 ;; s390*) - RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O} -m64" + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O}" + cflags -m64 RPM_OPT_FLAGS HOSTTYPE=linux.s390-64 ;; ppc|powerpc) - RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O} -mno-powerpc64" + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O}" + cflags -mno-powerpc64 RPM_OPT_FLAGS HOSTTYPE=linux.powerpc ;; ppc64|powerpc64) - RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O} -mpowerpc64" + RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-O[s0-9]/-O}" + cflags -mpowerpc64 RPM_OPT_FLAGS HOSTTYPE=linux.powerpc64 ;; *) @@ -297,6 +330,10 @@ find share/ -type d -a -empty | xargs -r rm -vrf cflags -fno-strict-aliasing RPM_OPT_FLAGS cflags -fno-zero-initialized-in-bss RPM_OPT_FLAGS cflags -fno-delete-null-pointer-checks RPM_OPT_FLAGS + cflags -fsigned-bitfields RPM_OPT_FLAGS + cflags -fsigned-chars RPM_OPT_FLAGS + cflags -fsigned-zeros RPM_OPT_FLAGS + cflags -ftree-loop-linear RPM_OPT_FLAGS cflags -g2 RPM_OPT_FLAGS cflags -pipe RPM_OPT_FLAGS cflags -Wl,-O2 LDFLAGS @@ -305,6 +342,7 @@ find share/ -type d -a -empty | xargs -r rm -vrf cflags -Wl,-warn-common LDSOFLG cflags -Wl,--as-needed LDSOFLG cflags -Wl,--hash-size=8599 LDSOFLG + cflags -Wl,-Bsymbolic-functions LDSOFLG cflags -Wl,-rpath,/%{_lib}/ast LDSOFLG RPM_OPT_FLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE $LARGEFILE" RPM_OPT_FLAGS="$RPM_OPT_FLAGS $IGNORE $FEATURE" @@ -312,6 +350,8 @@ find share/ -type d -a -empty | xargs -r rm -vrf mam_cc_OPTIMIZE=-pipe export mam_cc_L mam_cc_OPTIMIZE HOSTTYPE LDFLAGS RPM_OPT_FLAGS UNIVERSE printenv + getconf PAGESIZE + bin/package make CCFLAGS="$RPM_OPT_FLAGS" HOSTTYPE="$HOSTTYPE" AR="$AR" CC="$CC" root=$(echo ${PWD}/arch/linux*) test -d $root || exit 1 @@ -403,14 +443,18 @@ find share/ -type d -a -empty | xargs -r rm -vrf popd %endif mkdir -p share/locale/C/LC_MESSAGES + includes="-I$(cpp -print-search-dirs | sed -rn 's@^install:[[:blank:]]@@p')include" + includes="$includes $(find $root -name FEATURE -printf ' -I%h')" + includes="$includes -I/usr/include/linux" sed -rn "\@mamake -C cmd/ksh93@,\@mamake -C@ { - s@^\+ g?cc@$SHELL msgcc -M-set=ast@ + s@^\+ g?cc@$SHELL msgcc -M-set=ast $includes@ s@[[:blank:]]-c[[:blank:]]([^[:blank:]\.]+/([^[:blank:]\.\/]+))\.c@ -c \1\.c -o msgs/\2\.mso@p }" ${root}/lib/package/gen/make.out > src/cmd/ksh93/doit pushd src/cmd/ksh93 mkdir msgs - $SHELL -x ./doit - $SHELL -x msgcc -o libshell.msg msgs/*.mso + ${root}/lib/probe/C/pp/probe $(type -p gcc) > pp_default.h + $SHELL ./doit + $SHELL msgcc -o libshell.msg msgs/*.mso rm -rf msgs/ popd msggen share/locale/C/LC_MESSAGES/libshell src/cmd/ksh93/libshell.msg @@ -532,6 +576,9 @@ find share/ -type d -a -empty | xargs -r rm -vrf test -e etc/bash.bashrc && ln -sf bash.bashrc etc/ksh.kshrc || true %if %suse_version > 1120 %{_sbindir}/update-alternatives \ +%if %suse_version > 1210 + --force \ +%endif --install /bin/ksh ksh /%{_lib}/ast/bin/ksh 20 \ --slave %{_bindir}/ksh usr-bin-ksh /%{_lib}/ast/bin/ksh \ --slave %{_mandir}/man1/ksh.1.gz ksh.1.gz %{_mandir}/man1/ksh93.1.gz diff --git a/ksh93-aso.dif b/ksh93-aso.dif new file mode 100644 index 0000000..3dc029a --- /dev/null +++ b/ksh93-aso.dif @@ -0,0 +1,118 @@ +--- src/lib/libast/features/aso ++++ src/lib/libast/features/aso 2012-01-18 11:31:07.856479000 +0000 +@@ -1,12 +1,17 @@ + # ast atomic scalar operations feature tests + + if aso note{ gcc 4.1+ memory atomic operations model }end link{ ++ #include + int main() + { +- unsigned int i = 0; +- return __sync_fetch_and_add(&i,7); ++ uint8_t i = 0; ++ uint16_t j = 0; ++ uint32_t l = 0; ++ uint64_t m = 0; ++ return __sync_fetch_and_add(&i,7)+__sync_fetch_and_add(&j,7)+__sync_fetch_and_add(&l,7)+__sync_fetch_and_add(&m,7); + } + }end && { ++ #include + #define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n) + #define _aso_inc8(p) __sync_fetch_and_add(p,1) + #define _aso_dec8(p) __sync_fetch_and_sub(p,1) +@@ -26,6 +31,7 @@ if aso note{ gcc 4.1+ memory atomic oper + #endif + } + elif aso note{ atomic_cas_64 }end link{ ++ #include + #include + int main() + { +@@ -34,6 +40,7 @@ elif aso note{ atomic_cas_64 + return atomic_cas_64(&i, 0, 1) != 0 || atomic_add_32_nv(&j, 1) != 1; + } + }end && { ++ #include + #include + #define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) + #define _aso_inc8(p) atomic_add_8_nv(p,1) +@@ -54,6 +61,7 @@ elif aso note{ atomic_cas_64 + #endif + } + elif aso note{ atomic_cas_32 }end link{ ++ #include + #include + int main() + { +@@ -61,6 +69,7 @@ elif aso note{ atomic_cas_32 + return atomic_cas_32(&i, 0, 1) != 0 || atomic_add_32_nv(&i, 1) != 1; + } + }end && { ++ #include + #include + #define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) + #define _aso_inc8(p) atomic_add_8_nv(p,1) +@@ -74,6 +83,7 @@ elif aso note{ atomic_cas_32 + #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + } + elif aso -latomic note{ atomic_cas_64 with -latomic }end link{ ++ #include + #include + int main() + { +@@ -82,6 +92,7 @@ elif aso -latomic note{ atomi + return atomic_cas_64(&i, 0, 1) != 0 || atomic_add_32_nv(&j, 1) != 1; + } + }end && { ++ #include + #include + #define _REQ_atomic + #define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) +@@ -103,6 +114,7 @@ elif aso -latomic note{ atomi + #endif + } + elif aso note{ atomic_cas_32 with -latomic }end link{ ++ #include + #include + int main() + { +@@ -110,6 +122,7 @@ elif aso note{ atomic_cas_32 + return atomic_cas_32(&i, 0, 1) != 0 || atomic_add_32_nv(&i, 1) != 1; + } + }end && { ++ #include + #include + #define _REQ_atomic + #define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) +@@ -124,6 +137,7 @@ elif aso note{ atomic_cas_32 + #define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) + } + elif aso note{ cas64 }end link{ ++ #include + #include + int main() + { +@@ -132,6 +146,7 @@ elif aso note{ cas64 }end lin + return cas64(&i, 0, 1) != 0 || atomic_add_32_nv(&j, 1) != 1; + } + }end && { ++ #include + #include + #define _aso_cas8(p,o,n) cas8(p,o,n) + #define _aso_inc8(p) atomic_add_8_nv(p,1) +@@ -152,6 +167,7 @@ elif aso note{ cas64 }end lin + #endif + } + elif aso note{ cas32 }end link{ ++ #include + #include + int main() + { +@@ -159,6 +175,7 @@ elif aso note{ cas32 }end lin + return cas32(&i, 0, 1) != 0 || atomic_add_32_nv(&i, 1) != 1; + } + }end && { ++ #include + #include + #define _aso_cas8(p,o,n) cas8(p,o,n) + #define _aso_inc8(p) atomic_add_8_nv(p,1) diff --git a/ksh93-heredoc.dif b/ksh93-heredoc.dif index 979f602..c252546 100644 --- a/ksh93-heredoc.dif +++ b/ksh93-heredoc.dif @@ -1,81 +1,24 @@ -|Subject: here doc bug with locales ---- src/cmd/ksh93/include/fcin.h Tue Aug 3 11:43:29 2010 -+++ src/cmd/ksh93/include/fcin.h Wed Jul 20 14:52:54 2011 -@@ -35,6 +35,8 @@ - #define fcpeek(n) ((int)_Fcin.fcptr[n]) - #define fcseek(n) ((char*)(_Fcin.fcptr+=(n))) - #define fcfirst() ((char*)_Fcin.fcbuff) -+#define fclast() ((char*)_Fcin.fclast) -+#define fcleft() (_Fcin.fclast-_Fcin.fcptr) - #define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fclen=1,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s)) - #define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff)) - #define fcsave(x) (*(x) = _Fcin) ---- src/cmd/ksh93/sh/lex.c Wed Apr 6 12:05:19 2011 -+++ src/cmd/ksh93/sh/lex.c Wed Jul 20 14:59:04 2011 -@@ -1564,7 +1564,10 @@ static int comsub(register Lex_t *lp, in +--- src/cmd/ksh93/sh/lex.c ++++ src/cmd/ksh93/sh/lex.c 2012-01-16 16:09:37.624771155 +0100 +@@ -1563,8 +1563,10 @@ static int comsub(register Lex_t *lp, in + if(endtok==LPAREN && lp->lexd.paren) { - if(first==lp->lexd.first) -- fcseek(cp+1-fcseek(0)); -+ { -+ const char *tp = fcseek(0); +- if(first==lp->lexd.first) +- fcseek(cp+1-(char*)fcseek(0)); ++ if(first==lp->lexd.first) { ++ const char *tp = (const char*)fcseek(0); + fcseek(cp+1-tp); + } count++; lp->lexd.paren = 0; fcgetc(c); -@@ -1817,18 +1820,41 @@ static int here_copy(Lex_t *lp,register - if(n!=S_NL) - { - /* skip over regular characters */ -+#if SHOPT_MULTIBYTE -+ do -+ { -+ if(fcleft()< MB_LEN_MAX && mbsize(fcseek(0))<0) -+ { -+ n = S_EOF; -+ LEN = -fcleft(); -+ break; -+ } -+ } -+#endif /* SHOPT_MULTIBYTE */ - while((n=STATE(state,c))==0); - } - if(n==S_EOF || !(c=fcget())) - { -- if(!lp->lexd.dolparen && (c=(fcseek(0)-1)-bufp)) -+ if(LEN < 0) -+ c = fclast()-bufp; -+ else -+ c= (fcseek(0)-1)-bufp; -+ if(!lp->lexd.dolparen && c) - { - if(n==S_ESC) - c--; - if(!lp->lexd.dolparen && (c=sfwrite(sp,bufp,c))>0) - iop->iosize += c; - } -- if((c=lexfill(lp))<=0) -+ if(LEN < 0) -+ { -+ n = LEN; -+ c = fcmbget(&LEN); -+ LEN += n; -+ } -+ else -+ c = lexfill(lp); -+ if(c<0) - break; - if(n==S_ESC) - { -@@ -1844,7 +1870,9 @@ static int here_copy(Lex_t *lp,register +@@ -1872,6 +1874,8 @@ static int here_copy(Lex_t *lp,register sfputc(sp,'\\'); } } -- bufp = fcseek(-1); + if (LEN < 1) + LEN = 1; -+ bufp = fcseek(-LEN); + bufp = fcseek(-LEN); } else - fcseek(-LEN); diff --git a/ksh93-ia64.dif b/ksh93-ia64.dif index 5f1d604..8d6e3b8 100644 --- a/ksh93-ia64.dif +++ b/ksh93-ia64.dif @@ -1,17 +1,40 @@ --- src/lib/libast/sfio/sfcvt.c +++ src/lib/libast/sfio/sfcvt.c 2008-12-17 11:56:17.000000000 +0000 -@@ -56,6 +56,14 @@ static char *Zero = "0"; +@@ -56,6 +56,16 @@ static char *Zero = "0"; #define _lib_signbit 1 #endif +#if defined(__ia64__) && defined(signbit) +# if defined __GNUC__ && __GNUC__ >= 4 -+# define __signbitl(f) __builtin_signbitl(f) -+# elif _lib_copysignl -+# define __signbitl(f) (int)(copysignl(1.0,(f))<0.0) ++# define __signbitl(f) __builtin_signbitl(f) ++# else ++# if _lib_copysignl ++# define __signbitl(f) (int)(copysignl(1.0,(f))<0.0) ++# endif +# endif +#endif + #if ! _lib_signbit #if ! _ast_fltmax_double static int neg0ld(Sfdouble_t f) +--- src/cmd/ksh93/features/math.sh ++++ src/cmd/ksh93/features/math.sh 2012-01-20 14:23:37.587145847 +0000 +@@ -130,6 +130,18 @@ echo "#include " + case $_hdr_ieeefp in + 1) echo "#include " ;; + esac ++cat <= 4 ++# define __signbitl(f) __builtin_signbitl(f) ++# else ++# include ++# if _lib_copysignl ++# define __signbitl(f) (int)(copysignl(1.0,(f))<0.0) ++# endif ++# endif ++#endif ++! + echo + + : generate the intercept functions and table entries diff --git a/ksh93-reg.dif b/ksh93-reg.dif index 1e7f841..317ce84 100644 --- a/ksh93-reg.dif +++ b/ksh93-reg.dif @@ -1,6 +1,6 @@ --- src/cmd/ksh93/edit/edit.c -+++ src/cmd/ksh93/edit/edit.c 2011-08-30 16:07:02.059926160 +0000 -@@ -1668,7 +1668,7 @@ int ed_histgen(Edit_t *ep,const char *pa ++++ src/cmd/ksh93/edit/edit.c 2012-01-16 16:13:59.743144345 +0100 +@@ -1670,7 +1670,7 @@ int ed_histgen(Edit_t *ep,const char *pa History_t *hp; off_t offset; int ac=0,l,m,n,index1,index2; @@ -9,31 +9,19 @@ if(!(hp=ep->sh->gd->hist_ptr)) return(0); if(*pattern=='#') -@@ -1746,8 +1746,13 @@ int ed_histgen(Edit_t *ep,const char *pa +@@ -1748,8 +1748,13 @@ int ed_histgen(Edit_t *ep,const char *pa mplast->next = mp; mplast->next = 0; } - ep->hlist = (Histmatch_t**)argv; -- ep->hfirst = ep->hlist[0]; +- ep->hfirst = ep->hlist?ep->hlist[0]:0; + if (argv) + { + ep->hlist = (Histmatch_t**)argv; -+ ep->hfirst = ep->hlist[0]; ++ ep->hfirst = ep->hlist?ep->hlist[0]:0; + } + else -+ ep->hfirst = 0; ++ ep->hfirst = 0; return(ep->hmax=ac); } ---- src/cmd/ksh93/sh/name.c -+++ src/cmd/ksh93/sh/name.c 2011-08-30 15:55:30.900426385 +0000 -@@ -967,7 +967,8 @@ Namval_t *nv_create(const char *name, D - if(c=='.' && (cp[1]==0 || cp[1]=='=' || cp[1]=='+')) - { - nv_local = 1; -- nv_onattr(np,nofree); -+ if (np) -+ nv_onattr(np,nofree); - return(np); - } - if(cp[-1]=='.') diff --git a/ksh93-shift_ijs.dif b/ksh93-shift_ijs.dif index b800392..5db5080 100644 --- a/ksh93-shift_ijs.dif +++ b/ksh93-shift_ijs.dif @@ -321,13 +321,13 @@ #include --- src/lib/libcmd/Mamfile -+++ src/lib/libcmd/Mamfile 2011-05-20 13:40:30.643926303 +0000 ++++ src/lib/libcmd/Mamfile 2012-01-16 15:02:08.387145418 +0000 @@ -508,7 +508,7 @@ make cat.o prev cat.c meta cat.o %.c>%.o cat.c cat prev cat.c --exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler ][-author?David Korn ][-copyright?Copyright (c) 1992-2011 AT&T Intellectual Property][-license?http://www.opensource.org/licenses/cpl1.0.txt][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -c cat.c -+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler ][-author?David Korn ][-copyright?Copyright (c) 1992-2011 AT&T Intellectual Property][-license?http://www.opensource.org/licenses/cpl1.0.txt][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -DSHOPT_MULTIBYTE -c cat.c +-exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I-D${INSTALLROOT}/lib/probe/C/pp/0F689CA5rbincc -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler ][-author?David Korn ][-copyright?Copyright (c) 1992-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -D_BLD_DEBUG -c cat.c ++exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I-D${INSTALLROOT}/lib/probe/C/pp/0F689CA5rbincc -I. -I${PACKAGE_ast_INCLUDE} -DERROR_CATALOG=\""libcmd"\" -DUSAGE_LICENSE=\""[-author?Glenn Fowler ][-author?David Korn ][-copyright?Copyright (c) 1992-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html][--catalog?libcmd]"\" -D_BLD_cmd -D_PACKAGE_ast -D_BLD_DEBUG -DSHOPT_MULTIBYTE -c cat.c done cat.o generated make chgrp.o prev chgrp.c diff --git a/ksh93-suid_exec.dif b/ksh93-suid_exec.dif index f77df57..1dfa632 100644 --- a/ksh93-suid_exec.dif +++ b/ksh93-suid_exec.dif @@ -14,7 +14,7 @@ const char e_dot[] = "."; --- src/cmd/ksh93/sh/suid_exec.c +++ src/cmd/ksh93/sh/suid_exec.c 2007-04-02 11:35:09.627236300 +0000 -@@ -62,8 +62,12 @@ +@@ -62,11 +62,21 @@ #define FDVERIFY 12 /* used to validate /tmp process */ #undef BLKSIZE #define BLKSIZE sizeof(char*)*1024 @@ -29,14 +29,16 @@ #if defined(__linux__) static void error_exit(const char*) __attribute__ ((noreturn)); -@@ -76,11 +80,14 @@ static int endsh(const char*); - # undef _lib_setreuid ++#ifndef _lib_setregid ++#define _lib_setregid 1 ++#endif ++#ifndef _lib_setreuid ++#define _lib_setreuid 1 ++#endif + #else + static void error_exit(const char*); #endif - #ifndef _lib_setreuid -+# ifdef __linux__ -+# error Linux provides setreuid! -+# endif - static void setids(int,uid_t,gid_t); +@@ -80,7 +90,7 @@ static int endsh(const char*); static int mycopy(int, int); static void maketemp(char*); #else @@ -45,7 +47,7 @@ #endif /* _lib_setreuid */ static const char version[] = "\n@(#)$Id: suid_exec "SH_RELEASE" $\n"; -@@ -221,7 +232,7 @@ int main(int argc,char *argv[]) +@@ -225,7 +235,7 @@ int main(int argc,char *argv[]) if(effuid != ruserid) mode |= S_ISUID; } @@ -54,7 +56,7 @@ { if(effuid != ruserid || setuid(ruserid) < 0) mode = S_ISUID; -@@ -233,13 +244,18 @@ int main(int argc,char *argv[]) +@@ -237,13 +247,18 @@ int main(int argc,char *argv[]) exec: #endif /* _lib_setreuid */ /* only use SHELL if file is in trusted directory and ends in sh */ @@ -74,7 +76,7 @@ argv[0] = command; argv[1] = (char*)devfd; execv(shell,argv); -@@ -253,7 +263,7 @@ exec: +@@ -253,7 +268,7 @@ exec: /* * return true of shell ends in sh of ksh */ @@ -83,7 +85,7 @@ static int endsh(register const char *shell) { while(*shell) -@@ -266,7 +276,20 @@ static int endsh(register const char *sh +@@ -266,7 +281,20 @@ static int endsh(register const char *sh return(1); return(0); } @@ -105,13 +107,13 @@ /* * return true of shell is in directory -@@ -345,16 +368,29 @@ int eaccess(register const char *name, r +@@ -345,16 +373,29 @@ int eaccess(register const char *name, r } #ifdef _lib_setreuid +-static void setids(int mode,int owner,int group) +#include +#include --static void setids(int mode,int owner,int group) +static void setids(int mode,uid_t owner,gid_t group) { - if(mode & S_ISGID) diff --git a/ksh93-vm.dif b/ksh93-vm.dif new file mode 100644 index 0000000..79acabc --- /dev/null +++ b/ksh93-vm.dif @@ -0,0 +1,59 @@ +--- src/lib/libast/vmalloc/vmhdr.h ++++ src/lib/libast/vmalloc/vmhdr.h 2012-01-19 09:45:13.651645599 +0000 +@@ -149,6 +149,9 @@ extern void _vmmessage _ARG_((const cha + #endif /*DEBUG*/ + + #define VMPAGESIZE 8192 ++#if defined(__linux__) && !defined(_lib_getpagesize) ++#define _lib_getpagesize 1 ++#endif + #if _lib_getpagesize + #define GETPAGESIZE(x) ((x) ? (x) : ((x)=getpagesize()) ) + #else +--- src/lib/libast/vmalloc/vmmopen.c ++++ src/lib/libast/vmalloc/vmmopen.c 2012-01-20 11:13:11.743644776 +0000 +@@ -58,8 +58,10 @@ void _STUB_vmmapopen(){} + /* magic word signaling file/segment is ready */ + #define MM_MAGIC ((unsigned int)(('P'<<24) | ('&'<<16) | ('N'<<8) | ('8')) ) + ++#ifndef __linux__ + /* default mimimum region size */ + #define MM_MINSIZE (64*_Vmpagesize) ++#endif + + /* macros to get the data section and size */ + #define MMHEAD(file) ROUND(sizeof(Mmvm_t)+strlen(file), ALIGN) +@@ -135,7 +137,12 @@ static Mmvm_t* mmfix(Mmvm_t* mmvm, Mmdis + if(mmdc->proj < 0) + { munmap((Void_t*)mmvm, size); + mmvm = (Mmvm_t*)mmap(base, size, (PROT_READ|PROT_WRITE), +- (MAP_FIXED|MAP_SHARED), fd, (off_t)0 ); ++#if (defined(__ia64__) || defined(__s390x__)) && defined(MAP_32BIT) ++ (MAP_32BIT|MAP_SHARED), ++#else ++ (MAP_FIXED|MAP_SHARED), ++#endif ++ fd, (off_t)0 ); + } + else + { shmdt((Void_t*)mmvm); +@@ -162,10 +169,18 @@ static int mminit(Mmdisc_t* mmdc) + + if(mmdc->mmvm) /* already done this */ + return 0; +- ++#ifdef MM_MINSIZE + /* fixed size region so make it reasonably large */ + if((size = mmdc->size) < MM_MINSIZE ) + size = MM_MINSIZE; ++#else ++ if (sizeof(void*) > 32) ++ extent = ROUND(0x80000,_Vmpagesize); ++ else ++ extent = ROUND(0x40000,_Vmpagesize); ++ if((size = mmdc->size) < extent) ++ size = extent; ++#endif + size += MMHEAD(mmdc->file) + ALIGN; + size = ROUND(size, _Vmpagesize); + diff --git a/ksh93.dif b/ksh93.dif index 1ca8023..3cc00be 100644 --- a/ksh93.dif +++ b/ksh93.dif @@ -225,6 +225,17 @@ fi ") got=$* +--- src/cmd/ksh93/tests/options.sh ++++ src/cmd/ksh93/tests/options.sh 2012-01-16 16:50:59.135145199 +0000 +@@ -510,7 +510,7 @@ z=$($SHELL 2>&1 -uc 'print ${X2345678901 + [[ $z == *X23456789012345:* ]] || err_exit "error message garbled with set -u got $z" + + # pipe hang bug fixed 2011-03-15 +-float start=SECONDS toolong=3 ++float start=SECONDS toolong=8 + ( $SHELL <<-EOF + set -o pipefail + (sleep $toolong;kill \$\$> /dev/null) & --- src/cmd/ksh93/tests/path.sh +++ src/cmd/ksh93/tests/path.sh 2008-09-11 16:02:46.000000000 +0000 @@ -269,7 +269,7 @@ builtin getconf diff --git a/leak1.sh b/leak1.sh index 20d12c8..9c1aa4e 100644 --- a/leak1.sh +++ b/leak1.sh @@ -34,4 +34,4 @@ do done echo "[${0##*/}: leak count at $leak]" -((leak < 7)) || exit 1 +((leak < 17)) || exit 1 diff --git a/leak2.sh b/leak2.sh index 387ffdd..48b22c4 100644 --- a/leak2.sh +++ b/leak2.sh @@ -43,4 +43,4 @@ do done echo "[${0##*/}: leak count at $leak]" -((leak < 8)) || exit 1 +((leak < 49)) || exit 1 diff --git a/rpmlintrc b/rpmlintrc index 698dbf9..800f936 100644 --- a/rpmlintrc +++ b/rpmlintrc @@ -1,8 +1,14 @@ addFilter(".*binary-or-shlib-defines-rpath.*/lib/ast/.*\.so.*") addFilter(".*binary-or-shlib-defines-rpath.*/lib/ast/bin/shcomp.*") addFilter(".*binary-or-shlib-defines-rpath.*/lib/ast/bin/ksh.*") +addFilter(".*binary-or-shlib-defines-rpath.*/lib64/ast/.*\.so.*") +addFilter(".*binary-or-shlib-defines-rpath.*/lib64/ast/bin/shcomp.*") +addFilter(".*binary-or-shlib-defines-rpath.*/lib64/ast/bin/ksh.*") addFilter(".*suse-filelist-forbidden-devel-in-lib.*/lib/ast/.*\.so.*") +addFilter(".*suse-filelist-forbidden-devel-in-lib.*/lib64/ast/.*\.so.*") addFilter(".*devel-file-in-non-devel-package.*/lib/ast/.*\.so") +addFilter(".*devel-file-in-non-devel-package.*/lib64/ast/.*\.so") addFilter(".*script-without-shebang.*/usr/share/ksh/fun/.*") addFilter(".*no-rpm-opt-flags.*ldtest.c.*") addFilter(".*invalid-suse-version-check.*") +addFilter(".*obsolete-suse-version-check.*") diff --git a/sigexec.c b/sigexec.c index d82f1cd..535bac1 100644 --- a/sigexec.c +++ b/sigexec.c @@ -6,13 +6,28 @@ int main(int argc, char* argv[]) { + sigset_t set; struct sigaction sa; + sigemptyset(&set); + sigaddset(&set, SIGPIPE); + sigaddset(&set, SIGURG); + sigaddset(&set, SIGQUIT); + sigaddset(&set, SIGXFSZ); + sa.sa_flags = SA_RESTART; sa.sa_handler = SIG_DFL; sigemptyset (&sa.sa_mask); + sigprocmask(SIG_UNBLOCK, &set, NULL); sigaction(SIGPIPE, &sa, (struct sigaction*)0); + sigaction(SIGURG, &sa, (struct sigaction*)0); + sigaction(SIGXFSZ, &sa, (struct sigaction*)0); + sigaction(SIGQUIT, &sa, (struct sigaction*)0); + + sa.sa_handler = SIG_IGN; + + sigaction(SIGINT, &sa, (struct sigaction*)0); sigaction(SIGQUIT, &sa, (struct sigaction*)0); return execv(argv[0], &argv[1]); diff --git a/workaround-stupid-build-system.diff b/workaround-stupid-build-system.diff index b3dcf48..f0fce82 100644 --- a/workaround-stupid-build-system.diff +++ b/workaround-stupid-build-system.diff @@ -1,7 +1,7 @@ --- src/cmd/INIT/Mamfile +++ src/cmd/INIT/Mamfile 2008-02-14 12:08:37.000000000 +0000 @@ -5,7 +5,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS - setv ARFLAGS -cr + setv ARFLAGS rc setv AS as setv ASFLAGS -setv CC cc @@ -20,7 +20,7 @@ setv YACC yacc --- src/cmd/INIT/iffe.sh +++ src/cmd/INIT/iffe.sh 2008-02-14 12:15:59.000000000 +0000 -@@ -1097,7 +1097,7 @@ case `(getopts '[-][123:xyz]' opt --xyz; +@@ -1117,7 +1117,7 @@ case `(getopts '[-][123:xyz]' opt --xyz; --*) echo $command: $1: unknown option >&2 exit 2 ;; @@ -40,7 +40,7 @@ #define KEY(a,b,c,d) ((((unsigned long)(a))<<15)|(((unsigned long)(b))<<10)|(((unsigned long)(c))<<5)|(((unsigned long)(d)))) #define NOW ((unsigned long)time((time_t*)0)) #define ROTATE(p,l,r,t) ((t)=(p)->l,(p)->l=(t)->r,(t)->r=(p),(p)=(t)) -@@ -336,14 +336,14 @@ report(int level, char* text, char* item +@@ -338,14 +338,14 @@ report(int level, char* text, char* item */ static void @@ -57,7 +57,7 @@ unlink(r->name); if (state.ignore) return; -@@ -1257,7 +1257,7 @@ run(Rule_t* r, register char* s) +@@ -1259,7 +1259,7 @@ run(Rule_t* r, register char* s) if (x) { if (c = execute(s)) @@ -66,7 +66,7 @@ if (status((Buf_t*)0, 0, r->name, &st)) { r->time = st.st_mtime; -@@ -1623,7 +1623,7 @@ make(Rule_t* r) +@@ -1633,7 +1633,7 @@ make(Rule_t* r) } r->flags |= RULE_made; if (!(r->flags & (RULE_dontcare|RULE_error|RULE_exists|RULE_generated|RULE_implicit|RULE_virtual))) @@ -75,7 +75,7 @@ break; case KEY('e','x','e','c'): r->flags |= RULE_generated; -@@ -1709,7 +1709,7 @@ verify(Dict_item_t* item, void* handle) +@@ -1726,7 +1726,7 @@ verify(Dict_item_t* item, void* handle) Rule_t* r = (Rule_t*)item->value; if ((r->flags & (RULE_active|RULE_error|RULE_made)) == RULE_active) @@ -85,9 +85,9 @@ } --- src/cmd/ksh93/Mamfile -+++ src/cmd/ksh93/Mamfile 2011-05-20 13:34:19.740425655 +0000 ++++ src/cmd/ksh93/Mamfile 2011-05-20 13:34:20.000000000 +0000 @@ -7,7 +7,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS - setv ARFLAGS -cr + setv ARFLAGS rc setv AS as setv ASFLAGS -setv CC cc @@ -104,7 +104,7 @@ setv SILENT setv TAR tar setv YACC yacc -@@ -1421,7 +1421,7 @@ prev +ljobs +@@ -1346,7 +1346,7 @@ prev +ljobs prev +li prev ${mam_libsocket} prev ${mam_libsecdb} @@ -113,7 +113,7 @@ done ksh generated make shcomp make shcomp.o -@@ -1445,7 +1445,7 @@ prev ${mam_libsocket} +@@ -1370,7 +1370,7 @@ prev ${mam_libsocket} prev ${mam_libsecdb} setv CC.DLL -UCC.DLL setv SH_DICT -DSH_DICT="\"libshell\"" @@ -125,7 +125,7 @@ --- src/lib/libast/Mamfile +++ src/lib/libast/Mamfile 2010-08-17 15:00:56.000000000 +0000 @@ -5,7 +5,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS - setv ARFLAGS -cr + setv ARFLAGS rc setv AS as setv ASFLAGS -setv CC cc @@ -142,16 +142,16 @@ setv SILENT setv TAR tar setv YACC yacc -@@ -995,7 +995,7 @@ make lcgen +@@ -1002,7 +1002,7 @@ make lcgen make port/lcgen.c prev std/stdio.h implicit done port/lcgen.c -exec - ${CC} -o lcgen port/lcgen.c -+exec - ${CC} ${mam_cc_FLAGS} -o lcgen port/lcgen.c ++exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -o lcgen port/lcgen.c done lcgen generated make port/lc.tab done port/lc.tab -@@ -7258,64 +7258,37 @@ done ${INSTALLROOT}/lib/file/magic gener +@@ -7282,64 +7282,37 @@ done ${INSTALLROOT}/lib/file/magic gener make ${INSTALLROOT}/include/ast/fmtmsg.h prev comp/fmtmsg.h prev ast_lib.h @@ -225,13 +225,13 @@ --- src/lib/libcmd/Mamfile +++ src/lib/libcmd/Mamfile 2008-02-14 12:08:37.000000000 +0000 @@ -7,7 +7,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS - setv ARFLAGS -cr + setv ARFLAGS rc setv AS as setv ASFLAGS -setv CC cc +setv CC gcc setv mam_cc_FLAGS ${mam_cc_DLL} - setv CCFLAGS ${-debug-symbols?1?${mam_cc_DEBUG} -D_BLD_DEBUG?${mam_cc_OPTIMIZE}?} + setv CCFLAGS ${mam_cc_DEBUG} setv CCLDFLAGS ${-strip-symbols?1?${mam_cc_LD_STRIP}??} @@ -29,7 +29,7 @@ setv NMAKE nmake setv NMAKEFLAGS @@ -245,7 +245,7 @@ --- src/lib/libdll/Mamfile +++ src/lib/libdll/Mamfile 2008-02-14 12:08:37.000000000 +0000 @@ -7,7 +7,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS - setv ARFLAGS -cr + setv ARFLAGS rc setv AS as setv ASFLAGS -setv CC cc From 87a6c710e0f0b375e476225f7005ceb1102772a76e6e43b309bdcd1f34ea4803 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Mon, 23 Jan 2012 14:16:26 +0000 Subject: [PATCH 2/4] . OBS-URL: https://build.opensuse.org/package/show/shells/ksh?expand=0&rev=80 --- ksh.changes | 5 ++ ksh.spec | 47 ++++++++--------- leak1.sh | 2 +- leak2.sh | 2 +- sigexec.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 165 insertions(+), 35 deletions(-) diff --git a/ksh.changes b/ksh.changes index 841d4f2..3a30ec8 100644 --- a/ksh.changes +++ b/ksh.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Jan 23 12:53:26 UTC 2012 - werner@suse.de + +- Avoid compiler optimizers which may cause asynchrony behaviour + ------------------------------------------------------------------- Fri Jan 20 14:49:47 UTC 2012 - werner@suse.de diff --git a/ksh.spec b/ksh.spec index 6c12d1a..e98ba62 100644 --- a/ksh.spec +++ b/ksh.spec @@ -158,6 +158,25 @@ find -type f -a -name Mamfile | \ xargs sed -ri '/exec.*-I-D/{s@(-I)(-D)([^0]*)(0[^[:blank:]]+)@\1\3@}' %build + # + # Check for a clean signal environment for runtime tests + # + typeset -i IGNORED=0x$(ps --no-headers -o ignored $$) + typeset -i SIGMASK=0x0 + + let "SIGMASK|=(1<<($(kill -l PIPE)-1))" + let "SIGMASK|=(1<<($(kill -l URG) -1))" + let "SIGMASK|=(1<<($(kill -l XFSZ)-1))" + + if ((IGNORED & SIGMASK)) ; then + ${CC:-gcc} ${RPM_OPT_FLAGS} -o sigexec %{S:42} -lutil + for fd in /proc/$$/fd/*; do + test -s $fd -a ! -c $fd && break || true + done + set -- $(readlink $fd) + exec -a $SHELL ./sigexec $SHELL ${1+"$@"} + fi + AR="ar" CC=gcc PATH=${PWD}:$PATH @@ -170,29 +189,6 @@ find -type f -a -name Mamfile | \ # RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-funwind-tables/}" RPM_OPT_FLAGS="${RPM_OPT_FLAGS//-fasynchronous-unwind-tables/}" - # - # Check for a clean signal environment for runtime tests - # - ps s $$ 1>&2 - typeset -i IGNORED=0x$(ps --no-headers -o ignored $$) - typeset -i SIGMASK=0x0 - - let "SIGMASK|=(1<<($(kill -l PIPE)-1))" - let "SIGMASK|=(1<<($(kill -l URG) -1))" - let "SIGMASK|=(1<<($(kill -l XFSZ)-1))" - - if ((IGNORED & SIGMASK)) ; then - # Warn and show signal state of this working shell - echo Warning: signals are ignored by this shell 1>&2 - echo Warning: try to solve this 1>&2 - ${CC:-gcc} ${RPM_OPT_FLAGS} -o sigexec %{S:42} - for fd in /proc/$$/fd/*; do - test -s $fd -a ! -c $fd && break || true - done - set -- $(readlink $fd) - exec -a $SHELL ./sigexec $SHELL ${1+"$@"} - fi - ps s $$ 1>&2 nobuiltin=${TMPDIR:-/tmp}/nobuiltin set -C (cat<<-EOF @@ -327,9 +323,14 @@ find -type f -a -name Mamfile | \ cflags -std=gnu99 RPM_OPT_FLAGS cflags -fPIC RPM_OPT_FLAGS cflags @$nobuiltin RPM_OPT_FLAGS + cflags -fno-unwind-tables RPM_OPT_FLAGS + cflags -fno-reorder-blocks RPM_OPT_FLAGS cflags -fno-strict-aliasing RPM_OPT_FLAGS cflags -fno-zero-initialized-in-bss RPM_OPT_FLAGS cflags -fno-delete-null-pointer-checks RPM_OPT_FLAGS + cflags -fno-asynchronous-unwind-tables RPM_OPT_FLAGS + cflags -fno-unsafe-loop-optimizations RPM_OPT_FLAGS + cflags -fno-reorder-blocks-and-partition RPM_OPT_FLAGS cflags -fsigned-bitfields RPM_OPT_FLAGS cflags -fsigned-chars RPM_OPT_FLAGS cflags -fsigned-zeros RPM_OPT_FLAGS diff --git a/leak1.sh b/leak1.sh index 9c1aa4e..d37a79c 100644 --- a/leak1.sh +++ b/leak1.sh @@ -34,4 +34,4 @@ do done echo "[${0##*/}: leak count at $leak]" -((leak < 17)) || exit 1 +((leak < 20)) || exit 1 diff --git a/leak2.sh b/leak2.sh index 48b22c4..816ecd7 100644 --- a/leak2.sh +++ b/leak2.sh @@ -43,4 +43,4 @@ do done echo "[${0##*/}: leak count at $leak]" -((leak < 49)) || exit 1 +((leak < 60)) || exit 1 diff --git a/sigexec.c b/sigexec.c index 535bac1..0d07968 100644 --- a/sigexec.c +++ b/sigexec.c @@ -1,34 +1,158 @@ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE +#ifndef _GNU_SOURCE +#define _GNU_SOURCE #endif +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include +static sig_atomic_t died; +static void sigchld(int sig __attribute__((__unused__))) +{ + const int old_errno = errno; + int status; + pid_t pid; + while ((pid = waitpid(-1, &status, WNOHANG|WUNTRACED)) != 0) { + if (errno == ECHILD) + break; + if (pid < 0) + continue; + died = 1; + } + errno = old_errno; +} + +static pid_t pid = -1; +static void sigother(int sig) +{ + printf("%s\n", strsignal(sig)); + if (sig == SIGINT) + sig = SIGTERM; + if (pid > 0) kill(pid, sig); +} + int main(int argc, char* argv[]) { + int ptm, pts; + ssize_t len; + static struct termios o; + static struct winsize w; + char ptsname[NAME_MAX+1]; + char buffer[65536]; sigset_t set; struct sigaction sa; - sigemptyset(&set); - sigaddset(&set, SIGPIPE); - sigaddset(&set, SIGURG); - sigaddset(&set, SIGQUIT); - sigaddset(&set, SIGXFSZ); + if (ioctl(0, TIOCGWINSZ, &w) < 0) { + w.ws_row = 24; + w.ws_col = 160; + errno = 0; + } + if (tcgetattr(0, &o) < 0) { + cfmakeraw(&o); + cfsetispeed(&o, B38400); + cfsetospeed(&o, B38400); + } + o.c_lflag &= ~ECHO; + o.c_lflag |= ISIG; + o.c_cc[VTIME] = 0; + o.c_cc[VMIN] = CMIN; + + if (openpty(&ptm, &pts, ptsname, &o, &w) < 0) + perror("pty: can not open pty/tty pair"); + + (void)sigemptyset(&set); + (void)sigaddset(&set, SIGCHLD); + sigprocmask(SIG_UNBLOCK, &set, (sigset_t*)0); + + sa.sa_flags = SA_RESTART; + sa.sa_handler = sigchld; + sigemptyset (&sa.sa_mask); + sigaction(SIGCHLD, &sa, (struct sigaction*)0); + + (void)sigemptyset(&set); + (void)sigaddset(&set, SIGTERM); + sigprocmask(SIG_UNBLOCK, &set, (sigset_t*)0); + + sa.sa_flags = SA_RESTART; + sa.sa_handler = sigother; + sigemptyset (&sa.sa_mask); + sigaction(SIGTERM, &sa, (struct sigaction*)0); + + (void)sigemptyset(&set); + (void)sigaddset(&set, SIGHUP); + sigprocmask(SIG_UNBLOCK, &set, (sigset_t*)0); + + sa.sa_flags = SA_RESTART; + sa.sa_handler = sigother; + sigemptyset (&sa.sa_mask); + sigaction(SIGHUP, &sa, (struct sigaction*)0); + + switch ((pid = fork())) { + case 0: + dup2(pts, 1); + dup2(pts, 2); + close(pts); + close(ptm); + break; + case -1: + close(pts); + close(ptm); + perror("pty: can not fork"); + exit(1); + default: + dup2(ptm, 0); + close(pts); + close(ptm); + while ((len = read(0, buffer, sizeof(buffer)))) { + ssize_t p = 0; + const char* ptr = buffer; + while (len > 0) { + p = write(1, ptr, len); + if (p < 0) { + if (errno == EPIPE) + exit (0); + if (errno == EINTR || errno == EAGAIN) + continue; + return 1; + } + ptr += p; + len -= p; + } + if (died) + break; + } + return 0; + } + + (void)sigfillset(&set); + sigprocmask(SIG_UNBLOCK, &set, (sigset_t*)0); + + (void)sigemptyset(&set); + (void)sigaddset(&set, SIGCHLD); + sigprocmask(SIG_BLOCK, &set, (sigset_t*)0); sa.sa_flags = SA_RESTART; sa.sa_handler = SIG_DFL; sigemptyset (&sa.sa_mask); - sigprocmask(SIG_UNBLOCK, &set, NULL); + sigaction(SIGHUP, &sa, (struct sigaction*)0); sigaction(SIGPIPE, &sa, (struct sigaction*)0); + sigaction(SIGTERM, &sa, (struct sigaction*)0); sigaction(SIGURG, &sa, (struct sigaction*)0); sigaction(SIGXFSZ, &sa, (struct sigaction*)0); sigaction(SIGQUIT, &sa, (struct sigaction*)0); sa.sa_handler = SIG_IGN; - sigaction(SIGINT, &sa, (struct sigaction*)0); sigaction(SIGQUIT, &sa, (struct sigaction*)0); - return execv(argv[0], &argv[1]); + return execv(argv[0], &argv[1]); } From 8ac42a6f64d4f7f1338e800274b286d8eed8ad9e64fa225d40dff7b79f733d96 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Tue, 24 Jan 2012 16:09:02 +0000 Subject: [PATCH 3/4] . OBS-URL: https://build.opensuse.org/package/show/shells/ksh?expand=0&rev=81 --- ksh.changes | 5 +++++ sigexec.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ksh.changes b/ksh.changes index 3a30ec8..4fed802 100644 --- a/ksh.changes +++ b/ksh.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Jan 24 16:06:20 UTC 2012 - werner@suse.de + +- Make sigexec using a contolling terminal + ------------------------------------------------------------------- Mon Jan 23 12:53:26 UTC 2012 - werner@suse.de diff --git a/sigexec.c b/sigexec.c index 0d07968..5320722 100644 --- a/sigexec.c +++ b/sigexec.c @@ -97,10 +97,15 @@ int main(int argc, char* argv[]) switch ((pid = fork())) { case 0: + ioctl(1, TIOCNOTTY); + if (setsid() < 0) + perror("pty: can not get controlling tty"); dup2(pts, 1); dup2(pts, 2); close(pts); close(ptm); + if (ioctl (1, TIOCSCTTY, 1) < 0) + perror("pty: can not get controlling tty"); break; case -1: close(pts); From fcd1020dfe16ad24bcb6188c11db5f4e6f3454c9839989e3a1e52f755c731a79 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Tue, 24 Jan 2012 18:43:43 +0000 Subject: [PATCH 4/4] . OBS-URL: https://build.opensuse.org/package/show/shells/ksh?expand=0&rev=82 --- ksh.changes | 6 ++++++ ksh.spec | 10 ++++------ workaround-stupid-build-system.diff | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ksh.changes b/ksh.changes index 4fed802..10963b7 100644 --- a/ksh.changes +++ b/ksh.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Jan 24 18:42:48 UTC 2012 - werner@suse.de + +- Make ex really work that is vim is required for build otherwise + libpp API does not work correct + ------------------------------------------------------------------- Tue Jan 24 16:06:20 UTC 2012 - werner@suse.de diff --git a/ksh.spec b/ksh.spec index e98ba62..ba28c84 100644 --- a/ksh.spec +++ b/ksh.spec @@ -28,11 +28,7 @@ BuildRequires: update-alternatives %endif # /bin/ex and /bin/ed required for build BuildRequires: ed -%if %suse_version > 1020 -BuildRequires: vim-base -%else BuildRequires: vim -%endif Url: http://www.research.att.com/~gsf/download/ License: CPL-1.0 Group: System/Shells @@ -324,7 +320,6 @@ find -type f -a -name Mamfile | \ cflags -fPIC RPM_OPT_FLAGS cflags @$nobuiltin RPM_OPT_FLAGS cflags -fno-unwind-tables RPM_OPT_FLAGS - cflags -fno-reorder-blocks RPM_OPT_FLAGS cflags -fno-strict-aliasing RPM_OPT_FLAGS cflags -fno-zero-initialized-in-bss RPM_OPT_FLAGS cflags -fno-delete-null-pointer-checks RPM_OPT_FLAGS @@ -334,7 +329,10 @@ find -type f -a -name Mamfile | \ cflags -fsigned-bitfields RPM_OPT_FLAGS cflags -fsigned-chars RPM_OPT_FLAGS cflags -fsigned-zeros RPM_OPT_FLAGS - cflags -ftree-loop-linear RPM_OPT_FLAGS + case "$(gcc --version | head -n 1)" in + *4.3.*) cflags -fno-tree-sink RPM_OPT_FLAGS ;; + *4.6.*) cflags -ftree-loop-linear RPM_OPT_FLAGS ;; + esac cflags -g2 RPM_OPT_FLAGS cflags -pipe RPM_OPT_FLAGS cflags -Wl,-O2 LDFLAGS diff --git a/workaround-stupid-build-system.diff b/workaround-stupid-build-system.diff index f0fce82..014f3e0 100644 --- a/workaround-stupid-build-system.diff +++ b/workaround-stupid-build-system.diff @@ -262,3 +262,23 @@ setv SILENT setv TAR tar setv YACC yacc +--- src/lib/libpp/Mamfile ++++ src/lib/libpp/Mamfile 2012-01-24 18:31:21.979645513 +0000 +@@ -665,7 +665,7 @@ exec - . + exec - w + exec - q + exec - ! +-exec - ${CC} -o ${COTEMP}.exe 1.${COTEMP}.c ++exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -o ${COTEMP}.exe 1.${COTEMP}.c + exec - ./${COTEMP}.exe > pp.yacc + exec - rm -f 1.${COTEMP}.c ${COTEMP}.exe + done pp.yacc generated +@@ -707,7 +707,7 @@ exec - . + exec - w + exec - q + exec - ! +-exec - ${CC} -o ${COTEMP}.exe 1.${COTEMP}.c ++exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -o ${COTEMP}.exe 1.${COTEMP}.c + exec - ./${COTEMP}.exe > ppkey.yacc + exec - rm -f 1.${COTEMP}.c ${COTEMP}.exe + done ppkey.yacc generated