Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / 8b / 87e3dbce60158cb578c2be95f644c8ff008b5d
1 Return-Path: <david@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 1BF556DE091B\r
6  for <notmuch@notmuchmail.org>; Thu, 11 Aug 2016 22:51:32 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.008\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.008 tagged_above=-999 required=5 tests=[AWL=0.003,\r
12   SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id GY07eHWYz2ge for <notmuch@notmuchmail.org>;\r
16  Thu, 11 Aug 2016 22:51:24 -0700 (PDT)\r
17 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
18  by arlo.cworth.org (Postfix) with ESMTPS id 1BE346DE0362\r
19  for <notmuch@notmuchmail.org>; Thu, 11 Aug 2016 22:51:23 -0700 (PDT)\r
20 Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2)\r
21  (envelope-from <david@tethera.net>)\r
22  id 1bY5NV-0006ad-NV; Fri, 12 Aug 2016 01:51:33 -0400\r
23 Received: (nullmailer pid 18608 invoked by uid 1000);\r
24  Fri, 12 Aug 2016 05:51:16 -0000\r
25 From: David Bremner <david@tethera.net>\r
26 To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,\r
27  Notmuch Mail <notmuch@notmuchmail.org>\r
28 Subject: Re: [PATCH v4 01/16] add util/search-path.{c,\r
29  h} to test for executables in $PATH\r
30 In-Reply-To: <1467970047-8013-2-git-send-email-dkg@fifthhorseman.net>\r
31 References: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
32  <1467970047-8013-2-git-send-email-dkg@fifthhorseman.net>\r
33 User-Agent: Notmuch/0.22.1+61~g2ce0f13 (https://notmuchmail.org) Emacs/24.5.1\r
34  (x86_64-pc-linux-gnu)\r
35 Date: Fri, 12 Aug 2016 14:51:16 +0900\r
36 Message-ID: <878tw2r0vf.fsf@maritornes.cs.unb.ca>\r
37 MIME-Version: 1.0\r
38 Content-Type: text/plain\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.20\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43  <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
50  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Fri, 12 Aug 2016 05:51:32 -0000\r
52 \r
53 Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:\r
54 \r
55 > This is a utility function we can use to see whether an executa>\r
56 > +    if (strchr (exename, '/')) {\r
57 > +     if (0 == access (exename, X_OK))\r
58 > +         return TRUE;\r
59 > +     else\r
60 > +         return FALSE;\r
61 > +    }\r
62 \r
63 Should we distinguish between relative and absolute paths here?  I can't\r
64 think of any security implications, but I'm wondering if a relative path\r
65 is likely just a user error.\r
66 \r
67 > +     path = (char *) malloc (n);\r
68 > +     if (! path)\r
69 > +         return FALSE;\r
70 \r
71 I kindof hate hiding the error here, although I agree it's\r
72 unlikely. What about the unixy return 0 ok, 1 not found -1 error?\r
73 \r
74 > +     confstr (_CS_PATH, path, n);\r
75 > +    }\r
76 > +\r
77 > +    tok = strtok_r (path, ":", &save);\r
78 > +    while (tok) {\r
79 \r
80 I guess it's fine to modify path here, but another option is\r
81 strtok_len (in string-util.h)\r
82 \r