intp.c revision 380789fc80376bd1573770361cb177a08c7e3524
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R4 1.6 */
#include <sys/sysmacros.h>
#include <sys/pathname.h>
/*
* This is the loadable module wrapper.
*/
extern int intpexec();
0,
2,
};
/*
* Module linkage information for the kernel.
*/
extern struct mod_ops mod_execops;
};
static struct modlinkage modlinkage = {
};
int
_init()
{
return (mod_install(&modlinkage));
}
int
_fini()
{
return (mod_remove(&modlinkage));
}
int
{
}
/*
* Crack open a '#!' line.
*/
static int
{
int error;
/*
* Read the entire line and confirm that it starts with '#!'.
*/
return (error);
return (ENOEXEC);
/*
* Blank all white space and find the newline.
*/
if (*cp == '\t')
*cp = ' ';
return (ENOEXEC);
*cp = '\0';
/*
* Locate the beginning and end of the interpreter name.
* In addition to the name, one additional argument may
* optionally be included here, to be prepended to the
* arguments provided on the command line. Thus, for
* example, you can say
*
*/
;
if (*cp == '\0')
return (ENOEXEC);
cp++;
if (*cp == '\0')
else {
*cp++ = '\0';
while (*cp == ' ')
cp++;
if (*cp == '\0')
else {
cp++;
*cp = '\0';
}
}
return (0);
}
int
int level,
long *execsz,
int setid,
int brand_action)
{
int error = 0;
char *opath;
int fd = -1;
if (level) { /* Can't recurse */
goto bad;
}
/*
* Allocate a buffer to read in the interpreter pathname.
*/
goto fail;
/*
* Look the new vnode up.
*/
goto fail;
goto fail;
}
/* don't free resolvepn until we are done with args */
/*
* When we're executing a set-uid script resulting in uids
* mismatching or when we execute with additional privileges,
* we close the "replace script between exec and open by shell"
*/
if ((setid & EXECSETID_PRIVS) != 0 ||
goto done;
}
EBA_NONE);
done:
fail:
bad:
return (error);
}