Re: [PATCH 1/1] test/basic: replaced find -perm +111 with portable alternative
authorTomi Ollila <tomi.ollila@iki.fi>
Thu, 13 Jun 2013 19:47:33 +0000 (22:47 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:55:34 +0000 (09:55 -0800)
e1/d3bdc48c2d44cb82c1c24a94775dbb34fb43ba [new file with mode: 0644]

diff --git a/e1/d3bdc48c2d44cb82c1c24a94775dbb34fb43ba b/e1/d3bdc48c2d44cb82c1c24a94775dbb34fb43ba
new file mode 100644 (file)
index 0000000..c48bfe1
--- /dev/null
@@ -0,0 +1,127 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3ADDA431FC2\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Jun 2013 12:47:50 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 6L8GKctEND5q for <notmuch@notmuchmail.org>;\r
+       Thu, 13 Jun 2013 12:47:41 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 98014431FBC\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Jun 2013 12:47:41 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 596C51002BA;\r
+       Thu, 13 Jun 2013 22:47:33 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: [PATCH 1/1] test/basic: replaced find -perm +111 with portable\r
+       alternative\r
+In-Reply-To: <20130610155940.GE22196@mit.edu>\r
+References: <1370641049-17390-1-git-send-email-tomi.ollila@iki.fi>\r
+       <20130610155940.GE22196@mit.edu>\r
+User-Agent: Notmuch/0.15.2+181~gfb53171 (http://notmuchmail.org) Emacs/24.3.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Thu, 13 Jun 2013 22:47:33 +0300\r
+Message-ID: <m2r4g56be2.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 13 Jun 2013 19:47:50 -0000\r
+\r
+On Mon, Jun 10 2013, Austin Clements <amdragon@MIT.EDU> wrote:\r
+\r
+> LGTM.  Though, I wonder, why not *just* -perm -100?  That isn't quite\r
+> a correct test of whether the user can execute it: e.g., if the file\r
+> is owned by some other user and a group the current user isn't in,\r
+> then -perm -1 is the correct test, though unless the file has some\r
+> unusual permissions, -perm -100 is likely to pass anyway.  But the\r
+> test you have (and the test that was there before) isn't quite correct\r
+> either: if the file is owned by the current user and has some crazy\r
+> permission like 0611, the user won't be able to execute it, even\r
+> though someone else could.\r
+\r
+While giving considerable amount of thought for such an insignificant\r
+issue I came to realize this:\r
+\r
+The purpose of the '-perm ...' part in that expression is not to check\r
+whether the file is executable by the user but just to reduce the set\r
+of files the whole expression returns without need to "blacklist" more\r
+files that are already blacklisted with '! -name ...' subexpressions\r
+("Makefile", ".gitignore" and so on).\r
+\r
+With +111, /ppp and their portable alternative\r
+( -perm -100 -or -perm -10 -or -perm 1 ) the implicit reduction this\r
+part does is smaller than with -100.\r
+\r
+The returned list is then compared with ${TESTS} and if there is no\r
+exact match then this particular test fails.\r
+\r
+Whatever this test result is, the execution of any file in ${TESTS}\r
+will fail with "permission denied" if it is not executable by\r
+the user running the tests.\r
+\r
+I think that as we're doing this "shortcut" instead of full file\r
+blacklisting, this should reduce the output less rather than\r
+more and therefore use the version provided in this patch\r
+instead of changing +111 to -100.\r
+\r
+(In the future I'd like to see that we had some convention to name\r
+the test scripts and either do comparison to that list or that\r
+convention also dictates order and this test could be removed. There\r
+are a few alternatives that we could think of...).\r
+\r
+> It's too bad "-executable" is a GNU extension.\r
+\r
+I'd have uses for that :D\r
+\r
+Tomi\r
+\r
+> Quoth Tomi Ollila on Jun 08 at 12:37 am:\r
+>> The find option syntax `-perm +111` is deprecated gnu find feature.\r
+>> The replacement `( -perm -100 -o -perm -10 -o -perm 1 )` should also\r
+>> work outside of the GNU domain.\r
+>> ---\r
+>>  test/basic | 3 ++-\r
+>>  1 file changed, 2 insertions(+), 1 deletion(-)\r
+>>\r
+>> diff --git a/test/basic b/test/basic\r
+>> index 1b2a7d2..64eb7d7 100755\r
+>> --- a/test/basic\r
+>> +++ b/test/basic\r
+>> @@ -53,7 +53,8 @@ test_expect_code 2 'failure to clean up causes the test to fail' '\r
+>>  test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
+>>  eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
+>>  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
+>> -available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111  \\r
+>> +available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f \\r
+>> +   '(' -perm -100 -o -perm -10 -o -perm -1 ')' \\r
+>>      ! -name aggregate-results.sh    \\r
+>>      ! -name arg-test                        \\r
+>>      ! -name hex-xcode                       \\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r