mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Reenable the clobber method on UnixWare. (#160)
UnixWare's ps prefers to read psinfo (from the proc structure in kernel memory) within /proc as an anti-Trojan horse measure. Updates to argv[0] are still reflected within /proc/$pid/cmdline, which is useful for diagnostic purposes. src/cmd/ksh93/sh/main.c: - Remove __USLC__ from the list of platforms excluded from the fixargs method. src/cmd/ksh93/tests/basic.sh: - Read /proc/$pid/cmdline instead of ps on UnixWare.
This commit is contained in:
parent
d2cc520883
commit
e73696fd87
2 changed files with 13 additions and 4 deletions
|
@ -53,7 +53,7 @@
|
||||||
/* These routines are referenced by this module */
|
/* These routines are referenced by this module */
|
||||||
static void exfile(Shell_t*, Sfio_t*,int);
|
static void exfile(Shell_t*, Sfio_t*,int);
|
||||||
static void chkmail(Shell_t *shp, char*);
|
static void chkmail(Shell_t *shp, char*);
|
||||||
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__USLC__) && !defined(__sun)
|
#if defined(_lib_fork) && !defined(_NEXT_SOURCE) && !defined(__sun)
|
||||||
static void fixargs(char**,int);
|
static void fixargs(char**,int);
|
||||||
#else
|
#else
|
||||||
# define fixargs(a,b)
|
# define fixargs(a,b)
|
||||||
|
|
|
@ -712,19 +712,28 @@ getPsOutput() {
|
||||||
while [[ $actual == [[:space:]]* ]]; do actual=${actual#?}; done
|
while [[ $actual == [[:space:]]* ]]; do actual=${actual#?}; done
|
||||||
while [[ $actual == *[[:space:]] ]]; do actual=${actual%?}; done
|
while [[ $actual == *[[:space:]] ]]; do actual=${actual%?}; done
|
||||||
}
|
}
|
||||||
if [[ ! $(uname -s) =~ ^(SunOS|UnixWare)$ ]] &&
|
getCmdline() {
|
||||||
|
if [[ $(uname -s) =~ ^UnixWare$ ]]; then
|
||||||
|
# UnixWare's ps does not trust the value stored in argv[0] as a
|
||||||
|
# security measure. It is still accessible within cmdline.
|
||||||
|
actual=$(< "/proc/${1}/cmdline")
|
||||||
|
else
|
||||||
|
getPsOutput "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [[ ! $(uname -s) =~ ^SunOS$ ]] &&
|
||||||
getPsOutput "$$" &&
|
getPsOutput "$$" &&
|
||||||
[[ "$SHELL $0" == "$actual"* ]] # "$SHELL $0" is how shtests invokes this script
|
[[ "$SHELL $0" == "$actual"* ]] # "$SHELL $0" is how shtests invokes this script
|
||||||
then expect='./atest 1 2'
|
then expect='./atest 1 2'
|
||||||
echo 'sleep 10; exit 0' >atest
|
echo 'sleep 10; exit 0' >atest
|
||||||
chmod 755 atest
|
chmod 755 atest
|
||||||
./atest 1 2 &
|
./atest 1 2 &
|
||||||
getPsOutput "$!"
|
getCmdline "$!"
|
||||||
kill "$!"
|
kill "$!"
|
||||||
[[ $actual == "$expect" ]] || err_exit "ksh didn't rewrite argv correctly" \
|
[[ $actual == "$expect" ]] || err_exit "ksh didn't rewrite argv correctly" \
|
||||||
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
|
"(expected $(printf %q "$expect"), got $(printf %q "$actual"))"
|
||||||
fi
|
fi
|
||||||
unset -f getPsOutput
|
unset -f getPsOutput getCmdline
|
||||||
|
|
||||||
# ======
|
# ======
|
||||||
# https://bugzilla.redhat.com/1241013
|
# https://bugzilla.redhat.com/1241013
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue