From patchwork Thu May 28 23:32:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 39381 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B2D73870844; Thu, 28 May 2020 23:32:24 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id 2819C3851C03 for ; Thu, 28 May 2020 23:32:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2819C3851C03 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id C68EAD7F3; Fri, 29 May 2020 01:32:19 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e9nPEXmBGZig; Fri, 29 May 2020 01:32:18 +0200 (CEST) Received: from function (lfbn-bor-1-797-11.w86-234.abo.wanadoo.fr [86.234.239.11]) by hera.aquilenet.fr (Postfix) with ESMTPSA id CE918D6C5; Fri, 29 May 2020 01:32:18 +0200 (CEST) Received: from samy by function with local (Exim 4.93) (envelope-from ) id 1jeS0X-00604q-Ci; Fri, 29 May 2020 01:32:17 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Subject: [hurd,commited] hurd: Fix fexecve Date: Fri, 29 May 2020 01:32:17 +0200 Message-Id: <20200528233217.1430223-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Status: No, score=-14.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: commit-hurd@gnu.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * sysdeps/mach/hurd/fexecve.c (fexecve): Re-lookup fd with O_EXEC before calling _hurd_exec_paths. --- sysdeps/mach/hurd/fexecve.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sysdeps/mach/hurd/fexecve.c b/sysdeps/mach/hurd/fexecve.c index 2b24e46fbf..c6a00ebf1e 100644 --- a/sysdeps/mach/hurd/fexecve.c +++ b/sysdeps/mach/hurd/fexecve.c @@ -25,10 +25,23 @@ int fexecve (int fd, char *const argv[], char *const envp[]) { - error_t err = HURD_DPORT_USE (fd, _hurd_exec_paths (__mach_task_self (), - port, NULL, NULL, - argv, envp)); + file_t file; + error_t err; + enum retry_type doretry; + char retryname[1024]; + + err = HURD_DPORT_USE (fd, + __dir_lookup (port, "", O_EXEC, 0, &doretry, retryname, &file)); + + if (! err && (doretry != FS_RETRY_NORMAL || retryname[0] != '\0')) + err = EGRATUITOUS; + if (err) + return __hurd_fail(err); + + err = _hurd_exec_paths (__mach_task_self (), file, NULL, NULL, argv, envp); if (! err) err = EGRATUITOUS; + + __mach_port_deallocate (__mach_task_self (), file); return __hurd_fail (err); }