From patchwork Tue Mar 27 17:36:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandeep Patil X-Patchwork-Id: 891739 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="XUj8Hbm1"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 409dVH09PNz9ry1 for ; Wed, 28 Mar 2018 04:36:38 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id F12AC3E62D8 for ; Tue, 27 Mar 2018 19:36:35 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 7672B3E62C6 for ; Tue, 27 Mar 2018 19:36:33 +0200 (CEST) Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 5A66A1A01083 for ; Tue, 27 Mar 2018 19:36:32 +0200 (CEST) Received: by mail-pl0-x243.google.com with SMTP id n15-v6so14521893plp.12 for ; Tue, 27 Mar 2018 10:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=blakq81UTit2Xzsv5QrX15JT9m+i7h0BF6f+JpGDRCI=; b=XUj8Hbm1Kl08XenF++AU01WMUd5aMnlSnOARCMA8uBtVnho9zAmeqXMU37/G03qdrk AuA2CxghrQu8YHFgncprYvPoSTMVz89ZbUzqHTHtnMhbUmFNHhqsBFdPbm1RiziF7Nnx 4c+WKp5HFFJRHLj9tXu3kPerYUU5PtU2f3w4qoLAaLFGX8fm2UQTJDB3/SFtbxqFLKLz Yl6jU7N+ICADuvcIf+TITI0MsViTBoqBXEDo+Yc3V0PPsh0VBHV+PXKOhc7q53nymGJR 0QPcjZiOtEr0xF4HNJtfAQ6n2tgTwEN8PC4GXtMM3yHE6++KS+7spXRRA31ZAkPd9IPp 21Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=blakq81UTit2Xzsv5QrX15JT9m+i7h0BF6f+JpGDRCI=; b=HIkYZaJMzuhuQAmdWREFUCjLUlrrs2xSz1NAM7pJBDg3u0Bo5kebDeCUZhSvS2pzlm 9WjUUNUTTOBA4ulA5ChuKYazxB08TWPeE1wm9VR9b0sax+QvhKSH87U9038s6PtvMrFD IwlFCDYRQFyc1DoPjWYyZfgTQAvh31aOpMCMSUs1ggY4t8eSpwszzArh8RWzd2cfVf1l kA67yUklfmjNb9g8hqGDWRQPz//ouOix44U2Q8rBOv17WorAL0cpj6PSLGnQkdu6x9BU tMihFJr8Jsb9FO0iXXSaojx83vDS3QMrhAjdPwA+I+IkreBv7kTSryr/iF+lPWiXaSGq 31mQ== X-Gm-Message-State: AElRT7GDMHBNOktCw2UiwpJzAYkIL+QzPLcqX9oEcN7mizbN1lDuLF/R BVaYVyZ5dnaCyOFudku9BTHl5Egp78g= X-Google-Smtp-Source: AIpwx49pYXjwA+v5mpCrrnqMTeWugbdOlHX7zxqrVNyAqAQHDn+um59uM9zvWZlc5MDuX8Dd7xRC/w== X-Received: by 2002:a17:902:51c3:: with SMTP id y61-v6mr225907plh.101.1522172190059; Tue, 27 Mar 2018 10:36:30 -0700 (PDT) Received: from sspatil-desktop.mtv.corp.google.com ([2620:0:1000:1600:6e29:33f4:7c9a:4918]) by smtp.gmail.com with ESMTPSA id a7sm3366264pgq.74.2018.03.27.10.36.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Mar 2018 10:36:28 -0700 (PDT) From: Sandeep Patil To: ltp@lists.linux.it Date: Tue, 27 Mar 2018 10:36:22 -0700 Message-Id: <20180327173622.175056-1-sspatil@google.com> X-Mailer: git-send-email 2.17.0.rc0.231.g781580f067-goog X-Virus-Scanned: clamav-milter 0.99.2 at in-3.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, SPF_PASS, T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Cc: pvorel@suze.cz, kernel-team@android.com Subject: [LTP] [PATCH v2] setregid: use common user and group names. X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Android systems do not have groups names 'users' 'sys' etc. Replace them with 'nobody' and 'daemon' for the purposes of setregid0[34] tests and make the nomenclature across both of these tests more consistent. This was made possible due to following commit in 'system/core' project that adds the 'daemon' user to Android 8e8648463 ("libcutils: Add "daemon" and "bin" users for testing only") After this change, both setregid03 and setregid04 can run on Android systems. Signed-off-by: Sandeep Patil --- v1->v2 ------- - Add description of the change that adds the new user in Android in commit message .../kernel/syscalls/setregid/setregid03.c | 51 ++++++++++--------- .../kernel/syscalls/setregid/setregid04.c | 18 +++---- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/testcases/kernel/syscalls/setregid/setregid03.c b/testcases/kernel/syscalls/setregid/setregid03.c index a51719e80..97102e0ee 100644 --- a/testcases/kernel/syscalls/setregid/setregid03.c +++ b/testcases/kernel/syscalls/setregid/setregid03.c @@ -41,7 +41,7 @@ static gid_t neg_one = -1; /* flag to tell parent if child passed or failed. */ static int flag; -struct group users, sys, root, bin; +struct group nobody_gr, daemon_gr, root_gr, bin_gr; struct passwd nobody; /* * The following structure contains all test data. Each structure in the array @@ -57,27 +57,28 @@ struct test_data_t { char *test_msg; } test_data[] = { { - &sys.gr_gid, &bin.gr_gid, &pass, &sys, &bin, - "After setregid(sys, bin),"}, { - &neg_one, &sys.gr_gid, &pass, &sys, &sys, "After setregid(-1, sys)"}, - { - &neg_one, &bin.gr_gid, &pass, &sys, &bin, "After setregid(-1, bin),"}, - { - &bin.gr_gid, &neg_one, &pass, &bin, &bin, "After setregid(bin, -1),"}, - { - &neg_one, &neg_one, &pass, &bin, &bin, "After setregid(-1, -1),"}, { - &neg_one, &bin.gr_gid, &pass, &bin, &bin, "After setregid(-1, bin),"}, - { - &bin.gr_gid, &neg_one, &pass, &bin, &bin, "After setregid(bin, -1),"}, - { - &bin.gr_gid, &bin.gr_gid, &pass, &bin, &bin, + &daemon_gr.gr_gid, &bin_gr.gr_gid, &pass, &daemon_gr, &bin_gr, + "After setregid(daemon, bin),"}, { + &neg_one, &daemon_gr.gr_gid, &pass, &daemon_gr, &daemon_gr, + "After setregid(-1, daemon)"}, { + &neg_one, &bin_gr.gr_gid, &pass, &daemon_gr, &bin_gr, + "After setregid(-1, bin),"}, { + &bin_gr.gr_gid, &neg_one, &pass, &bin_gr, &bin_gr, + "After setregid(bin, -1),"}, { + &neg_one, &neg_one, &pass, &bin_gr, &bin_gr, + "After setregid(-1, -1),"}, { + &neg_one, &bin_gr.gr_gid, &pass, &bin_gr, &bin_gr, + "After setregid(-1, bin),"}, { + &bin_gr.gr_gid, &neg_one, &pass, &bin_gr, &bin_gr, + "After setregid(bin, -1),"}, { + &bin_gr.gr_gid, &bin_gr.gr_gid, &pass, &bin_gr, &bin_gr, "After setregid(bin, bin),"}, { - &sys.gr_gid, &neg_one, &fail, &bin, &bin, "After setregid(sys, -1)"}, - { - &neg_one, &sys.gr_gid, &fail, &bin, &bin, "After setregid(-1, sys)"}, - { - &sys.gr_gid, &sys.gr_gid, &fail, &bin, &bin, - "After setregid(sys, sys)"},}; + &daemon_gr.gr_gid, &neg_one, &fail, &bin_gr, &bin_gr, + "After setregid(daemon, -1)"}, { + &neg_one, &daemon_gr.gr_gid, &fail, &bin_gr, &bin_gr, + "After setregid(-1, daemon)"}, { + &daemon_gr.gr_gid, &daemon_gr.gr_gid, &fail, &bin_gr, &bin_gr, + "After setregid(daemon, daemon)"},}; int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); @@ -102,7 +103,7 @@ int main(int ac, char **av) tst_count = 0; /* set the appropriate ownership values */ - if (SETREGID(NULL, sys.gr_gid, bin.gr_gid) == -1) + if (SETREGID(NULL, daemon_gr.gr_gid, bin_gr.gr_gid) == -1) tst_brkm(TBROK, NULL, "Initial setregid failed"); SAFE_SETEUID(NULL, nobody.pw_uid); @@ -191,11 +192,11 @@ static void setup(void) tst_brkm(TBROK, NULL, "%s must be a valid group", #group); \ } \ GID16_CHECK(junk->gr_gid, setregid, NULL); \ - group = *(junk); \ + group ## _gr = *(junk); \ } while (0) - GET_GID(users); - GET_GID(sys); + GET_GID(nobody); + GET_GID(daemon); GET_GID(bin); TEST_PAUSE; diff --git a/testcases/kernel/syscalls/setregid/setregid04.c b/testcases/kernel/syscalls/setregid/setregid04.c index 0e0aae782..73f8bcb03 100644 --- a/testcases/kernel/syscalls/setregid/setregid04.c +++ b/testcases/kernel/syscalls/setregid/setregid04.c @@ -35,7 +35,7 @@ TCID_DEFINE(setregid04); static gid_t neg_one = -1; -static struct group users_gr, daemon_gr, root_gr, bin_gr; +static struct group nobody_gr, daemon_gr, root_gr, bin_gr; /* * The following structure contains all test data. Each structure in the array @@ -52,8 +52,8 @@ struct test_data_t { { &root_gr.gr_gid, &root_gr.gr_gid, &root_gr, &root_gr, "After setregid(root, root),"}, { - &users_gr.gr_gid, &neg_one, &users_gr, &root_gr, - "After setregid(users, -1)"}, { + &nobody_gr.gr_gid, &neg_one, &nobody_gr, &root_gr, + "After setregid(nobody, -1)"}, { &root_gr.gr_gid, &neg_one, &root_gr, &root_gr, "After setregid(root,-1),"}, { &neg_one, &neg_one, &root_gr, &root_gr, @@ -62,12 +62,12 @@ struct test_data_t { "After setregid(-1, root)"}, { &root_gr.gr_gid, &neg_one, &root_gr, &root_gr, "After setregid(root, -1),"}, { - &daemon_gr.gr_gid, &users_gr.gr_gid, &daemon_gr, &users_gr, - "After setregid(daemon, users)"}, { - &neg_one, &neg_one, &daemon_gr, &users_gr, + &daemon_gr.gr_gid, &nobody_gr.gr_gid, &daemon_gr, &nobody_gr, + "After setregid(daemon, nobody)"}, { + &neg_one, &neg_one, &daemon_gr, &nobody_gr, "After setregid(-1, -1)"}, { - &neg_one, &users_gr.gr_gid, &daemon_gr, &users_gr, - "After setregid(-1, users)"} + &neg_one, &nobody_gr.gr_gid, &daemon_gr, &nobody_gr, + "After setregid(-1, nobody)"} }; int TST_TOTAL = sizeof(test_data) / sizeof(test_data[0]); @@ -123,7 +123,7 @@ static void setup(void) tst_sig(FORK, DEF_HANDLER, cleanup); SAFE_GETGROUP(root); - SAFE_GETGROUP(users); + SAFE_GETGROUP(nobody); SAFE_GETGROUP(daemon); SAFE_GETGROUP(bin);