Accepting request 106791 from shells

- Remove check-build.sh as the memory leaks are fixed now

- Avoid possible problems pointed out by a gcc warning about overflow
  in arraysubscript, that is use full size of structure Namval as
  well as access this area at position 0 

- Update to 2012-02-14 of ksh93u+ which includes the real fix for
  the IFS crash, the ulimit, and the mem leaks (bnc#743244, bnc#744355,
  bnc#744589, and bnc#744992) as well as other fixes like:
  12-02-14 A bug in which ^Z did not stop a pipeline when the last component
           was a shell built-in has been fixed.
  12-02-14 getconf("PATH") used to initialize ed(1) path.
  12-02-13 +In earlier version read from standard input would fail when called
           from the KEYBD trap.  Now read options -N, -n, and -t should work
           when called from a KEYBD trap.
  12-02-13 If FCEDIT is not set and fc is invoked without the -e option,
           ed will be invoked if found instead of /bin/ed. 
  12-02-10 Another bug in the saving and restoring of IFS in a subshell
           that caused a core dump has been fixed.
  12-02-08 A bug in which .sh.fun disciplines could be cleared after a
           function completes has been fixed.
  12-02-08 A bug in job control in which the foregroup process group was not
           set correctly after restarting a stopped pipeline has been fixed.
  12-02-07 A bug in which numbers with leading zeros could be treated as
           octal constants outside of ((...)) has been fixed.
  12-02-06 A bug in arithmetic with compound variables containing multiple
           array elements has been fixed.
  libast:
  12-02-10 sfvprintf.c: fix 1 byte too long buffer access
  12-02-07 malloc.c/features/vmalloc: add gnu __malloc_hook tests

OBS-URL: https://build.opensuse.org/request/show/106791
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/ksh?expand=0&rev=74
This commit is contained in:
Stephan Kulow 2012-02-25 06:30:19 +00:00 committed by Git OBS Bridge
commit 4cde68ba44
21 changed files with 657 additions and 284 deletions

View File

@ -7,7 +7,3 @@ wget --user='I accept www.opensource.org/licenses/cpl' --password='.' \
http://www2.research.att.com/sw/download/beta/ast-ksh.${version}.tgz \
http://www2.research.att.com/sw/download/beta/INIT.${version}.tgz \
http://www2.research.att.com/sw/download/beta/ast-base.${version}.tgz
tar xfz ast-base.${version}.tgz src/cmd/msgcc/ src/lib/libpp/
tar cfj ast-msgcc.${version}.tar.bz2 src/
rm -f ast-base.${version}.tgz

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ea89823ade1949c828e6012cf85f58aebcfe8cb9f31052370936e215a9b126a6
size 296877

3
INIT.2012-02-14.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fedd8f2100f784dbcf60b1b6392d61c10902aaf2ff61a34134cd1ba83f4d2e11
size 297404

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2711f072573a7e69746fe8a1e88a72978e37b3b3097ff921aa6f23b624e76925
size 6377383

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1ddaab5c6ae873e61e0706024abd57f0363891a8ad5bf026082c0706b7557665
size 1573400

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:334fc6d4e407cc8c9ffbcc6b4efdb3bb94da045126d608b7329f23b022f389de
size 1575644

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:318716d403b0b0f5be08848235122ab27d4c13f6daceca55cd61a41cd3c8cfb4
size 129260

View File

@ -1,11 +0,0 @@
#!/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 3145728 && exit 1
test $(ulimit -v) -lt 4194304 && exit 1
else
test $(ulimit -m) -lt 4194304 && exit 1
test $(ulimit -v) -lt 6683794 && exit 1
fi
exit 0

View File

@ -1,6 +1,23 @@
#!/bin/ksh
trap 'echo "[${0##*/}: crash]"' SIGSEGV SIGABRT SIGBUS SIGFPE
typeset -lui count=${1:-4}
function g
{
IFS=
}
function f
{
typeset IFS
(g)
: $V
}
while ((count-- > 0))
do
f
done
function crash
{

View File

@ -1,3 +1,78 @@
-------------------------------------------------------------------
Fri Feb 24 11:38:56 UTC 2012 - werner@suse.de
- Remove check-build.sh as the memory leaks are fixed now
-------------------------------------------------------------------
Tue Feb 21 10:43:58 UTC 2012 - werner@suse.de
- Avoid possible problems pointed out by a gcc warning about overflow
in arraysubscript, that is use full size of structure Namval as
well as access this area at position 0
-------------------------------------------------------------------
Mon Feb 20 14:09:55 UTC 2012 - werner@suse.de
- Update to 2012-02-14 of ksh93u+ which includes the real fix for
the IFS crash, the ulimit, and the mem leaks (bnc#743244, bnc#744355,
bnc#744589, and bnc#744992) as well as other fixes like:
12-02-14 A bug in which ^Z did not stop a pipeline when the last component
was a shell built-in has been fixed.
12-02-14 getconf("PATH") used to initialize ed(1) path.
12-02-13 +In earlier version read from standard input would fail when called
from the KEYBD trap. Now read options -N, -n, and -t should work
when called from a KEYBD trap.
12-02-13 If FCEDIT is not set and fc is invoked without the -e option,
ed will be invoked if found instead of /bin/ed.
12-02-10 Another bug in the saving and restoring of IFS in a subshell
that caused a core dump has been fixed.
12-02-08 A bug in which .sh.fun disciplines could be cleared after a
function completes has been fixed.
12-02-08 A bug in job control in which the foregroup process group was not
set correctly after restarting a stopped pipeline has been fixed.
12-02-07 A bug in which numbers with leading zeros could be treated as
octal constants outside of ((...)) has been fixed.
12-02-06 A bug in arithmetic with compound variables containing multiple
array elements has been fixed.
libast:
12-02-10 sfvprintf.c: fix 1 byte too long buffer access
12-02-07 malloc.c/features/vmalloc: add gnu __malloc_hook tests
12-02-06 vmmopen.c: fix ALIGN vs sys/param.h macro conflict
libcmd:
12-02-14 rm.c: --force ignores no file operands specified
libpp:
12-02-14 ppproto.c: fix "already noticed" logic
cmd/builtin:
12-02-11 what.c: fix boyer moore cut n paste bug -- thanks werner
-------------------------------------------------------------------
Tue Feb 14 15:36:22 UTC 2012 - werner@suse.de
- Fix a nasty crash in IFS handling
-------------------------------------------------------------------
Fri Feb 10 17:11:36 UTC 2012 - werner@suse.de
- Fix bug in src/cmd/builtin/what.c
-------------------------------------------------------------------
Fri Feb 10 15:45:09 UTC 2012 - werner@suse.de
- Make pty and other ast-base command available as this helps to
test out some major features of the ksh (compare with bnc#743244)
-------------------------------------------------------------------
Thu Feb 9 14:14:53 UTC 2012 - werner@suse.de
- Modify some tests of the test suite not to show false results on
highly loaded build hosts as well as on build shares mounted with
noatime option
-------------------------------------------------------------------
Thu Feb 9 09:47:38 UTC 2012 - werner@suse.de
- Add patch from David Korn to fix foreground job control (bnc #743244)
-------------------------------------------------------------------
Mon Feb 6 12:01:10 UTC 2012 - werner@suse.de

306
ksh.spec
View File

@ -19,6 +19,19 @@
Name: ksh
%global date 2012-02-14
%global use_suid_exe 0
%if %suse_version > 1210
%global use_opt_bins 1
%else
%global use_opt_bins 0
%endif
%if !0%{?qemu_user_space_build:1}
%global do_tests 1
%else
%global do_tests 0
%endif
%global use_locale 0
BuildRequires: bind-utils bison flex gdbm-devel glibc-devel ncurses-devel procps psmisc pwdutils zlib-devel
%if %suse_version > 1020
BuildRequires: bind-libs libbz2-devel
@ -40,15 +53,18 @@ Requires(postun): /bin/ln /bin/rm /etc/bash.bashrc /bin/true
Requires(post): update-alternatives
Requires(preun): update-alternatives
%endif
%if %use_suid_exe
PreReq: permissions
%endif
AutoReqProv: on
Version: 93u
Release: 1
Summary: Korn Shell
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source: INIT.2012-02-02.tar.bz2
Source1: ast-ksh.2012-02-02.tar.bz2
Source2: ast-msgcc.2012-02-02.tar.bz2
Source3: CPL
Source: INIT.%{date}.tar.bz2
Source1: ast-ksh.%{date}.tar.bz2
Source2: ast-base.%{date}.tar.bz2
Source4: CPL
Source10: leak1.sh
Source11: leak2.sh
Source12: ifs-crash.sh
@ -82,10 +98,9 @@ Patch19: ksh93-reg.dif
Patch20: ksh93-aso.dif
Patch21: ksh93-vm.dif
Patch22: ksh93-limit-name-len.dif
Patch23: ksh93-foreground-prgrp.dif
Patch24: ksh93-builtin.dif
Patch42: ksh-locale.patch
%global use_suid_exe 0
%global use_locale 0
%global debug_memleak 0
%description
The original Korn Shell. The ksh is an sh-compatible command
@ -123,7 +138,8 @@ Authors:
%prep
chmod +x %{S:31}
%setup -q -n ksh93 -T -c -a 0 -a 1 -a 2
%setup -q -n ksh93 -T -c -a 0 -a 1
tar --use-compress-program=bzcat -xf %{S:2} src/cmd/builtin/ src/cmd/msgcc/ src/lib/libpp/ src/lib/libuu/
if test -d share ; then
find share/ \( -name chef -o -name fudd -o -name piglatin -o -name valley \) -a -type d |\
xargs -r rm -vrf
@ -160,6 +176,8 @@ fi
%patch20
%patch21
%patch22
%patch23
%patch24
%build
#
@ -223,6 +241,7 @@ fi
test -n "${!LC_*}" && unset "${!LC_*}"
cflags ()
{
set +x
local flag=$1; shift
local var=$1; shift
test -n "${flag}" -a -n "${var}" || return
@ -243,6 +262,24 @@ fi
fi
esac
set +o noclobber
set -x
}
relink ()
{
set +x
local search=$1; shift
local target=$1; shift
test -n "${search}" -a -n "${target}" || exit 1
local object=$(find ${root:-/tmp}/src/cmd/ -name ${search}.o)
local cmd=$(
grep -e "-o $search" ${log:-/dev/null} | tail -n 1 | \
sed -r -e "s@\+ g?cc@${CC:-gcc}@" \
-e "s@-o $search@-o ${root:-/tmp}$target@" \
-e "s@[[:blank:]]${search}.o[[:blank:]]@ $object @" \
-e "s@[[:blank:]](/[^[:blank:]]*)?lib([[:alnum:]]+)\.a@ -l\2@g" \
-e "s@'@@g")
set -x
$cmd ${1+"$@"}
}
#
# If _you_ are knowing how to fix this in the autogenerated
@ -321,12 +358,13 @@ fi
HOSTTYPE=linux.$RPM_ARCH
;;
esac
MEMORY=execve
for mm in mmap mmap2 mmap64 munmap munmap2 munmap64 ; do
if strace -e $mm /bin/true > /dev/null 2>&1 ; then
MEMORY="${MEMORY:+${MEMORY},}$mm"
fi
done
MEMORY="${MEMORY:+-e ${MEMORY}}"
MEMORY="-s 128 ${MEMORY:+-e ${MEMORY}}"
RPM_OPT_FLAGS=$(echo "${RPM_OPT_FLAGS}"|sed -r 's/[[:blank:]]+-g[0-9]?/ -g2/g')
UNIVERSE=att
LDFLAGS="-lm"
@ -408,71 +446,65 @@ fi
diff -u $nobuiltin - || true
base=src/cmd/ksh93
test=${PWD}/${base}/tests
OPATH=$PATH
OSHELL=$SHELL
PATH=$PATH:${root}/bin
SHELL=${root}/bin/ksh
SHCOMP=${root}/bin/shcomp
export PATH SHCOMP SHELL
%if %do_tests
pushd ${test}
typeset -i failed=0
ln -sf ${root}/lib ${test}/../
sed -ri '/^L[[:blank:]]/a \t 8000' pty.sh
sed -ri 's/(SECONDS[[:blank:]]*>[[:blank:]]*)([[:digit:]]+)/\18/p' signal.sh
unset ${!LESS*}
${SHELL} shtests
exec 3> ${TMPDIR:-/tmp}/log
LANG=POSIX
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:10} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:10} 4000
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:11} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:11} 4000
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:12} 4
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:12} 40
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:13} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:13} 4000
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:14} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:14} 4000
if test $((IGNORED & SIGPIPE)) -eq 0 ; then
${SHELL} -c 'g="false"; trap "print -u2 PIPED; \$g && exit 0 ; g=true" PIPE ; while true ; do echo hello ; done' | head -n 10
fi
LANG=en_US.UTF-8
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:10} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:10} 4000
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:11} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:11} 4000
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:12} 4
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:12} 40
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:13} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:13} 4000
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:14} 400
strace $MEMORY -o '!%{S:31}' ${SHELL} %{S:14} 4000
if test $((IGNORED & SIGPIPE)) -eq 0 ; then
${SHELL} -c 'g="false"; trap "print -u2 PIPED; \$g && exit 0 ; g=true" PIPE ; while true ; do echo hello ; done' | head -n 10
fi
LANG=POSIX
exec 3>&-
uniq -c ${TMPDIR:-/tmp}/log
killall -q -s 9 ${SHELL} || true
popd
%endif
pushd ${root}/${base}
rm -f libshell.a
rm -f ${root}/bin/ksh
rm -f ${root}/bin/shcomp
ksh=$(grep -e '-o ksh' $log | tail -n 1 |\
sed "s@+ g\?cc@$CC@;s@-o ksh@-o ${root}/bin/ksh@;s@[a-zA-Z0-9_/\.-]*lib\([a-z]\+\)\.a@-l\1@g;s@'@@g")
ksht=$(grep -e '-o ksh' $log | tail -n 1 |\
sed "s@+ g\?cc@$CC@;s@-o ksh@-o ${root}/bin/ksh.test@;s@[a-zA-Z0-9_/\.-]*lib\([a-z]\+\)\.a@-l\1@g;s@'@@g")
test -n "${ksh}" || { echo build of ksh failed; exit 1; }
shcomp=$(grep -e '-o shcomp' $log | tail -n 1 |\
sed "s@+ g\?cc@$CC@;s@-o shcomp@-o ${root}/bin/shcomp@;s@[a-zA-Z0-9_/\.-]*lib\([a-z]\+\)\.a@-l\1@g;s@'@@g")
shcompt=$(grep -e '-o shcomp' $log | tail -n 1 |\
sed "s@+ g\?cc@$CC@;s@-o shcomp@-o ${root}/bin/shcomp.test@;s@[a-zA-Z0-9_/\.-]*lib\([a-z]\+\)\.a@-l\1@g;s@'@@g")
test -n "${shcomp}" || { echo build of shcomp failed; exit 1; }
suidex=$(grep -e '-o suid_exec' $log | tail -n 1 |\
sed "s@+ g\?cc@$CC@;s@-o shcomp@-o ${root}/bin/suid_exec@;s@[a-zA-Z0-9_/\.-]*lib\([a-z]\+\)\.a@-l\1@g;s@'@@g")
test -n "${suidex}" || { echo build of suidex failed; exit 1; }
${ksht} -Wl,-rpath,${root}/lib
${shcompt} -Wl,-rpath,${root}/lib
${ksh} -Wl,-rpath-link,${root}/lib -Wl,-rpath,/%{_lib}/ast
${shcomp} -Wl,-rpath-link,${root}/lib -Wl,-rpath,/%{_lib}/ast
${suidex} -Wl,-rpath-link,${root}/lib -Wl,-rpath,/%{_lib}/ast
for bin in ksh shcomp pty what mime asa dlls suid_exec ; do
relink $bin /bin/$bin -Wl,-rpath-link,${root}/lib -Wl,-rpath,/%{_lib}/ast
done
popd
OPATH=$PATH
OSHELL=$SHELL
PATH=$PATH:${root}/bin
SHELL=${root}/bin/ksh.test
SHCOMP=${root}/bin/shcomp.test
export PATH SHCOMP SHELL
%if !0%{?qemu_user_space_build:1}
pushd ${test}
typeset -i failed=0
ln -sf ${root}/lib ${test}/../
rm -f pty.sh
${root}/bin/ksh.test shtests
LANG=POSIX
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:10} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:10} 4000
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:11} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:11} 4000
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:12}
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:13} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:13} 4000
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:14} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:14} 4000
if test $((IGNORED & SIGPIPE)) -eq 0 ; then
${root}/bin/ksh.test -c 'g="false"; trap "print -u2 PIPED; \$g && exit 0 ; g=true" PIPE ; while true ; do echo hello ; done' | head -n 10
fi
LANG=en_US.UTF-8
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:10} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:10} 4000
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:11} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:11} 4000
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:12}
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:13} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:13} 4000
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:14} 400
strace $MEMORY -o '!%{S:31}' ${root}/bin/ksh.test %{S:14} 4000
if test $((IGNORED & SIGPIPE)) -eq 0 ; then
${root}/bin/ksh.test -c 'g="false"; trap "print -u2 PIPED; \$g && exit 0 ; g=true" PIPE ; while true ; do echo hello ; done' | head -n 10
fi
LANG=POSIX
killall -q -s 9 ${root}/bin/ksh.test || true
popd
%endif
LD_LIBRARY_PATH=${root}/lib
export LD_LIBRARY_PATH
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')"
@ -491,18 +523,20 @@ fi
msggen share/locale/C/LC_MESSAGES/libshell src/cmd/ksh93/libshell.msg
pushd ${root}/bin
PATH=$PATH:.
set -- $(shcomp.test --version 2>&1)
set -- $(shcomp --version 2>&1)
eval version=\${$#}
shcomp.test --nroff 2>&1 | sed 's/\(\.TH .*\)/\1 "2003-03-02" "" "Korn shell utilities"/' > ../man/man1/shcomp.1
rm -v ksh.test shcomp.test
for bin in shcomp pty what mime asa dlls ; do
$bin --nroff 2>&1 | sed 's/\(\.TH .*\)/\1 "%{date}" "" "Korn shell utilities"/' > ../man/man1/$bin.1
done
popd
test -d /tmp -ef ${TMPDIR} || rm -rf ${TMPDIR}
SHELL=$OSHELL
PATH=$OPATH
%install
root=$(echo ${PWD}/arch/linux*)
test -d $root || exit 1
pushd $root || exit 1
pushd $root || exit 1
mkdir -p %{buildroot}/bin
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}/%{_lib}/ast/bin
@ -516,25 +550,27 @@ fi
%endif
mkdir -p %{buildroot}%{_datadir}/ksh/fun
mkdir -p %{buildroot}%{_sysconfdir}/permissions.d
install bin/ksh %{buildroot}/%{_lib}/ast/bin/
install bin/shcomp %{buildroot}/%{_lib}/ast/bin/
install bin/ksh %{buildroot}/bin/ksh93
install bin/shcomp %{buildroot}%{_bindir}/shcomp
%if %use_opt_bins
for bin in pty what mime asa dlls ; do
install bin/$bin %{buildroot}/%{_bindir}/$bin
done
%endif
%if %use_suid_exe
install bin/suid_exec %{buildroot}/%{_lib}/ast/bin/
%endif
ln -sf bin/ksh %{buildroot}/%{_lib}/ast/ksh
# create ghost files
ln -sf /bin/true %{buildroot}/bin/ksh
ln -sf /bin/true %{buildroot}%{_bindir}/ksh
%if %suse_version > 1120
ln -sf ../man1/ksh93.1.gz %{buildroot}/%{_mandir}/man1/ksh.1.gz
ln -sf /%{_lib}/ast/bin/ksh %{buildroot}/bin/ksh93
ln -sf /%{_lib}/ast/bin/ksh %{buildroot}%{_bindir}/ksh93
%endif
ln -sf /%{_lib}/ast/bin/ksh %{buildroot}%{_bindir}/rksh
ln -sf /%{_lib}/ast/bin/shcomp %{buildroot}%{_bindir}/shcomp
ln -sf ast %{buildroot}/%{_lib}/ksh
cp -a lib/*.so* %{buildroot}/%{_lib}/ast/
cp -a fun/* %{buildroot}%{_datadir}/ksh/fun/
ln -sf /bin/true %{buildroot}/bin/ksh
ln -sf /bin/true %{buildroot}%{_bindir}/ksh
ln -sf /bin/ksh93 %{buildroot}%{_bindir}/rksh
ln -sf /bin/ksh93 %{buildroot}/%{_lib}/ast/ksh
ln -sf ast %{buildroot}/%{_lib}/ksh
cp -a lib/*.so* %{buildroot}/%{_lib}/ast/
cp -a fun/* %{buildroot}%{_datadir}/ksh/fun/
if cmp -s %{buildroot}%{_datadir}/ksh/fun/pushd %{buildroot}%{_datadir}/ksh/fun/popd ; then
ln -sf pushd %{buildroot}%{_datadir}/ksh/fun/popd
fi
for so in %{buildroot}/%{_lib}/ast/*.so.*.* ; do
so=${so##*/}
ln -sf /%{_lib}/ast/$so %{buildroot}%{_libdir}/ast/${so%%%%.*}.so
@ -550,16 +586,27 @@ fi
install -m 0644 lib/*.a %{buildroot}%{_libdir}/ast/
%if %suse_version > 1120
install -m 0644 man/man1/sh.1 %{buildroot}%{_mandir}/man1/ksh93.1
ln -sf ../man1/ksh93.1.gz %{buildroot}/%{_mandir}/man1/ksh.1.gz
ln -sf ../man1/ksh93.1.gz %{buildroot}/%{_mandir}/man1/rksh.1.gz
%else
install -m 0644 man/man1/sh.1 %{buildroot}%{_mandir}/man1/ksh.1
ln -sf ../man1/ksh.1.gz %{buildroot}/%{_mandir}/man1/rksh.1.gz
%endif
install -m 0644 man/man1/shcomp.1 %{buildroot}%{_mandir}/man1/shcomp.1
%if %use_opt_bins
for bin in pty what mime asa dlls ; do
install -m 0644 man/man1/$bin.1 %{buildroot}%{_mandir}/man1/$bin.1
done
%endif
for man in man/man3/*.3 ; do
man=${man##*/}
ast=${man}ast
install -m 0644 man/man3/${man} %{buildroot}%{_mandir}/man3/${ast}
done
install -m 0644 include/ast/* %{buildroot}%{_includedir}/ast/
if cmp -s %{buildroot}%{_includedir}/ast/namval.h %{buildroot}%{_includedir}/ast/ast_namval.h ; then
ln -sf ast_namval.h %{buildroot}%{_includedir}/ast/namval.h
fi
popd
%if %use_locale
for msg in share/locale/* ; do
@ -579,7 +626,7 @@ fi
if test -s lib/package/LICENSES/ast ; then
cp lib/package/LICENSES/ast LICENSE
else
cp %{S:3} LICENSE
cp %{S:4} LICENSE
fi
mv src/cmd/ksh93/OBSOLETE src/cmd/ksh93/OBSOLETE.mm
echo '.VERBON 22' > grep.mm
@ -603,22 +650,50 @@ fi
set +C
%endif
%if %use_suid_exe
%if %{defined verify_permissions}
%verifyscript
%verify_permissions -e /%{_lib}/ast/bin/suid_exec
%endif
%endif
%post
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 \
%if %use_suid_exe
%if %{defined set_permissions}
%set_permissions /%{_lib}/ast/bin/suid_exec
%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
%endif
%if %suse_version > 1120
if test -x /%{_lib}/ast/bin/ksh ; then
%{_sbindir}/update-alternatives \
--quiet \
%if %suse_version > 1210
--force \
%endif
--remove ksh /%{_lib}/ast/bin/ksh
rm -f /%{_lib}/ast/bin/ksh
rm -f /%{_lib}/ast/bin/shcomp
fi
%{_sbindir}/update-alternatives \
--quiet \
%if %suse_version > 1210
--force \
%endif
--install /bin/ksh ksh /bin/ksh93 20 \
--slave %{_bindir}/ksh usr-bin-ksh /bin/ksh93 \
--slave %{_mandir}/man1/ksh.1.gz ksh.1.gz %{_mandir}/man1/ksh93.1.gz \
--slave %{_mandir}/man1/rksh.1.gz rksh.1.gz %{_mandir}/man1/ksh93.1.gz
%else
if test -x %{_lib}/ast/bin/ksh ; then
if test -x /%{_lib}/ast/bin/ksh ; then
rm -f /%{_lib}/ast/bin/ksh
rm -f /%{_lib}/ast/bin/shcomp
fi
if test -x /bin/ksh93 ; then
rm -f bin/ksh
ln -sf /%{_lib}/ast/bin/ksh bin/ksh
ln -sf /bin/ksh93 bin/ksh
rm -f %{_exec_prefix}/bin/ksh
ln -sf /%{_lib}/ast/bin/ksh %{_exec_prefix}/bin/ksh
ln -sf /bin/ksh93 %{_exec_prefix}/bin/ksh
fi
%endif
@ -626,52 +701,55 @@ fi
%preun
if test $1 -eq 0 ; then
%{_sbindir}/update-alternatives --remove ksh /%{_lib}/ast/bin/ksh
%{_sbindir}/update-alternatives --quiet --remove ksh /bin/ksh93
fi
%endif
%postun
if test ! -x %{_lib}/ast/bin/ksh ; then
if test ! -x bin/ksh ; then
if test ! -x bin/pdksh ; then
rm -f etc/ksh.kshrc
fi
%if %suse_version <= 1120
if test ! -e bin/ksh ; then
rm -f bin/ksh %{_exec_prefix}/bin/ksh
fi
rm -f bin/ksh %{_exec_prefix}/bin/ksh
%endif
fi
%files -f ksh.lang
%defattr(-,root,root)
%if %use_suid_exe
%{_sysconfdir}/permissions.d/ksh
%{_sysconfdir}/permissions.d/ksh.paranoid
%config %attr(0644,root,root) %{_sysconfdir}/permissions.d/ksh
%config %attr(0644,root,root) %{_sysconfdir}/permissions.d/ksh.paranoid
%endif
%doc LICENSE src/cmd/ksh93/COMPATIBILITY src/cmd/ksh93/RELEASE*
%doc Builtins PROMO OBSOLETE MEMORANDUM
%doc %{_mandir}/man1/shcomp.1.gz
/bin/ksh93
%ghost %verify(not link) /bin/ksh
%ghost %verify(not link) %{_bindir}/ksh
%if %suse_version > 1120
%ghost %verify(not link) %{_mandir}/man1/ksh.1.gz
%ghost %verify(not link) %{_mandir}/man1/rksh.1.gz
%doc %{_mandir}/man1/ksh93.1.gz
/bin/ksh93
%{_bindir}/ksh93
%else
%doc %{_mandir}/man1/ksh.1.gz
%doc %{_mandir}/man1/rksh.1.gz
%endif
%{_bindir}/rksh
%{_bindir}/shcomp
%doc %{_mandir}/man1/shcomp.1.gz
%if %use_opt_bins
%doc %{_mandir}/man1/pty.1.gz
%doc %{_mandir}/man1/what.1.gz
%doc %{_mandir}/man1/mime.1.gz
%doc %{_mandir}/man1/asa.1.gz
%doc %{_mandir}/man1/dlls.1.gz
%endif
%{_bindir}/*
%dir /%{_lib}/ast
%dir /%{_lib}/ast/bin
/%{_lib}/ast/ksh
/%{_lib}/ast/bin/ksh
/%{_lib}/ast/bin/shcomp
%if %use_suid_exe
%attr(4755,root,root) /%{_lib}/ast/bin/suid_exec
%endif
/%{_lib}/ast/*.so*
/%{_lib}/ast/ksh
/%{_lib}/ksh
%dir %{_datadir}/ksh
%dir %{_datadir}/ksh/fun

View File

@ -1,5 +1,5 @@
--- src/lib/libast/features/aso
+++ src/lib/libast/features/aso 2012-02-06 11:25:03.897933168 +0100
+++ src/lib/libast/features/aso 2012-02-20 12:09:41.065934089 +0100
@@ -5,7 +5,10 @@ if aso note{ gcc 4.1+ 64 bit memory atom
int main()
{
@ -12,115 +12,14 @@
}
}end && {
#define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n)
@@ -27,10 +30,13 @@ if aso note{ gcc 4.1+ 64 bit memory atom
#endif
}
elif aso note{ gcc 4.1+ 32 bit memory atomic operations model }end link{
+ #include <stdint.h>
@@ -31,7 +34,9 @@ elif aso note{ gcc 4.1+ 32 bit memory at
int main()
{
- unsigned int i = 0;
uint32_t i = 0;
- return __sync_fetch_and_add(&i,7);
+ uint32_t i = 0;
+ uint16_t j = 0;
+ uint8_t l = 0;
+ return __sync_fetch_and_add(&i,7)+__sync_fetch_and_add(&j,7)+__sync_fetch_and_add(&l,7);
}
}end && {
#define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n)
@@ -45,6 +51,7 @@ elif aso note{ gcc 4.1+ 32 bit memory at
#define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint32_t)o,(uint32_t)n))
}
elif aso note{ <atomic.h> atomic_cas_64 }end link{
+ #include <stdint.h>
#include <atomic.h>
int main()
{
@@ -53,6 +60,7 @@ elif aso note{ <atomic.h> atomic_cas_64
return atomic_cas_64(&i, 0, 1) != 0 || (atomic_add_32_nv(&j, 1) != 1;-1)
}
}end && {
+ #include <stdint.h>
#include <atomic.h>
#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n)
#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1)
@@ -73,6 +81,7 @@ elif aso note{ <atomic.h> atomic_cas_64
#endif
}
elif aso note{ <atomic.h> atomic_cas_32 }end link{
+ #include <stdint.h>
#include <atomic.h>
int main()
{
@@ -80,6 +89,7 @@ elif aso note{ <atomic.h> atomic_cas_32
return atomic_cas_32(&i, 0, 1) != 0 || (atomic_add_32_nv(&i, 1) != 1;-1)
}
}end && {
+ #include <stdint.h>
#include <atomic.h>
#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n)
#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1)
@@ -93,6 +103,7 @@ elif aso note{ <atomic.h> 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.h> atomic_cas_64 with -latomic }end link{
+ #include <stdint.h>
#include <atomic.h>
int main()
{
@@ -101,6 +112,7 @@ elif aso -latomic note{ <atomic.h> atomi
return atomic_cas_64(&i, 0, 1) != 0 || (atomic_add_32_nv(&j, 1) != 1;-1)
}
}end && {
+ #include <stdint.h>
#include <atomic.h>
#define _REQ_atomic
#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n)
@@ -122,6 +134,7 @@ elif aso -latomic note{ <atomic.h> atomi
#endif
}
elif aso note{ <atomic.h> atomic_cas_32 with -latomic }end link{
+ #include <stdint.h>
#include <atomic.h>
int main()
{
@@ -129,6 +142,7 @@ elif aso note{ <atomic.h> atomic_cas_32
return atomic_cas_32(&i, 0, 1) != 0 || (atomic_add_32_nv(&i, 1) != 1;-1)
}
}end && {
+ #include <stdint.h>
#include <atomic.h>
#define _REQ_atomic
#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n)
@@ -143,6 +157,7 @@ elif aso note{ <atomic.h> 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{ <atomic.h> cas64 }end link{
+ #include <stdint.h>
#include <atomic.h>
int main()
{
@@ -151,6 +166,7 @@ elif aso note{ <atomic.h> cas64 }end lin
return cas64(&i, 0, 1) != 0 || (atomic_add_32_nv(&j, 1) != 1;-1)
}
}end && {
+ #include <stdint.h>
#include <atomic.h>
#define _aso_cas8(p,o,n) cas8(p,o,n)
#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1)
@@ -171,6 +187,7 @@ elif aso note{ <atomic.h> cas64 }end lin
#endif
}
elif aso note{ <atomic.h> cas32 }end link{
+ #include <stdint.h>
#include <atomic.h>
int main()
{
@@ -178,6 +195,7 @@ elif aso note{ <atomic.h> cas32 }end lin
return cas32(&i, 0, 1) != 0 || (atomic_add_32_nv(&i, 1) != 1;-1)
}
}end && {
+ #include <stdint.h>
#include <atomic.h>
#define _aso_cas8(p,o,n) cas8(p,o,n)
#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1)

58
ksh93-builtin.dif Normal file
View File

@ -0,0 +1,58 @@
--- src/cmd/builtin/pty.c
+++ src/cmd/builtin/pty.c 2012-02-13 13:35:02.577933517 +0000
@@ -215,6 +215,12 @@ mkpty(int* master, int* slave)
#if !_lib_openpty
char* sname;
#endif
+#ifdef __linux__
+ sigset_t blckttou, oldset;
+ (void)sigemptyset(&blckttou);
+ (void)sigaddset(&blckttou, SIGTTOU);
+ sigprocmask(SIG_BLOCK, &blckttou, &oldset);
+#endif
/*
* some systems hang hard during the handshake
* if you know why then please let us know
@@ -237,6 +243,12 @@ mkpty(int* master, int* slave)
error(-1, "unable to get standard error window size");
}
#endif
+#ifdef __linux__
+# if !_lib_openpty
+# undef _lib_openpty
+# define _lib_openpty 1
+# endif
+#endif
#if _lib_openpty
if (openpty(master, slave, NULL, ttyp, winp) < 0)
return -1;
@@ -276,6 +288,9 @@ mkpty(int* master, int* slave)
#endif
fcntl(*master, F_SETFD, FD_CLOEXEC);
fcntl(*slave, F_SETFD, FD_CLOEXEC);
+#ifdef __linux__
+ sigprocmask(SIG_SETMASK, &oldset, NULL);
+#endif
alarm(0);
return 0;
}
--- src/cmd/builtin/what.c
+++ src/cmd/builtin/what.c 2012-02-13 11:02:18.645933606 +0000
@@ -68,7 +68,7 @@ static struct
int match;
int single;
size_t skip[UCHAR_MAX+1];
- unsigned char prev[3];
+ unsigned char prev[4];
} state;
static void
@@ -99,7 +99,7 @@ what(const char* file, Sfio_t* ip, Sfio_
{
next:
s = state.prev;
- s[0] = s[1] = s[2] = 0;
+ s[0] = s[1] = s[2] = s[3] = 0;
switch (mid)
{
default:

View File

@ -1,31 +1,18 @@
--- src/lib/libast/features/libpath.sh
+++ src/lib/libast/features/libpath.sh 2007-03-30 18:45:55.030440187 +0200
@@ -21,7 +21,7 @@
########################################################################
ok=0
for i in \
- -x /lib/ld.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
+ -x /lib64/ld.so /lib/ld.so /lib64/ld-*.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
-f /usr/shlib/libc.so /shlib/libc.so /usr/lib/libc.so \
-r /usr/shlib/libc.so /shlib/libc.so
do case $i in
--- src/lib/libast/features/map.c
+++ src/lib/libast/features/map.c 2009-12-09 12:13:24.423429613 +0100
@@ -66,10 +66,14 @@ main()
#define _map_malloc 1
printf("\n");
printf("#define _map_libc 1\n");
--- src/lib/libast/astsa/ast.h
+++ src/lib/libast/astsa/ast.h 2012-02-21 12:03:32.810434306 +0000
@@ -94,6 +94,12 @@ typedef struct
#define pointerof(x) ((void*)((char*)0+(x)))
#define roundof(x,y) (((x)+(y)-1)&~((y)-1))
+#ifdef __GNUC__
+#if (__GNUC__ >= 4) && !defined(offsetof)
+#define offsetof(type,member) __builtin_offsetof(type,member)
+#endif
+#if _map_libc || defined(__linux__)
printf("#undef basename\n");
printf("#define basename _ast_basename\n");
printf("#undef dirname\n");
printf("#define dirname _ast_dirname\n");
+#endif
+#if _map_libc
#if !_lib_eaccess
printf("#undef eaccess\n");
printf("#define eaccess _ast_eaccess\n");
+
#ifndef offsetof
#define offsetof(type,member) ((unsigned long)&(((type*)0)->member))
#endif
--- src/lib/libdll/features/dll
+++ src/lib/libdll/features/dll 2007-03-30 18:40:58.855596004 +0200
@@ -15,7 +15,7 @@ tst dll_DYNAMIC link{
@ -55,3 +42,42 @@
lib=$abi/$lib
fi
;;
--- src/lib/libast/features/libpath.sh
+++ src/lib/libast/features/libpath.sh 2007-03-30 18:45:55.030440187 +0200
@@ -21,7 +21,7 @@
########################################################################
ok=0
for i in \
- -x /lib/ld.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
+ -x /lib64/ld.so /lib/ld.so /lib64/ld-*.so /lib/ld-*.so /usr/lib/ld.so /lib/rld \
-f /usr/shlib/libc.so /shlib/libc.so /usr/lib/libc.so \
-r /usr/shlib/libc.so /shlib/libc.so
do case $i in
--- src/lib/libast/features/map.c
+++ src/lib/libast/features/map.c 2009-12-09 12:13:24.423429613 +0100
@@ -66,10 +66,14 @@ main()
#define _map_malloc 1
printf("\n");
printf("#define _map_libc 1\n");
+#endif
+#if _map_libc || defined(__linux__)
printf("#undef basename\n");
printf("#define basename _ast_basename\n");
printf("#undef dirname\n");
printf("#define dirname _ast_dirname\n");
+#endif
+#if _map_libc
#if !_lib_eaccess
printf("#undef eaccess\n");
printf("#define eaccess _ast_eaccess\n");
--- src/lib/libast/features/sys
+++ src/lib/libast/features/sys 2012-02-21 12:04:43.269934994 +0000
@@ -126,7 +126,7 @@ tst typ_signed_size_t output{
}
}end
-define offsetof (type,member) ((size_t)&(((type*)0)->member))
+define offsetof (type,member) __builtin_offsetof(type,member)
define EXIT_FAILURE 1
define EXIT_SUCCESS 0
define MB_CUR_MAX 1

View File

@ -0,0 +1,13 @@
--- src/cmd/ksh93/sh/jobs.c
+++ src/cmd/ksh93/sh/jobs.c 2012-02-08 11:52:14.000000000 +0100
@@ -841,7 +841,9 @@ static void job_reset(register struct pr
{
/* save the terminal state for current job */
#ifdef SIGTSTP
- job_fgrp(pw,tcgetpgrp(job.fd));
+ pid_t tgrp;
+ if((tgrp=tcgetpgrp(job.fd))!=job.mypid)
+ job_fgrp(pw,tgrp);
if(tcsetpgrp(job.fd,job.mypid) !=0)
return;
#endif /* SIGTSTP */

View File

@ -9,3 +9,23 @@
const char* description;
int index;
const char* conf;
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2012-02-21 11:26:13.622577250 +0100
@@ -169,7 +169,7 @@ struct match
char *val;
char *rval[2];
int *match;
- char node[NV_MINSZ+sizeof(char*)];
+ char node[NV_MINSZ+sizeof(char*)+sizeof(Dtlink_t)];
int first;
int vsize;
int nmatch;
@@ -772,7 +772,7 @@ static int hasgetdisc(register Namfun_t
void sh_setmatch(Shell_t *shp,const char *v, int vsize, int nmatch, int match[],int index)
{
struct match *mp = &ip->SH_MATCH_init;
- Namval_t *np = nv_namptr(mp->node,0);
+ Namval_t *np = (Namval_t*)(&(mp->node[0]));
register int i,n,x, savesub=shp->subshell;
Namarr_t *ap = nv_arrayptr(SH_MATCHNOD);
shp->subshell = 0;

View File

@ -1,11 +1,11 @@
--- src/cmd/ksh93/bltins/read.c
+++ src/cmd/ksh93/bltins/read.c 2008-12-17 14:01:01.000000000 +0000
@@ -263,6 +263,19 @@ int sh_readline(register Shell_t *shp,ch
@@ -280,6 +280,19 @@ int sh_readline(register Shell_t *shp,ch
delim = ((unsigned)flags)>>D_FLAG;
if(shp->fdstatus[fd]&IOTTY)
if((shp->fdstatus[fd]&IOTTY) && !keytrap)
tty_raw(fd,1);
+#if defined(__linux__)
+ else if (flags&N_FLAG)
+ if ((flags&N_FLAG) && (shp->fdstatus[fd]&(IOTTY|IONOSEEK))==0)
+ {
+ struct stat st;
+ if ((fstat(fd, &st) == 0) && S_ISFIFO(st.st_mode))

View File

@ -301,7 +301,7 @@
+ ({p+=ast.tmp_int;ast.tmp_wchar;}) : \
+ ({ast.tmp_int=*(unsigned char*)p;p+=ast.mb_sync+1;ast.tmp_int;})) : \
+ (*(unsigned char*)(p++)))
+#define mbnchar(p,n) (mbwide(p) ? \
+#define mbnchar(p,n) (mbwide() ? \
+ (((ast.tmp_int=(*ast.mb_towc)(&ast.tmp_wchar,(char*)(p),n))>0) ? \
+ ({p+=ast.tmp_int;ast.tmp_wchar;}) : \
+ ({ast.tmp_int=*(unsigned char*)p;p+=ast.mb_sync+1;ast.tmp_int;})) : \

178
ksh93.dif
View File

@ -179,6 +179,27 @@
fi
unset var
typeset -b var
--- src/cmd/ksh93/tests/bracket.sh
+++ src/cmd/ksh93/tests/bracket.sh 2012-02-09 14:11:32.365933854 +0000
@@ -221,6 +221,10 @@ done
[[ abcdcdabcde == {5}(ab|cd)e ]] || err_exit 'abcdcdabcd == {5}(ab|cd)e'
) || err_exit 'errors with {..}(...) patterns'
[[ D290.2003.02.16.temp == D290.+(2003.02.16).temp* ]] || err_exit 'pattern match bug with +(...)'
+atime=$(stat -c '%X' $file)
+sleep 2
+cat $file > /dev/null
+if [[ $atime -lt $(stat -c '%X' $file) ]] then
rm -rf $file
{
[[ -N $file ]] && err_exit 'test -N $tmp/*: st_mtime>st_atime after creat'
@@ -231,6 +235,7 @@ sleep 2
read
[[ -N $file ]] && err_exit 'test -N $tmp/*: st_mtime>st_atime after read'
} > $file < $file
+fi
if rm -rf "$file" && ln -s / "$file"
then [[ -L "$file" ]] || err_exit '-L not working'
[[ -L "$file"/ ]] && err_exit '-L with file/ not working'
--- src/cmd/ksh93/tests/builtins.sh
+++ src/cmd/ksh93/tests/builtins.sh 2009-07-09 13:14:50.000000000 +0000
@@ -332,7 +332,7 @@ wait $pid1
@ -190,6 +211,87 @@
v=$(getconf LIBPATH)
for v in ${v//,/ }
do v=${v#*:}
--- src/cmd/ksh93/tests/coprocess.sh
+++ src/cmd/ksh93/tests/coprocess.sh 2012-02-09 13:39:13.794169756 +0000
@@ -107,15 +107,15 @@ ${SHELL-ksh} |&
cop=$!
exp=Done
print -p $'print hello | cat\nprint '$exp
-read -t 5 -p
-read -t 5 -p
+read -t 50 -p
+read -t 50 -p
got=$REPLY
if [[ $got != $exp ]]
then err_exit "${SHELL-ksh} coprocess io failed -- got '$got', expected '$exp'"
fi
exec 5<&p 6>&p
exec 5<&- 6>&-
-{ sleep 4; kill $cop; } 2>/dev/null &
+{ sleep 10; kill $cop; } 2>/dev/null &
spy=$!
if wait $cop 2>/dev/null
then kill $spy 2>/dev/null
@@ -128,10 +128,10 @@ echo line1 | grep 'line2'
echo line2 | grep 'line1'
} |&
SECONDS=0 count=0
-while read -p -t 10 line
+while read -p -t 100 line
do ((count++))
done
-if (( SECONDS > 8 ))
+if (( SECONDS > 80 ))
then err_exit "read -p hanging (SECONDS=$SECONDS count=$count)"
fi
wait $!
@@ -154,7 +154,7 @@ e=12345
wait $!
done
print
-) 2>/dev/null | read -t 10 r
+) 2>/dev/null | read -t 100 r
[[ $r == $e ]] || err_exit "coprocess timing bug -- expected $e, got '$r'"
r=
(
@@ -166,8 +166,9 @@ r=
wait $!
done
print $r
-) 2>/dev/null | read -t 10 r
+) 2>/dev/null | read -t 100 r
[[ $r == $e ]] || err_exit "coprocess command substitution bug -- expected $e, got '$r'"
+kill $(jobs -p) 2>/dev/null
(
/bin/cat |&
@@ -205,7 +206,7 @@ do if ( trap - $sig ) 2> /dev/null
done
trap 'sleep_pid=; kill $pid; err_exit "coprocess 1 hung"' TERM
-{ sleep 5; kill $$; } &
+{ sleep 10; kill $$; } &
sleep_pid=$!
builtin cat
cat |&
@@ -220,7 +221,7 @@ trap - TERM
[[ $sleep_pid ]] && kill $sleep_pid
trap 'sleep_pid=; kill $pid; err_exit "coprocess 2 hung"' TERM
-{ sleep 5; kill $$; } &
+{ sleep 10; kill $$; } &
sleep_pid=$!
cat |&
pid=$!
@@ -232,7 +233,7 @@ trap - TERM
[[ $sleep_pid ]] && kill $sleep_pid
trap 'sleep_pid=; kill $pid; err_exit "coprocess 3 hung"' TERM
-{ sleep 5; kill $$; } &
+{ sleep 10; kill $$; } &
sleep_pid=$!
cat |&
pid=$!
--- src/cmd/ksh93/tests/locale.sh
+++ src/cmd/ksh93/tests/locale.sh 2011-05-24 16:46:02.000000000 +0200
@@ -62,7 +62,7 @@ done
@ -253,6 +355,29 @@
PATH=$path
--- src/cmd/ksh93/tests/pty.sh
+++ src/cmd/ksh93/tests/pty.sh 2012-02-20 13:49:24.729935773 +0000
@@ -419,16 +419,16 @@ r echo repeat-3
!
# err_exit #
-whence -q less &&
+whence -q more &&
TERM=vt100 tst $LINENO <<"!"
L ksh process/terminal group exercise
-w while :; do echo y; done | less
-u ^:\E
+w while :; do echo y; done | more
+u --More--
c \cZ
r Stopped
w fg
-u ^:\E
+w q
!
exit $((Errors<125?Errors:125))
--- src/cmd/ksh93/tests/signal.sh
+++ src/cmd/ksh93/tests/signal.sh 2011-05-20 13:25:48.196426330 +0000
@@ -285,10 +285,10 @@ then for exp in TERM VTALRM PIPE
@ -385,3 +510,56 @@
chmodf = lchmod;
goto commit;
#else
--- src/lib/libcmd/vmstate.c
+++ src/lib/libcmd/vmstate.c 2012-02-21 13:10:56.085934573 +0000
@@ -50,6 +50,7 @@ USAGE_LICENSE
#include <cmd.h>
#include <vmalloc.h>
+#include <sfdisc.h>
typedef struct State_s
{
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c 2012-02-20 10:33:24.362018545 +0000
@@ -508,25 +508,26 @@ static void put_cdpath(register Namval_t
static void put_ifs(register Namval_t* np,const char *val,int flags,Namfun_t *fp)
{
register struct ifs *ip = (struct ifs*)fp;
+ Namfun_t *xp;
ip->ifsnp = 0;
- if(!val)
+ if(val)
{
- fp = nv_stack(np, NIL(Namfun_t*));
- if(fp && !fp->nofree)
- {
- free((void*)fp);
- fp = 0;
- }
+ if(val != np->nvalue.cp)
+ nv_putv(np, val, flags, fp);
+ return;
}
- if(val != np->nvalue.cp)
- nv_putv(np, val, flags, fp);
- if(!val)
+ if((xp = nv_stack(np, NIL(Namfun_t*))) != fp)
+ sfprintf(sfstderr, "BUG in %s:%s(%d) xp(%p) != fp(%p)\n",
+ __FILE__, __FUNCTION__, __LINE__, xp, fp);
+ if(fp && !fp->nofree)
{
- fp->next = np->nvfun;
- np->nvfun = fp;
+ free((void*)fp);
+ fp = NIL(Namfun_t*);
}
- else if(!val)
- np->nvfun = 0;
+ nv_putv(np, NIL(char*), flags, fp);
+ if(fp)
+ fp->next = np->nvfun;
+ np->nvfun = fp;
}
/*

View File

@ -5,32 +5,38 @@
#
# Usage:
#
# strace -e mmap,mmap2,munmap -o '|./vmbalance' ksh leak1.sh
# strace -s 128 -e execve,mmap,mmap2,munmap -o '|./vmbalance' ksh leak1.sh
#
BEGIN {
FS="([[:blank:]]|[[:punct:]])"
ignore=""
script=""
sum=0
allocs=0
frees=0
}
/^execve/ {
if (FNR == 1) {
script = gensub(/.*SOURCES\/([[:alnum:]_-]+\.sh).*/, "\\1", "g", $0)
}
}
/^mmap(2|64)?\(/ {
if ($0 !~ /.*MAP_PRIVATE\|MAP_ANONYMOUS.*/) {
if ($0 !~ /.*MAP_PRIVATE\|MAP_ANONYMOUS.*/) {
if (ignore)
ignore=ignore "|" $NF
else
ignore=$NF
} else {
} else {
sum+=$4
allocs++
}
}
}
/^munmap(2|64)?\(/ {
if ($0 !~ ignore) {
if ($0 !~ ignore) {
sum-=$4
frees++
}
}
}
END {
print sum " bytes with " allocs " chunks allocated and " frees " chunks freed"
print script ": " sum " bytes with " allocs " chunks allocated and " frees " chunks freed" > "/dev/fd/3"
}

View File

@ -85,7 +85,7 @@
}
--- src/cmd/ksh93/Mamfile
+++ src/cmd/ksh93/Mamfile 2011-05-20 13:34:20.000000000 +0000
+++ src/cmd/ksh93/Mamfile 2012-02-10 15:30:30.774546719 +0100
@@ -7,7 +7,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS
setv ARFLAGS rc
setv AS as
@ -122,8 +122,25 @@
done shcomp generated
make suid_exec
make suid_exec.o
@@ -1377,14 +1377,14 @@ meta suid_exec.o %.c>%.o sh/suid_exec.c
prev sh/suid_exec.c
setv CC.DLL -UCC.DLL
setv _BLD_shell -U_BLD_shell
-exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DERROR_CONTEXT_T=Error_context_t -D_API_ast=20100309 -D_PACKAGE_ast -c sh/suid_exec.c
+exec - ${CC} ${mam_cc_FLAGS} ${CCFLAGS} -fPIE -I. -Iinclude -I${PACKAGE_ast_INCLUDE} -DERROR_CONTEXT_T=Error_context_t -D_API_ast=20100309 -D_PACKAGE_ast -c sh/suid_exec.c
done suid_exec.o generated
prev +ljobs
prev +li
prev ${mam_libsocket}
prev ${mam_libsecdb}
setv CC.DLL -UCC.DLL
-exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -o suid_exec suid_exec.o ${mam_libast} ${mam_libnsl} ${mam_libast}
+exec - ${CC} ${CCLDFLAGS} ${mam_cc_FLAGS} ${CCFLAGS} ${LDFLAGS} ${mam_cc_L+-L.} ${mam_cc_L+-L${INSTALLROOT}/lib} -pie -o suid_exec suid_exec.o ${mam_libast} ${mam_libnsl} ${mam_libast}
done suid_exec generated
make shell
prev libshell.a archive
--- src/lib/libast/Mamfile
+++ src/lib/libast/Mamfile 2012-02-06 10:05:34.917933005 +0000
+++ src/lib/libast/Mamfile 2012-02-20 12:00:37.157934600 +0100
@@ -5,7 +5,7 @@ setv AR ${mam_cc_AR} ${mam_cc_AR_ARFLAGS
setv ARFLAGS rc
setv AS as
@ -151,7 +168,7 @@
done lcgen generated
make port/lc.tab
done port/lc.tab
@@ -7282,64 +7282,37 @@ done ${INSTALLROOT}/lib/file/magic gener
@@ -7280,65 +7280,38 @@ done ${INSTALLROOT}/lib/file/magic gener
make ${INSTALLROOT}/include/ast/fmtmsg.h
prev comp/fmtmsg.h
prev ast_lib.h
@ -172,7 +189,8 @@
exec - }
-exec - ;;
-exec - esac
prev ${INSTALLROOT}/include/prototyped.h implicit
make ${INSTALLROOT}/include/prototyped.h implicit
done ${INSTALLROOT}/include/prototyped.h dontcare
done ${INSTALLROOT}/include/ast/fmtmsg.h generated
make ${INSTALLROOT}/include/ast/libgen.h
prev comp/libgen.h