From: David Bremner Date: Fri, 12 Aug 2016 05:51:16 +0000 (+0900) Subject: Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=068a0736f64f0c62085acf190138039bb35fe2f2;p=notmuch-archives.git Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH --- diff --git a/8b/87e3dbce60158cb578c2be95f644c8ff008b5d b/8b/87e3dbce60158cb578c2be95f644c8ff008b5d new file mode 100644 index 000000000..d8f6307bd --- /dev/null +++ b/8b/87e3dbce60158cb578c2be95f644c8ff008b5d @@ -0,0 +1,82 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 1BF556DE091B + for ; Thu, 11 Aug 2016 22:51:32 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.008 +X-Spam-Level: +X-Spam-Status: No, score=-0.008 tagged_above=-999 required=5 tests=[AWL=0.003, + SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id GY07eHWYz2ge for ; + Thu, 11 Aug 2016 22:51:24 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id 1BE346DE0362 + for ; Thu, 11 Aug 2016 22:51:23 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) + (envelope-from ) + id 1bY5NV-0006ad-NV; Fri, 12 Aug 2016 01:51:33 -0400 +Received: (nullmailer pid 18608 invoked by uid 1000); + Fri, 12 Aug 2016 05:51:16 -0000 +From: David Bremner +To: Daniel Kahn Gillmor , + Notmuch Mail +Subject: Re: [PATCH v4 01/16] add util/search-path.{c, + h} to test for executables in $PATH +In-Reply-To: <1467970047-8013-2-git-send-email-dkg@fifthhorseman.net> +References: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net> + <1467970047-8013-2-git-send-email-dkg@fifthhorseman.net> +User-Agent: Notmuch/0.22.1+61~g2ce0f13 (https://notmuchmail.org) Emacs/24.5.1 + (x86_64-pc-linux-gnu) +Date: Fri, 12 Aug 2016 14:51:16 +0900 +Message-ID: <878tw2r0vf.fsf@maritornes.cs.unb.ca> +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 12 Aug 2016 05:51:32 -0000 + +Daniel Kahn Gillmor writes: + +> This is a utility function we can use to see whether an executa> +> + if (strchr (exename, '/')) { +> + if (0 == access (exename, X_OK)) +> + return TRUE; +> + else +> + return FALSE; +> + } + +Should we distinguish between relative and absolute paths here? I can't +think of any security implications, but I'm wondering if a relative path +is likely just a user error. + +> + path = (char *) malloc (n); +> + if (! path) +> + return FALSE; + +I kindof hate hiding the error here, although I agree it's +unlikely. What about the unixy return 0 ok, 1 not found -1 error? + +> + confstr (_CS_PATH, path, n); +> + } +> + +> + tok = strtok_r (path, ":", &save); +> + while (tok) { + +I guess it's fine to modify path here, but another option is +strtok_len (in string-util.h) +