service.c revision 1573d361e97690e67db291a1e0dc9a9b58f73fd8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* UNIX shell
*/
#include "defs.h"
#include <errno.h>
#include <fcntl.h>
#include "sh_policy.h"
#define ARGMK 01
static unsigned char *execs();
static void gsort();
static int split();
extern short topfd;
/*
* service routines for `execute'
*/
short
{
unsigned char *ion;
int ioufd;
short lastfd;
int newmode;
while (iop) {
if (save) {
}
if (iof & IODOC_SUBST) {
/*
* pushed in tmpfil() --
* bug fix for problem with
* in-line scripts
*/
poptemp();
fd = -1;
}
else
} else {
}
if (fd >= 0)
}
}
return (lastfd);
}
unsigned char *
simple(s)
unsigned char *s;
{
unsigned char *sname;
sname = s;
while (1) {
while (*sname++ != '/')
;
else
return (sname);
}
}
unsigned char *
getpath(s)
unsigned char *s;
{
int pathlen;
if (any('/', s))
{
failed(s, restricted);
else
return ((unsigned char *)nullstr);
return ((unsigned char *)defpath);
else {
/* Add extra ':' if PATH variable ends in ':' */
return (newpath);
} else
}
}
int
{
int f;
do
{
return (f);
}
unsigned char *
{
/*
* leaves result on top of stack
*/
}
*argp++ = '/';
}
scanp++;
do
{
}
return (path);
}
unsigned char *
{
scanp++;
scanp++;
}
static const char *xecmsg;
static unsigned char **xecenv;
void
{
unsigned char *path;
unsigned char **t = at;
int cnt;
xecenv = local_setenv();
if (pos > 0) {
cnt = 1;
++cnt;
}
}
;
}
}
static unsigned char *
{
unsigned char *p, *prefix;
unsigned char *savptr;
sigchk();
/*
* Need to save the stack information, or the
* first memory allocation in secpolicy_profile_lookup()
* will clobber it.
*/
pfstatus = secpolicy_pfexec((const char *)p,
(char **)t, (const char **)xecenv);
}
}
execve((const char *)p, (char *const *)&t[0],
(char *const *)xecenv);
}
switch (errno) {
case ENOEXEC: /* could be a shell script */
funcnt = 0;
flags = 0;
*flagadr = 0;
comdiv = 0;
ioset = 0;
clearup(); /* remove open files and for loop junk */
if (input)
#ifdef ACCT
preacct(p); /* reset accounting */
#endif
/*
* set up new args
*/
setargs(t);
case ENOMEM:
case E2BIG:
case ETXTBSY:
case ELIBACC:
case ELIBBAD:
case ELIBSCN:
case ELIBMAX:
default:
case ENOENT:
return (prefix);
}
}
void
{
unsigned char *last;
unsigned char *current;
unsigned char c;
int len;
nosubst = 0;
while (c = *current) {
MB_LEN_MAX)) <= 0) {
*last++ = c;
current++;
continue;
}
if (wc != '\\') {
continue;
}
/* remove \ and quoted nulls */
nosubst = 1;
current++;
if (c = *current) {
MB_LEN_MAX)) <= 0) {
*last++ = c;
current++;
continue;
}
} else
current++;
}
*last = 0;
}
}
/* Same as trim, but only removes backlashes before slashes */
void
unsigned char *at;
{
unsigned char *last;
unsigned char *current;
unsigned char c;
int len;
{
while (c = *current) {
MB_LEN_MAX)) <= 0) {
*last++ = c;
current++;
continue;
}
if (wc != '\\') {
continue;
}
/* remove \ and quoted nulls */
current++;
if (!(c = *current)) {
current++;
continue;
}
if (c == '/') {
*last++ = c;
current++;
continue;
}
*last++ = '\\';
MB_LEN_MAX)) <= 0) {
*last++ = c;
current++;
continue;
}
}
*last = 0;
}
}
unsigned char *
mactrim(s)
unsigned char *s;
{
unsigned char *t = macro(s);
trim(t);
return (t);
}
unsigned char **
int argn;
{
while (argp)
{
{
}
}
return (comargn);
}
static void
{
int k, m, n;
int i, j;
return;
for (j = 1; j <= n; j *= 2)
;
for (m = 2 * j - 1; m /= 2; )
{
k = n - m;
for (j = 0; j < k; j++)
{
for (i = j; i >= 0; i -= m)
{
unsigned char **fromi;
{
break;
}
else
{
unsigned char *s;
s = fromi[m];
fromi[0] = s;
}
}
}
}
}
/*
* Argument list generation
*/
int
{
int count = 0;
struct comnod *c;
if (c = ac)
{
while (argp)
{
}
}
return (count);
}
static int
split(s) /* blank interpretation routine */
unsigned char *s;
{
unsigned char *argp;
int c;
int count = 0;
for (;;)
{
int length;
sigchk();
while (c = *s) {
MB_LEN_MAX)) <= 0) {
wc = (unsigned char)*s;
length = 1;
}
if (c == '\\') { /* skip over quoted characters */
*argp++ = c;
s++;
/* get rest of multibyte character */
MB_LEN_MAX)) <= 0) {
wc = (unsigned char)*s;
length = 1;
}
*argp++ = *s++;
while (--length > 0) {
*argp++ = *s++;
}
continue;
}
/* skip to next character position */
s += length;
break;
}
*argp++ = c;
s++;
while (--length > 0) {
*argp++ = *s++;
}
}
{
if (c)
{
continue;
}
else
{
return (count);
}
}
/*
* file name generation
*/
count += c;
else
{
count++;
}
}
}
#ifdef ACCT
static int shaccton; /* 0 implies do not write record on exit */
/* 1 implies write acct record on exit */
/*
* suspend accounting until turned on by preacct()
*/
void
suspacct(void)
{
shaccton = 0;
}
void
{
unsigned char *simple();
shaccton = 1;
}
}
void
doacct(void)
{
int fd;
if (shaccton) {
}
}
}
/*
* Produce a pseudo-floating point representation
* with 3 bits base-8 exponent, 13 bits fraction
*/
static comp_t
{
int exp = 0;
int rund = 0;
while (t >= 8192) {
exp++;
rund = t & 04;
t >>= 3;
}
if (rund) {
t++;
if (t >= 8192) {
t >>= 3;
exp++;
}
}
return ((exp << 13) + t);
}
#endif