--- /dev/null
+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 arlo.cworth.org (Postfix) with ESMTP id C22316DE0AC2\r
+ for <notmuch@notmuchmail.org>; Sat, 12 Dec 2015 15:25:07 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.696\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.696 tagged_above=-999 required=5 tests=[AWL=0.044, \r
+ SPF_NEUTRAL=0.652] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ynT4wIKu_b6B for <notmuch@notmuchmail.org>;\r
+ Sat, 12 Dec 2015 15:25:05 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 2E69E6DE005F\r
+ for <notmuch@notmuchmail.org>; Sat, 12 Dec 2015 15:25:04 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 9C9FB10004A;\r
+ Sun, 13 Dec 2015 01:25:18 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,\r
+ Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: Re: [PATCH 7/9] add a gpg_path value for notmuch_database_t\r
+In-Reply-To: <87mvtgfws4.fsf@alice.fifthhorseman.net>\r
+References: <1449718786-28000-1-git-send-email-dkg@fifthhorseman.net>\r
+ <1449718786-28000-8-git-send-email-dkg@fifthhorseman.net>\r
+ <m21tas7ifa.fsf@guru.guru-group.fi> <87mvtgfws4.fsf@alice.fifthhorseman.net>\r
+User-Agent: Notmuch/0.21+32~g73439f8 (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: Sun, 13 Dec 2015 01:25:17 +0200\r
+Message-ID: <m2fuz75jxe.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 12 Dec 2015 23:25:07 -0000\r
+\r
+On Sat, Dec 12 2015, Daniel Kahn Gillmor <dkg@fifthhorseman.net> wrote:\r
+\r
+> On Fri 2015-12-11 17:02:33 -0500, Tomi Ollila wrote:\r
+>> The above code finds gpg/gpg2 (when called w/ these args) from\r
+>> _CS_PATH (seems to be /bin:/usr/bin by default in linux (tried to\r
+>> look how this set in *BSD -- initially it looks like /usr/local/bin\r
+>> not included but... maybe we let them to complain if this is the case\r
+>> ... :/)\r
+>> ... anyway, the full found path is not set anywhere -- how is it found\r
+>> when used (exec*p() using $PATH? :O)\r
+>\r
+> Hm, according to exec(3):\r
+>\r
+> Special semantics for execlp() and execvp()\r
+> The execlp(), execvp(), and execvpe() functions duplicate the\r
+> actions of the shell in searching for an executable file if the\r
+> specified filename does not contain a slash (/) character. The\r
+> file is sought in the colon-separated list of directory pathnames\r
+> specified in the PATH environment variable. If this variable\r
+> isn't defined, the path list defaults to the current directory\r
+> followed by the list of directories returned by\r
+> confstr(_CS_PATH). (This confstr(3) call typically returns the\r
+> value "/bin:/usr/bin".)\r
+>\r
+> So this code probably also ought to be searching $PATH as well. yuck.\r
+> You'd think there would be a commonly-available function for doing this\r
+> specific check without having to actually try to exec() something.\r
+\r
+Indeed.\r
+\r
+Shells seems to be smart and do pre-check through PATH (but not=20\r
+_CS_PATH...(**)) and then exec just with the found path. I straced\r
+one execlp() usage and it na=C3=AFvely attempted to execve() through the\r
+name appended to path (if getting ENOENT); when execve() succeeds\r
+it does not return...\r
+\r
+I originally had a fast thought that it was a security feature not\r
+use PATH (which user can screw up ;/), but some safer path set.\r
+Perhaps that is not necessary...\r
+\r
+Perhaps the search should go through PATH if it is defined and\r
+if not defined then use confstr(_CS_PATH). If PATH is empty\r
+then not use confstr (but use current dir !!11!!?++?+?? (*))\r
+\r
+One thing I forgot from the review:\r
+\r
+the #define try_gpg_path(z) is done inside {}:s, so\r
+before closing } there could be\r
+#undef try_gpg_path (to make the "liveness" of it match the scope)\r
+\r
+\r
+(*) what is the yuckiness of this:\r
+\r
+ $ PATH=3D ls\r
+ zsh: command not found: ls\r
+\r
+ $ bash -c 'PATH=3D ls'\r
+ bash: ls: No such file or directory\r
+\r
+ $ echo '#!/bin/echo this is ./ls ?' >! ./ls\r
+ $ chmod 755 ./ls\r
+\r
+ $ PATH=3D ls\r
+ this is ./ls ? ls -F\r
+\r
+ $ PATH=3D command ls\r
+ this is ./ls ? ls\r
+\r
+ $ bash -c 'PATH=3D ls'\r
+ this is ./ls ? ls\r
+\r
+ $ rm ./ls\r
+\r
+(**) unset PATH had the same effect in bash and dash but zsh did not=20\r
+ check ./ls after 'unset PATH'\r
+\r
+-- I personally think we could just ignore empty components in PATH\r
+(being it like PATH=3D, PATH=3D:/path/to, PATH=3D/path/to: and finally\r
+PATH=3D/path/to::/path/to) (or then not, just be as compliant (and stupid)\r
+as the PATH handling is).\r
+\r
+Tomi\r
+\r
+>\r
+> --dkg\r