Created sysctl kern.fallback_elf_brand. Defaults to "none", which will

give the same behaviour produced before today.  If sysadmin sets it
to a valid ELF brand, ELF image activator will attempt to run unbranded
ELF exectutables as if they were branded with that value.

Suggested by: Dima Ruban <dima@best.net>
This commit is contained in:
Mark Newton 1999-02-05 03:43:18 +00:00
parent 46bc42dcf8
commit f8b3601e08
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43631

View File

@ -26,7 +26,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: imgact_elf.c,v 1.47 1999/01/29 22:59:43 dillon Exp $
* $Id: imgact_elf.c,v 1.48 1999/02/04 12:42:31 newton Exp $
*/
#include "opt_rlimit.h"
@ -83,6 +83,12 @@ static int exec_elf_imgact __P((struct image_params *imgp));
static int elf_trace = 0;
SYSCTL_INT(_debug, OID_AUTO, elf_trace, CTLFLAG_RW, &elf_trace, 0, "");
/*
* XXX Maximum length of an ELF brand (sysctl wants a statically-allocated
* buffer).
*/
#define MAXBRANDLEN 16
static struct sysentvec elf_freebsd_sysvec = {
SYS_MAXSYSCALL,
sysent,
@ -406,6 +412,11 @@ elf_load_file(struct proc *p, char *file, u_long *addr, u_long *entry)
return error;
}
static char fallback_elf_brand[MAXBRANDLEN+1] = { "none" };
SYSCTL_STRING(_kern, OID_AUTO, fallback_elf_brand, CTLFLAG_RW,
fallback_elf_brand, sizeof(fallback_elf_brand),
"ELF brand of last resort");
static int
exec_elf_imgact(struct image_params *imgp)
{
@ -542,6 +553,19 @@ exec_elf_imgact(struct image_params *imgp)
}
}
/* Lacking a recognized interpreter, try the default brand */
if (brand_info == NULL & fallback_elf_brand[0] != '\0') {
for (i = 0; i < MAX_BRANDS; i++) {
Elf_Brandinfo *bi = elf_brand_list[i];
if (bi != NULL
&& strcmp(fallback_elf_brand, bi->brand) == 0) {
brand_info = bi;
break;
}
}
}
#ifdef __alpha__
/* XXX - Assume FreeBSD on the alpha. */
if (brand_info == NULL)