/*
* 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
*/
/*
*/
#include "lint.h"
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
#include <sys/systeminfo.h>
/*
* This is a utility routine to allow wrapper programs to simply
* implement the isalist exec algorithms. See PSARC/1997/220.
*/
int
{
const char *fname;
char *isalist;
char *pathname;
char *str;
char *lasts;
int fd;
int saved_errno;
/*
* Extract the isalist(5) for userland from the kernel.
*/
do {
if (ret == -1l) {
return (-1);
}
} else
break;
/*
* Then either a malloc or a realloc failed.
*/
return (-1);
}
/*
* Allocate a full pathname buffer. The sum of the lengths of the
* 'path' and isalist strings is guaranteed to be big enough.
*/
return (-1);
}
/*
* Break the exec name into directory and file name components.
*/
*++str = '\0';
} else {
*pathname = '\0';
}
/*
* For each name in the isa list, look for an executable file
* with the given file name in the corresponding subdirectory.
* If it's there, exec it. If it's not there, or the exec
* fails, then run the next version ..
*/
do {
/*
* File exists and is open for O_EXEC. Attempt
* to execute the file from the subdirectory,
* using the user-supplied argv and envp.
* Retain the current name of the process
* (so shell scripts retain their own names
* and don't become, for example, "ksh93").
*/
/*
* If we failed to exec because of a temporary
* resource shortage, it's better to let our
* caller handle it (free memory, sleep for a while,
* or whatever before retrying) rather than drive
* on to run the "less capable" version.
*/
saved_errno = errno;
break;
}
}
errno = saved_errno;
return (-1);
}