[{"id":1766815,"web_url":"http://patchwork.ozlabs.org/comment/1766815/","msgid":"<a0860d61-668b-48ed-e17f-abd2eebd77a2@denx.de>","list_archive_url":null,"date":"2017-09-12T09:29:32","subject":"Re: [swupdate] [PATCH 1/3] tmpdir: introduce get_tmpdir()\n\trespecting TMPDIR","submitter":{"id":5771,"url":"http://patchwork.ozlabs.org/api/people/5771/","name":"Stefano Babic","email":"sbabic@denx.de"},"content":"On 08/09/2017 15:45, Christian Storm wrote:\n> Introduce a get_tmpdir() method that is to be used instead\n> of the #define'd TMPDIR hard-coded to /tmp so that SWUpdate\n> respects the TMPDIR environment variable or, if it is unset,\n> falls back to /tmp as sane default and current behavior.\n> \n> Signed-off-by: Christian Storm <christian.storm@siemens.com>\n> ---\n>  core/util.c    | 23 +++++++++++++++++++++++\n>  include/util.h |  2 +-\n>  2 files changed, 24 insertions(+), 1 deletion(-)\n> \n> diff --git a/core/util.c b/core/util.c\n> index b714f29..fe2a657 100644\n> --- a/core/util.c\n> +++ b/core/util.c\n> @@ -52,6 +52,29 @@ char *sdup(const char *str) {\n>  \treturn p;\n>  }\n>  \n> +static char* TMPDIR = NULL;\n> +\n> +const char* get_tmpdir(void)\n> +{\n> +\tif (TMPDIR != NULL) {\n> +\t\treturn TMPDIR;\n> +\t}\n> +\n> +\tchar *env_tmpdir = getenv(\"TMPDIR\");\n> +\tif (env_tmpdir == NULL) {\n> +\t\tTMPDIR = (char*)\"/tmp/\";\n> +\t\treturn TMPDIR;\n> +\t}\n> +\n> +\tif (env_tmpdir[strlen(env_tmpdir)] == '/') {\n> +\t\tTMPDIR = env_tmpdir;\n> +\t\treturn TMPDIR;\n> +\t}\n> +\n> +\tasprintf(&TMPDIR, \"%s/\", env_tmpdir);\n> +\treturn TMPDIR;\n> +}\n> +\n>  static int countargc(char *args, char **argv)\n>  {\n>  \tint count = 0;\n> diff --git a/include/util.h b/include/util.h\n> index 70a0acc..9fb7860 100644\n> --- a/include/util.h\n> +++ b/include/util.h\n> @@ -112,7 +112,6 @@ typedef void (*notifier) (RECOVERY_STATUS status, int level, const char *msg);\n>  \n>  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))\n>  \n> -#define TMPDIR\t\t\"/tmp/\"\n>  \n>  #define LG_16 4\n>  #define FROM_HEX(f) from_ascii (f, sizeof f, LG_16)\n> @@ -196,5 +195,6 @@ static inline int decompress_image(int __attribute__ ((__unused__))infile,\n>  }\n>  #endif\n>  \n> +const char* get_tmpdir(void);\n>  \n>  #endif\n> \nApplied to -master, thanks !\n\nBest regards,\nStefano Babic","headers":{"Return-Path":"<swupdate+bncBAABBAGS33GQKGQEGWD644Q@googlegroups.com>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=googlegroups.com\n\t(client-ip=2a00:1450:4010:c07::23b;\n\thelo=mail-lf0-x23b.google.com;\n\tenvelope-from=swupdate+bncbaabbags33gqkgqegwd644q@googlegroups.com;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=googlegroups.com header.i=@googlegroups.com\n\theader.b=\"OKWHzdPU\"; dkim-atps=neutral"],"Received":["from mail-lf0-x23b.google.com (mail-lf0-x23b.google.com\n\t[IPv6:2a00:1450:4010:c07::23b])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrzyp6B0dz9s7f\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 19:29:38 +1000 (AEST)","by mail-lf0-x23b.google.com with SMTP id l196sf279269lfl.10\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 12 Sep 2017 02:29:38 -0700 (PDT)","by 10.46.2.203 with SMTP id y72ls68877lje.18.gmail;\n\tTue, 12 Sep 2017 02:29:35 -0700 (PDT)","from mail-out.m-online.net (mail-out.m-online.net.\n\t[2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id\n\tb130si613213wme.0.2017.09.12.02.29.35\n\tfor <swupdate@googlegroups.com>\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 12 Sep 2017 02:29:35 -0700 (PDT)","from frontend03.mail.m-online.net (unknown [192.168.6.182])\n\tby mail-out.m-online.net (Postfix) with ESMTP id 3xrzyl579Yz1qvnL;\n\tTue, 12 Sep 2017 11:29:35 +0200 (CEST)","from localhost (dynscan3.mnet-online.de [192.168.6.84])\n\tby mail.m-online.net (Postfix) with ESMTP id 3xrzyl4tLxz1qsQH;\n\tTue, 12 Sep 2017 11:29:35 +0200 (CEST)","from mail.mnet-online.de ([192.168.8.182])\n\tby localhost (dynscan3.mail.m-online.net [192.168.6.84]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id JR8ujHJmGtoi; Tue, 12 Sep 2017 11:29:35 +0200 (CEST)","from babic.homelinux.org\n\t(host-88-217-136-221.customer.m-online.net [88.217.136.221])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby mail.mnet-online.de (Postfix) with ESMTPS;\n\tTue, 12 Sep 2017 11:29:34 +0200 (CEST)","from localhost (mail.babic.homelinux.org [127.0.0.1])\n\tby babic.homelinux.org (Postfix) with ESMTP id 79DD445405CE;\n\tTue, 12 Sep 2017 11:29:34 +0200 (CEST)","from babic.homelinux.org ([127.0.0.1])\n\tby localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new,\n\tport 10024)\n\twith ESMTP id sBQ0RC4DJEf1; Tue, 12 Sep 2017 11:29:32 +0200 (CEST)","from [192.168.178.132] (papero.fritz.box [192.168.178.132])\n\tby babic.homelinux.org (Postfix) with ESMTP id 2A4C445405CD;\n\tTue, 12 Sep 2017 11:29:32 +0200 (CEST)"],"ARC-Seal":["i=2; a=rsa-sha256; t=1505208576; cv=pass;\n\td=google.com; s=arc-20160816;\n\tb=sRe3QeglYbz18xfXtai+B+rOno/VVBZ4VsZcP1Ii0tdDTmlYhfN73w8fzyu97yaU2x\n\ttOGsen5Dxd72dbN024NvZgzdanCtt2THzF/1IyDHRb+EgF2PoxOMj7ZcKcxW0RI7S7BI\n\t9XP7XkkixvJaN45ZZfi/Af7qCdo2lOSc6xp8MarQYedenvBHQMSgqDBwrQyJexYWl+I0\n\tOoaOSHhibVPQEEMlAd+obsHBh3/tgcUtPCHvzHkF9OvSfznt2OFbtsk4hTLnHJkONJDU\n\tlso6FGYYE+eWPGfdocdc775qwuwfjDeJzIa5T2h0vJv+Qb4l954jCQNr9O6ibMx7kPzi\n\tk2Uw==","i=1; a=rsa-sha256; t=1505208575; cv=none;\n\td=google.com; s=arc-20160816;\n\tb=TpMb21JAdspAlW6v3K/IcXDgaey/9aBXOaWt21/WurbUPxeW9bS8+kaEuLmt+zaGcH\n\teePfUSG9u35mLt0M11T15goqFYB9MtQkmKlxb/G39xG6h2/hPW5QyjKIiJpNCReAg9p5\n\tn+kiYhBK0Fj3jdbfR9j7dJzzxHc1RaobjD0XW1Ve2Iv+KL3Tf80rrHlQvDyA/pFjDnKX\n\tAyq+4J2TBJR4jm03y7CaeYHAZzsyPyo+lo+iuSY8HvFUMB1yUtlCHgiAqv6JBFGhb802\n\twU7C0c70ChzH/VYImEU985lRNfmKV3v7tzT89QTcy/K2BJnhwBUbRG8eOI9FwSPjdE3e\n\tPPIw=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=list-unsubscribe:list-subscribe:list-archive:list-help:list-post\n\t:list-id:mailing-list:precedence:content-language:in-reply-to\n\t:mime-version:user-agent:date:message-id:from:references:to:subject\n\t:arc-authentication-results:arc-message-signature:sender\n\t:dkim-signature:arc-authentication-results;\n\tbh=1PXD9v6DLM/aoGBR4bVBHgSsQ0uFfSMGnCPRm7Y/Cls=;\n\tb=jvRpHKNrNz8EJPQuPt7KYd8BWDRGmIeYnvtPw6edd2/6s2yf+zRwuCmDvcvdr8r0Pu\n\tizx+6hFVbmaJW956l8pAz83f9OgNWDLUMVqSKwUfyOmagjnqEXr1uVpsDu7rzcCswn6v\n\t2DHgZAJjI/wX9Zt/2MjqdDfVNrD2bEL5ENHu0FwjirWGTeu38krIjdNGUwjD0uR74hye\n\to37XD/YGEjCI6EPAuTWcRqpNXxvWMM2GZea8as/+4FLVYpakM+ePnCZgmcM+5HhiidjA\n\te/PEFG5G0Ch74SCoN53jPa5w2lf2LezUND9FpRxllSoSUCq3jpm+AxA3ODVokbHYPtCk\n\tV+iA==","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=arc-20160816; \n\th=content-transfer-encoding:content-language:in-reply-to:mime-version\n\t:user-agent:date:message-id:from:references:to:subject\n\t:arc-authentication-results;\n\tbh=VY1h7Rcz1ywqdwmK+iikkTnNLR0guT0uFEiiBJKBrjE=;\n\tb=jEhxzEAXP1H83Ul43JaLd/Ye+Hh3RFdQeD4/IlUp6fr/d0zZkt7Mg7aTn9wB0FU36W\n\tU6IXfGtp+fUFmxioL1nASTwEUYLn4lbBwYNiOmGzzf+0khhgD2j6O7SGMg4QwhK2VhMN\n\t80SJrjcJN7PljAsTA555ZkwbGiG/lyH88W0j1N5lON11aek5IUbhu3XuJApHdxNEkxXx\n\tvMd5mVB7XYS9o170d7ksuL0XB98kPsYtudXbCmfnyMkcdVt4EHE9jQzukSEQBYLNBJkH\n\t5sPZuf5i+tsG5dJ37wn5Q0OgAj6VzJbCCNOS5/SaZZxWTVzUydWS/d/p0gB51oCkRBtR\n\tQW+w=="],"ARC-Authentication-Results":["i=2; gmr-mx.google.com;\n\tspf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted\n\tnor denied by best guess record for domain of sbabic@denx.de)\n\tsmtp.mailfrom=sbabic@denx.de","i=1; gmr-mx.google.com;\n\tspf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted\n\tnor denied by best guess record for domain of sbabic@denx.de)\n\tsmtp.mailfrom=sbabic@denx.de"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=googlegroups.com; s=20161025;\n\th=sender:subject:to:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:x-original-sender\n\t:x-original-authentication-results:precedence:mailing-list:list-id\n\t:list-post:list-help:list-archive:list-subscribe:list-unsubscribe;\n\tbh=1PXD9v6DLM/aoGBR4bVBHgSsQ0uFfSMGnCPRm7Y/Cls=;\n\tb=OKWHzdPUDNJg2qcBGuJTD6i1yw9nGgzdSoO5NuDY+6we5+pQ2q0idlQbFcOcX12jv0\n\tBNNzpetsKkcfkl2kx2RtCnY2zieT1AvW/ls3nAl5ASqbTvGkeTiHbeBkNDQPXbe43r+H\n\toAgCirlNc0BvPGjQV0GLV8wTkanvvHnCzXxAVk3cXhw4V3oRt5JxjIGPEbYmjVhLGUah\n\tSbhHRm3g7RgbxqeKZPvG7dP4Gvl3wW3sBIPyVX4RfKBOY/oF/wWr1uD44YrVqS6P4OLU\n\tG0zFLC73owX3YVqNGeGE1ezBPfh3AD16kzWQg3+M5+hq/JxhkeuHCvdIExS8KNzI3gyq\n\t+Ktw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=sender:x-gm-message-state:subject:to:references:from:message-id\n\t:date:user-agent:mime-version:in-reply-to:content-language\n\t:x-original-sender:x-original-authentication-results:precedence\n\t:mailing-list:list-id:x-spam-checked-in-group:list-post:list-help\n\t:list-archive:list-subscribe:list-unsubscribe;\n\tbh=1PXD9v6DLM/aoGBR4bVBHgSsQ0uFfSMGnCPRm7Y/Cls=;\n\tb=XSQNnd669oxiwUnTIEqYWsMSaEzNTl7gz8bwND2fwe9uQEqYKA0Wd3fcAyKXDKABVJ\n\tNLTvCiG0aWM2lb11IjpBrCTRWbsMpKV7IEvX2Hkwo8qEvO+N1aAsQ45cQJCZ+R7qvCK8\n\tYUpVRhzMA941I/baPEUf62i5DicWawHZVzFXcr4LqMsyB53tViLJtqzE6gQKG8MbFjGs\n\tQiMaSb+J3JrPVTD8aCVWEQNmuY29fEP9fPcuuDnQ3G1tRB/rrQF45iltUqW8KbVK+/T0\n\tZKsaICMI6VGLa48xR5zcP6AC70gctrQG0/FqlYy3LdHKYgs9/ecFyc8vvsmyDcu4IjA1\n\tbGCg==","Sender":"swupdate@googlegroups.com","X-Gm-Message-State":"AHPjjUiQHLRyxIGrhw0maynhpbRb5GPQauplF2JXzK8DEh6G+BmBYr78\n\tXOiSWFYX8BJ89g==","X-Google-Smtp-Source":"AOwi7QDSpl9ldlLdHYcGml8FQQA0TEsYjiEnxBvyST9jMnTKuREonn9u11trSQeqs6h8tHADvxza4Q==","X-Received":["by 10.46.16.86 with SMTP id j83mr27246lje.25.1505208576242;\n\tTue, 12 Sep 2017 02:29:36 -0700 (PDT)","by 10.46.25.146 with SMTP id 18mr420812ljz.9.1505208575985;\n\tTue, 12 Sep 2017 02:29:35 -0700 (PDT)"],"X-BeenThere":"swupdate@googlegroups.com","Received-SPF":"neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither\n\tpermitted nor denied by best guess record for domain of\n\tsbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; ","X-Virus-Scanned":["amavisd-new at mnet-online.de","Debian amavisd-new at babic.homelinux.org"],"Subject":"Re: [swupdate] [PATCH 1/3] tmpdir: introduce get_tmpdir()\n\trespecting TMPDIR","To":"Christian Storm <christian.storm@siemens.com>, swupdate@googlegroups.com","References":"<20170908134547.9170-1-christian.storm@siemens.com>","From":"Stefano Babic <sbabic@denx.de>","Message-ID":"<a0860d61-668b-48ed-e17f-abd2eebd77a2@denx.de>","Date":"Tue, 12 Sep 2017 11:29:32 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170908134547.9170-1-christian.storm@siemens.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Language":"de-DE","X-Original-Sender":"sbabic@denx.de","X-Original-Authentication-Results":"gmr-mx.google.com;       spf=neutral\n\t(google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied\n\tby best\n\tguess record for domain of sbabic@denx.de)\n\tsmtp.mailfrom=sbabic@denx.de","Precedence":"list","Mailing-list":"list swupdate@googlegroups.com;\n\tcontact swupdate+owners@googlegroups.com","List-ID":"<swupdate.googlegroups.com>","X-Spam-Checked-In-Group":"swupdate@googlegroups.com","X-Google-Group-Id":"605343134186","List-Post":"<https://groups.google.com/group/swupdate/post>,\n\t<mailto:swupdate@googlegroups.com>","List-Help":"<https://groups.google.com/support/>,\n\t<mailto:swupdate+help@googlegroups.com>","List-Archive":"<https://groups.google.com/group/swupdate","List-Subscribe":"<https://groups.google.com/group/swupdate/subscribe>,\n\t<mailto:swupdate+subscribe@googlegroups.com>","List-Unsubscribe":"<mailto:googlegroups-manage+605343134186+unsubscribe@googlegroups.com>,\n\t<https://groups.google.com/group/swupdate/subscribe>"}}]