From patchwork Thu Sep 28 10:09:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 819522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::239; helo=mail-wr0-x239.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbduwwphakgqekgoouuy@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="hCoxC/7c"; dkim-atps=neutral Received: from mail-wr0-x239.google.com (mail-wr0-x239.google.com [IPv6:2a00:1450:400c:c0c::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y2r8x35MWz9t5w for ; Thu, 28 Sep 2017 20:12:33 +1000 (AEST) Received: by mail-wr0-x239.google.com with SMTP id r74sf407193wrb.7 for ; Thu, 28 Sep 2017 03:12:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1506593550; cv=pass; d=google.com; s=arc-20160816; b=0MDkHS9ZddmKKI9Tlmps6WhMqJGiDbrrrWnfPzsLfXi9SHkDKdNvFs/+UijRobbPVD 85PCCEJUKeMYutecixHsBPpZcvOKx3EFwe5cHJiOHJ5k6jGS4kQvRTo2CNN4lXdkyxBP jYSZocYyQ1W7kFSYAuM0pG9ncpeMO2OC4SuZjAeO5Wvf4Mq7RVzsszN4XBuNmqwhm1qL J46tlZI4T5eS3mDHRaqdVwnqKPbdBv8fSPXwPMg/zYovqWWm0lMbvNEMnrvLUJZugJBh R7nWCTgKWY8zzfyP+zIJ7O4P1KWSt21tg1gDgCCDKItbB7xDV6hcxa2hnuxzbPOI5AEt 2q6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=6Cz1nk36ffo+D1E32gZHfHdULxaZDhcLXz6vwCUcSwM=; b=BxSPKjHAhNbOlz56MkySzuKnEALbQa9pLaqryifGVzEFcHhHosV4SVo+OHb4UCLsnO 8L6HpvMEUnFDfa2q+lX0Ec6D4I5l4DZu6rf8tKc9oXFkr2uLvcEUxtLM95Y+lcGZJNAe 0Gic/NcBnDLvJCIhMRuYDp/GveOrQE+ANSeFzFbhRkFq2RTcMb1pt5vIhgdUuET6vWpg pnowY7EQwrkgelQ5Q4suNKGc3Hviw7HaAK1j65A6eOuQT3hfkbTKqVxk0Z0A3G4M2ZdR GkEVD/zrz7cLEMZZ9BOCvN+rAYb6PYtTyL3JvoCHnln30vdZ6FbRiMtSS+cq43ttXLpl xJHA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=6Cz1nk36ffo+D1E32gZHfHdULxaZDhcLXz6vwCUcSwM=; b=hCoxC/7csd/Z/N4PDg7q9/H3OjnSdT+Hfwa/y8rUL/uQl2HTRVAIkZGQO37+1zvHj6 m6T1N5mmqo3hRLTnESs5uPzGTkRVXRsgd/YLe/FTtVOoMpOyIRr0wuz8QX90Y8O0pehi W5NH5ANamvxsJurAEG0CaFW1SleNUzkdP9pzLttSbRgxxBFrsBEJsALcMLjFn2y8PdC9 4pSU5llq0YnDupndc+KjINOFICtyUjKL2juxRgAj6fN2IXYFgKf+3b0tcQF9UNBQ9EMx z3Hd5ZqlP1eOWkCTpEE7l6U0iDAe1fQMqg3kpM3Kp87VXsNQwYh8SOamxhsaaGho87Kr 42GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=6Cz1nk36ffo+D1E32gZHfHdULxaZDhcLXz6vwCUcSwM=; b=Olu0eMdQw73qngQMbvagnlYoD/5XYV6k9u8to84YC6M54PkzqaAZ89kbEkDzRlzS13 KCaUOQIvz9pdT+N6Y7pXbxn0I02UXiSR7iXQaCh+tVr7SoQFkb50OinFo2R/GCWG9mTn SAJdZ3Tw2t8TzvblUS+cnE2dpAY7dUvktXInaRvKoRp4WWQP18tnOwdUrQUGwwlzvpsQ BqVwL9dXqDAuOEZiwl5R3+CP2d2lWmT9oexAqxWV+4nP3YHK/9k8SyeV6v1jN+qMkNTS u34ErMwtfMwbqhXz8UQPLR8MuDYWVohkfWeR0R9/W4LTRpF+EYd+cktV6HSEDG66OtUB s0Sg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AMCzsaWGvfH1xvwTuekMR67WjRSsijr8P+VeudlMGT3Mrn+YY6sXO53D JJBQgfcuS6f5R3tr2u9bysc= X-Google-Smtp-Source: AOwi7QAwV3CBOLzFiL+7QUjkgtyWxmmUiTHWrjavrVNpsTQxUJA5HUoClFGFapWszdnk0M2WpfUMmw== X-Received: by 10.28.132.196 with SMTP id g187mr2192wmd.4.1506593550151; Thu, 28 Sep 2017 03:12:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.5.8 with SMTP id 8ls126771wmf.11.canary-gmail; Thu, 28 Sep 2017 03:12:29 -0700 (PDT) X-Received: by 10.28.15.72 with SMTP id 69mr82096wmp.3.1506593549883; Thu, 28 Sep 2017 03:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506593549; cv=none; d=google.com; s=arc-20160816; b=JB+UiUQAiLjo5l+1k6BoZk1p677nQJUNoYdvUQOiIERukMdMRR3BF5bzoOm4ZWV0sV jHAZmxbhDr64ZPRqxVwq+WBvdfA2fuyDBf59DcNGyisNxTlErBF13Pjo0kCznvTZGIq4 62VrENDUB8tnmg+okoXCAG88elcXTtPX1d1gH8JuGwNq28UznuRr2T4KbINe+rejvwSp mMJpwhrAxBMIqTkDoWV6ItxyH07phkNmeZLOtWD1v9MfMNtfNjqcIm1L5qWpIMW+Qca8 RkL4UGkL65/R0gMhsnn38KtKVfbnMjrZOF2XTnkYQ/ar+cmChzCRKB3nGq/fuA14aOpL 1htQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=S6ReCnw3FIBihChK8q2WKTgSLQvdpakqciLsBDvp0wk=; b=dmAFvTmerzchXqWHyx+q8fcSfPKRufaIMPe7jHQlZCqDFULjTDpDbaGT5trUehT6+M 5nbGse4i/rgq4F1fD5h1epLxKoxhuKPBkTfXg3PksfeGRonGD2jKiQyULQuDIAhA08o7 bCjCpn1wxglwdzFBWb2Qk0a1kVphZo1x48J/tgJHzP5b3x+rxY3FDIXNHgN3N3XOB2x3 FP+p/msgkTgVgdChGxHrwzzeZSXjMl1UsU6xDxVh9pNtfZtJXOGKpx8cMAUKej1QJhxM fFr5a2WxarNoBCnOMV1/7MdpID/y/1rqI4CFnUk8jrEtUx4Fc8rLypCJTzcmZTQyJDyF KO2w== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id d82si53120wmd.1.2017.09.28.03.12.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Sep 2017 03:12:29 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) client-ip=192.35.17.2; Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id v8SACTTW012898 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 28 Sep 2017 12:12:29 +0200 Received: from MD1KR9XC.ww002.siemens.net ([139.25.69.251]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id v8SACTIo008481; Thu, 28 Sep 2017 12:12:29 +0200 From: Christian Storm To: swupdate@googlegroups.com Cc: Christian Storm Subject: [swupdate] [PATCH] installer: extract/remove scripts respecting SCRIPTS_DIR_SUFFIX Date: Thu, 28 Sep 2017 12:09:32 +0200 Message-Id: <20170928100932.13342-1-christian.storm@siemens.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170928080418.wfhvejd5tpulydta@MD1KR9XC.ww002.siemens.net> References: <20170928080418.wfhvejd5tpulydta@MD1KR9XC.ww002.siemens.net> X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of christian.storm@siemens.com) smtp.mailfrom=christian.storm@siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Patch 97e3f8a "tmpdir: make use of get_tmpdir()" expects to find scripts in $TMPDIR/SCRIPTS_DIR_SUFFIX/ However, scripts are still extracted to $TMPDIR/ Fix extraction of scripts to $TMPDIR/SCRIPTS_DIR_SUFFIX/ Fix removal of scripts from $TMPDIR/SCRIPTS_DIR_SUFFIX/ Signed-off-by: Christian Storm Reported-by: Arun Sooraj PS --- corelib/installer.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/corelib/installer.c b/corelib/installer.c index 6c6271c..5bdf4f0 100644 --- a/corelib/installer.c +++ b/corelib/installer.c @@ -257,9 +257,14 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile) /* Extract all scripts, preinstall scripts must be run now */ if (fromfile) { - ret = extract_script(fdsw, &sw->scripts, TMPDIR); + char* TMPDIR_SCRIPTS = alloca(strlen(TMPDIR)+strlen(SCRIPTS_DIR_SUFFIX)+1); + if (sprintf(TMPDIR_SCRIPTS, "%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX) < 0) { + ERROR("preparing script extraction path failed!"); + return -1; + } + ret = extract_script(fdsw, &sw->scripts, TMPDIR_SCRIPTS); if (ret) { - ERROR("extracting script to TMPDIR failed"); + ERROR("extracting script to %s failed", TMPDIR_SCRIPTS); return ret; } } @@ -414,7 +419,7 @@ void cleanup_files(struct swupdate_cfg *software) { } LIST_FOREACH(img, &software->scripts, next) { if (img->fname[0]) { - if (snprintf(fn, sizeof(fn), "%s%s", TMPDIR, + if (snprintf(fn, sizeof(fn), "%s%s%s", TMPDIR, SCRIPTS_DIR_SUFFIX, img->fname) >= (int)sizeof(fn)) { ERROR("Path too long: %s%s", TMPDIR, img->fname); }