From patchwork Wed Nov 18 19:55:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41102 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 9F2CD3942021; Wed, 18 Nov 2020 19:56:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F2CD3942021 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605729367; bh=aIM+y8xIIq9MEsVjEFj4PlVrtoH7mvVwFNgJzmYXa7s=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eYwCYMQwvKe+8BH/lnLu0TrtXtbyIaInRU4P/IDwjSDFwAwJQ9jfrakJVWUy3PlOO n1kT76zvMbbwlYq2s4BhJRxR2RCPBPb4/G4kG6u+LALKf0kvmKHMzzRK+hy4zMRw4a W4QtYVUCMQtHESlolFJHhqMEGkPhWCyxsvJeOJDo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by sourceware.org (Postfix) with ESMTPS id 64F943854800 for ; Wed, 18 Nov 2020 19:56:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 64F943854800 Received: by mail-qk1-x744.google.com with SMTP id q22so3082130qkq.6 for ; Wed, 18 Nov 2020 11:56:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aIM+y8xIIq9MEsVjEFj4PlVrtoH7mvVwFNgJzmYXa7s=; b=rNQq7h0jAx8q7n6RgqlL/Ez7+uh8uXu5A/Ib9FUumTAz+vk0Bw/3OjnUVOAYKUm7Bn fr7yCrbP1PEzMYopw7CjT7VIMgM+IyjAEKuQxmdyu6uA76JaYNt4iRuL1hqD3Gg5mG8E uiAOfMnbBOCT9YQeMx+vNkgh3HGgmUeMoMHxDHEq7Gw/fCZxpcVgZ/T3ufx5sBI+NWpK n1VP9RLwFWkAx3M1xaOSQtxLTueFUmejGfh8A5WvrpXkJF7kwjuZzJKFw8XY4nNzyRyz iXnYMVK6ucFeI1ImqnPY8W2GrbHPB9L95TpNYyQ94UJq7O5ttADn3MYaPui72sd3GAGj qL+Q== X-Gm-Message-State: AOAM533iL7op/aHYLUuVOHfwGnb6A8nfLpVPsZDdDnYpobTIsb2+LPxG Y3YlTzgoctLcmoDHDmwVmY5msgwgxnkBEw== X-Google-Smtp-Source: ABdhPJy3HKtZS40Fg+Rfk7hI6DqAW+fTUQqZbhPJ/ybRsOEkCOQdORHUoIUCdWF4Yp7ZZHeECny1ZA== X-Received: by 2002:a05:620a:10a3:: with SMTP id h3mr6248385qkk.459.1605729362665; Wed, 18 Nov 2020 11:56:02 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id f27sm6538775qtv.95.2020.11.18.11.56.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 11:56:02 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 03/28] Remove local-setxid.h Date: Wed, 18 Nov 2020 16:55:27 -0300 Message-Id: <20201118195552.2687336-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201118195552.2687336-1-adhemerval.zanella@linaro.org> References: <20201118195552.2687336-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The required Linux specific implementation is moved to internal posix_spawn implementation. No semantic changes expected. --- sysdeps/generic/local-setxid.h | 4 ---- sysdeps/posix/spawni.c | 5 ++--- sysdeps/unix/sysv/linux/local-setxid.h | 16 ---------------- sysdeps/unix/sysv/linux/spawni.c | 19 ++++++++++++++++++- 4 files changed, 20 insertions(+), 24 deletions(-) delete mode 100644 sysdeps/generic/local-setxid.h delete mode 100644 sysdeps/unix/sysv/linux/local-setxid.h diff --git a/sysdeps/generic/local-setxid.h b/sysdeps/generic/local-setxid.h deleted file mode 100644 index b70d9ffb32..0000000000 --- a/sysdeps/generic/local-setxid.h +++ /dev/null @@ -1,4 +0,0 @@ -/* No special support. Fall back to the regular functions. */ - -#define local_seteuid(id) seteuid (id) -#define local_setegid(id) setegid (id) diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c index 943a598771..2dcbc1bf24 100644 --- a/sysdeps/posix/spawni.c +++ b/sysdeps/posix/spawni.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -139,8 +138,8 @@ __spawni_child (void *arguments) /* Set the effective user and group IDs. */ if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0 - && (local_seteuid (__getuid ()) != 0 - || local_setegid (__getgid ())) != 0) + && (__seteuid (__getuid ()) != 0 + || __setegid (__getgid ())) != 0) goto fail; /* Execute the file actions. */ diff --git a/sysdeps/unix/sysv/linux/local-setxid.h b/sysdeps/unix/sysv/linux/local-setxid.h deleted file mode 100644 index 97d787d942..0000000000 --- a/sysdeps/unix/sysv/linux/local-setxid.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SETxID functions which only have to change the local thread and - none of the possible other threads. */ -#include - -#ifdef __NR_setresuid32 -# define local_seteuid(id) INLINE_SYSCALL (setresuid32, 3, -1, id, -1) -#else -# define local_seteuid(id) INLINE_SYSCALL (setresuid, 3, -1, id, -1) -#endif - - -#ifdef __NR_setresgid32 -# define local_setegid(id) INLINE_SYSCALL (setresgid32, 3, -1, id, -1) -#else -# define local_setegid(id) INLINE_SYSCALL (setresgid, 3, -1, id, -1) -#endif diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index f157bfffd2..d8623534cf 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -74,6 +73,24 @@ # define STACK(__stack, __stack_size) (__stack + __stack_size) #endif +/* SETxID functions which only have to change the local thread and none of the + possible other threads. */ +static int local_seteuid (uid_t euid) +{ +#ifndef __NR_setresuid32 +# define __NR_setresuid32 __NR_setresuid +#endif + return INLINE_SYSCALL_CALL (setresuid32, -1, euid, -1); +} + +static int local_setegid (uid_t egid) +{ +#ifndef __NR_setresgid32 +# define __NR_setresgid32 __NR_setresgid +#endif + return INLINE_SYSCALL_CALL (setresgid32, -1, egid, -1); +} + struct posix_spawn_args {