/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
#include <sys/pathname.h>
/*
* This is the loadable module wrapper.
*/
/* Local prototypes */
static int
int level,
long *execsz,
int setid,
int brand_action);
extern char shbinmagicstr[];
/*
* Our list where we may find a copy of ksh93. The ordering is:
* 1. 64bit (may not be installed or not supported in hardware)
* 2. 32bit
*
* isaexec overhead).
*/
static char *shell_list[] =
{
#if defined(__sparc)
#else
#endif
};
0,
};
/*
* Module linkage information for the kernel.
*/
extern struct mod_ops mod_execops;
};
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (mod_remove(&modlinkage));
}
int
{
}
static int
{
int error;
/*
* Read the entire line and confirm that it starts with the magic
* sequence for compiled ksh93 shell scripts.
*/
return (error);
return (ENOEXEC);
return (0);
}
static int
int level,
long *execsz,
int setid,
int brand_action)
{
int error = 0;
char *opath;
int i;
if (level) { /* Can't recurse */
goto bad;
}
/*
* Check whether the executable has the correct magic value.
*/
goto fail;
/*
* Travel the list of shells and look for one which is available...
*/
for (i = 0; shell_list[i] != NULL; i++) {
if (error != 0) {
break;
}
if (!error) {
/* Found match */
break;
}
/* No match found ? Then continue with the next item... */
}
if (error) {
goto fail;
}
/*
* Setup interpreter data
* "--" is passed to mark the end-of-arguments before adding
* the scripts file name, preventing problems when a
* a script's name starts with a '-' character.
*/
/* 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);
if (!error) {
/*
* Close this script as the sh interpreter
* will open and close it later on.
*/
}
done:
fail:
bad:
return (error);
}