From 697bbd1aa77f691343197a5b892dbc8700900993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Wed, 9 Oct 2024 02:52:15 +0200 Subject: [PATCH] dso, execve{,at}, posix_spawn: do not run OpenBSD dynamic loader The ELF dynamic loader in OpenBSD is not executable. -bash-5.2$ ls -l /usr/libexec/ld.so -r--r--r-- 1 root bin 359016 Oct 8 19:57 /usr/libexec/ld.so This conditionizes the code to run the dynamic loader if not OpenBSD. --- dso.c | 4 +++- execve.c | 4 ++-- execveat.c | 4 ++-- posix_spawn.c | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dso.c b/dso.c index 7b8e8113..3c9c66e1 100644 --- a/dso.c +++ b/dso.c @@ -696,6 +696,7 @@ static int __fld_needed(int fd, return __path_iterate(needed, __ld_needed_callback, &ctx); } +#ifndef __OpenBSD__ static int __ld_needed(const char *path, const char *rpath, const char *ld_library_path, @@ -721,6 +722,7 @@ static int __ld_needed(const char *path, return ret; } +#endif struct __ld_open_needed_context { int flags; @@ -3538,7 +3540,7 @@ hidden ssize_t __dl_access(const char *path, int mode, char *buf, bufsiz); } -#ifndef __NetBSD__ +#if !defined __NetBSD__ && !defined __OpenBSD__ static const char *__root_basepath(const char *path) { const char *root; diff --git a/execve.c b/execve.c index 0a48aa6f..c4b61f38 100644 --- a/execve.c +++ b/execve.c @@ -19,7 +19,7 @@ extern int next_faccessat(int, const char *, int, int); -#ifndef __NetBSD__ +#if !defined __NetBSD__ && !defined __OpenBSD__ extern int __ldso_execve(const char *, char * const[], char * const[]); #endif @@ -207,7 +207,7 @@ int execve(const char *path, char * const argv[], char * const envp[]) off += siz+1; /* NULL-terminated */ loader: -#ifndef __NetBSD__ +#if !defined __NetBSD__ && !defined __OpenBSD__ /* It is the dynamic loader */ ret = __is_ldso(__basename(path)); /* Try to run the dynamic loader internaly... */ diff --git a/execveat.c b/execveat.c index 29ea5580..ba9eb15a 100644 --- a/execveat.c +++ b/execveat.c @@ -16,7 +16,7 @@ #include "iamroot.h" -#ifndef __NetBSD__ +#if !defined __NetBSD__ && !defined __OpenBSD__ extern int __ldso_execveat(int, const char *, char * const[], char * const[]); #endif @@ -146,7 +146,7 @@ int execveat(int dfd, const char *path, char * const argv[], off += siz+1; /* NULL-terminated */ loader: -#ifndef __NetBSD__ +#if !defined __NetBSD__ && !defined __OpenBSD__ /* It is the dynamic loader */ ret = __is_ldso(__basename(path)); /* Try to run the dynamic loader internaly... */ diff --git a/posix_spawn.c b/posix_spawn.c index 5e4f3140..92e0400d 100644 --- a/posix_spawn.c +++ b/posix_spawn.c @@ -17,7 +17,7 @@ #include "iamroot.h" -#ifndef __NetBSD__ +#if !defined __NetBSD__ && !defined __OpenBSD__ extern int __ldso_posix_spawn(pid_t *, const char *, const posix_spawn_file_actions_t *, @@ -159,7 +159,7 @@ int posix_spawn(pid_t *pid, const char *path, off += siz+1; /* NULL-terminated */ loader: -#ifndef __NetBSD__ +#if !defined __NetBSD__ && !defined __OpenBSD__ /* It is the dynamic loader */ ret = __is_ldso(__basename(path)); /* Try to run the dynamic loader internaly... */