[{"id":1498,"web_url":"https://patchwork.libcamera.org/comment/1498/","msgid":"<622125f9-01e7-93ec-3c69-a27c81b508fe@ideasonboard.com>","date":"2019-04-26T07:02:55","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: utils: call\n\tsecure_getenv() if it exists or workaround with issetugid()","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Giulio\n\nOn 24/04/2019 13:00, Giulio Benetti wrote:\n> When secure_getenv() is not available, need to have a workaround.\n> \n> Check if secure_getenv() is present, otherwise call issetugid() on its\n> place.\n> \n> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>\n> ---\n>  src/libcamera/utils.cpp | 8 ++++++--\n>  1 file changed, 6 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 66123b1..529dd4a 100644\n> --- a/src/libcamera/utils.cpp\n> +++ b/src/libcamera/utils.cpp\n> @@ -8,7 +8,7 @@\n>  #include \"utils.h\"\n>  \n>  #include <string.h>\n> -#include <sys/auxv.h>\n> +#include <unistd.h>\n>  \n>  /**\n>   * \\file utils.h\n> @@ -57,10 +57,14 @@ const char *basename(const char *path)\n>   */\n>  char *secure_getenv(const char *name)\n>  {\n> -\tif (getauxval(AT_SECURE))\n> +#if HAVE_SECURE_GETENV\n> +\treturn secure_getenv(name);\n\nThis causes segfaults in the tests, which is odd as reading the code I\nexpected an infinite loop.\n\n(you can run the tests with ninja test)\n\nI believe the correct expression here is to add '::' to choose the top\nlevel name-space explicitly:\n\n+\treturn ::secure_getenv(name);\n\n\n> +#else\n> +\tif (issetugid())\n>  \t\treturn NULL;\n>  \n>  \treturn getenv(name);\n> +#endif\n>  }\n>  \n>  /**\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 53E4D60004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Apr 2019 09:02:58 +0200 (CEST)","from [192.168.1.6] (net-37-182-44-227.cust.vodafonedsl.it\n\t[37.182.44.227])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A78645F;\n\tFri, 26 Apr 2019 09:02:57 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556262177;\n\tbh=v02SgIU4kmaVB/jETlpSofcPJIhbZeX+0Ab94xZ14FE=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=NIeUiX6nS9+Nu9W777Rjnr/Rf7xxw3u/zl/B3idXE5jorNIw3/pZMcKP/f2fCDnIC\n\txVReITdBEVQLNr3uEWjvR07uFhqXT3vXVtpZTz/RFmMFEHJTRTFzDqBGbO8cr37Tcz\n\tcrQ9UEb40dDFrWN5n5gxoiw245LUI+kzF1y4pJ94=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Giulio Benetti <giulio.benetti@micronovasrl.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<364aa322-85ca-2c17-984e-1e807bd832ca@micronovasrl.com>\n\t<20190424110044.12608-1-giulio.benetti@micronovasrl.com>\n\t<20190424110044.12608-3-giulio.benetti@micronovasrl.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWk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FbxABEBAAGJAiUEGAEKAA8CGwwFAlnDlGsFCQeA/gIACgkQoR5GchCkYf1yYRAAq+Yo\n\tnbf9DGdK1kTAm2RTFg+w9oOp2Xjqfhds2PAhFFvrHQg1XfQR/UF/SjeUmaOmLSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<622125f9-01e7-93ec-3c69-a27c81b508fe@ideasonboard.com>","Date":"Fri, 26 Apr 2019 09:02:55 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.6.1","MIME-Version":"1.0","In-Reply-To":"<20190424110044.12608-3-giulio.benetti@micronovasrl.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: utils: call\n\tsecure_getenv() if it exists or workaround with issetugid()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 26 Apr 2019 07:02:58 -0000"}},{"id":1500,"web_url":"https://patchwork.libcamera.org/comment/1500/","msgid":"<9b6372a8-14be-b89e-525b-c9465e5e9c45@micronovasrl.com>","date":"2019-04-26T07:43:40","subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: utils: call\n\tsecure_getenv() if it exists or workaround with issetugid()","submitter":{"id":16,"url":"https://patchwork.libcamera.org/api/people/16/","name":"Giulio Benetti","email":"giulio.benetti@micronovasrl.com"},"content":"Hi Kieran, All,\n\nIl 26/04/2019 09:02, Kieran Bingham ha scritto:\n> Hi Giulio\n> \n> On 24/04/2019 13:00, Giulio Benetti wrote:\n>> When secure_getenv() is not available, need to have a workaround.\n>>\n>> Check if secure_getenv() is present, otherwise call issetugid() on its\n>> place.\n>>\n>> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>\n>> ---\n>>   src/libcamera/utils.cpp | 8 ++++++--\n>>   1 file changed, 6 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n>> index 66123b1..529dd4a 100644\n>> --- a/src/libcamera/utils.cpp\n>> +++ b/src/libcamera/utils.cpp\n>> @@ -8,7 +8,7 @@\n>>   #include \"utils.h\"\n>>   \n>>   #include <string.h>\n>> -#include <sys/auxv.h>\n>> +#include <unistd.h>\n>>   \n>>   /**\n>>    * \\file utils.h\n>> @@ -57,10 +57,14 @@ const char *basename(const char *path)\n>>    */\n>>   char *secure_getenv(const char *name)\n>>   {\n>> -\tif (getauxval(AT_SECURE))\n>> +#if HAVE_SECURE_GETENV\n>> +\treturn secure_getenv(name);\n> \n> This causes segfaults in the tests, which is odd as reading the code I\n> expected an infinite loop.\n> \n> (you can run the tests with ninja test)\n\nThis is good to know. Thanks.\n\n> I believe the correct expression here is to add '::' to choose the top\n> level name-space explicitly:\n> \n> +\treturn ::secure_getenv(name);\n\nGosh, I've done a c++ recursive call instead of calling a c function.\n\nI'm going to send v2 patchset modifying both patches.\nBoth reviews make a lot of sense!\n\nBest regards\nGiulio\n\n> \n>> +#else\n>> +\tif (issetugid())\n>>   \t\treturn NULL;\n>>   \n>>   \treturn getenv(name);\n>> +#endif\n>>   }\n>>   \n>>   /**\n>>\n>","headers":{"Return-Path":"<giulio.benetti@micronovasrl.com>","Received":["from mail.micronovasrl.com (mail.micronovasrl.com [212.103.203.10])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A250360004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Apr 2019 09:43:40 +0200 (CEST)","from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1])\n\tby mail.micronovasrl.com (Postfix) with ESMTP id 517ECB01544\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Apr 2019 09:43:40 +0200 (CEST)","from mail.micronovasrl.com ([127.0.0.1])\n\tby mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1])\n\t(amavisd-new, port 10026)\n\twith ESMTP id 89ul5CiUsS_y for <libcamera-devel@lists.libcamera.org>; \n\tFri, 26 Apr 2019 09:43:39 +0200 (CEST)","from [192.168.2.109] (88-149-228-83.v4.ngi.it [88.149.228.83])\n\tby mail.micronovasrl.com (Postfix) with ESMTPSA id 93656B00C10;\n\tFri, 26 Apr 2019 09:43:39 +0200 (CEST)"],"Authentication-Results":"mail.micronovasrl.com (amavisd-new); dkim=pass\n\treason=\"pass (just generated, assumed good)\" header.d=micronovasrl.com","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com;\n\th=content-transfer-encoding:content-language:content-type\n\t:content-type:in-reply-to:mime-version:user-agent:date:date\n\t:message-id:from:from:references:to:subject:subject; s=dkim; t=\n\t1556264619; x=1557128620; bh=/Qa8OHehatTjV++JXzJ8WZui7zW+TyRDh4H\n\tJckT5kVs=; b=BuXehyyIHUgdHXoWy+EgNCwksRdduUsWhkqlzluUHD6CwU5Xw9c\n\tgA+S1tnXedgkyGHVzfHHboFY7awxd8gG5V1Kp0OAU0bpcMsobHfAEVBt7hBSGaLp\n\tWUTjQiLJuq1K7G3w6azJBDd+RZLidPv9eB978VyGsgYRzxN+xo79V7BI=","X-Virus-Scanned":"Debian amavisd-new at mail.micronovasrl.com","X-Spam-Flag":"NO","X-Spam-Score":"-2.9","X-Spam-Level":"","X-Spam-Status":"No, score=-2.9 tagged_above=-10 required=4.5\n\ttests=[ALL_TRUSTED=-1, BAYES_00=-1.9]\n\tautolearn=unavailable autolearn_force=no","To":"kieran.bingham@ideasonboard.com, libcamera-devel@lists.libcamera.org","References":"<364aa322-85ca-2c17-984e-1e807bd832ca@micronovasrl.com>\n\t<20190424110044.12608-1-giulio.benetti@micronovasrl.com>\n\t<20190424110044.12608-3-giulio.benetti@micronovasrl.com>\n\t<622125f9-01e7-93ec-3c69-a27c81b508fe@ideasonboard.com>","From":"Giulio Benetti <giulio.benetti@micronovasrl.com>","Message-ID":"<9b6372a8-14be-b89e-525b-c9465e5e9c45@micronovasrl.com>","Date":"Fri, 26 Apr 2019 09:43:40 +0200","User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101\n\tThunderbird/60.6.1","MIME-Version":"1.0","In-Reply-To":"<622125f9-01e7-93ec-3c69-a27c81b508fe@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Language":"it","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 2/2] libcamera: utils: call\n\tsecure_getenv() if it exists or workaround with issetugid()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 26 Apr 2019 07:43:40 -0000"}}]