public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Hoang Nguyen <the_hoang0709@yahoo.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] prot_hsymlinks: Fix failure on read-only machine
Date: Wed, 5 Apr 2017 01:14:20 +0000 (UTC)	[thread overview]
Message-ID: <150206007.41990.1491354860494@mail.yahoo.com> (raw)
In-Reply-To: <241709389.146541.1490151985827@mail.yahoo.com>

Hello,
Could you help to check if the patch is ok or not ?
Thanks and regards.
Hoang

      From: Hoang Nguyen <the_hoang0709@yahoo.com>
 To: "the_hoang0709@yahoo.com" <the_hoang0709@yahoo.com>; "ltp@lists.linux.it" <ltp@lists.linux.it> 
 Sent: Wednesday, 22 March 2017, 10:06
 Subject: Re: [LTP] [PATCH] prot_hsymlinks: Fix failure on read-only machine
   
Hi,
Could you help to check, so that we can close the Issue ?
Thanks and regards
Hoang

Sent from Yahoo Mail on Android 
 
 On Fri, Mar 10, 2017 at 7:55, the_hoang0709@yahoo.com<the_hoang0709@yahoo.com> wrote:  From: Hoang Nguyen <the_hoang0709@yahoo.com>

Return 32 if /etc/passwd is read-only.
Also move tst_tmpdir before useradd in setup, to avoid "TESTDIR was
NULL" in tst_rmdir in cleanup.

Fixes #88

Signed-off-by: Hoang Nguyen <the_hoang0709@yahoo.com>
---
 testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c b/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
index b23064a..31ddefa 100644
--- a/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
+++ b/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
@@ -206,6 +206,8 @@ static void setup(int argc, char *argv[])
 
     tst_sig(FORK, DEF_HANDLER, cleanup);
 
+    tst_tmpdir();
+
     test_user_cmd("useradd");
     /*
     * enable hardlinks and symlinks restrictions,
@@ -220,8 +222,6 @@ static void setup(int argc, char *argv[])
         disable_protected_slinks = 1;
     }
 
-    tst_tmpdir();
-
     init_base_dirs();
 
     init_files_dirs();
@@ -273,7 +273,8 @@ static void cleanup(void)
     if (skip_cleanup)
         return;
 
-    test_user_cmd("userdel -r");
+    if (!eaccess("/etc/passwd", W_OK))
+        test_user_cmd("userdel -r");
 
     if (disable_protected_hlinks) {
         tst_resm(TINFO, "Disable protected hardlinks mode back");
@@ -316,8 +317,13 @@ static void test_user_cmd(const char *user_cmd)
     char cmd[MAX_CMD_LEN];
     snprintf(cmd, MAX_CMD_LEN, "%s %s", user_cmd, users[TEST_USER].name);
     if (system(cmd) != 0) {
-        tst_brkm(TBROK, cleanup, "Failed to run cmd: %s %s",
+        if (eaccess("/etc/passwd", W_OK)) {
+            tst_brkm(TCONF, cleanup,
+            "/etc/passwd is not accessible");
+        } else {
+            tst_brkm(TBROK, cleanup, "Failed to run cmd: %s %s",
             user_cmd, users[TEST_USER].name);
+        }
     }
 }
 
-- 
2.7.4

  


   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20170405/1007f06e/attachment.html>

  reply	other threads:[~2017-04-05  1:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-10  0:54 [LTP] [PATCH] prot_hsymlinks: Fix failure on read-only machine the_hoang0709
2017-03-22  3:06 ` Hoang Nguyen
2017-04-05  1:14   ` Hoang Nguyen [this message]
2017-04-05 17:25 ` Alexey Kodanev
2017-04-09  8:29   ` Hoang Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=150206007.41990.1491354860494@mail.yahoo.com \
    --to=the_hoang0709@yahoo.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox