mksh no longer looks at its own called name or $SHELL

to determine if it should be a restricted shell
This commit is contained in:
tg 2005-07-04 11:57:55 +00:00
parent 29d0a88111
commit bfc5b81602
3 changed files with 7 additions and 30 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.18 2005/06/24 15:42:03 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.19 2005/07/04 11:57:55 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -3700,5 +3700,5 @@ category: pdksh
stdin:
echo $KSH_VERSION
expected-stdout:
@(#)MIRBSD KSH R23 2005/06/24
@(#)MIRBSD KSH R23 2005/07/04
---

21
main.c
View File

@ -1,4 +1,4 @@
/** $MirOS: src/bin/mksh/main.c,v 1.16 2005/06/24 15:42:03 tg Exp $ */
/** $MirOS: src/bin/mksh/main.c,v 1.17 2005/07/04 11:57:55 tg Exp $ */
/* $OpenBSD: main.c,v 1.38 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: tty.c,v 1.8 2005/03/30 17:16:37 deraadt Exp $ */
/* $OpenBSD: io.c,v 1.21 2005/03/30 17:16:37 deraadt Exp $ */
@ -13,15 +13,14 @@
#include <time.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.16 2005/06/24 15:42:03 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.17 2005/07/04 11:57:55 tg Exp $");
const char ksh_version[] = "@(#)MIRBSD KSH R23 2005/06/24";
const char ksh_version[] = "@(#)MIRBSD KSH R23 2005/07/04";
extern char **environ;
static void reclaim(void);
static void remove_temps(struct temp * tp);
static int is_restricted(char *name);
static const char initifs[] = "IFS= \t\n";
@ -329,8 +328,6 @@ main(int argc, char *argv[])
include(env_file, 0, NULL, 1);
}
if (is_restricted(argv[0]) || is_restricted(str_val(global("SHELL"))))
restricted = 1;
if (restricted) {
static const char *const restr_com[] = {
"typeset", "-r", "PATH",
@ -687,18 +684,6 @@ remove_temps(struct temp *tp)
}
}
/* Returns true if name refers to a restricted shell */
static int
is_restricted(char *name)
{
char *p;
if ((p = strrchr(name, '/')))
name = p;
/* accepts rsh, rksh, rmksh, rpdksh, pdrksh, etc. */
return (p = strchr(name, 'r')) && strstr(p, "sh");
}
void
aerror(Area *ap __attribute__((unused)), const char *msg)
{

12
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.9 2005/06/08 21:51:21 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.10 2005/07/04 11:57:55 tg Exp $
.\" $OpenBSD: ksh.1,v 1.99 2005/05/25 16:52:06 jaredy Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\"
@ -107,15 +107,7 @@ Restricted shell.
A shell is
.Dq restricted
if this
option is used or if either the basename the shell was invoked
with or the
.Ev SHELL
parameter match the pattern
.Dq *r*sh
(e.g.\&
.Nm rsh ,
.Nm rksh ,
.Nm rpdksh ) .
option is used.
The following restrictions come into effect after the shell processes any
profile and
.Ev ENV