1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Yet more misc. cleanups; rm SHOPT_PFSH, SHOPT_TYPEDEF

Notable changes:
- Remove SHOPT_PFSH compile-time option and associated code.
  This was meant to work with Solaris rights profiles, see:
  https://docs.oracle.com/cd/E23824_01/html/821-1461/profiles-1.html#REFMAN1profiles-1
  But it has been obsolete for years as Solaris stopped using
  it in its shipped ksh several OS versions ago, preferring a
  library-based wrapper around ksh and other shells.
  Nonetheless I experimented with the option on Solaris 11.4.
  Result: no external command will run; output of unitialised
  memory in error message. So it's already fallen victim to bit
  rot. There's nothing interesting here, so just get rid.
- Remove SHOPT_TYPEDEF compile-time option (but keep the code!).
  Turning it off caused the build to fail. It may be possible to
  fix it, but the type definition code is integral to ksh now (e.g.
  'enum' depends on much of it) so it makes no sense to disable it.
  This was removed in the ksh 93v- beta version as well.
- Remove nv_close() calls and remove nv_close() documentation from
  the nval.3 man page. This function is a dummy, present without
  any changes since the beginning of the ast-open-archive repo in
  1995. The comment was: "Currently this is a dummy, but someday
  will be needed for reference counting". 27 or more years later,
  it's time to admit it's never going to happen. (And of course,
  nv_close() calls were not being used with anything resembling
  consistency.)
- Add a null nv_close() macro to nval.h for compatibility with
  third party code that follows the old documentation.
- Add a few missing regression tests.
This commit is contained in:
Martijn Dekker 2022-02-10 13:44:43 +00:00
parent a00fe6b7fd
commit 14a43a0a88
38 changed files with 101 additions and 356 deletions

View file

@ -48,9 +48,6 @@ static char *null;
/* The following order is determined by sh_optset */
static const char optksh[] =
#if SHOPT_PFSH
"P"
#endif
"Dircabefhkmnpstuvx"
#if SHOPT_BRACEPAT
"B"
@ -62,9 +59,6 @@ static const char optksh[] =
;
static const int flagval[] =
{
#if SHOPT_PFSH
SH_PFSH,
#endif
SH_DICTIONARY, SH_INTERACTIVE, SH_RESTRICTED, SH_CFLAG,
SH_ALLEXPORT, SH_NOTIFY, SH_ERREXIT, SH_NOGLOB, SH_TRACKALL,
SH_KEYWORD, SH_MONITOR, SH_NOEXEC, SH_PRIVILEGED, SH_SFLAG, SH_TFLAG,
@ -306,10 +300,7 @@ int sh_argopts(int argc,register char *argv[])
strsort(sh.st.dolv+1,sh.st.dolc,strcoll);
}
if(np)
{
nv_setvec(np,0,argc,argv);
nv_close(np);
}
else if(argc>0 || ((cp=argv[-1]) && strcmp(cp,"--")==0))
argset(ap,argv-1);
}

View file

@ -404,7 +404,9 @@ static Namval_t *array_find(Namval_t *np,Namarr_t *arp, int flag)
return(np);
}
#if SHOPT_TYPEDEF
/*
* for 'typeset -T' types
*/
int nv_arraysettype(Namval_t *np, Namval_t *tp, const char *sub, int flags)
{
Namval_t *nq;
@ -431,7 +433,6 @@ int nv_arraysettype(Namval_t *np, Namval_t *tp, const char *sub, int flags)
}
return(0);
}
#endif /* SHOPT_TYPEDEF */
static Namfun_t *array_clone(Namval_t *np, Namval_t *mp, int flags, Namfun_t *fp)
@ -622,10 +623,8 @@ static void array_putval(Namval_t *np, const char *string, int flags, Namfun_t *
nv_putval(mp, string, flags);
if(string)
{
#if SHOPT_TYPEDEF
if(ap->hdr.type && ap->hdr.type!=nv_type(mp))
nv_arraysettype(np,ap->hdr.type,nv_getsub(np),0);
#endif /* SHOPT_TYPEDEF */
continue;
}
ap->nelem |= scan;
@ -713,10 +712,8 @@ static void array_putval(Namval_t *np, const char *string, int flags, Namfun_t *
else if(mp==np)
aq->val[aq->cur].cp = 0;
}
#if SHOPT_TYPEDEF
if(string && ap->hdr.type && nv_isvtree(np))
nv_arraysettype(np,ap->hdr.type,nv_getsub(np),0);
#endif /* SHOPT_TYPEDEF */
}
while(!string && nv_nextsub(np));
if(ap)

View file

@ -587,9 +587,7 @@ void sh_exit(register int xno)
sh.arithrecursion = 0;
sh.intrace = 0;
sh.prefix = 0;
#if SHOPT_TYPEDEF
sh.mktype = 0;
#endif /* SHOPT_TYPEDEF */
if(job.in_critical)
job_unlock();
if(pp->mode == SH_JMPSCRIPT && !pp->prev)

View file

@ -131,10 +131,6 @@ char e_version[] = "\n@(#)$Id: Version "
#define ATTRS 1
"M"
#endif
#if SHOPT_PFSH && _hdr_exec_attr
#define ATTRS 1
"P"
#endif
#if SHOPT_REGRESS
#define ATTRS 1
"R"
@ -1200,14 +1196,6 @@ int sh_type(register const char *path)
}
if (!(t & (SH_TYPE_PROFILE|SH_TYPE_RESTRICTED)))
{
#if SHOPT_PFSH
if (*s == 'p' && *(s+1) == 'f')
{
s += 2;
t |= SH_TYPE_PROFILE;
continue;
}
#endif
if (*s == 'r')
{
s++;
@ -1406,11 +1394,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit)
/* check for restricted shell */
if(type&SH_TYPE_RESTRICTED)
sh_onoption(SH_RESTRICTED);
#if SHOPT_PFSH
/* check for profile shell */
else if(type&SH_TYPE_PROFILE)
sh_onoption(SH_PFSH);
#endif
/* look for options */
/* sh.st.dolc is $# */
if((sh.st.dolc = sh_argopts(-argc,argv)) < 0)
@ -1468,15 +1451,6 @@ Shell_t *sh_init(register int argc,register char *argv[], Shinit_f userinit)
/* import variable attributes from environment */
if(!sh_isoption(SH_POSIX))
env_import_attributes(save_envmarker);
#if SHOPT_PFSH
if (sh_isoption(SH_PFSH))
{
struct passwd *pw = getpwuid(sh.userid);
if(pw)
sh.user = sh_strdup(pw->pw_name);
}
#endif
/* set[ug]id scripts require the -p flag */
if(sh.userid!=sh.euserid || sh.groupid!=sh.egroupid)
{
@ -2054,7 +2028,6 @@ static char *env_init(void)
{
nv_onattr(np,NV_IMPORT);
np->nvenv = cp;
nv_close(np);
}
else /* swap with front */
{

View file

@ -870,9 +870,7 @@ int sh_lex(Lex_t* lp)
poplevel(lp);
}
break;
#if SHOPT_TYPEDEF
case '@':
#endif /* SHOPT_TYPEDEF */
case '!':
if(n!=S_ALP)
goto dolerr;

View file

@ -91,7 +91,7 @@ typedef struct _mac_
#define M_NAMECOUNT 7 /* ${#var*} */
#define M_TYPE 8 /* ${@var} */
static noreturn void mac_error(Namval_t*);
static noreturn void mac_error(void);
static int substring(const char*, size_t, const char*, int[], int);
static void copyto(Mac_t*, int, int);
static void comsubst(Mac_t*, Shnode_t*, int);
@ -1128,13 +1128,11 @@ retry1:
{
if(c=='#')
type = M_SIZE;
#if SHOPT_TYPEDEF
else if(c=='@')
{
type = M_TYPE;
goto retry1;
}
#endif /* SHOPT_TYPEDEF */
else
type = M_VNAME;
mode = c;
@ -1439,7 +1437,6 @@ retry1:
if(ap && !mp->dotdot && !(ap->nelem&ARRAY_UNDEF))
addsub = 1;
}
#if SHOPT_TYPEDEF
else if(type==M_TYPE)
{
Namval_t *nq = nv_type(np);
@ -1450,7 +1447,6 @@ retry1:
nv_attribute(np,sh.strbuf,"typeset",1);
v = sfstruse(sh.strbuf);
}
#endif /* SHOPT_TYPEDEF */
#if SHOPT_FILESCAN
else if(sh.cur_line && np==REPLYNOD)
v = sh.cur_line;
@ -1521,7 +1517,7 @@ retry1:
if(type>M_TREE)
{
if(c!=RBRACE)
mac_error(np);
mac_error();
if(type==M_NAMESCAN || type==M_NAMECOUNT)
{
sh.last_root = sh.var_tree;
@ -1602,7 +1598,7 @@ retry1:
if(!isbracechar(c))
{
if(!nulflg)
mac_error(np);
mac_error();
fcseek(-LEN);
c = ':';
}
@ -1781,7 +1777,7 @@ retry1:
vsize = v?strlen(v):0;
}
if(*ptr)
mac_error(np);
mac_error();
stkseek(stkp,offset);
argp = 0;
}
@ -2022,7 +2018,7 @@ retry2:
goto retry2;
}
else
mac_error(np);
mac_error();
}
}
else if(var && sh_isoption(SH_NOUNSET) && type<=M_TREE && (!np || nv_isnull(np) || (nv_isarray(np) && !np->nvalue.cp)))
@ -2036,13 +2032,10 @@ retry2:
}
else
id = nv_name(np);
nv_close(np);
}
errormsg(SH_DICT,ERROR_exit(1),e_notset,id);
UNREACHABLE();
}
if(np)
nv_close(np);
if(pattern)
free(pattern);
if(idx)
@ -2056,9 +2049,8 @@ nosub:
return(1);
}
if(type)
mac_error(np);
mac_error();
fcseek(-1);
nv_close(np);
return(0);
}
@ -2798,10 +2790,8 @@ static char *special(register int c)
/*
* Handle macro expansion errors
*/
static noreturn void mac_error(Namval_t *np)
static noreturn void mac_error(void)
{
if(np)
nv_close(np);
errormsg(SH_DICT,ERROR_exit(1),e_subst,fcfirst());
UNREACHABLE();
}

View file

@ -77,16 +77,15 @@ struct adata
char *attval;
};
#if SHOPT_TYPEDEF
struct sh_type
{
/* for a 'typeset -T' type */
struct sh_type
{
void *previous;
Namval_t **nodes;
Namval_t *rp;
short numnodes;
short maxnodes;
};
#endif /* SHOPT_TYPEDEF */
};
#if NVCACHE
struct Namcache
@ -175,7 +174,9 @@ void nv_outname(Sfio_t *out, char *name, int len)
stakseek(offset);
}
#if SHOPT_TYPEDEF
/*
* for 'typeset -T' types
*/
Namval_t *nv_addnode(Namval_t* np, int remove)
{
register struct sh_type *sp = (struct sh_type*)sh.mktype;
@ -233,7 +234,6 @@ Namval_t *nv_addnode(Namval_t* np, int remove)
sp->nodes[sp->numnodes++] = np;
return(np);
}
#endif /* SHOPT_TYPEDEF */
/*
* given a list of assignments, determine <name> is on the list
@ -271,8 +271,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
Namarr_t *ap;
Namval_t node;
struct Namref nr;
#if SHOPT_TYPEDEF
int maketype = flags&NV_TYPE;
int maketype = flags&NV_TYPE; /* make a 'typeset -T' type definition command */
struct sh_type shtp;
if(maketype)
{
@ -283,7 +282,6 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
shtp.rp = 0;
shtp.nodes = (Namval_t**)sh_malloc(shtp.maxnodes*sizeof(Namval_t*));
}
#endif /* SHOPT_TYPEDEF */
#if SHOPT_NAMESPACE
if(sh.namespace && nv_dict(sh.namespace)==sh.var_tree)
flags |= NV_NOSCOPE;
@ -344,7 +342,6 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
stakputs(cp);
cp = stakfreeze(1);
}
nv_close(np);
}
}
np = nv_open(cp,sh.var_tree,flag|NV_ASSIGN);
@ -378,11 +375,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
nv_settype(np,typ,0);
}
if((flags&NV_STATIC) && !nv_isattr(np,NV_EXPORT) && !nv_isnull(np))
#if SHOPT_TYPEDEF
goto check_type;
#else
continue;
#endif /* SHOPT_TYPEDEF */
ap=nv_arrayptr(np);
#if SHOPT_FIXEDARRAY
if(ap && ap->fixed)
@ -408,13 +401,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
}
}
if(array && tp->tre.tretyp!=TLST && !tp->com.comset && !tp->com.comarg)
{
#if SHOPT_TYPEDEF
goto check_type;
#else
continue;
#endif /* SHOPT_TYPEDEF */
}
goto check_type;
/* check for array assignment */
if(tp->tre.tretyp!=TLST && tp->com.comarg && !tp->com.comset && ((array&NV_IARRAY) || !((mp=tp->com.comnamp) && nv_isattr(mp,BLT_DCL))))
{
@ -422,14 +409,12 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
Dt_t *last_root = sh.last_root;
char **argv = sh_argbuild(&argc,&tp->com,0);
sh.last_root = last_root;
#if SHOPT_TYPEDEF
if(sh.mktype && sh.dot_depth==0 && np==((struct sh_type*)sh.mktype)->nodes[0])
{
sh.mktype = 0;
errormsg(SH_DICT,ERROR_exit(1),"%s: not a known type name",argv[0]);
UNREACHABLE();
}
#endif /* SHOPT_TYPEDEF */
if(!(arg->argflag&ARG_APPEND))
{
#if SHOPT_FIXEDARRAY
@ -462,11 +447,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
sfwrite(sfstderr,")\n",2);
}
}
#if SHOPT_TYPEDEF
goto check_type;
#else
continue;
#endif /* SHOPT_TYPEDEF */
}
if((tp->tre.tretyp&COMMSK)==TFUN)
goto skip;
@ -494,17 +475,11 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
sh.prefix = prefix;
if(tp->com.comset->argval[1]!='[')
nv_setvtree(np);
nv_close(np);
#if SHOPT_TYPEDEF
goto check_type;
#else
continue;
#endif /* SHOPT_TYPEDEF */
}
if(*cp!='.' && *cp!='[' && strchr(cp,'['))
{
cp = stakcopy(nv_name(np));
nv_close(np);
if(!(arg->argflag&ARG_APPEND))
flag &= ~NV_ARRAY;
sh.prefix_root = sh.first_root;
@ -570,9 +545,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
L_ARGNOD->nvfun = 0;
}
sh_exec(tp,sh_isstate(SH_ERREXIT));
#if SHOPT_TYPEDEF
if(sh.prefix)
#endif
{
L_ARGNOD->nvalue.nrp = node.nvalue.nrp;
L_ARGNOD->nvflag = node.nvflag;
@ -594,11 +567,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
if(tp->com.comarg || tp->com.comset)
np->nvfun->dsize = 0;
}
#if SHOPT_TYPEDEF
goto check_type;
#else
continue;
#endif /* SHOPT_TYPEDEF */
}
cp = arg->argval;
mp = 0;
@ -659,7 +628,6 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
sh_debug(trap,name,sub,av,append);
}
}
#if SHOPT_TYPEDEF
check_type:
if(maketype)
{
@ -678,7 +646,7 @@ void nv_setlist(register struct argnod *arg,register int flags, Namval_t *typ)
L_ARGNOD->nvfun = node.nvfun;
}
}
#endif /* SHOPT_TYPEDEF */
/* continue loop */
}
}
@ -1490,10 +1458,8 @@ nocache:
}
c = *cp;
skip:
#if SHOPT_TYPEDEF
if(np && sh.mktype)
np = nv_addnode(np,0);
#endif /* SHOPT_TYPEDEF */
if(c=='=' && np && (flags&NV_ASSIGN))
{
cp++;
@ -2271,10 +2237,8 @@ static int scanfilter(Namval_t *np, struct scan *sp)
register int k=np->nvflag;
register struct adata *tp = (struct adata*)sp->scandata;
char *cp;
#if SHOPT_TYPEDEF
if(!is_abuiltin(np) && tp && tp->tp && nv_type(np)!=tp->tp)
return(0);
#endif /* SHOPT_TYPEDEF */
if(sp->scanmask==NV_TABLE && nv_isvtree(np))
k = NV_TABLE;
if(sp->scanmask?(k&sp->scanmask)==sp->scanflags:(!sp->scanflags || (k&sp->scanflags)))
@ -2423,15 +2387,6 @@ void sh_envnolocal (register Namval_t *np, void *data)
nv_onattr(np,NV_EXPORT);
}
/*
* Currently this is a dummy, but someday will be needed
* for reference counting
*/
void nv_close(Namval_t *np)
{
NOT_USED(np);
}
static void table_unset(register Dt_t *root, int flags, Dt_t *oroot)
{
register Namval_t *np,*nq, *npnext;
@ -3030,7 +2985,7 @@ void nv_newattr (register Namval_t *np, unsigned newatts, int size)
np->nvflag |= newatts;
goto skip;
}
#endif /* SHOPT_TYPEDEF */
#endif /* SHOPT_FIXEDARRAY */
}
do
{
@ -3113,7 +3068,7 @@ void nv_newattr (register Namval_t *np, unsigned newatts, int size)
while(ap && nv_nextsub(np));
#if SHOPT_FIXEDARRAY
skip:
#endif /* SHOPT_TYPEDEF */
#endif /* SHOPT_FIXEDARRAY */
if(fp)
np->nvfun = fp;
if(ap)

View file

@ -246,8 +246,7 @@ static void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle)
struct blocked block, *bp = block_info(np, &block);
Namval_t node;
union Value *up = np->nvalue.up;
#if SHOPT_TYPEDEF
Namval_t *tp, *nr;
Namval_t *tp, *nr; /* for 'typeset -T' types */
if(val && (tp=nv_type(np)) && (nr=nv_open(val,sh.var_tree,NV_VARNAME|NV_ARRAY|NV_NOADD|NV_NOFAIL)) && tp==nv_type(nr))
{
char *sub = nv_getsub(np);
@ -261,7 +260,6 @@ static void assign(Namval_t *np,const char* val,int flags,Namfun_t *handle)
nv_clone(nr,np,0);
goto done;
}
#endif /* SHOPT_TYPEDEF */
if(val || isblocked(bp,type))
{
if(!nq || isblocked(bp,type))
@ -1278,7 +1276,6 @@ Namval_t *sh_addbuiltin(const char *path, Shbltin_f bltin, void *extra)
if(nq)
{
cp=nv_setdisc(nq,cp+1,np,(Namfun_t*)nq);
nv_close(nq);
if(!cp)
{
errormsg(SH_DICT,ERROR_exit(1),e_baddisc,name);

View file

@ -878,7 +878,6 @@ static char **genvalue(char **argv, const char *prefix, int n, struct Walk *wp)
if(wp->indent>0)
sfnputc(outfile,'\t',wp->indent);
nv_attribute(np,outfile,"typeset",1);
nv_close(np);
sfputr(outfile,arg+m+r+(n?n:0),(k?'=':'\n'));
if(!k)
{

View file

@ -450,10 +450,8 @@ static Namfun_t *clone_type(Namval_t* np, Namval_t *mp, int flags, Namfun_t *fp)
}
else
nv_putval(nq,nv_getval(nr),NV_RDONLY);
#if SHOPT_TYPEDEF
if(sh.mktype)
nv_addnode(nr,1);
#endif /* SHOPT_TYPEDEF */
if(pp->strsize<0)
continue;
_nv_unset(nr,0);
@ -1303,7 +1301,6 @@ int nv_settype(Namval_t* np, Namval_t *tp, int flags)
Namarr_t *ap=0;
int nelem = 0;
unsigned int subshell = sh.subshell;
#if SHOPT_TYPEDEF
Namval_t *tq;
if(nv_type(np)==tp)
return(0);
@ -1341,8 +1338,8 @@ int nv_settype(Namval_t* np, Namval_t *tp, int flags)
}
}
else
#endif /* SHOPT_TYPEDEF */
{
/* non-typeset -T type */
if(isnull)
flags &= ~NV_APPEND;
else if(!nv_isvtree(np))

View file

@ -36,16 +36,6 @@
#include "test.h"
#include "FEATURE/dynamic"
#include "FEATURE/externs"
#if SHOPT_PFSH
# ifdef _hdr_exec_attr
# include <exec_attr.h>
# endif
# if _lib_vfork
# include <ast_vfork.h>
# else
# define vfork() fork()
# endif
#endif
#define RW_ALL (S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR|S_IWGRP|S_IWOTH)
#define LIBCMD "cmd"
@ -87,60 +77,6 @@ static int ondefpath(const char *name)
return(0);
}
#if SHOPT_PFSH
int path_xattr(const char *path, char *rpath)
{
char resolvedpath[PATH_MAX + 1];
if (sh.user && *sh.user)
{
execattr_t *pf;
if(!rpath)
rpath = resolvedpath;
if (!realpath(path, resolvedpath))
return -1;
if(pf=getexecuser(sh.user, KV_COMMAND, resolvedpath, GET_ONE))
{
if (!pf->attr || pf->attr->length == 0)
{
free_execattr(pf);
return(0);
}
free_execattr(pf);
return(1);
}
}
errno = ENOENT;
return(-1);
}
static pid_t pf_execve(const char *path, char *argv[],char *const envp[],int spawn)
{
char resolvedpath[PATH_MAX + 1];
pid_t pid;
if(spawn)
{
while((pid = vfork()) < 0)
_sh_fork(pid, 0, (int*)0);
if(pid)
return(pid);
}
if(!sh_isoption(SH_PFSH))
return(execve(path, argv, envp));
/* Solaris implements realpath(3C) using the resolvepath(2) */
/* system call so we can save us to call access(2) first */
/* we can exec the command directly instead of via pfexec(1) if */
/* there is a matching entry without attributes in exec_attr(4) */
if(!path_xattr(path,resolvedpath))
return(execve(path, argv, envp));
--argv;
argv[0] = argv[1];
argv[1] = resolvedpath;
return(execve("/usr/bin/pfexec", argv, envp));
}
#endif /* SHOPT_PFSH */
static pid_t _spawnveg(const char *path, char* const argv[], char* const envp[], pid_t pgid)
{
pid_t pid;
@ -219,11 +155,7 @@ static pid_t command_xargs(const char *path, char *argv[],char *const envp[], in
saveargs = 0;
}
}
#if SHOPT_PFSH
else if(spawn && !sh_isoption(SH_PFSH))
#else
else if(spawn)
#endif
{
sh.xargexit = exitval;
if(saveargs)
@ -234,11 +166,7 @@ static pid_t command_xargs(const char *path, char *argv[],char *const envp[], in
{
if(saveargs)
free((void*)saveargs);
#if SHOPT_PFSH
return(pf_execve(path,argv,envp,spawn));
#else
return(execve(path,argv,envp));
#endif
}
}
if(!spawn)
@ -1242,17 +1170,10 @@ pid_t path_spawn(const char *opath,register char **argv, char **envp, Pathcomp_t
}
else
#endif
#if SHOPT_PFSH
if(spawn && !sh_isoption(SH_PFSH))
pid = _spawnveg(opath, &argv[0], envp, spawn>>1);
else
pid = pf_execve(opath, &argv[0], envp, spawn);
#else
if(spawn)
pid = _spawnveg(opath, &argv[0], envp, spawn>>1);
else
pid = execve(opath, &argv[0], envp);
#endif /* SHOPT_PFSH */
if(xp)
*xp = xval;
#ifdef SHELLMAGIC
@ -1365,7 +1286,7 @@ static noreturn void exscript(register char *path,register char *argv[],char **e
sh_close(sh.infd);
sh_setstate(sh_state(SH_FORKED));
sfsync(sfstderr);
#if SHOPT_SUID_EXEC && !SHOPT_PFSH
#if SHOPT_SUID_EXEC
/* check if file cannot open for read or script is setuid/setgid */
{
static char name[] = "/tmp/euidXXXXXXXXXX";
@ -1401,11 +1322,7 @@ static noreturn void exscript(register char *path,register char *argv[],char **e
}
savet = *--argv;
*argv = path;
#if SHOPT_PFSH
pf_execve(e_suidexec,argv,envp,0);
#else
execve(e_suidexec,argv,envp);
#endif
fail:
/*
* The following code is just for compatibility

View file

@ -2,7 +2,7 @@
* *
* This software is part of the ast package *
* Copyright (c) 1982-2011 AT&T Intellectual Property *
* Copyright (c) 2020-2021 Contributors to ksh 93u+m *
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *

View file

@ -60,7 +60,6 @@
#endif
#define SH_NTFORK SH_TIMING
#define NV_BLTPFSH NV_ARRAY
#if _lib_nice
extern int nice(int);
@ -1026,19 +1025,6 @@ int sh_exec(register const Shnode_t *t, int flags)
#endif /* SHOPT_NAMESPACE */
np = dtsearch(sh.fun_tree,np);
}
#if SHOPT_PFSH
if(sh_isoption(SH_PFSH) && nv_isattr(np,NV_BLTINOPT) && !nv_isattr(np,NV_BLTPFSH))
{
if(path_xattr(np->nvname,(char*)0))
{
dtdelete(sh.bltin_tree,np);
np = 0;
}
else
nv_onattr(np,NV_BLTPFSH);
}
#endif /* SHOPT_PFSH */
}
if(com0)
{
@ -1084,12 +1070,11 @@ int sh_exec(register const Shnode_t *t, int flags)
flgs |= NV_MOVE;
if(np==SYSNAMEREF || checkopt(com,'n'))
flgs |= NV_NOREF;
#if SHOPT_TYPEDEF
else if(argn>=3 && checkopt(com,'T'))
{
if(sh.subshell && !sh.subshare)
sh_subfork();
# if SHOPT_NAMESPACE
#if SHOPT_NAMESPACE
if(sh.namespace)
{
if(!sh.strbuf2)
@ -1099,12 +1084,11 @@ int sh_exec(register const Shnode_t *t, int flags)
nv_open(sh.prefix,sh.var_base,NV_VARNAME);
}
else
# endif /* SHOPT_NAMESPACE */
#endif /* SHOPT_NAMESPACE */
sh.prefix = NV_CLASS;
flgs |= NV_TYPE;
}
#endif /* SHOPT_TYPEDEF */
if(sh.fn_depth && !sh.prefix)
flgs |= NV_NOSCOPE;
}
@ -2067,7 +2051,7 @@ int sh_exec(register const Shnode_t *t, int flags)
case TLST:
{
/* a list of commands are executed here */
/* a list of commands is executed here */
do
{
sh_exec(t->lst.lstlef,errorflg|OPTIMIZE);
@ -2215,7 +2199,6 @@ int sh_exec(register const Shnode_t *t, int flags)
sh.st.execbrk = (--sh.st.breakcnt !=0);
sh.st.loopcnt--;
sh_argfree(argsav,0);
nv_close(np);
break;
}
@ -2453,10 +2436,7 @@ int sh_exec(register const Shnode_t *t, int flags)
{
Namval_t *np = nv_open("TIMEFORMAT",sh.var_tree,NV_NOADD);
if(np)
{
format = nv_getval(np);
nv_close(np);
}
if(!format)
format = e_timeformat;
}