mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-27 06:11:06 +02:00
26950: warn on failed attempt to change user or group ID
26593: print warning but dont fail test if simple Unicode conversion fails
This commit is contained in:
parent
b2176aa525
commit
ff0b4ebdd5
3 changed files with 39 additions and 17 deletions
|
@ -1,5 +1,11 @@
|
||||||
2009-05-08 Peter Stephenson <pws@csr.com>
|
2009-05-08 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 26953: Test/D07multibyte.ztst: print warning but don't fail test
|
||||||
|
if system apparently can't do simple character set conversion.
|
||||||
|
|
||||||
|
* 26950: Src/params.c: warn on failed attempt to change real or
|
||||||
|
effective group or user ID.
|
||||||
|
|
||||||
* 26949: Completion/Unix/Command/_sudo: new options and sudoedit.
|
* 26949: Completion/Unix/Command/_sudo: new options and sudoedit.
|
||||||
|
|
||||||
* 26948: Src/Zle/zle_refresh.c: ensure recorded window sizes
|
* 26948: Src/Zle/zle_refresh.c: ensure recorded window sizes
|
||||||
|
@ -11673,5 +11679,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.4680 $
|
* $Revision: 1.4681 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
18
Src/params.c
18
Src/params.c
|
@ -3527,7 +3527,11 @@ usernamesetfn(UNUSED(Param pm), char *x)
|
||||||
# ifdef USE_INITGROUPS
|
# ifdef USE_INITGROUPS
|
||||||
initgroups(x, pswd->pw_gid);
|
initgroups(x, pswd->pw_gid);
|
||||||
# endif
|
# endif
|
||||||
if(!setgid(pswd->pw_gid) && !setuid(pswd->pw_uid)) {
|
if (setgid(pswd->pw_gid))
|
||||||
|
zwarn("failed to change group ID: %e", errno);
|
||||||
|
else if (setuid(pswd->pw_uid))
|
||||||
|
zwarn("failed to change user ID: %e", errno);
|
||||||
|
else {
|
||||||
zsfree(cached_username);
|
zsfree(cached_username);
|
||||||
cached_username = ztrdup(pswd->pw_name);
|
cached_username = ztrdup(pswd->pw_name);
|
||||||
cached_uid = pswd->pw_uid;
|
cached_uid = pswd->pw_uid;
|
||||||
|
@ -3553,7 +3557,8 @@ void
|
||||||
uidsetfn(UNUSED(Param pm), zlong x)
|
uidsetfn(UNUSED(Param pm), zlong x)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SETUID
|
#ifdef HAVE_SETUID
|
||||||
setuid((uid_t)x);
|
if (setuid((uid_t)x))
|
||||||
|
zwarn("failed to change user ID: %e", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3573,7 +3578,8 @@ void
|
||||||
euidsetfn(UNUSED(Param pm), zlong x)
|
euidsetfn(UNUSED(Param pm), zlong x)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SETEUID
|
#ifdef HAVE_SETEUID
|
||||||
seteuid((uid_t)x);
|
if (seteuid((uid_t)x))
|
||||||
|
zwarn("failed to change effective user ID: %e", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3593,7 +3599,8 @@ void
|
||||||
gidsetfn(UNUSED(Param pm), zlong x)
|
gidsetfn(UNUSED(Param pm), zlong x)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SETUID
|
#ifdef HAVE_SETUID
|
||||||
setgid((gid_t)x);
|
if (setgid((gid_t)x))
|
||||||
|
zwarn("failed to change group ID: %e", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3613,7 +3620,8 @@ void
|
||||||
egidsetfn(UNUSED(Param pm), zlong x)
|
egidsetfn(UNUSED(Param pm), zlong x)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SETEUID
|
#ifdef HAVE_SETEUID
|
||||||
setegid((gid_t)x);
|
if (setegid((gid_t)x))
|
||||||
|
zwarn("failed to change effective group ID: %e", errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,17 +378,25 @@
|
||||||
>X$'\300'Y$'\a'Z$'\177'T
|
>X$'\300'Y$'\a'Z$'\177'T
|
||||||
|
|
||||||
# This also isn't strictly multibyte and is here to reduce the
|
# This also isn't strictly multibyte and is here to reduce the
|
||||||
# likelihood of a "can't do character set conversion" error.
|
# likelihood of a "cannot do character set conversion" error.
|
||||||
testfn() { (LC_ALL=C; print $'\u00e9') }
|
(print $'\u00e9') 2>&1 | read
|
||||||
repeat 4 testfn 2>&1 | while read line; do
|
if [[ $REPLY != é ]]; then
|
||||||
if [[ $line = *"character not in range"* ]]; then
|
print "warning: your system can't do simple Unicode conversion." >&$ZTST_fd
|
||||||
print OK
|
print "Check you have a correctly installed iconv library." >&$ZTST_fd
|
||||||
elif [[ $line = "?" ]]; then
|
# cheat
|
||||||
print OK
|
repeat 4 print OK
|
||||||
else
|
else
|
||||||
print Failed: no error message and no question mark
|
testfn() { (LC_ALL=C; print $'\u00e9') }
|
||||||
fi
|
repeat 4 testfn 2>&1 | while read line; do
|
||||||
done
|
if [[ $line = *"character not in range"* ]]; then
|
||||||
|
print OK
|
||||||
|
elif [[ $line = "?" ]]; then
|
||||||
|
print OK
|
||||||
|
else
|
||||||
|
print Failed: no error message and no question mark
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
true
|
true
|
||||||
0:error handling in Unicode quoting
|
0:error handling in Unicode quoting
|
||||||
>OK
|
>OK
|
||||||
|
|
Loading…
Reference in a new issue