1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
26 * AT&T Bell Laboratories
28 * shell library support
35 * return pointer to the full path name of the shell
37 * SHELL is read from the environment and must start with /
39 * if set-uid or set-gid then the executable and its containing
40 * directory must not be owned by the real user/group
42 * root/administrator has its own test
44 * astconf("SH",NiL,NiL) is returned by default
46 * NOTE: csh is rejected because the bsh/csh differentiation is
47 * not done for `csh script arg ...'
62 if ((sh
= getenv("SHELL")) && *sh
== '/' && strmatch(sh
, "*/(sh|*[!cC]sh)*([[:digit:]])?(-+([.[:alnum:]]))?(.exe)"))
64 if (!(ru
= getuid()) || !eaccess("/bin", W_OK
))
68 if (ru
!= st
.st_uid
&& !strmatch(sh
, "?(/usr)?(/local)/?([ls])bin/?([[:lower:]])sh?(.exe)"))
76 if (ru
!= eu
|| rg
!= eg
)
86 if (ru
!= eu
&& st
.st_uid
== ru
)
88 if (rg
!= eg
&& st
.st_gid
== rg
)
92 if (strlen(s
) >= sizeof(dir
))
95 if (!(s
= strrchr(dir
, '/')))
107 if (!*(sh
= astconf("SH", NiL
, NiL
)) || *sh
!= '/' || eaccess(sh
, X_OK
) || !(sh
= strdup(sh
)))