From nobody Sun Feb 18 10:02:21 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Td1Rx3Ym2z5C7R1; Sun, 18 Feb 2024 10:02:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Td1Rx2x6wz47bJ; Sun, 18 Feb 2024 10:02:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708250541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YRyr9Un/YGasRUMdAiIJ34k5kbz7HKw7MuDlHRi24aM=; b=hnzvvmt69HRdU7WOBpwkAB903Pt4vnYMi2SElYFGEey9SXiYs1gx/zT4s6XUsK8I1hH6M+ VEM6Sn0c0f9948vWnhMcogHfpM0uvALD3l4PNj9xeM0vLEcmL+FC+QI13If6B24vg+ZKkn 4xjg0DnIvQmA2KT211YtCICqPiiGIbcL8OiaQ2iqQ9NWXCt9cTGApRgead3b2poW+cHxeE J8r2lMxQVECucJoBYviWOv4KLtxvZNjMaNZ3Q6WmO8G/jXk/Mndq5oe1/ylxP/qM4wbgbW 2oCxX601ZHw7OymDJD0nYeEPKa/rTy2PoGv7vd1mZuwZIVRWom4mBDXq+zwRHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708250541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YRyr9Un/YGasRUMdAiIJ34k5kbz7HKw7MuDlHRi24aM=; b=w4OZEBrKiOnVALbCSF0gzXnbCTnIs3AVr/yi2uG6Y0uDvR5lslEFYEnxVjiX5Cji2T0KTN kFbyHc5yLT3hcXGyy5jZ9luZmCKINAPDoC/xHLMnym/iTrqD0+G3lCsEXk89H6wt6xSKH+ roXJiWj/6rHWv/YX5RhK/N/pdF0y4JS194yhPQ78CAamsg0EFl6wW0eSsCpwYfzMvVioMv t00Rj1D0EeMdYUq1Lr8Jwbs7SzZtoqoGUYmVqXwqZ4vzNTifSAbU6Sq9bBSjjfD/i00O+L QMWQE+GNprZT2F+SuZx9iZx63Nz+ogrz5ZhY0DCwArXvHKu3MwkQFCiQQYWX7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708250541; a=rsa-sha256; cv=none; b=Oh4twPmfkwYh9WQ/ip6BsHiil3m8GPPJzeACbuhPKJZTD2tMInZycusOKy4pQbReP1iNxQ hx33ExMsakeD2VLMnC3OTsGQD8j4x+P1+czwQXgREmryms8ARSyXVOrmWSFm+8kWWkf8qa ECT9r6FbmjvHWWUHPgfMN23SjV8KdEaY4sGpulb9R8Tpav4f64jpXfgJ/1GZyzvHtUF9DU E71iwYZ7zwyakAqXZvfjI1b2vOI3qxdP4hTyeQ1xyza6VojSZZ6qjVnNPpFqVS3Yo1tb12 zItW34jL05Tb++yHWBNV17pl5W1FRTbzHMo16CrRZUUvVNDDfAlNVRtow8pTXw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Td1Rx1zfDzmyx; Sun, 18 Feb 2024 10:02:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41IA2LLq084409; Sun, 18 Feb 2024 10:02:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41IA2LHN084406; Sun, 18 Feb 2024 10:02:21 GMT (envelope-from git) Date: Sun, 18 Feb 2024 10:02:21 GMT Message-Id: <202402181002.41IA2LHN084406@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 0667d0e0e365 - stable/14 - libc: expose execvpe for Linux compat List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 0667d0e0e3658128098ff4d672f5c2ce8aa9068e Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0667d0e0e3658128098ff4d672f5c2ce8aa9068e commit 0667d0e0e3658128098ff4d672f5c2ce8aa9068e Author: Brooks Davis AuthorDate: 2023-12-11 19:24:53 +0000 Commit: Konstantin Belousov CommitDate: 2024-02-18 10:01:46 +0000 libc: expose execvpe for Linux compat PR: 275370 (cherry picked from commit 8ccd0b876e67fda6249f294ff484798cc1e1569f) --- cddl/lib/libzfs/Makefile | 1 + cddl/usr.sbin/zfsd/Makefile.common | 2 +- include/unistd.h | 1 + lib/libc/gen/Symbol.map | 4 ++++ lib/libc/gen/exec.3 | 26 ++++++++++++++++++++------ lib/libc/gen/exec.c | 4 ++-- lib/libc/gen/posix_spawn.c | 4 ++-- lib/libc/include/libc_private.h | 3 --- 8 files changed, 31 insertions(+), 14 deletions(-) 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 7d3aace103d0..8c246a146e6c 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -504,6 +504,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/Symbol.map b/lib/libc/gen/Symbol.map index b68d63b279f3..51c7348c5cc4 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -457,6 +457,10 @@ FBSD_1.7 { __cpuset_free; }; +FBSD_1.8 { + execvpe; +}; + FBSDprivate_1.0 { /* needed by thread libraries */ __thr_jtable; diff --git a/lib/libc/gen/exec.3 b/lib/libc/gen/exec.3 index ead7ea0f416f..8f866e5ab321 100644 --- a/lib/libc/gen/exec.3 +++ b/lib/libc/gen/exec.3 @@ -25,9 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)exec.3 8.3 (Berkeley) 1/24/94 -.\" -.Dd March 22, 2020 +.Dd December 11, 2023 .Dt EXEC 3 .Os .Sh NAME @@ -37,6 +35,7 @@ .Nm exect , .Nm execv , .Nm execvp , +.Nm execvpe , .Nm execvP .Nd execute a file .Sh LIBRARY @@ -58,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 @@ -99,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 @@ -112,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 @@ -136,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 @@ -146,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. @@ -271,7 +276,8 @@ The .Fn execl , .Fn execle , .Fn execlp , -.Fn execvp +.Fn execvp , +.Fn execvpe , and .Fn execvP functions @@ -309,6 +315,9 @@ and functions conform to .St -p1003.1-88 . +The +.Fn execvpe +function is a GNU extension. .Sh HISTORY The .Fn exec @@ -332,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 @@ -342,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 15dc7f0200ac..a096e6a61b1d 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -138,7 +138,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 @@ -290,7 +290,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 *);