From patchwork Fri Sep 8 14:14:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1831588 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=cLF/cl8V; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=7MFYU0ZX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RhymM5LGYz1yhG for ; Sat, 9 Sep 2023 00:14:43 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 90EE63CE974 for ; Fri, 8 Sep 2023 16:14:41 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 91E193CB543 for ; Fri, 8 Sep 2023 16:14:16 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 014DC1001594 for ; Fri, 8 Sep 2023 16:14:15 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8342C21C81; Fri, 8 Sep 2023 14:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694182455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0V1VvSM7JZAE0j5BtsDujXNb3ECXuH/JxxMOHPK2v6U=; b=cLF/cl8VQqh+TOUsLdXQNTzYt0es0a/XaQWoLrdvD6AwLzzqNwkmY4hEUvewX8GSVIzH0X ieqhexP9wzibMXkFgnMY9bYR32b1/QlkrXCXQ9w7A3VFz8xj2vDdfIre/yvYYvuSmSpzu2 dBpabe8n95O325ax/tuD7tchb1bB9kU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694182455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0V1VvSM7JZAE0j5BtsDujXNb3ECXuH/JxxMOHPK2v6U=; b=7MFYU0ZXPuX1GcSHjkWYAHZHhcQytlEdv/AM2b8TnzmJzEqlZfQOGSIqGFbezOmw0he5rk K+K8qy89AdMFC8DQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 56C66132F2; Fri, 8 Sep 2023 14:14:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2BXDEjcs+2RocQAAMHmgww (envelope-from ); Fri, 08 Sep 2023 14:14:15 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Fri, 8 Sep 2023 16:14:13 +0200 Message-Id: <20230908141414.28359-2-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230908141414.28359-1-andrea.cervesato@suse.de> References: <20230908141414.28359-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.1 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v2 1/2] Refactor getegid01 using new LTP API X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato This new version also verifies that getegid() effectively returns the right effective group ID by looking at /proc/self/status information. Signed-off-by: Andrea Cervesato --- testcases/kernel/syscalls/getegid/getegid01.c | 95 ++++--------------- 1 file changed, 20 insertions(+), 75 deletions(-) diff --git a/testcases/kernel/syscalls/getegid/getegid01.c b/testcases/kernel/syscalls/getegid/getegid01.c index 271fbb6b6..46cdc680b 100644 --- a/testcases/kernel/syscalls/getegid/getegid01.c +++ b/testcases/kernel/syscalls/getegid/getegid01.c @@ -1,87 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ - * + * William Roske, Dave Fenner + * Copyright (C) 2023 SUSE LLC Andrea Cervesato */ -/* - * AUTHOR : William Roske - * CO-PILOT : Dave Fenner +/*\ + * [Description] + * + * This test checks if getegid() returns the effective group id. */ -#include -#include -#include -#include - -#include "test.h" -#include "compat_16.h" - -static void setup(); -static void cleanup(); +#include "tst_test.h" +#include "compat_tst_16.h" -TCID_DEFINE(getegid01); -int TST_TOTAL = 1; - -int main(int ac, char **av) +static void run(void) { - int lc; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - TEST(GETEGID(cleanup)); + gid_t gid, st_egid; - if (TEST_RETURN == -1) { - tst_resm(TFAIL | TTERRNO, "getegid failed"); - continue; /* next loop for MTKERNEL */ - } + SAFE_FILE_LINES_SCANF("/proc/self/status", "Gid: %*d %d", &st_egid); + gid = getegid(); - tst_resm(TPASS, "getegid returned %ld", TEST_RETURN); - } - - cleanup(); - tst_exit(); -} - -static void setup(void) -{ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; + if (GID_SIZE_CHECK(st_egid)) + TST_EXP_EQ_LI(gid, st_egid); + else + tst_res(TPASS, "getegid() passed"); } -static void cleanup(void) -{ -} +static struct tst_test test = { + .test_all = run, +}; From patchwork Fri Sep 8 14:14:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1831587 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Iu4Y2Gho; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=TYEpnJwC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rhym81Z6xz1yhG for ; Sat, 9 Sep 2023 00:14:32 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E12E03CC6BA for ; Fri, 8 Sep 2023 16:14:29 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 015153CB543 for ; Fri, 8 Sep 2023 16:14:16 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 0C57E206C38 for ; Fri, 8 Sep 2023 16:14:16 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C3C0721CC1; Fri, 8 Sep 2023 14:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694182455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0NdYM86YsxycvyImygfa7Alq47I9Ickaz886pdKZzA8=; b=Iu4Y2Gho943nijzeHP90TNsT1GFxE+l5ebY2osQEU8WkJx62dPrdRp+BBD3YVTUScvSljy 6OftPhcHPjNj+nkanxOpaFG1KOjSIrfXkSIzi9QA6ZGE/ICsqiv5d11El0v0Zua72O7oGm sSCG6BVPo9hipOrODhVnANmV5ngQl74= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694182455; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0NdYM86YsxycvyImygfa7Alq47I9Ickaz886pdKZzA8=; b=TYEpnJwCdLxQZT/6MNXklWNs9f+YW/gbA/c5lZug8EHOh10qOE5oHiYXFKHnFWG5La4vH9 QR7S3e/DKdeKOxBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 935F1132F2; Fri, 8 Sep 2023 14:14:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0AmHITcs+2RocQAAMHmgww (envelope-from ); Fri, 08 Sep 2023 14:14:15 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Fri, 8 Sep 2023 16:14:14 +0200 Message-Id: <20230908141414.28359-3-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230908141414.28359-1-andrea.cervesato@suse.de> References: <20230908141414.28359-1-andrea.cervesato@suse.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 1.0.1 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v2 2/2] Refactor getegid02 using new LTP API X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Signed-off-by: Andrea Cervesato --- testcases/kernel/syscalls/getegid/getegid02.c | 93 +++++-------------- 1 file changed, 21 insertions(+), 72 deletions(-) diff --git a/testcases/kernel/syscalls/getegid/getegid02.c b/testcases/kernel/syscalls/getegid/getegid02.c index 60f09501e..2f64bd869 100644 --- a/testcases/kernel/syscalls/getegid/getegid02.c +++ b/testcases/kernel/syscalls/getegid/getegid02.c @@ -1,90 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (c) International Business Machines Corp., 2001 - * Ported by Wayne Boyer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * William Roske, Dave Fenner + * Copyright (C) 2023 SUSE LLC Andrea Cervesato */ -/* - * Testcase to check the basic functionality of getegid(). +/*\ + * [Description] * - * For functionality test the return value from getegid() is compared to passwd - * entry. + * This test checks if getegid() returns the same effective group given by + * passwd entry via getpwuid(). */ #include -#include - -#include "test.h" -#include "compat_16.h" -static void cleanup(void); -static void setup(void); +#include "tst_test.h" +#include "compat_tst_16.h" -TCID_DEFINE(getegid02); -int TST_TOTAL = 1; - -int main(int ac, char **av) +static void run(void) { - int lc; uid_t euid; + gid_t egid; struct passwd *pwent; - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - - TEST(GETEGID(cleanup)); + UID16_CHECK((euid = geteuid()), "geteuid"); - if (TEST_RETURN < 0) { - tst_brkm(TBROK, cleanup, "This should never happen"); - } + pwent = getpwuid(euid); + if (!pwent) + tst_brk(TBROK | TERRNO, "getpwuid() error"); - euid = geteuid(); - pwent = getpwuid(euid); + GID16_CHECK((egid = getegid()), "getegid"); - if (pwent == NULL) - tst_brkm(TBROK, cleanup, "geteuid() returned " - "unexpected value %d", euid); - - GID16_CHECK(pwent->pw_gid, getegid, cleanup); - - if (pwent->pw_gid != TEST_RETURN) { - tst_resm(TFAIL, "getegid() return value" - " %ld unexpected - expected %d", - TEST_RETURN, pwent->pw_gid); - } else { - tst_resm(TPASS, - "effective group id %ld " - "is correct", TEST_RETURN); - } - } - - cleanup(); - tst_exit(); -} - -static void setup(void) -{ - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; + TST_EXP_EQ_LI(pwent->pw_gid, egid); } -static void cleanup(void) -{ -} +static struct tst_test test = { + .test_all = run, +};