From patchwork Tue Feb 20 13:13:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1901466 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=pXmRHV46; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=AT8LNd9g; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=pXmRHV46; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=AT8LNd9g; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TfKbd2NTCz1yP6 for ; Wed, 21 Feb 2024 00:13:33 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E331A3CF1EA for ; Tue, 20 Feb 2024 14:13:30 +0100 (CET) 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 (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 9E0CA3CDA3B for ; Tue, 20 Feb 2024 14:13:25 +0100 (CET) Authentication-Results: in-7.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 671D120D393 for ; Tue, 20 Feb 2024 14:13:25 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (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) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E40DB220DA; Tue, 20 Feb 2024 13:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708434803; 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; bh=0nLbEwsXYvXw62K5G/K/suoBx31Y5U+wDpOerpThLr8=; b=pXmRHV46vFos3zaTRdODGGXFeMxDxR5Mf5yy+G3o+X6hqcyTQoHE0hzFJe8VJv58QW1KYg oz9y9l/q07WpEUQTsMaytceCjcBI6mp6AlX49wBnxryTy2q+xO3jdkP69DQfZe3pVR39pp Xeu/LXC+W5ENNfq1wdA8KkbVJCZFqWc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708434803; 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; bh=0nLbEwsXYvXw62K5G/K/suoBx31Y5U+wDpOerpThLr8=; b=AT8LNd9g93s+J0Ohkgfs8mBlQIkBs9pXZ4SkZq4wWI/wTF2KjpS/EBN7sNXsxI+XWDExFH CZSBOyBOtaU6t0Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708434803; 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; bh=0nLbEwsXYvXw62K5G/K/suoBx31Y5U+wDpOerpThLr8=; b=pXmRHV46vFos3zaTRdODGGXFeMxDxR5Mf5yy+G3o+X6hqcyTQoHE0hzFJe8VJv58QW1KYg oz9y9l/q07WpEUQTsMaytceCjcBI6mp6AlX49wBnxryTy2q+xO3jdkP69DQfZe3pVR39pp Xeu/LXC+W5ENNfq1wdA8KkbVJCZFqWc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708434803; 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; bh=0nLbEwsXYvXw62K5G/K/suoBx31Y5U+wDpOerpThLr8=; b=AT8LNd9g93s+J0Ohkgfs8mBlQIkBs9pXZ4SkZq4wWI/wTF2KjpS/EBN7sNXsxI+XWDExFH CZSBOyBOtaU6t0Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B0C1B139D0; Tue, 20 Feb 2024 13:13:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id OR1aKHOl1GXEIgAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 13:13:23 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Tue, 20 Feb 2024 14:13:19 +0100 Message-Id: <20240220131319.11761-1-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 3.43 X-Spamd-Result: default: False [3.43 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.27)[73.95%] 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, T_SCC_BODY_TEXT_LINE 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 X-Virus-Scanned: clamav-milter 1.0.3 at in-7.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2] Add chmod08 test 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 test has been extracted from symlink01 and it verifies that chmod() is working correctly on symlink() generated files. Signed-off-by: Andrea Cervesato --- testcases/kernel/syscalls/chmod/chmod08.c | 61 +++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 testcases/kernel/syscalls/chmod/chmod08.c diff --git a/testcases/kernel/syscalls/chmod/chmod08.c b/testcases/kernel/syscalls/chmod/chmod08.c new file mode 100644 index 000000000..f9ca4e45a --- /dev/null +++ b/testcases/kernel/syscalls/chmod/chmod08.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Author: David Fenner + * Copilot: Jon Hendrickson + * Copyright (C) 2024 Andrea Cervesato andrea.cervesato@suse.com + */ + +/*\ + * [Description] + * + * This test verifies that chmod() is working correctly on symlink() + * generated files. + */ + +#include "tst_test.h" + +#define PERMS 01777 +#define TESTFILE "myobject" + +static char testfile[PATH_MAX]; + +static void run(void) +{ + char *symname = "my_symlink0"; + struct stat oldsym_stat; + struct stat newsym_stat; + + SAFE_TOUCH(testfile, 0644, NULL); + SAFE_SYMLINK(testfile, symname); + SAFE_STAT(symname, &oldsym_stat); + + TST_EXP_PASS(chmod(symname, PERMS)); + SAFE_STAT(symname, &newsym_stat); + + TST_EXP_EQ_LI(newsym_stat.st_mode & PERMS, PERMS); + TST_EXP_EXPR(oldsym_stat.st_mode != newsym_stat.st_mode, + "file mode has changed"); + + SAFE_UNLINK(symname); + remove(testfile); +} + +static void setup(void) +{ + int tmplen; + char *tmpdir; + + tmpdir = tst_get_tmpdir(); + tmplen = strlen(tmpdir); + + testfile[tmplen] = '/'; + memcpy(testfile, tmpdir, tmplen); + memcpy(testfile + tmplen + 1, TESTFILE, strlen(TESTFILE)); +} + +static struct tst_test test = { + .setup = setup, + .test_all = run, + .needs_tmpdir = 1, +};