From 48c06903babc0da88c3450df55e8736bbdb51ed5 Mon Sep 17 00:00:00 2001 From: cognet Date: Mon, 14 Nov 2005 22:24:00 +0000 Subject: Add a new sysctl, kern.elf[32|64].can_exec_dyn. When set to 1, one can execute a ET_DYN binary (shared object). This does not make much sense, but some linux scripts expect to be able to execute /lib/ld-linux.so.2 (ldd comes to mind). The sysctl defaults to 0. MFC after: 3 days --- sys/kern/imgact_elf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index b469898..1901591 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -97,6 +97,11 @@ SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, TUNABLE_INT("kern.elf" __XSTRING(__ELF_WORD_SIZE) ".fallback_brand", &__elfN(fallback_brand)); +int __elfN(can_exec_dyn) = 0; +SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, + can_exec_dyn, CTLFLAG_RW, &__elfN(can_exec_dyn), 0, + __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) " can exec shared libraries"); + static int elf_trace = 0; SYSCTL_INT(_debug, OID_AUTO, __elfN(trace), CTLFLAG_RW, &elf_trace, 0, ""); @@ -660,7 +665,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) /* * Do we have a valid ELF header ? */ - if (__elfN(check_header)(hdr) != 0 || hdr->e_type != ET_EXEC) + if (__elfN(check_header)(hdr) != 0 || (hdr->e_type != ET_EXEC + && (!__elfN(can_exec_dyn) || hdr->e_type != ET_DYN))) return (-1); /* -- cgit v1.1