mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [mesos] asekretenko commented on a change in pull request #381: Fixed NNP isolator test on systems with POSIX-compliant /bin/sh.
Date Sun, 31 Jan 2021 17:35:27 GMT

asekretenko commented on a change in pull request #381:
URL: https://github.com/apache/mesos/pull/381#discussion_r567458262



##########
File path: src/tests/containerizer/linux_nnp_isolator_tests.cpp
##########
@@ -102,18 +102,26 @@ TEST_F(LinuxNNPIsolatorTest, ROOT_CheckNoNewPrivileges)
   containerId.set_value(id::UUID::random().toString());
 
   // Test that the child process inherits the PR_NO_NEW_PRIVS flag.
-  // Using parameter expansion to parse the process status file
+  // Using convoluted way to parse the process status file
   // due to minimal docker image. The child process should inherit
   // the PR_NO_NEW_PRIVS flag. Parse the process status file and
   // determine if "NoNewPrivs: 1" is found.
   ExecutorInfo executor = createExecutorInfo(
       "test_executor",
       R"~(
-      #!/bin/bash
-      x=$(cat /proc/self/status);
-      y=${x##*NoNewPrivs:};
-      read -a a <<< $y;
-      if [ ${a[0]} == "1" ]; then exit 0; else exit 1; fi
+      nnp_seen="false"
+      for line in $(cat /proc/self/status); do

Review comment:
       @cf-natali IMO, `line` is a very unfortunate name for this variable; readers can be
mislead into thinking that lines in `/proc/self/status` contain no whitespaces and this script
reads it line by line.
   Something like `word`/`piece`/`segment`/... would be much less confusing.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message