diff options
author | newton <newton@FreeBSD.org> | 1999-02-05 03:43:18 +0000 |
---|---|---|
committer | newton <newton@FreeBSD.org> | 1999-02-05 03:43:18 +0000 |
commit | a867bd47b788a00dbb8ce2e8e2771868161fb9b5 (patch) | |
tree | 8da7b66fb542703e233533d16146add165bd8e28 /sys/kern/imgact_elf.c | |
parent | 3a93d52d6ab7e8d9e0b9c4e2fd274eb90b5615dd (diff) | |
download | FreeBSD-src-a867bd47b788a00dbb8ce2e8e2771868161fb9b5.zip FreeBSD-src-a867bd47b788a00dbb8ce2e8e2771868161fb9b5.tar.gz |
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>
Diffstat (limited to 'sys/kern/imgact_elf.c')
-rw-r--r-- | sys/kern/imgact_elf.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 4bc0fac..1cecde6 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -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 @@ fail: 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) |