FreeBSD Bugzilla – Attachment 246678 Details for
Bug 275370
Add execvpe()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
patch
execvpe.diff (text/plain), 7.77 KB, created by
Brooks Davis
on 2023-11-30 00:35:02 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Brooks Davis
Created:
2023-11-30 00:35:02 UTC
Size:
7.77 KB
patch
obsolete
>commit b0b4abe710971b482ef0d7b5537e156b72062d76 >Author: Brooks Davis <brooks@FreeBSD.org> >Date: Wed Nov 29 23:25:38 2023 +0000 > > libc: expose execvpe for Linux compat > > We already implemented execvpe internally with an _ prefix in libc so > go ahead and expose it for compatibility with Linux. > > This reverts c605eea952146348e5e1ad5cab6c127d7a1bd164. > > Bump __FreeBSD_version for the addition and add definitions to supress > compat shims in libzfs. > > PR: 275370 > >diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile >index ee57c30cc6ca..c05fe0c1c12b 100644 >--- a/cddl/lib/libzfs/Makefile >+++ b/cddl/lib/libzfs/Makefile >@@ -99,6 +99,7 @@ CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include > CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include > CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h > CFLAGS+= -DHAVE_ISSETUGID >+CFLAGS+= -DHAVE_EXECVPE > CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h > CFLAGS+= -DSYSCONFDIR=\"/etc\" > CFLAGS+= -DPKGDATADIR=\"/usr/share/zfs\" >diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common >index 1755031fee72..c1ed4bba9289 100644 >--- a/cddl/usr.sbin/zfsd/Makefile.common >+++ b/cddl/usr.sbin/zfsd/Makefile.common >@@ -22,8 +22,8 @@ CFLAGS+= -I${SRCTOP}/sys > CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h > CFLAGS+= -I${SRCTOP}/cddl/usr.sbin > >-# use issetugid(2) > CFLAGS+= -DHAVE_ISSETUGID >+CFLAGS+= -DHAVE_EXECVPE > > LIBADD+= devdctl zfs util geom bsdxml sbuf nvpair avl uutil zutil > >diff --git a/include/unistd.h b/include/unistd.h >index e3e5675b3da0..8a01d563fe99 100644 >--- a/include/unistd.h >+++ b/include/unistd.h >@@ -501,6 +501,7 @@ int eaccess(const char *, int); > void endusershell(void); > int exect(const char *, char * const *, char * const *); > int execvP(const char *, const char *, char * const *); >+int execvpe(const char *, char * const *, char * const *); > int feature_present(const char *); > char *fflagstostr(u_long); > int getdomainname(char *, int); >diff --git a/lib/libc/gen/exec.3 b/lib/libc/gen/exec.3 >index 539a4b2ba42d..cf4136ff13d0 100644 >--- a/lib/libc/gen/exec.3 >+++ b/lib/libc/gen/exec.3 >@@ -25,7 +25,7 @@ > .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > .\" SUCH DAMAGE. > .\" >-.Dd March 22, 2020 >+.Dd December 1, 2023 > .Dt EXEC 3 > .Os > .Sh NAME >@@ -35,6 +35,7 @@ > .Nm exect , > .Nm execv , > .Nm execvp , >+.Nm execvpe , > .Nm execvP > .Nd execute a file > .Sh LIBRARY >@@ -56,6 +57,8 @@ > .Ft int > .Fn execvp "const char *file" "char *const argv[]" > .Ft int >+.Fn execvpe "const char *file" "char *const argv[]" "char *const envp[]" >+.Ft int > .Fn execvP "const char *file" "const char *search_path" "char *const argv[]" > .Sh DESCRIPTION > The >@@ -97,6 +100,7 @@ The > .Fn exect , > .Fn execv , > .Fn execvp , >+.Fn execvpe , > and > .Fn execvP > functions provide an array of pointers to null-terminated strings that >@@ -110,9 +114,10 @@ be terminated by a > pointer. > .Pp > The >-.Fn execle >+.Fn execle , >+.Fn exect , > and >-.Fn exect >+.Fn execvpe > functions also specify the environment of the executed process by following > the > .Dv NULL >@@ -134,6 +139,7 @@ Some of these functions have special semantics. > The functions > .Fn execlp , > .Fn execvp , >+.Fn execvpe , > and > .Fn execvP > will duplicate the actions of the shell in searching for an executable file >@@ -144,6 +150,7 @@ For > .Fn execlp > and > .Fn execvp , >+.Fn execvpe , > search path is the path specified in the environment by > .Dq Ev PATH > variable. >@@ -269,7 +276,8 @@ The > .Fn execl , > .Fn execle , > .Fn execlp , >-.Fn execvp >+.Fn execvp , >+.Fn execvpe , > and > .Fn execvP > functions >@@ -307,6 +315,9 @@ and > functions > conform to > .St -p1003.1-88 . >+The >+.Fn execvpe >+function is a GNU extension. > .Sh HISTORY > The > .Fn exec >@@ -330,6 +341,10 @@ The > .Fn execvP > function first appeared in > .Fx 5.2 . >+The >+.Fn execvpe >+function first appeared in >+.Fx 15.0 . > .Sh BUGS > The type of the > .Fa argv >@@ -340,6 +355,7 @@ parameters to > .Fn exect , > .Fn execv , > .Fn execvp , >+.Fn execvpe , > and > .Fn execvP > is a historical accident and no sane implementation should modify the provided >diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c >index d2181c6e2b91..d9285733e965 100644 >--- a/lib/libc/gen/exec.c >+++ b/lib/libc/gen/exec.c >@@ -136,7 +136,7 @@ execv(const char *name, char * const *argv) > int > execvp(const char *name, char * const *argv) > { >- return (_execvpe(name, argv, environ)); >+ return (execvpe(name, argv, environ)); > } > > static int >@@ -288,7 +288,7 @@ execvP(const char *name, const char *path, char * const argv[]) > } > > int >-_execvpe(const char *name, char * const argv[], char * const envp[]) >+execvpe(const char *name, char * const argv[], char * const envp[]) > { > const char *path; > >diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c >index b1bb49d63ffd..a067d1f68ea5 100644 >--- a/lib/libc/gen/posix_spawn.c >+++ b/lib/libc/gen/posix_spawn.c >@@ -226,7 +226,7 @@ struct posix_spawn_args { > #if defined(__i386__) || defined(__amd64__) > /* > * Below we'll assume that _RFORK_THREAD_STACK_SIZE is appropriately aligned for >- * the posix_spawn() case where we do not end up calling _execvpe and won't ever >+ * the posix_spawn() case where we do not end up calling execvpe and won't ever > * try to allocate space on the stack for argv[]. > */ > #define _RFORK_THREAD_STACK_SIZE 4096 >@@ -253,7 +253,7 @@ _posix_spawn_thr(void *data) > } > envp = psa->envp != NULL ? psa->envp : environ; > if (psa->use_env_path) >- _execvpe(psa->path, psa->argv, envp); >+ execvpe(psa->path, psa->argv, envp); > else > _execve(psa->path, psa->argv, envp); > psa->error = errno; >diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h >index a9ad2ef21b0b..bfeada696538 100644 >--- a/lib/libc/include/libc_private.h >+++ b/lib/libc/include/libc_private.h >@@ -422,9 +422,6 @@ int __sys_futimens(int fd, const struct timespec *times) __hidden; > int __sys_utimensat(int fd, const char *path, > const struct timespec *times, int flag) __hidden; > >-/* execve() with PATH processing to implement posix_spawnp() */ >-int _execvpe(const char *, char * const *, char * const *); >- > int _elf_aux_info(int aux, void *buf, int buflen); > struct dl_phdr_info; > int __elf_phdr_match_addr(struct dl_phdr_info *, void *); >diff --git a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h >index 15d3ff0dcb56..1ff3ca8025fc 100644 >--- a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h >+++ b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/param.h >@@ -57,6 +57,8 @@ > extern size_t spl_pagesize(void); > #define PAGESIZE (spl_pagesize()) > >+#ifndef HAVE_EXECVPE > extern int execvpe(const char *name, char * const argv[], char * const envp[]); >+#endif > > #endif >diff --git a/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c b/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c >index d1c1fea7fb68..0f140799cffd 100644 >--- a/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c >+++ b/sys/contrib/openzfs/lib/libzfs/os/freebsd/libzfs_compat.c >@@ -39,6 +39,7 @@ > #endif > > >+#ifndef HAVE_EXECVPE > static int > execvPe(const char *name, const char *path, char * const *argv, > char * const *envp) >@@ -192,6 +193,7 @@ execvpe(const char *name, char * const argv[], char * const envp[]) > > return (execvPe(name, path, argv, envp)); > } >+#endif /* !HAVE_EXECVPE */ > > static __thread char errbuf[ERRBUFLEN]; > >diff --git a/sys/sys/param.h b/sys/sys/param.h >index 107b86707c9e..c79c46ab4342 100644 >--- a/sys/sys/param.h >+++ b/sys/sys/param.h >@@ -73,7 +73,7 @@ > * cannot include sys/param.h and should only be updated here. > */ > #undef __FreeBSD_version >-#define __FreeBSD_version 1500005 >+#define __FreeBSD_version 1500006 > > /* > * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 275370
:
246678
|
246807