From nobody Tue Dec 07 00:27:37 2021 X-Original-To: dev-commits-src-all@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 5CB1A18D3C90; Tue, 7 Dec 2021 00:27:39 +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 4J7LjQ0zr0z4SJr; Tue, 7 Dec 2021 00:27:38 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 EAC4015DB9; Tue, 7 Dec 2021 00:27:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B70RbRf021432; Tue, 7 Dec 2021 00:27:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B70Rbag021431; Tue, 7 Dec 2021 00:27:37 GMT (envelope-from git) Date: Tue, 7 Dec 2021 00:27:37 GMT Message-Id: <202112070027.1B70Rbag021431@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: 54cdfdf12a3d - stable/13 - posix_spawn: add closefrom non-portable action List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/13 X-Git-Reftype: branch X-Git-Commit: 54cdfdf12a3dd061b7a695096c8ae7c008abb31b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638836858; 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=eSfJkE81SB2zGxIc1NZ4V4WiI1XlYtu8Zuu8Fk05cgM=; b=uWDi0U4F/YOk8UGCzHxyTOo98OUfHqohwT5uxYc/wxzyAqze/My4ohi0nOMldZbqKbgwKv idMELLT5BxlWWrfaG+FSogpBjcEHkkSQOMzpAq5sAe3muz8dR1pUXc+zdYCPfihklws+u4 esFGKBl78T0yAHqtlAv1dRrnO5N+XeYuyW72Z/m5EvMgXBncdCe/eN14HbixKBuvXX+Nyw +O2rGrj7W+9OUQAYH7In8dfH87+GTd1bzk3ISv5N5GkeFWCOybn4eo8gwqN8yUoue4OluG j6Qaqis+gQGhtsRvNeL+34X7hiVfmUv8hbJfmhdPDxU+rhcuwQyso/4ngvk+hg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638836858; a=rsa-sha256; cv=none; b=E21ha3Zpf9oJY+VgaS6DUoLs7yy0E1v9JBKNY6BUEDANybQDN8FHQJ3GpDpbdqCUR+NIEI 24blm+/0sLOWVfpqf9q1O3+6SGuA0g2nKDVG0hSeXOcYJe+h7AFugNhSAEKL5DeVowz9vX hxNPG7iBNc+E9F9XNo1i4eDcT9716iHbpTR+9lWdxYXaEc/v66Y/MQKu4oxsUMtFguUnLZ eS4j5YIROlUkcAenSNdAHODVOTSMONkNy/aCcVw44WBcA+IryxzUs2mpz4iwSPUn4r8qMr GC/BOhIHuonbsFqJN3Wc4qjImjxYDDWnp6SApURLW+lRgkKFThnahT+rCVqPiA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=54cdfdf12a3dd061b7a695096c8ae7c008abb31b commit 54cdfdf12a3dd061b7a695096c8ae7c008abb31b Author: Konstantin Belousov AuthorDate: 2021-11-27 22:54:16 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-07 00:25:55 +0000 posix_spawn: add closefrom non-portable action (cherry picked from commit a18ddf775744f31a844fd01fbe90207f7c5e706d) --- include/spawn.h | 2 ++ lib/libc/gen/Symbol.map | 1 + lib/libc/gen/posix_spawn.c | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/include/spawn.h b/include/spawn.h index 4ba3998a3e90..53373a6c8db8 100644 --- a/include/spawn.h +++ b/include/spawn.h @@ -92,6 +92,8 @@ int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t * __restrict, const char * __restrict); int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, int); +int posix_spawn_file_actions_addclosefrom_np(posix_spawn_file_actions_t *, + int); #endif /* diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 5cf14d569cdb..d5ed0681073c 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -437,6 +437,7 @@ FBSD_1.6 { FBSD_1.7 { posix_spawn_file_actions_addchdir_np; + posix_spawn_file_actions_addclosefrom_np; posix_spawn_file_actions_addfchdir_np; }; diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index 00d1724a6515..909db9a60a02 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -68,6 +68,7 @@ typedef struct __posix_spawn_file_actions_entry { FAE_CLOSE, FAE_CHDIR, FAE_FCHDIR, + FAE_CLOSEFROM, } fae_action; int fae_fildes; @@ -190,6 +191,9 @@ process_file_actions_entry(posix_spawn_file_actions_entry_t *fae) if (fchdir(fae->fae_fildes) != 0) return (errno); break; + case FAE_CLOSEFROM: + closefrom(fae->fae_fildes); + break; } return (0); } @@ -533,6 +537,27 @@ posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *__restrict fa, return (0); } +int +posix_spawn_file_actions_addclosefrom_np (posix_spawn_file_actions_t * + __restrict fa, int from) +{ + posix_spawn_file_actions_entry_t *fae; + + if (from < 0) + return (EBADF); + + /* Allocate object */ + fae = malloc(sizeof(posix_spawn_file_actions_entry_t)); + if (fae == NULL) + return (errno); + + fae->fae_action = FAE_CLOSEFROM; + fae->fae_fildes = from; + + STAILQ_INSERT_TAIL(&(*fa)->fa_list, fae, fae_list); + return (0); +} + /* * Spawn attributes */