From patchwork Thu Mar 11 11:40:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23a; helo=mail-lj1-x23a.google.com; envelope-from=swupdate+bncbcxploxj6ikrboedvcbamgqe2ftz3ay@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=n/Rh8r28; dkim-atps=neutral Received: from mail-lj1-x23a.google.com (mail-lj1-x23a.google.com [IPv6:2a00:1450:4864:20::23a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dx6TG08D5z9sVw for ; Thu, 11 Mar 2021 22:40:49 +1100 (AEDT) Received: by mail-lj1-x23a.google.com with SMTP id o8sf8395456ljp.15 for ; Thu, 11 Mar 2021 03:40:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462841; cv=pass; d=google.com; s=arc-20160816; b=OrshOLCG1SkYKVk4+xDGsejISTPAT/1KksoJTxJ2tUr3e1p3GrPSJWGQdhyhNcOkUf 1+9QRnBIB9Yi4PwTQihQ/cgM1+whHmzftDYT2EyGPzELrg56w8/tPft49HAHYDMDXohE BSz7Q4IpTFmcSBYfyaLh86ZbHYDEQr+DnGrCvh+Zib6DRuvyaC0wCmRyPWPvpwwfEk3q /obw1cYB8v8kGPzNlkYgnrJ3+AhriIdTtOxSqu5UE7tQbLQrYKQmqsJv3Yh0Zja1P0SX PfSY/g7y25cWLF2a/vllx+HfF2QSuK/4/k92khZZdiByM3hsQn8yIBWcjEtyyg9DkG3/ FtXQ== 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:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=LeCM3XeNS9ng3Bn5lMG1lHOtFsscdiqDaKaJjvFckRo=; b=lcUNQxmOCqPV1bcTLDQrFeTQK2SgQRsN+NfO4UZGZrAE963P+LTJaTlJ7UyTN9EQ5c jHZiGzW7sUrI4pib6r6OSDwGGQdaA82m1XwGnx3oo/9fgm0naPKTTAcY9TNUNfvTaXsT IGuxw3VMhgSY82oRO3tECKpp5wNxEyKtFYSNnpVdD6+XevELa8RFsRrNgQ9YV5HVABj5 +7KF6tF0fR/MmGGnZV5MsIGOblI25Sg3roA8ZidEaGOE0UF+4XE5ZRobuRlYVftxhOfh 4HpmHxkauL0yi86THNM/a08FkSCLp009fB+i/tQZbAKQT0cscumhnQzqLTceuc/eogFG PBtw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=LeCM3XeNS9ng3Bn5lMG1lHOtFsscdiqDaKaJjvFckRo=; b=n/Rh8r28tANEEz15fioTg46imQCjeu3M8ydSCS/B04CNMvIpFeoAk1R394/rMvU4By A9IHkUEMmAPsm4fsGIWMupgcviRugeg+fHguvZ6WYBmGSLDVkYV2hJ9719+X9GoVmBgt 0qRew/GXAhmRSxIsXlVuU128UVw8Uc14V1+1Fd0vsnNwqInqYx2kGc9f5YR+dfO3mfjG gnKrckJmJ8I5YmMrj63NRJGV4KmkZQ6tK3HU6Zn3RwZp5Ima3EA581gOxYrieCmc3Qvc /MNAAAwOxdnKq3d/jH20BgVPSbLmm7lkIxTag6WFAkTLByhaYRejNaXz8CqZamBVBBYK 9RJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version: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=LeCM3XeNS9ng3Bn5lMG1lHOtFsscdiqDaKaJjvFckRo=; b=SVnaBKJyJSeuDaLr0rXRtF844fkQyKluQu20kq5bQ+OSIfy0ZHzDou6g+Ne5BcPze8 JHfdtDho/z86OaylPBTZ50lP4zk8wN5yklI/WRpfoMsGYJLwOkOI/NESoA2Wc2UXLbdl 814BzIfdf3nTXLBJPtLjss4G1wsEi5yZPMT1DSmzmHg/Hi1gQYfJzedIxhKIvMpg1Emi T61xaieXgEQUCCy/ItxSZGbyJZSOZxQhF9jxiO60QN7nIVom+nScnidM4K5kKGM1QvQA dtLPMgM/2eM7CWGA/X1XNEU1Unn4EVf9u6/U1KtOgLTchPBN1/Jdm/ghxd9hz4RxqYw9 rRLg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM53342pbw4XowOVM07Uw5XFq9DX5rmMVgmc3951nNckKORpVr2cYk oGzR+ay+PoeHaEyjZBNaZ5E= X-Google-Smtp-Source: ABdhPJxJLV8HOCy9uVlvH+E09w2nq4X5N2eOqproxXaNuOc2ALbnVniY0yOrakSt1Boj7EKtBFXcpQ== X-Received: by 2002:a19:9109:: with SMTP id t9mr2144936lfd.49.1615462841222; Thu, 11 Mar 2021 03:40:41 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:9a48:: with SMTP id k8ls1202760ljj.10.gmail; Thu, 11 Mar 2021 03:40:40 -0800 (PST) X-Received: by 2002:a2e:3015:: with SMTP id w21mr4598841ljw.120.1615462839931; Thu, 11 Mar 2021 03:40:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462839; cv=none; d=google.com; s=arc-20160816; b=NSh9KKtQqV2Ux/SDFi1M6BdPhbi7WYcrtbm8tZYE1bXRJ6LwKUuVeMo7+bBcFsxkg9 iQxAs4V/GmOLueOQGX3xUYr5I4YHhjGVNwywMGBiyFotpSRyNNkvIAGKDT7rmi9ZNot3 g2h3BGMIFRyEP9+U8ZC4UHelpQps9GcGOkS7UaBjWvW3qClm0UELVl5xkIyw6TEpZNzz kEvVTbXPuVFH2iSDTRkD1ZBCc96zU3IVcVcD8rSyaPdLY7GdC7pNGrrTgW9lSXsjIR8c CaLtE+qZ+K662F/A1pzfC6Kyh9Lv5WOoWZbpImKKs2wvWx84obd3YyMT0Bg2U3KLQ108 ntFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=MBfupKiSDKIPfInO+MKGa5DmFFcY0nDEhhwq/0goSmA=; b=IgCiWYBL+zKqy92MN2XX2dmMjLqWqgdeWiTloLzUs7J1GmDVADYw6rTFL9XKn9KkOp +82FBjwW03iwG0yPwoO/mgHH5EPDu9LV3XYp3WUS26IL+m8l713+QChMRa8EVv7V5Qjg z1/2ubhIow4PBjCtRVR4gVBbTsEmQlDSjoEbpUJBySSYsjnIXf+xvV3knegEYDq01b71 mqNbPHnwRfpSWFzSBZmaaNLX2e6vpnyVtG8qOBKDQBD1jhzkW09/rK9szGWj8mQRaK+a kOwyJ3qL3+0w8Plk95oGxjntBYAv1XchYgkQfg01kwF9vdtQZFVfwcBmgAG5Gdtg8Ydc xTiA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id a66si81245lfd.7.2021.03.11.03.40.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:40:39 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dx6T31zF3z1rwvn; Thu, 11 Mar 2021 12:40:39 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6T31kW6z1qr4l; Thu, 11 Mar 2021 12:40:39 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id CgDt2O2EZ2zp; Thu, 11 Mar 2021 12:40:38 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 11 Mar 2021 12:40:38 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id C6565454016E; Thu, 11 Mar 2021 12:40:37 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id vh5HMHFn2slJ; Thu, 11 Mar 2021 12:40:34 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 2CC5E45407C8; Thu, 11 Mar 2021 12:40:34 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 1/6] Introduce an upper check for version to be installed Date: Thu, 11 Mar 2021 12:40:26 +0100 Message-Id: <20210311114031.71507-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , Even a maximum release number is requested in some projects, mainly if the update is then bound to a licensing policy. This introduce a check if the version to be installed is smaller as the one configured. Signed-off-by: Stefano Babic --- core/parser.c | 13 +++++++++++++ core/swupdate.c | 11 +++++++++++ doc/source/swupdate.rst | 8 ++++++++ include/swupdate.h | 2 ++ 4 files changed, 34 insertions(+) diff --git a/core/parser.c b/core/parser.c index 648d969..72bde66 100644 --- a/core/parser.c +++ b/core/parser.c @@ -219,6 +219,19 @@ int parse(struct swupdate_cfg *sw, const char *descfile) } } + /* + * Check if update is allowed until a chosen version, convert + * versions in numbers to be compared and check to get a + * newer version + */ + if (sw->globals.check_max_version) { + if (compare_versions(sw->version, sw->globals.maximum_version) > 0) { + ERROR("Max version set: new version %s >= max allowed %s", + sw->version, sw->globals.maximum_version); + return -EPERM; + } + } + /* * If reinstalling is not allowed, compare * version strings diff --git a/core/swupdate.c b/core/swupdate.c index e959568..2b7cdc2 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -82,6 +82,7 @@ static struct option long_options[] = { {"dry-run", no_argument, NULL, 'n'}, {"no-downgrading", required_argument, NULL, 'N'}, {"no-reinstalling", required_argument, NULL, 'R'}, + {"max-version", required_argument, NULL, '3'}, {"no-transaction-marker", no_argument, NULL, 'M'}, {"no-state-marker", no_argument, NULL, 'm'}, #ifdef CONFIG_SIGNED_IMAGES @@ -153,6 +154,7 @@ static void usage(char *programname) " -n, --dry-run : run SWUpdate without installing the software\n" " -N, --no-downgrading : not install a release older as \n" " -R, --no-reinstalling : not install a release same as \n" + " --max-version : not install a release bigger as \n" " -M, --no-transaction-marker : disable setting bootloader transaction marker\n" " -m, --no-state-marker : disable setting update state in bootloader\n" " -o, --output : saves the incoming stream\n" @@ -357,6 +359,10 @@ static int read_globals_settings(void *elem, void *data) "no-downgrading", sw->globals.minimum_version); if (strlen(sw->globals.minimum_version)) sw->globals.no_downgrading = 1; + GET_FIELD_STRING(LIBCFG_PARSER, elem, + "max-version", sw->globals.maximum_version); + if (strlen(sw->globals.maximum_version)) + sw->globals.check_max_version = 1; GET_FIELD_STRING(LIBCFG_PARSER, elem, "no-reinstalling", sw->globals.current_version); if (strlen(sw->globals.current_version)) @@ -640,6 +646,11 @@ int main(int argc, char **argv) strlcpy(swcfg.globals.forced_signer_name, optarg, sizeof(swcfg.globals.forced_signer_name)); break; + case '3': + swcfg.globals.check_max_version = 1; + strlcpy(swcfg.globals.maximum_version, optarg, + sizeof(swcfg.globals.maximum_version)); + break; #ifdef CONFIG_ENCRYPTED_IMAGES case 'K': strlcpy(swcfg.globals.aeskeyfname, diff --git a/doc/source/swupdate.rst b/doc/source/swupdate.rst index 22d135a..361f248 100644 --- a/doc/source/swupdate.rst +++ b/doc/source/swupdate.rst @@ -507,6 +507,14 @@ Command line parameters | | | the range 0..65535) or it is a semantic | | | | version. | +-------------+----------+--------------------------------------------+ +| -max-version| string | The maximum required version of software. | +| | | This will be checked with the version of | +| | | new software. | +| | | Version consists of either 4 numbers | +| | | (major.minor.rev.build with each field in | +| | | the range 0..65535) or it is a semantic | +| | | version. | ++-------------+----------+--------------------------------------------+ | -R | string | The current installed version of software. | | | | This will be checked with the version of | | | | new software and forbids reinstalling. | diff --git a/include/swupdate.h b/include/swupdate.h index e607ed6..f9b6093 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -132,6 +132,7 @@ struct swupdate_global_cfg { int no_reinstalling; int no_transaction_marker; int no_state_marker; + int check_max_version; char publickeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char aeskeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char postupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; @@ -140,6 +141,7 @@ struct swupdate_global_cfg { char default_running_mode[SWUPDATE_GENERAL_STRING_SIZE]; int default_dry_run; char minimum_version[SWUPDATE_GENERAL_STRING_SIZE]; + char maximum_version[SWUPDATE_GENERAL_STRING_SIZE]; char current_version[SWUPDATE_GENERAL_STRING_SIZE]; int cert_purpose; char forced_signer_name[SWUPDATE_GENERAL_STRING_SIZE]; From patchwork Thu Mar 11 11:40:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43a; helo=mail-wr1-x43a.google.com; envelope-from=swupdate+bncbcxploxj6ikrbomdvcbamgqeu5sgd5i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=ee0faQtz; dkim-atps=neutral Received: from mail-wr1-x43a.google.com (mail-wr1-x43a.google.com [IPv6:2a00:1450:4864:20::43a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dx6TG1fh5z9sWv for ; Thu, 11 Mar 2021 22:40:48 +1100 (AEDT) Received: by mail-wr1-x43a.google.com with SMTP id h21sf9319509wrc.19 for ; Thu, 11 Mar 2021 03:40:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462841; cv=pass; d=google.com; s=arc-20160816; b=pVTbuQrLrMwEsMK6DpDmPub/YkCL37l/jKcyb192Wjba5AymjEEMBbWYNX2+dyJG9E R0txNvUdqFtUJ11gu2b563SP/kjIP+NeF4aVYXm5XOtg3qNLDrIFjI+D9uxZ6npaWY2B 5wY836qiFCMZS/Eg8UyYLfsXOmBWIfZbQSr77Rejz+hdIV+/yc50QjIJMenAL7wtuA8V jrxHvkz35wzB8Rsup4sJP1GT+SyBo9zu03dpQW+8mSqz3DcMJChq7pcn/iO2GjnjmiEf 4TEq+h31RKUmqgeMuMDSndv34Qcse76nmMJajOQBbfIWKqKWUBIlfUKLpb6qo5BMaR3t IFng== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=B1yUWt4nUaOMwir5xu7zFq5S5P2RINoyU2cp2NdxP2Q=; b=aIcqiHjen7Cg5Rvs3Y/BKBOCvb02PZC9LrY04P/b5x3NSOdtqjZZfwJzhzrzkahwsW nF436NhnJBJUWIrYNwveuDQWLRd9S8zHJVXNlr1rPqCCJeGkAxjZPgxTGuHQimzH6Ths rYsIJLAsAN5OFgKtjSN1ogW0iJLPzDk7EuS01773SvAIyUu5JIHXhol5kFiSRto0UdnG fev8DelQ0RSz9cxPOSz19cF1Yhm7pgxYXxkwu59jmSisNeS/GuEL6FsKHl1R5xwp6y0y qVghsJ4UnQMjSwQamK882fKKnka1pn3SW1rX9Otl6+IipdVMV6W9RhXRtFb/NYfYgV3f 6puw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=B1yUWt4nUaOMwir5xu7zFq5S5P2RINoyU2cp2NdxP2Q=; b=ee0faQtzj9G6E6scj41hSebfFsQwL+ijoHHIIrCG/gPwwnmlkxu4nloeu9KtLw8S4s v8+G1ljeVNwRBh2F6pVWeqGj1VIVH+Q2Lxp8I4XJDV8eih7B0aVXnR4a8XkB7OIzN+Pb mHKNWcbqAC3H4Omb4UQ/VCRXtSsvId2SIAw34JnEQDFz1UReZlcF0zIVxf1viEtUpCIY iSpaiVoxMPo0wyFnahx/RydJeNP3uv7M/Gk8s0/npc5kFUjRYDOiI68oc0ljoC7iFZ8V dUPG6yxk7kqabt7lqTAjf1lxI+ddcsR19Ni5c2AB8auNPfla6ak3P1qiKrD9zwQ/WIWK XOZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version: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=B1yUWt4nUaOMwir5xu7zFq5S5P2RINoyU2cp2NdxP2Q=; b=a+TE3J5NYNEH2w7DCImyx+0y4Db2O20jl29xl5/kZflU09asHp0a2CKkCbmM0LLgWI xVLvkrZTlg5emWD/3gIaU1GznjXJsIzqi6U5Sex7AzNAyNPWnEmWkAqHHPICTRhQNuDb PKgRASGq9b+LHgTFmZTUc83gEv003lcfj3HcawfqAI3XYvY/PTYgAn3MdLhpDAAs2cXY OtCnvEISywnooDmQCzIjAAuXqEYoG4oQ2KrnqkODTiGLFG/28uUqhQdkLG+qjZpc54zO Y/j5UyCWfmFKGEqUJpf4SxPDa/my1BmznmUIZODWLvlnUjKJ32zbxQDywpDQD4adNvt6 2X0Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532eHjlWTVyJMSp6CiRNIh5KJBN/UsiZsN6aRx8/bET5ceTyTbnP kL+BHEd0BYc430vzVMaQaBw= X-Google-Smtp-Source: ABdhPJyLbx7fXexQtPNWnj+WdgiDgQNoML1Cl2cZZ7tLoeuVHEN6lxvRhgpTBuripN0Rm7KKwx6Gxw== X-Received: by 2002:a5d:6d0c:: with SMTP id e12mr8049172wrq.136.1615462841540; Thu, 11 Mar 2021 03:40:41 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1c:bd84:: with SMTP id n126ls2707969wmf.2.canary-gmail; Thu, 11 Mar 2021 03:40:40 -0800 (PST) X-Received: by 2002:a05:600c:2cd8:: with SMTP id l24mr7764098wmc.88.1615462840730; Thu, 11 Mar 2021 03:40:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462840; cv=none; d=google.com; s=arc-20160816; b=h+h5p1ILAe01ptlgNqhfcKA0CnwQIHeYXc2h+1cnpw7LKdmxohJ81DMrxgJiQHU82L FvGHEimqwakdLAua1m5WiPs+2WK+iExD4BMhUyF5V+N7flPXeQP7tSVJ2oIo4GKaOexc P3c1+KwMiAk5xjsDIih3wk9cFRWh62tP0Ww+2wOXNrQZ7H70ETPjIiwGSg7m8d/Cr4qm UyUkMHRt3rd2+AiTMAENCixYO03XkEjNQEMtls9uA7/Jia//oPO7Io/l/XFWE/dehlGc 34VMYMyjgObVsY33rWMi1YI+JDVmDtrIt82tKmMhxaxEYmFYAmdlHZkBVGovl2+bZJZE Zi3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=zcas52sUgU4H5bGXZ0QqRLXYHldAgQ4Kjj4yIpesNBE=; b=r1+Uz+O4W0Wc0b4jXXbhx1X0jU+E0YGiopTVmWFgAGQsT02Nctfqk86OD0zVawW2Co MEeffapWzIWZBEd/O7/K4lQNJft0xNoaZc7dCp/nke8R6XAnbo8Oywg2HPnOBj+lFLPW 80zak5WlXncC9AKwNId6h1dHU1L8DHSJkwPpcCrhMgIx9DrB1uysSuRbRneJp+E68ExX nO31J5Zz+5liKtS81vVQpOb8ZHqP2cPwfn1hEUaxzjbm+eg68nni3M38aYppnGcc4HUe eKY4HyGhKqvbjDC68ykaJ3c7iqIcNFoEtRrU76R2XZJAC7oV22Ib4YyPjcFjQ/B4V0lw 5mYA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id p65si428624wmp.0.2021.03.11.03.40.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:40:40 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dx6T43lHKz1rwvn; Thu, 11 Mar 2021 12:40:40 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6T43STkz1qr4j; Thu, 11 Mar 2021 12:40:40 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 84vl_sAui0E6; Thu, 11 Mar 2021 12:40:39 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 11 Mar 2021 12:40:39 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id D601845407C8; Thu, 11 Mar 2021 12:40:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([IPv6:::1]) by localhost (mail.babic.homelinux.org [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id mOCc9oEldEeR; Thu, 11 Mar 2021 12:40:34 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 4B3A64542848; Thu, 11 Mar 2021 12:40:34 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 2/6] Type dry_run as bool Date: Thu, 11 Mar 2021 12:40:27 +0100 Message-Id: <20210311114031.71507-2-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311114031.71507-1-sbabic@denx.de> References: <20210311114031.71507-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , dry_run is used as boolean, switch from int type. Signed-off-by: Stefano Babic --- core/installer.c | 4 ++-- core/stream_interface.c | 4 ++-- core/swupdate.c | 2 +- include/installer.h | 2 +- include/swupdate.h | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/installer.c b/core/installer.c index a324f1b..fdce432 100644 --- a/core/installer.c +++ b/core/installer.c @@ -209,7 +209,7 @@ static int run_prepost_scripts(struct imglist *list, script_fn type) return 0; } -int install_single_image(struct img_type *img, int dry_run) +int install_single_image(struct img_type *img, bool dry_run) { struct installer_handler *hnd; int ret; @@ -255,7 +255,7 @@ int install_images(struct swupdate_cfg *sw) char *filename; struct stat buf; const char* TMPDIR = get_tmpdir(); - int dry_run = sw->globals.dry_run; + bool dry_run = sw->globals.dry_run; bool dropimg; /* Extract all scripts, preinstall scripts must be run now */ diff --git a/core/stream_interface.c b/core/stream_interface.c index d459010..6566bf9 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -525,10 +525,10 @@ void *network_initializer(void *data) */ switch (req->dry_run){ case RUN_DRYRUN: - software->globals.dry_run = 1; + software->globals.dry_run = true; break; case RUN_INSTALL: - software->globals.dry_run = 0; + software->globals.dry_run = false; break; case RUN_DEFAULT: default: diff --git a/core/swupdate.c b/core/swupdate.c index 2b7cdc2..617a19b 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -629,7 +629,7 @@ int main(int argc, char **argv) loglevel = strtoul(optarg, NULL, 10); break; case 'n': - swcfg.globals.default_dry_run = 1; + swcfg.globals.default_dry_run = true; break; case 'L': swcfg.globals.syslog_enabled = 1; diff --git a/include/installer.h b/include/installer.h index f69a94f..9e7fb16 100644 --- a/include/installer.h +++ b/include/installer.h @@ -18,7 +18,7 @@ swupdate_file_t check_if_required(struct imglist *list, struct filehdr *pfdh, const char *destdir, struct img_type **pimg); int install_images(struct swupdate_cfg *sw); -int install_single_image(struct img_type *img, int dry_run); +int install_single_image(struct img_type *img, bool dry_run); int install_from_file(const char *filename, bool check); int postupdate(struct swupdate_cfg *swcfg, const char *info); int preupdatecmd(struct swupdate_cfg *swcfg); diff --git a/include/swupdate.h b/include/swupdate.h index f9b6093..d2ff532 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -127,7 +127,7 @@ struct swupdate_global_cfg { char mtdblacklist[SWUPDATE_GENERAL_STRING_SIZE]; int loglevel; int syslog_enabled; - int dry_run; + bool dry_run; int no_downgrading; int no_reinstalling; int no_transaction_marker; @@ -139,7 +139,7 @@ struct swupdate_global_cfg { char preupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; char default_software_set[SWUPDATE_GENERAL_STRING_SIZE]; char default_running_mode[SWUPDATE_GENERAL_STRING_SIZE]; - int default_dry_run; + bool default_dry_run; char minimum_version[SWUPDATE_GENERAL_STRING_SIZE]; char maximum_version[SWUPDATE_GENERAL_STRING_SIZE]; char current_version[SWUPDATE_GENERAL_STRING_SIZE]; From patchwork Thu Mar 11 11:40:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53f; helo=mail-ed1-x53f.google.com; envelope-from=swupdate+bncbcxploxj6ikrboudvcbamgqekv7ba6i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=I0WTdo4I; dkim-atps=neutral Received: from mail-ed1-x53f.google.com (mail-ed1-x53f.google.com [IPv6:2a00:1450:4864:20::53f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dx6TG1ffbz9sWY for ; Thu, 11 Mar 2021 22:40:48 +1100 (AEDT) Received: by mail-ed1-x53f.google.com with SMTP id u2sf9729328edj.20 for ; Thu, 11 Mar 2021 03:40:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462842; cv=pass; d=google.com; s=arc-20160816; b=L38EGCyhshJTbf+VhAPK1i/YjrKkCgFRTVRowRT8amEV5KsBP7NHJIlQD+opGCsMuX qtnVVgZ9oeqKaibnRcdMRhs3+kRuv0Tzcg3W0Fz3OQwLWTFRHZ5jEcFdwqMXjqCbZ2rd 0QUzoyz5vUGMg/gT/3tFuHZWXt+2hzlSzSl8ZhlLgluJ4PWj5e/zpFTDG+oT65x009h5 QTUGO4jndL+x25bbmjFY4y9C3LlIeHzDSFVDXA1xzhota+7pKrz2+hCf8y9Z8GqOCoiW lXTi/CezOuMVh6vMSmXaqOG0XudqglGcIJwKfXeUfpxvbsJzMcfon55E5DBHMpqPxk2t CcJA== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=17TL5ahuIo2KYpqPkXFMjffF8/L5ph22m1f5OXaO5NM=; b=U+TL3NZmn1PKETmQRAHJrb8oRHypMuDUt/Mqi9/mn5ddKptLjTZK72K+0av0GMUsoU vJtlClj0noB5QpIkINPMdhyqW447t9Gaz2+ubSr2Khb5x7GjcJlRzqv/tMLqc+gelF7i V3SZjr3RDG8rD927+P4TWEQ9Qqip+loPzau4fbCAGWubf0IWtRsNp46nAimU475Wx5On U746IIshS949BW7D/ql75b5jbMK+tAVGpU5/2CureQWCtoZutIIvGdWeytksIdkqIn7q vkdk/phILUEeCzPdyJUW4OLjYaSX7Zsp0vIeNz6zfvzGKgoYLGGWc0ClgJFD/sdEFyT4 JxTg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=17TL5ahuIo2KYpqPkXFMjffF8/L5ph22m1f5OXaO5NM=; b=I0WTdo4ItKj54QcTpO9ZstmQtvMx15n1sIUyhSKsSWIDnkZ/3jqH/TkbNq884j31om 9Al4J+FP1wDaEuK2hXyN/wcL8mViU+8dZqlrUN+6Ibe55U7cYZx0VfQAV5cJwXUL1gcA Qq3ap1oulOaRABEq35p+iyEbt1oiEchC+d/PfNjge5MCBkcLTvzcyqgMRC77NTx3JEra MjTC+sbRTY5H+HOgwIwmNqnk5PMoGPwQp9AZYidiZnIK8rgmVezuvPhkwVP3jeADMagk +kGZvAVJbZUw4xzZbTSbUUcpOGins5DAMdR8GEsXyxTjCC6KUynsi62YSdG/cYj/uNxh E4Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version: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=17TL5ahuIo2KYpqPkXFMjffF8/L5ph22m1f5OXaO5NM=; b=aOs/JB7Twe831xdOB45Gg4LWrClA/ufEJTvUndJXk8dSFG0HomqFhKfCU24bbd960k kQbK1JWNn6apIWXQe6xIyeZEk5CqB5QvWZ+MmjGi/7E9KmvRIu5Sbo0ak/9HWwifDwkc +sfh0lmg89/GIIszDnjIW7NCvUhDI8trlKFVK5jOsf2Zh6OJ/ANcoCYBdhxv2V7OeTan ca5RYuqR6xQDd6IAo20TbaNRIMZCjPoxYE3YWUTBd3HUlrJ0zspW2s9QT9xlTCmsZbT/ 4iSiHPRNFqsLItncLFIrrnLdkqU4WoIrxLekw5qQJGczinhmSNeZhdSkIsJhMaCJR3aB ZHfw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5324uKpub5ZUi+xKHG4bx/7ENDtgpMO17isoaIsJZH64gimDZUfh u25ZCiO0exikC6y/OUVoiBA= X-Google-Smtp-Source: ABdhPJxsvw9/c+e7p5tBJVRD23Dz85bGdvMI2gLPdK2k0PcAezhO2+z/YaOTWadBtKBg5wo7v6omsA== X-Received: by 2002:a17:906:1d55:: with SMTP id o21mr2622460ejh.485.1615462842318; Thu, 11 Mar 2021 03:40:42 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:3592:: with SMTP id y18ls390703edc.0.gmail; Thu, 11 Mar 2021 03:40:41 -0800 (PST) X-Received: by 2002:a05:6402:c11:: with SMTP id co17mr8246221edb.246.1615462841523; Thu, 11 Mar 2021 03:40:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462841; cv=none; d=google.com; s=arc-20160816; b=RO3xGyLBjs3+6YQES+2A+Z6GD3H2cajOXc3JPa0ZUhGowKvKbICcUuVz/Vko8Zskr7 JdYka3WH/7ehPg9SlXzJ9YwdO6O6gXEPTv6xdb91orCqiV/TxWaYYo0Xt+fF8HwdZPmH UVWic/ysZZIzYPPZKiLfi9GnzZEgWkYfDnBlkMbbCZ5AJTKoJnHyxO1UjmCiV4fifk1t HKlW5G8EZW3RvR5mm4K5LaCGadSNLd54NKB8nVz7Vw4jR7DayOMnjmYULl6Iie9K7Fu+ WdEuxwmn3uajNIofDtqUj3vff0b1WhV5jN8fQkEh25+ukdJHWG0pukg5GFXpgik4RGkD EUXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=MmV5Lolvi9GMiW6/ehrBNy+XF7s0mz6PhH7XmVJ6w8g=; b=CAsQxu4igfNkzOSKE/ofhGegGvrTt5HsweTFaTSFTnPzovez3KHNj3IQehxDHXqTvl O7mErNyzCEDMzP6oDbeWZZQWr59+mB+N2vu62vBgeCZd8IaH3WdDPvzJQN+W4XM+kZvR JCFGD1LQvjpkaEaLVy4R340pXJFq06rQFAU4HkOufVWfLWUHw+Q4sUL0qrJ9CST3JUAY Kk86LrxpbKieZb1IhVVICr1LyGIs7/j7Jo0dX7AS2qOow5lF1Upspd9WryKBeLlz2h0E UzyJ9OYUn1459BE6CAtpFOfd0ZQs9dK0E2ksNwtOP04WIyjYhs102hNwRusIOUgUFQGA +hKg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id t7si76794edr.0.2021.03.11.03.40.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:40:41 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dx6T51ynNz1qsjl; Thu, 11 Mar 2021 12:40:41 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6T51pLGz1qr4j; Thu, 11 Mar 2021 12:40:41 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id asW_UZucSMCT; Thu, 11 Mar 2021 12:40:40 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 11 Mar 2021 12:40:40 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 2DB76454016E; Thu, 11 Mar 2021 12:40:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ny9QHVk_rKec; Thu, 11 Mar 2021 12:40:38 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 6E54E454285F; Thu, 11 Mar 2021 12:40:34 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/6] Cleanup: type boolean in general structure Date: Thu, 11 Mar 2021 12:40:28 +0100 Message-Id: <20210311114031.71507-3-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311114031.71507-1-sbabic@denx.de> References: <20210311114031.71507-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , Some configuration values are used as boolean, but implemented as int. Signed-off-by: Stefano Babic --- core/swupdate.c | 18 +++++++++--------- include/swupdate.h | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/swupdate.c b/core/swupdate.c index 617a19b..34d7ef2 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -358,15 +358,15 @@ static int read_globals_settings(void *elem, void *data) GET_FIELD_STRING(LIBCFG_PARSER, elem, "no-downgrading", sw->globals.minimum_version); if (strlen(sw->globals.minimum_version)) - sw->globals.no_downgrading = 1; + sw->globals.no_downgrading = true; GET_FIELD_STRING(LIBCFG_PARSER, elem, "max-version", sw->globals.maximum_version); if (strlen(sw->globals.maximum_version)) - sw->globals.check_max_version = 1; + sw->globals.check_max_version = true; GET_FIELD_STRING(LIBCFG_PARSER, elem, "no-reinstalling", sw->globals.current_version); if (strlen(sw->globals.current_version)) - sw->globals.no_reinstalling = 1; + sw->globals.no_reinstalling = true; GET_FIELD_STRING(LIBCFG_PARSER, elem, "cert-purpose", tmp); if (tmp[0] != '\0') @@ -632,7 +632,7 @@ int main(int argc, char **argv) swcfg.globals.default_dry_run = true; break; case 'L': - swcfg.globals.syslog_enabled = 1; + swcfg.globals.syslog_enabled = true; break; case 'k': strlcpy(swcfg.globals.publickeyfname, @@ -647,7 +647,7 @@ int main(int argc, char **argv) sizeof(swcfg.globals.forced_signer_name)); break; case '3': - swcfg.globals.check_max_version = 1; + swcfg.globals.check_max_version = true; strlcpy(swcfg.globals.maximum_version, optarg, sizeof(swcfg.globals.maximum_version)); break; @@ -659,21 +659,21 @@ int main(int argc, char **argv) break; #endif case 'N': - swcfg.globals.no_downgrading = 1; + swcfg.globals.no_downgrading = true; strlcpy(swcfg.globals.minimum_version, optarg, sizeof(swcfg.globals.minimum_version)); break; case 'R': - swcfg.globals.no_reinstalling = 1; + swcfg.globals.no_reinstalling = true; strlcpy(swcfg.globals.current_version, optarg, sizeof(swcfg.globals.current_version)); break; case 'M': - swcfg.globals.no_transaction_marker = 1; + swcfg.globals.no_transaction_marker = true; TRACE("transaction_marker globally disabled"); break; case 'm': - swcfg.globals.no_state_marker = 1; + swcfg.globals.no_state_marker = true; TRACE("state_marker globally disabled"); break; case 'e': diff --git a/include/swupdate.h b/include/swupdate.h index d2ff532..0d8a317 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -126,13 +126,13 @@ struct swupdate_global_cfg { int verbose; char mtdblacklist[SWUPDATE_GENERAL_STRING_SIZE]; int loglevel; - int syslog_enabled; + bool syslog_enabled; bool dry_run; - int no_downgrading; - int no_reinstalling; - int no_transaction_marker; - int no_state_marker; - int check_max_version; + bool no_downgrading; + bool no_reinstalling; + bool no_transaction_marker; + bool no_state_marker; + bool check_max_version; char publickeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char aeskeyfname[SWUPDATE_GENERAL_STRING_SIZE]; char postupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; From patchwork Thu Mar 11 11:40:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::340; helo=mail-wm1-x340.google.com; envelope-from=swupdate+bncbcxploxj6ikrbpmdvcbamgqeuilln7y@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=JUMisKVP; dkim-atps=neutral Received: from mail-wm1-x340.google.com (mail-wm1-x340.google.com [IPv6:2a00:1450:4864:20::340]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dx6TG1fgTz9sWb for ; Thu, 11 Mar 2021 22:40:50 +1100 (AEDT) Received: by mail-wm1-x340.google.com with SMTP id r18sf3922099wmq.5 for ; Thu, 11 Mar 2021 03:40:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462845; cv=pass; d=google.com; s=arc-20160816; b=ovSNMQ/NLLfh2nbFpTWxkeZ4nelv961k6s2V1V1J3Kw//TSB83GdOA4foRkBNOruoc H5FdnteAVvyfHW9lhfEwY/sD0x7VlPo554cxw5GNxu3PIxicj3l3gUBsKJYOk+NefBsk gR7ACdT3FE3p5xKqnFfwGW2yTBeAnVB7SSSYegFkHYfdkthu0u9eBA/92Hr43l1u59gm I9+GUoh6wsv2V9L/kZ3lehUPGH6nE94ADCaVFYKQc7Vwiu20DuR4Bn9PbdlC6iDAdFOZ 5AHwmwyncNLVNiJzis3cheUaG/LI+3A76tCIlJm5xzCFIhEoCOVNdhslJLAN2kTu0aJC GasA== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=r/D64Yj9icZlbN4+AI9kZ+lnt206TzJv5zspE4LPyQA=; b=wAC3m1SxDAnQ2kvFf0muveu5nsizMFeeftbPpPTqGv2/zdINnAJGrIXl/Jdk0IECAx sPZgsweC3poLxZiwOjo07Fwp4r3D9eWaztr7LHcI/QElRcBotf6XAVcd1aFseDCiqvYy OL4T+vKxhGej59QNwT8ebAd0cPb8yYy0+x1eNLkiRn3eHxQv/EtkBL7QXJ8i7R0XeHWQ wtdBn7yT4+QXYEMI3wTEFwEhqnkuv9Pd5xI83bCO7Tt84R4yaRvDrAOrF5+y6MXiJ0p6 kOQcyfMa+BnK/I9VSEjF3PLdiuoAjSZzsUdoRRkZFeklDM33YteKuAMeJqgfIYc52tQh oDbQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=r/D64Yj9icZlbN4+AI9kZ+lnt206TzJv5zspE4LPyQA=; b=JUMisKVPr1tigo96H8nRlNb4vX/z103p63etPjtZ9W0FzLLdzs23NWHWJ/AKjXjPjt 4J1ZjXBQDIZ2QJu+CAoaakYgv4n+56CWqNYYpFVep5vLo6QncAf6vFKrQaZhcz/3TN3b yEtMA4A9lUG4kBOvW3qr0ZccgOCMe8GPAE9LZJqzQG9p1V/gB+KH2cTcRsKDz53xe9Gp c2cKFOGG5MwVV9Ak2ApP6fM9Il5NNlcLJTVihUfambIJh86Q0SwaB/RYBv5q4G56AX8g JkXB5bVkkVU1fFsDNbt71gci0OYUPk8lNA0LRr8Y4qChBiVw8HuXUIJPzdFPzPqSGnVr 7wBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version: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=r/D64Yj9icZlbN4+AI9kZ+lnt206TzJv5zspE4LPyQA=; b=hFOzodvNNMSOoBo0N9JeGIRyCc6AO9Zi2HOTGQs5zqb9TwqvXJ8YXlg935t9c+ZYmB B0cNgXwiuT/DiEzzvnyQzHMXO4N5AHBYoci/9iuqm4BMufbDFz3zFxjQV/G+D+rzsIG9 OWtT601URaipAmUUKtFlMSWjrUE/zkQCIKC06G4+uX3tAooflUmDIrw4asrMOhSr2a2x 5Lv2W6qnU603oiZ3YVx1mzYukJhEinXNkTzwABOZP4viFkxN0zSde5fV/gCAfAltS+Sw Xxcdr9C2DADTI9H3V5fImM3YPxZKkq6hY+UDl0lkyeJfvBFt2jv5jOV4JqPIo41WAATU FDYQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM5310hwDsa9IRM8aVdquQKxJpNsRydFM6lHVgfmMVsk1t0IpWJg/o dOrD7bxNAW7NwdYApXygfLk= X-Google-Smtp-Source: ABdhPJw6PkmiJ8Q1lnbuiI5wUC4T8i9Dzz6OS2ITOhMoHNXGHdLsuNDoQKIW/ztggF6iv02xs0ur/A== X-Received: by 2002:a05:600c:198f:: with SMTP id t15mr7888253wmq.8.1615462845466; Thu, 11 Mar 2021 03:40:45 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:1546:: with SMTP id f6ls2708975wmg.3.canary-gmail; Thu, 11 Mar 2021 03:40:44 -0800 (PST) X-Received: by 2002:a1c:bb0b:: with SMTP id l11mr8077288wmf.150.1615462844659; Thu, 11 Mar 2021 03:40:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462844; cv=none; d=google.com; s=arc-20160816; b=oBP/InW3NSLv1PehcWWj5G3RWTSCKfqaqnjQlQC5V5SR2xm4CHQQRFFdPhgJfQ3CDy pSwrpsT6L/zJS5o9wGZvzh4cDBFQlm1I/75FQ5oMAuegMz/pgCGBOdE2ItlTC99+HF9O IwtnHQqTtvdNunobMDRA0mjbirtcL+pHvlKpX3STMchnUbFnNKr6qVg/JHJE6ybmdPIk Kp77WVH899mwecg5FMIykBplkKe+GQbJRkbwpmmrisCJ6/aZqBKlZHkZ6nYejMJUYYzU Zy22T6KHoczCFdV4iXD61Z01wISLOSk6xeAC/3NtCzaehkbm0I2RgiINGkQP3zK3BmCq rzSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=6kBDd1ML8ytkX+H93ZhBeDOFMsKZ4HEaa/J3XkTwNkc=; b=Ytb7BAdfyOzE1ZXF6GUAK28vvOM+kU4lIGWQ0KRvLziaN4FG7sKzVT72o5QaTpN9I6 zyQ+Jkaq1SX9Aaiodz8sIaOZjiagRhyl7j+AaJo5OpiXd+OrveZiVYb3i1hc6jgUqiu3 RLJAcn9clLlpmmUO5yz8MaEjuZy/pJS0KnHRYKVJtKxAOvEAGWmaTKX0N3EJntQJ6H7K p0RCfG3MFAjS3/t7pJpscS/wMlfF8MHdg1iGFqP8optA22/e4HFFUf7v8/W0mrBCvwlK iLBBXBpPJQEjiPpgBytn7R0YjBtb85v2FRu1207gpKhLOWZE0BM4zaKbZyCUmPkTz7F5 TLhw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.10]) by gmr-mx.google.com with ESMTPS id r11si92112wrm.1.2021.03.11.03.40.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:40:44 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.10; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dx6T83SrVz1rwn0; Thu, 11 Mar 2021 12:40:44 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6T83DZ4z1qr4j; Thu, 11 Mar 2021 12:40:44 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id zM37bBwhfQWd; Thu, 11 Mar 2021 12:40:42 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 11 Mar 2021 12:40:42 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 04943454016E; Thu, 11 Mar 2021 12:40:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iLOR_jhRFHQE; Thu, 11 Mar 2021 12:40:38 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id 836794542872; Thu, 11 Mar 2021 12:40:34 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 4/6] Restructure swupdate data Date: Thu, 11 Mar 2021 12:40:29 +0100 Message-Id: <20210311114031.71507-4-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311114031.71507-1-sbabic@denx.de> References: <20210311114031.71507-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.10 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , The internal SWUpdate database was split to have a "globals" sub-structure with the original goal to have here the parameters read from the "globals" section in swupdate.cfg. However, entries were already mixed and there is no real use case for it. Move most parameters into the main structure, and create a structure for paramteres that can be changed on each instance of an update (mainly via IPC). This avoids to save somewhere the default parameters as it was done previously, and if additional parameters can be changed in future via IPC, it is enough to move them into this internal structure to let them automatically restored after each run. Signed-off-by: Stefano Babic --- core/installer.c | 4 +- core/parser.c | 20 +++--- core/stream_interface.c | 27 ++++---- core/swupdate.c | 122 ++++++++++++++++++------------------- corelib/verify_signature.c | 2 +- include/swupdate.h | 47 +++++++------- parser/parser.c | 16 ++--- 7 files changed, 119 insertions(+), 119 deletions(-) diff --git a/core/installer.c b/core/installer.c index fdce432..202c3eb 100644 --- a/core/installer.c +++ b/core/installer.c @@ -458,7 +458,7 @@ int preupdatecmd(struct swupdate_cfg *swcfg) DEBUG("Dry run, skipping Pre-update command"); } else { DEBUG("Running Pre-update command"); - return run_system_cmd(swcfg->globals.preupdatecmd); + return run_system_cmd(swcfg->preupdatecmd); } } @@ -474,7 +474,7 @@ int postupdate(struct swupdate_cfg *swcfg, const char *info) DEBUG("Dry run, skipping Post-update command"); } else { DEBUG("Running Post-update command"); - return run_system_cmd(swcfg->globals.postupdatecmd); + return run_system_cmd(swcfg->postupdatecmd); } } diff --git a/core/parser.c b/core/parser.c index 72bde66..1f83d44 100644 --- a/core/parser.c +++ b/core/parser.c @@ -144,7 +144,7 @@ int parse(struct swupdate_cfg *sw, const char *descfile) strcat(sigfile, ".sig"); ret = swupdate_verify_file(sw->dgst, sigfile, descfile, - sw->globals.forced_signer_name); + sw->forced_signer_name); free(sigfile); if (ret) @@ -211,10 +211,10 @@ int parse(struct swupdate_cfg *sw, const char *descfile) * versions in numbers to be compared and check to get a * newer version */ - if (sw->globals.no_downgrading) { - if (compare_versions(sw->version, sw->globals.minimum_version) < 0) { + if (sw->no_downgrading) { + if (compare_versions(sw->version, sw->minimum_version) < 0) { ERROR("No downgrading allowed: new version %s <= installed %s", - sw->version, sw->globals.minimum_version); + sw->version, sw->minimum_version); return -EPERM; } } @@ -224,10 +224,10 @@ int parse(struct swupdate_cfg *sw, const char *descfile) * versions in numbers to be compared and check to get a * newer version */ - if (sw->globals.check_max_version) { - if (compare_versions(sw->version, sw->globals.maximum_version) > 0) { + if (sw->check_max_version) { + if (compare_versions(sw->version, sw->maximum_version) > 0) { ERROR("Max version set: new version %s >= max allowed %s", - sw->version, sw->globals.maximum_version); + sw->version, sw->maximum_version); return -EPERM; } } @@ -236,11 +236,11 @@ int parse(struct swupdate_cfg *sw, const char *descfile) * If reinstalling is not allowed, compare * version strings */ - if (sw->globals.no_reinstalling) { + if (sw->no_reinstalling) { - if (strcmp(sw->version, sw->globals.current_version) == 0) { + if (strcmp(sw->version, sw->current_version) == 0) { ERROR("No reinstalling allowed: new version %s == installed %s", - sw->version, sw->globals.current_version); + sw->version, sw->current_version); return -EPERM; } } diff --git a/core/stream_interface.c b/core/stream_interface.c index 6566bf9..0e011ab 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -496,6 +496,7 @@ void *network_initializer(void *data) int ret; struct swupdate_cfg *software = data; struct swupdate_request *req; + struct swupdate_parms parms; /* No installation in progress */ memset(&inst, 0, sizeof(inst)); @@ -520,6 +521,11 @@ void *network_initializer(void *data) req = &inst.req; + /* + * Save default values, they can be changed by a + * install request + */ + parms = software->globals; /* * Check if the dry run flag is overwritten */ @@ -531,8 +537,7 @@ void *network_initializer(void *data) software->globals.dry_run = false; break; case RUN_DEFAULT: - default: - software->globals.dry_run = software->globals.default_dry_run; + break; } /* @@ -540,13 +545,8 @@ void *network_initializer(void *data) */ if ((strnlen(req->software_set, sizeof(req->software_set)) > 0) && (strnlen(req->running_mode, sizeof(req->running_mode)) > 0)) { - strlcpy(software->software_set, req->software_set, sizeof(software->software_set) - 1); - strlcpy(software->running_mode, req->running_mode, sizeof(software->running_mode) - 1); - } else { - strlcpy(software->software_set, software->globals.default_software_set, - sizeof(software->software_set) - 1); - strlcpy(software->running_mode, software->globals.default_running_mode, - sizeof(software->running_mode) - 1); + strlcpy(software->globals.software_set, req->software_set, sizeof(software->globals.software_set) - 1); + strlcpy(software->globals.running_mode, req->running_mode, sizeof(software->globals.running_mode) - 1); } /* @@ -634,6 +634,11 @@ void *network_initializer(void *data) swupdate_progress_end(inst.last_install); + /* + * Reload default values for update + */ + software->globals = parms; + pthread_mutex_lock(&stream_mutex); inst.status = IDLE; pthread_mutex_unlock(&stream_mutex); @@ -658,7 +663,7 @@ void get_install_swset(char *buf, size_t len) if (!buf) return; - strncpy(buf, inst.software->software_set, len - 1); + strncpy(buf, inst.software->globals.software_set, len - 1); } @@ -668,7 +673,7 @@ void get_install_running_mode(char *buf, size_t len) if (!buf) return; - strncpy(buf, inst.software->running_mode, len - 1); + strncpy(buf, inst.software->globals.running_mode, len - 1); } /* diff --git a/core/swupdate.c b/core/swupdate.c index 34d7ef2..16d6e12 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -234,13 +234,11 @@ static int parse_image_selector(const char *selector, struct swupdate_cfg *sw) * the runtime copy in swcfg can be overloaded by IPC, * so maintain a copy to restore it after an update */ - strlcpy(sw->globals.default_software_set, selector, sizeof(sw->globals.default_software_set)); - strlcpy(sw->software_set, selector, sizeof(sw->software_set)); + strlcpy(sw->globals.software_set, selector, sizeof(sw->globals.software_set)); /* pos + 1 will either be NULL or valid text */ - strlcpy(sw->globals.default_running_mode, pos + 1, sizeof(sw->globals.default_running_mode)); - strlcpy(sw->running_mode, pos + 1, sizeof(sw->running_mode)); + strlcpy(sw->globals.running_mode, pos + 1, sizeof(sw->globals.running_mode)); - if (strlen(sw->software_set) == 0 || strlen(sw->running_mode) == 0) + if (strlen(sw->globals.software_set) == 0 || strlen(sw->globals.running_mode) == 0) return -EINVAL; return 0; @@ -303,7 +301,7 @@ static void swupdate_init(struct swupdate_cfg *sw) LIST_INIT(&sw->bootscripts); LIST_INIT(&sw->bootloader); LIST_INIT(&sw->extprocs); - sw->globals.cert_purpose = SSL_PURPOSE_DEFAULT; + sw->cert_purpose = SSL_PURPOSE_DEFAULT; /* Create directories for scripts */ @@ -341,38 +339,38 @@ static int read_globals_settings(void *elem, void *data) struct swupdate_cfg *sw = (struct swupdate_cfg *)data; GET_FIELD_STRING(LIBCFG_PARSER, elem, - "public-key-file", sw->globals.publickeyfname); + "public-key-file", sw->publickeyfname); GET_FIELD_STRING(LIBCFG_PARSER, elem, - "ca-path", sw->globals.publickeyfname); + "ca-path", sw->publickeyfname); GET_FIELD_STRING(LIBCFG_PARSER, elem, - "aes-key-file", sw->globals.aeskeyfname); + "aes-key-file", sw->aeskeyfname); GET_FIELD_STRING(LIBCFG_PARSER, elem, - "mtd-blacklist", sw->globals.mtdblacklist); + "mtd-blacklist", sw->mtdblacklist); GET_FIELD_STRING(LIBCFG_PARSER, elem, - "postupdatecmd", sw->globals.postupdatecmd); + "postupdatecmd", sw->postupdatecmd); GET_FIELD_STRING(LIBCFG_PARSER, elem, - "preupdatecmd", sw->globals.preupdatecmd); - get_field(LIBCFG_PARSER, elem, "verbose", &sw->globals.verbose); - get_field(LIBCFG_PARSER, elem, "loglevel", &sw->globals.loglevel); - get_field(LIBCFG_PARSER, elem, "syslog", &sw->globals.syslog_enabled); + "preupdatecmd", sw->preupdatecmd); + get_field(LIBCFG_PARSER, elem, "verbose", &sw->verbose); + get_field(LIBCFG_PARSER, elem, "loglevel", &sw->loglevel); + get_field(LIBCFG_PARSER, elem, "syslog", &sw->syslog_enabled); GET_FIELD_STRING(LIBCFG_PARSER, elem, - "no-downgrading", sw->globals.minimum_version); - if (strlen(sw->globals.minimum_version)) - sw->globals.no_downgrading = true; + "no-downgrading", sw->minimum_version); + if (strlen(sw->minimum_version)) + sw->no_downgrading = true; GET_FIELD_STRING(LIBCFG_PARSER, elem, - "max-version", sw->globals.maximum_version); - if (strlen(sw->globals.maximum_version)) - sw->globals.check_max_version = true; + "max-version", sw->maximum_version); + if (strlen(sw->maximum_version)) + sw->check_max_version = true; GET_FIELD_STRING(LIBCFG_PARSER, elem, - "no-reinstalling", sw->globals.current_version); - if (strlen(sw->globals.current_version)) - sw->globals.no_reinstalling = true; + "no-reinstalling", sw->current_version); + if (strlen(sw->current_version)) + sw->no_reinstalling = true; GET_FIELD_STRING(LIBCFG_PARSER, elem, "cert-purpose", tmp); if (tmp[0] != '\0') - sw->globals.cert_purpose = parse_cert_purpose(tmp); + sw->cert_purpose = parse_cert_purpose(tmp); GET_FIELD_STRING(LIBCFG_PARSER, elem, "forced-signer-name", - sw->globals.forced_signer_name); + sw->forced_signer_name); char software_select[SWUPDATE_GENERAL_STRING_SIZE] = ""; GET_FIELD_STRING(LIBCFG_PARSER, elem, "select", software_select); @@ -580,7 +578,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } - loglevel = swcfg.globals.verbose ? TRACELEVEL : swcfg.globals.loglevel; + loglevel = swcfg.verbose ? TRACELEVEL : swcfg.loglevel; /* * The following sections are optional, hence -ENODATA error code is @@ -629,51 +627,51 @@ int main(int argc, char **argv) loglevel = strtoul(optarg, NULL, 10); break; case 'n': - swcfg.globals.default_dry_run = true; + swcfg.globals.dry_run = true; break; case 'L': - swcfg.globals.syslog_enabled = true; + swcfg.syslog_enabled = true; break; case 'k': - strlcpy(swcfg.globals.publickeyfname, + strlcpy(swcfg.publickeyfname, optarg, - sizeof(swcfg.globals.publickeyfname)); + sizeof(swcfg.publickeyfname)); break; case '1': - swcfg.globals.cert_purpose = parse_cert_purpose(optarg); + swcfg.cert_purpose = parse_cert_purpose(optarg); break; case '2': - strlcpy(swcfg.globals.forced_signer_name, optarg, - sizeof(swcfg.globals.forced_signer_name)); + strlcpy(swcfg.forced_signer_name, optarg, + sizeof(swcfg.forced_signer_name)); break; case '3': - swcfg.globals.check_max_version = true; - strlcpy(swcfg.globals.maximum_version, optarg, - sizeof(swcfg.globals.maximum_version)); + swcfg.check_max_version = true; + strlcpy(swcfg.maximum_version, optarg, + sizeof(swcfg.maximum_version)); break; #ifdef CONFIG_ENCRYPTED_IMAGES case 'K': - strlcpy(swcfg.globals.aeskeyfname, + strlcpy(swcfg.aeskeyfname, optarg, - sizeof(swcfg.globals.aeskeyfname)); + sizeof(swcfg.aeskeyfname)); break; #endif case 'N': - swcfg.globals.no_downgrading = true; - strlcpy(swcfg.globals.minimum_version, optarg, - sizeof(swcfg.globals.minimum_version)); + swcfg.no_downgrading = true; + strlcpy(swcfg.minimum_version, optarg, + sizeof(swcfg.minimum_version)); break; case 'R': - swcfg.globals.no_reinstalling = true; - strlcpy(swcfg.globals.current_version, optarg, - sizeof(swcfg.globals.current_version)); + swcfg.no_reinstalling = true; + strlcpy(swcfg.current_version, optarg, + sizeof(swcfg.current_version)); break; case 'M': - swcfg.globals.no_transaction_marker = true; + swcfg.no_transaction_marker = true; TRACE("transaction_marker globally disabled"); break; case 'm': - swcfg.globals.no_state_marker = true; + swcfg.no_state_marker = true; TRACE("state_marker globally disabled"); break; case 'e': @@ -734,12 +732,12 @@ int main(int argc, char **argv) opt_c = true; break; case 'p': - strlcpy(swcfg.globals.postupdatecmd, optarg, - sizeof(swcfg.globals.postupdatecmd)); + strlcpy(swcfg.postupdatecmd, optarg, + sizeof(swcfg.postupdatecmd)); break; case 'P': - strlcpy(swcfg.globals.preupdatecmd, optarg, - sizeof(swcfg.globals.preupdatecmd)); + strlcpy(swcfg.preupdatecmd, optarg, + sizeof(swcfg.preupdatecmd)); break; default: fprintf(stdout, "Try %s -h for usage\n", argv[0]); @@ -759,7 +757,7 @@ int main(int argc, char **argv) * Parameters are parsed: now performs plausibility * tests before starting processes and threads */ - if (public_key_mandatory && !strlen(swcfg.globals.publickeyfname)) { + if (public_key_mandatory && !strlen(swcfg.publickeyfname)) { fprintf(stderr, "Error: SWUpdate is built for signed images, provide a public key file.\n"); exit(EXIT_FAILURE); @@ -786,8 +784,8 @@ int main(int argc, char **argv) swupdate_crypto_init(); - if (strlen(swcfg.globals.publickeyfname)) { - if (swupdate_dgst_init(&swcfg, swcfg.globals.publickeyfname)) { + if (strlen(swcfg.publickeyfname)) { + if (swupdate_dgst_init(&swcfg, swcfg.publickeyfname)) { fprintf(stderr, "Error: Crypto cannot be initialized.\n"); exit(EXIT_FAILURE); @@ -806,16 +804,16 @@ int main(int argc, char **argv) sa.sa_handler = sigchld_handler; sigaction(SIGCHLD, &sa, NULL); #ifdef CONFIG_UBIATTACH - if (strlen(swcfg.globals.mtdblacklist)) - mtd_set_ubiblacklist(swcfg.globals.mtdblacklist); + if (strlen(swcfg.mtdblacklist)) + mtd_set_ubiblacklist(swcfg.mtdblacklist); #endif /* * If an AES key is passed, load it to allow * to decrypt images */ - if (strlen(swcfg.globals.aeskeyfname)) { - if (load_decryption_key(swcfg.globals.aeskeyfname)) { + if (strlen(swcfg.aeskeyfname)) { + if (load_decryption_key(swcfg.aeskeyfname)) { fprintf(stderr, "Error: Key file does not contain a valid AES key.\n"); exit(EXIT_FAILURE); @@ -828,7 +826,7 @@ int main(int argc, char **argv) INFO("Running on %s Revision %s", swcfg.hw.boardname, swcfg.hw.revision); print_registered_handlers(); - if (swcfg.globals.syslog_enabled) { + if (swcfg.syslog_enabled) { if (syslog_init()) { ERROR("failed to initialize syslog notifier"); } @@ -842,9 +840,9 @@ int main(int argc, char **argv) } /* check if software_set or running_mode was parsed and log both values */ - if (swcfg.globals.default_software_set[0] != '\0' || swcfg.globals.default_running_mode[0] != '\0') { - INFO("software set: %s mode: %s", swcfg.globals.default_software_set, - swcfg.globals.default_running_mode); + if (swcfg.globals.software_set[0] != '\0' || swcfg.globals.running_mode[0] != '\0') { + INFO("software set: %s mode: %s", swcfg.globals.software_set, + swcfg.globals.running_mode); } /* Read sw-versions */ diff --git a/corelib/verify_signature.c b/corelib/verify_signature.c index c89e0b2..26ff502 100644 --- a/corelib/verify_signature.c +++ b/corelib/verify_signature.c @@ -166,7 +166,7 @@ int swupdate_dgst_init(struct swupdate_cfg *sw, const char *keyfile) } } - if (!X509_STORE_set_purpose(dgst->certs, sw->globals.cert_purpose)) { + if (!X509_STORE_set_purpose(dgst->certs, sw->cert_purpose)) { ERROR("failed to set purpose"); ret = -EINVAL; goto dgst_init_error; diff --git a/include/swupdate.h b/include/swupdate.h index 0d8a317..720e6a0 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -122,29 +122,10 @@ enum { SCRIPT_POSTINSTALL }; -struct swupdate_global_cfg { - int verbose; - char mtdblacklist[SWUPDATE_GENERAL_STRING_SIZE]; - int loglevel; - bool syslog_enabled; +struct swupdate_parms { bool dry_run; - bool no_downgrading; - bool no_reinstalling; - bool no_transaction_marker; - bool no_state_marker; - bool check_max_version; - char publickeyfname[SWUPDATE_GENERAL_STRING_SIZE]; - char aeskeyfname[SWUPDATE_GENERAL_STRING_SIZE]; - char postupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; - char preupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; - char default_software_set[SWUPDATE_GENERAL_STRING_SIZE]; - char default_running_mode[SWUPDATE_GENERAL_STRING_SIZE]; - bool default_dry_run; - char minimum_version[SWUPDATE_GENERAL_STRING_SIZE]; - char maximum_version[SWUPDATE_GENERAL_STRING_SIZE]; - char current_version[SWUPDATE_GENERAL_STRING_SIZE]; - int cert_purpose; - char forced_signer_name[SWUPDATE_GENERAL_STRING_SIZE]; + char software_set[SWUPDATE_GENERAL_STRING_SIZE]; + char running_mode[SWUPDATE_GENERAL_STRING_SIZE]; }; struct swupdate_cfg { @@ -153,9 +134,25 @@ struct swupdate_cfg { char version[SWUPDATE_GENERAL_STRING_SIZE]; bool bootloader_transaction_marker; bool bootloader_state_marker; - char software_set[SWUPDATE_GENERAL_STRING_SIZE]; - char running_mode[SWUPDATE_GENERAL_STRING_SIZE]; char output[SWUPDATE_GENERAL_STRING_SIZE]; + char publickeyfname[SWUPDATE_GENERAL_STRING_SIZE]; + char aeskeyfname[SWUPDATE_GENERAL_STRING_SIZE]; + char postupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; + char preupdatecmd[SWUPDATE_GENERAL_STRING_SIZE]; + char minimum_version[SWUPDATE_GENERAL_STRING_SIZE]; + char maximum_version[SWUPDATE_GENERAL_STRING_SIZE]; + char current_version[SWUPDATE_GENERAL_STRING_SIZE]; + char mtdblacklist[SWUPDATE_GENERAL_STRING_SIZE]; + char forced_signer_name[SWUPDATE_GENERAL_STRING_SIZE]; + bool syslog_enabled; + bool no_downgrading; + bool no_reinstalling; + bool no_transaction_marker; + bool no_state_marker; + bool check_max_version; + int verbose; + int loglevel; + int cert_purpose; struct hw_type hw; struct hwlist hardware; struct swver installed_sw_list; @@ -166,7 +163,7 @@ struct swupdate_cfg { struct dict accepted_set; struct proclist extprocs; void *dgst; /* Structure for signed images */ - struct swupdate_global_cfg globals; + struct swupdate_parms globals; const char *embscript; }; diff --git a/parser/parser.c b/parser/parser.c index ffbee2b..24abed2 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -67,21 +67,21 @@ static void *find_node_and_path(parsertype p, void *root, const char *field, nodes[0] = NULL; switch(i) { case 0: - if (strlen(swcfg->running_mode) && strlen(swcfg->software_set) && + if (strlen(swcfg->globals.running_mode) && strlen(swcfg->globals.software_set) && strlen(hardware->boardname)) { nodes[0] = NODEROOT; nodes[1] = hardware->boardname; - nodes[2] = swcfg->software_set; - nodes[3] = swcfg->running_mode; + nodes[2] = swcfg->globals.software_set; + nodes[3] = swcfg->globals.running_mode; nodes[4] = NULL; } break; case 1: /* try with software set and mode */ - if (strlen(swcfg->running_mode) && strlen(swcfg->software_set)) { + if (strlen(swcfg->globals.running_mode) && strlen(swcfg->globals.software_set)) { nodes[0] = NODEROOT; - nodes[1] = swcfg->software_set; - nodes[2] = swcfg->running_mode; + nodes[1] = swcfg->globals.software_set; + nodes[2] = swcfg->globals.running_mode; nodes[3] = NULL; } break; @@ -196,7 +196,7 @@ static bool get_common_fields(parsertype p, void *cfg, struct swupdate_cfg *swcf TRACE("Description %s", swcfg->description); } - if(swcfg->globals.no_state_marker) { + if(swcfg->no_state_marker) { swcfg->bootloader_state_marker = false; } else { swcfg->bootloader_state_marker = true; @@ -207,7 +207,7 @@ static bool get_common_fields(parsertype p, void *cfg, struct swupdate_cfg *swcf } } - if(swcfg->globals.no_transaction_marker) { + if(swcfg->no_transaction_marker) { swcfg->bootloader_transaction_marker = false; } else { swcfg->bootloader_transaction_marker = true; From patchwork Thu Mar 11 11:40:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23b; helo=mail-lj1-x23b.google.com; envelope-from=swupdate+bncbcxploxj6ikrbpudvcbamgqe6gps4oa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=JJAlfAQD; dkim-atps=neutral Received: from mail-lj1-x23b.google.com (mail-lj1-x23b.google.com [IPv6:2a00:1450:4864:20::23b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dx6TG39npz9sWw for ; Thu, 11 Mar 2021 22:40:50 +1100 (AEDT) Received: by mail-lj1-x23b.google.com with SMTP id b14sf8385144ljf.22 for ; Thu, 11 Mar 2021 03:40:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462846; cv=pass; d=google.com; s=arc-20160816; b=phodQLh94YhBkovYb0UawC8ubtZAQM5xON2EK2dcKgr0x9i0s5Jb+Ut+y3bWx6MhP8 FUgTl010DIUvH5d92zvMmdgPsTUI93p2mXryTwSbiDi3Oq4OU+NR+tOR833FtHcbDctA 3/7bHakVNfTLT1p8zf4vUc7cT7oI5t8lOv12+cU3vxEBn84aV4NPTEpBb4UR7QC3yvfw S6ZNZ8H32HKNIwoLpORY5+J7e8/mERtKqB8F70ekLzM+jtrEZMrowkEW8BdnM4HQB1mB 7EuzUwk4zseFql4llFMEabnZ4ANLKfOGCsC+/D/hZMvuAvkcjgg9vaesyGSeig4NtYFS ZF7Q== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=WS4VjViuu89V+O0/hXXEt04/HvsMlD7Gr/6qge+twb0=; b=AtmdcmI67pcjORWnFbEBjEM1umDh5G3BujZoXkkyhgEOUtHFlXq6lxRj2rla8cOU2A XBMV0BnYA0lw5/ns3nce7JHF1tbubEHoPAp8ydRW+IPksVwH5b4nPjVTUYYfPlJk3gOV gutViqJgD1Qg6asaEep5dwq2kLe7UiXxbGgD1j5B7K/DIStK6L6bqfWGGLzGTI5XIUou pQgwHrjwP0kuXHvyew4Gx63JLq0RVzGGSmtPXocMAfgbX59kDv7DzRnJyYDN3Gf//ADX kOPaKywjl2WKxvfiaaLjZ5e1z8e9H2oJWCc3a0rvC7NKyi76WdttzBsm+7Ebsvq1RYYb RUeg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=WS4VjViuu89V+O0/hXXEt04/HvsMlD7Gr/6qge+twb0=; b=JJAlfAQDfBOIChaX5AmSt/lH3nzucXGzXNi5DIKuNHUZzpjhMx7Bi7xvp2IxFpY1zI DXm3BjTQCsL3zVkrF+WYqEWNyVEo+LEcgEPQkQ0SV/mEG0COl4zkHMfAY60i5+8T1EM3 KhLx4zYDRy3e+ahytOu+ns6uNxSW7NYVgp+YpjGTgBTTyBT85TQD/dhjJIyM0lh4HygN hwgCKstYRSGiDS5aKBzAIvTVT86UVC9vOQ7s2F4B6L1VhREKzH2eietDTi3+vNLL7FZl MtdbCt0TZg7L97ROmIHUKFX17kRtfN9x6acDq+N6Ad+1sQ5AsL+ESsUoxgAOsp44eWwR P8wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version: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=WS4VjViuu89V+O0/hXXEt04/HvsMlD7Gr/6qge+twb0=; b=NX9GQxo9VLgTV5bwwm/+3oTB14gmj2Qs7y5C28RGatQ3MWtzNNrD/iTEiQHJJANhua Krq+uAC9/evfULH+BwtddnDemp/ZG7CZfKt2qMCe5dzRJArf1E8X4GKJBuaqWQHcg2E5 7bu4gumTsmPY7kxKcJLYovz365WpYHAf+Y0WtvtRHjv8wyQPRmEzxGE5crpiq+59241v VQjbqMHR6YEHfmN7Zizr5ihFMus5gmoYITmqDlYF3xaphH+qeyF/ZjGPcgllIprY1amn gI0lBwiJG7WrsCqCbdIyKUKuXnDnhOU62OY3Z47Mtm9GoFyHtVl5fPtPBi1O0d1dbSCD C5OA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530JGvAbWOjIZa3FbBMn90I6BVUFNqB9r9zG7KvR+9M1ewD5k2Yy xVrO+B1iVtL6W7LSyr6cmgk= X-Google-Smtp-Source: ABdhPJxL4iVQHPYrbvvL2prm8PSnDm7pnWVQba3HeI784dvjOxSnspy+lTu60s8SIGxXL78BLc6tWA== X-Received: by 2002:a19:4911:: with SMTP id w17mr1964688lfa.361.1615462846259; Thu, 11 Mar 2021 03:40:46 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:3c10:: with SMTP id j16ls1212690lja.2.gmail; Thu, 11 Mar 2021 03:40:45 -0800 (PST) X-Received: by 2002:a2e:8e70:: with SMTP id t16mr4680827ljk.489.1615462845362; Thu, 11 Mar 2021 03:40:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462845; cv=none; d=google.com; s=arc-20160816; b=ASwlmK1kA8AoOwJlX0pKkSfo1AiJxCz3nxvyz9RSe0HjrFKPYCe1Y5TFlC/SlTrqCK NwDrGDKwF+2thz/QzMnNpHWv+iwxO9/ohVkWxAKH7jQPJuqRShlr8GHLWLljVEXz3TRP Pk7WAyk32wG7Pm6LGer9up/6mfFiP7aVPfE4cr3QQzBp+udQ5xpAKqut9DPP8qVNb4ts lvDdvQJZ/gV45k3LfFf6Uk5zW6TGVmF43Sjs/xOYWRRNWYvAdLs9XSbVyjqKOQ0TYhh1 ty21O1rwvKYHt6LKyBVovQBEv5WbVgiBIztyYlA3EAiRb0QoXyyTKQ0K6fpX4k5N8C8L YiWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=yJGrZeYZYIdLwJU/L/8SRbofJ7SGG5i8Hcc8N8sjZHg=; b=pbf8PeeNCehvqiEalvAIVs8uwM7tYGRMF2yo9s36fHx7UuJcpB6a0U1vXv681UzXGE HlsByJqxntE2GfmM/aJmQV162zZcYDwn0mejOhegXFf5O9b/X0SGQl/uwg+kWhImfZHN GNvcK6U8we5qLxnuSj5Geqreqef5yWB5bTJ+QrilNMap6eCAwhRTqZhsGXwsEkC9Mg/U 5BmoqtK5t29qXzPhJAP2MdBXsFJj1BjDPsYhkAwYjPzUGxJgaTRiLW4yZ+TjRG6IU8fd 299xubs7h3cE6AeNzvertT8qfUsRqwt7HFmR2ZrSvKy+gQ7w2wF5fQdH/udi2+k5diFm dQLw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id j2si31363lfe.5.2021.03.11.03.40.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:40:45 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dx6T86llSz1rwn0; Thu, 11 Mar 2021 12:40:44 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6T86Tvgz1qr4j; Thu, 11 Mar 2021 12:40:44 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id WZbBE8GgejKd; Thu, 11 Mar 2021 12:40:43 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 11 Mar 2021 12:40:43 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id C47EC45407C8; Thu, 11 Mar 2021 12:40:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F-TmLXbIzKOH; Thu, 11 Mar 2021 12:40:40 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id A0B574542873; Thu, 11 Mar 2021 12:40:34 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 5/6] Rename structure globals to parms Date: Thu, 11 Mar 2021 12:40:30 +0100 Message-Id: <20210311114031.71507-5-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311114031.71507-1-sbabic@denx.de> References: <20210311114031.71507-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , Signed-off-by: Stefano Babic --- core/installer.c | 6 +++--- core/stream_interface.c | 32 ++++++++++++++++---------------- core/swupdate.c | 14 +++++++------- include/swupdate.h | 2 +- parser/parser.c | 12 ++++++------ 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/core/installer.c b/core/installer.c index 202c3eb..c3094df 100644 --- a/core/installer.c +++ b/core/installer.c @@ -255,7 +255,7 @@ int install_images(struct swupdate_cfg *sw) char *filename; struct stat buf; const char* TMPDIR = get_tmpdir(); - bool dry_run = sw->globals.dry_run; + bool dry_run = sw->parms.dry_run; bool dropimg; /* Extract all scripts, preinstall scripts must be run now */ @@ -454,7 +454,7 @@ void cleanup_files(struct swupdate_cfg *software) { int preupdatecmd(struct swupdate_cfg *swcfg) { if (swcfg) { - if (swcfg->globals.dry_run) { + if (swcfg->parms.dry_run) { DEBUG("Dry run, skipping Pre-update command"); } else { DEBUG("Running Pre-update command"); @@ -470,7 +470,7 @@ int postupdate(struct swupdate_cfg *swcfg, const char *info) swupdate_progress_done(info); if (swcfg) { - if (swcfg->globals.dry_run) { + if (swcfg->parms.dry_run) { DEBUG("Dry run, skipping Post-update command"); } else { DEBUG("Running Post-update command"); diff --git a/core/stream_interface.c b/core/stream_interface.c index 0e011ab..a68f557 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -250,7 +250,7 @@ static int extract_files(int fd, struct swupdate_cfg *software) * just once */ if (!installed_directly) { - if (!software->globals.dry_run && software->bootloader_transaction_marker) { + if (!software->parms.dry_run && software->bootloader_transaction_marker) { bootloader_env_set(BOOTVAR_TRANSACTION, get_state_string(STATE_IN_PROGRESS)); } installed_directly = true; @@ -264,7 +264,7 @@ static int extract_files(int fd, struct swupdate_cfg *software) if (!part->install_directly && part->is_partitioner) { TRACE("Need to adjust partition %s before streaming %s", part->volname, img->fname); - if (install_single_image(part, software->globals.dry_run)) { + if (install_single_image(part, software->parms.dry_run)) { ERROR("Error adjusting partition %s", part->volname); return -1; } @@ -273,7 +273,7 @@ static int extract_files(int fd, struct swupdate_cfg *software) } } img->fdin = fd; - if (install_single_image(img, software->globals.dry_run)) { + if (install_single_image(img, software->parms.dry_run)) { ERROR("Error streaming %s", img->fname); return -1; } @@ -525,16 +525,16 @@ void *network_initializer(void *data) * Save default values, they can be changed by a * install request */ - parms = software->globals; + parms = software->parms; /* * Check if the dry run flag is overwritten */ switch (req->dry_run){ case RUN_DRYRUN: - software->globals.dry_run = true; + software->parms.dry_run = true; break; case RUN_INSTALL: - software->globals.dry_run = false; + software->parms.dry_run = false; break; case RUN_DEFAULT: break; @@ -545,8 +545,8 @@ void *network_initializer(void *data) */ if ((strnlen(req->software_set, sizeof(req->software_set)) > 0) && (strnlen(req->running_mode, sizeof(req->running_mode)) > 0)) { - strlcpy(software->globals.software_set, req->software_set, sizeof(software->globals.software_set) - 1); - strlcpy(software->globals.running_mode, req->running_mode, sizeof(software->globals.running_mode) - 1); + strlcpy(software->parms.software_set, req->software_set, sizeof(software->parms.software_set) - 1); + strlcpy(software->parms.running_mode, req->running_mode, sizeof(software->parms.running_mode) - 1); } /* @@ -591,19 +591,19 @@ void *network_initializer(void *data) * must be successful. Set we have * initiated an update */ - if (!software->globals.dry_run && software->bootloader_transaction_marker) { + if (!software->parms.dry_run && software->bootloader_transaction_marker) { bootloader_env_set(BOOTVAR_TRANSACTION, get_state_string(STATE_IN_PROGRESS)); } notify(RUN, RECOVERY_NO_ERROR, INFOLEVEL, "Installation in progress"); ret = install_images(software); if (ret != 0) { - if (!software->globals.dry_run && software->bootloader_transaction_marker) { + if (!software->parms.dry_run && software->bootloader_transaction_marker) { bootloader_env_set(BOOTVAR_TRANSACTION, get_state_string(STATE_FAILED)); } notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Installation failed !"); inst.last_install = FAILURE; - if (!software->globals.dry_run + if (!software->parms.dry_run && software->bootloader_state_marker && save_state(STATE_FAILED) != SERVER_OK) { WARN("Cannot persistently store FAILED update state."); @@ -613,10 +613,10 @@ void *network_initializer(void *data) * Clear the recovery variable to indicate to bootloader * that it is not required to start recovery again */ - if (!software->globals.dry_run && software->bootloader_transaction_marker) { + if (!software->parms.dry_run && software->bootloader_transaction_marker) { bootloader_env_unset(BOOTVAR_TRANSACTION); } - if (!software->globals.dry_run + if (!software->parms.dry_run && software->bootloader_state_marker && save_state(STATE_INSTALLED) != SERVER_OK) { ERROR("Cannot persistently store INSTALLED update state."); @@ -637,7 +637,7 @@ void *network_initializer(void *data) /* * Reload default values for update */ - software->globals = parms; + software->parms = parms; pthread_mutex_lock(&stream_mutex); inst.status = IDLE; @@ -663,7 +663,7 @@ void get_install_swset(char *buf, size_t len) if (!buf) return; - strncpy(buf, inst.software->globals.software_set, len - 1); + strncpy(buf, inst.software->parms.software_set, len - 1); } @@ -673,7 +673,7 @@ void get_install_running_mode(char *buf, size_t len) if (!buf) return; - strncpy(buf, inst.software->globals.running_mode, len - 1); + strncpy(buf, inst.software->parms.running_mode, len - 1); } /* diff --git a/core/swupdate.c b/core/swupdate.c index 16d6e12..03a7e4b 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -234,11 +234,11 @@ static int parse_image_selector(const char *selector, struct swupdate_cfg *sw) * the runtime copy in swcfg can be overloaded by IPC, * so maintain a copy to restore it after an update */ - strlcpy(sw->globals.software_set, selector, sizeof(sw->globals.software_set)); + strlcpy(sw->parms.software_set, selector, sizeof(sw->parms.software_set)); /* pos + 1 will either be NULL or valid text */ - strlcpy(sw->globals.running_mode, pos + 1, sizeof(sw->globals.running_mode)); + strlcpy(sw->parms.running_mode, pos + 1, sizeof(sw->parms.running_mode)); - if (strlen(sw->globals.software_set) == 0 || strlen(sw->globals.running_mode) == 0) + if (strlen(sw->parms.software_set) == 0 || strlen(sw->parms.running_mode) == 0) return -EINVAL; return 0; @@ -627,7 +627,7 @@ int main(int argc, char **argv) loglevel = strtoul(optarg, NULL, 10); break; case 'n': - swcfg.globals.dry_run = true; + swcfg.parms.dry_run = true; break; case 'L': swcfg.syslog_enabled = true; @@ -840,9 +840,9 @@ int main(int argc, char **argv) } /* check if software_set or running_mode was parsed and log both values */ - if (swcfg.globals.software_set[0] != '\0' || swcfg.globals.running_mode[0] != '\0') { - INFO("software set: %s mode: %s", swcfg.globals.software_set, - swcfg.globals.running_mode); + if (swcfg.parms.software_set[0] != '\0' || swcfg.parms.running_mode[0] != '\0') { + INFO("software set: %s mode: %s", swcfg.parms.software_set, + swcfg.parms.running_mode); } /* Read sw-versions */ diff --git a/include/swupdate.h b/include/swupdate.h index 720e6a0..f2a2056 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -163,7 +163,7 @@ struct swupdate_cfg { struct dict accepted_set; struct proclist extprocs; void *dgst; /* Structure for signed images */ - struct swupdate_parms globals; + struct swupdate_parms parms; const char *embscript; }; diff --git a/parser/parser.c b/parser/parser.c index 24abed2..44b3926 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -67,21 +67,21 @@ static void *find_node_and_path(parsertype p, void *root, const char *field, nodes[0] = NULL; switch(i) { case 0: - if (strlen(swcfg->globals.running_mode) && strlen(swcfg->globals.software_set) && + if (strlen(swcfg->parms.running_mode) && strlen(swcfg->parms.software_set) && strlen(hardware->boardname)) { nodes[0] = NODEROOT; nodes[1] = hardware->boardname; - nodes[2] = swcfg->globals.software_set; - nodes[3] = swcfg->globals.running_mode; + nodes[2] = swcfg->parms.software_set; + nodes[3] = swcfg->parms.running_mode; nodes[4] = NULL; } break; case 1: /* try with software set and mode */ - if (strlen(swcfg->globals.running_mode) && strlen(swcfg->globals.software_set)) { + if (strlen(swcfg->parms.running_mode) && strlen(swcfg->parms.software_set)) { nodes[0] = NODEROOT; - nodes[1] = swcfg->globals.software_set; - nodes[2] = swcfg->globals.running_mode; + nodes[1] = swcfg->parms.software_set; + nodes[2] = swcfg->parms.running_mode; nodes[3] = NULL; } break; From patchwork Thu Mar 11 11:40:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1451089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53a; helo=mail-ed1-x53a.google.com; envelope-from=swupdate+bncbcxploxj6ikrbpudvcbamgqe6gps4oa@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=F2ds9dAb; dkim-atps=neutral Received: from mail-ed1-x53a.google.com (mail-ed1-x53a.google.com [IPv6:2a00:1450:4864:20::53a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dx6TH3bz4z9sXL for ; Thu, 11 Mar 2021 22:40:50 +1100 (AEDT) Received: by mail-ed1-x53a.google.com with SMTP id bi17sf9723592edb.6 for ; Thu, 11 Mar 2021 03:40:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1615462847; cv=pass; d=google.com; s=arc-20160816; b=MKlM886CZeaK83hpHTDp9X+ZuSf7rA+BHW1D9g5lZaq6CblS5I13Fzy7QbpOhRp+mA KkylhUzOrOMJH8adm+dQRUaOI+NBN0oqsVonZHPsUV+Ka84e+Ox9cHU2yyxOSLbrKV0N 10c4QYEILZtSOhFf/SK+sgyeIfoaVhMM0wg6YsN9l9HX6OCWjsYNiU9m7kXdrxPQ5Xee jlGro756HuoF2OI4hs0klnp0qRrqmCPhx/aoHsSATtJzv+K0GGakXyAWIZZfC6eXFpaL BOMcI4UJC7kfC0cnpm//2v617u5mPYQrrpUt25oEZ8w/ABZIO17Dc25ERsla3fIY3ZE2 /JDw== 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:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=4u5ujwpRmpVegAkhS6oN+wxbAnNgISsXKDIeueKd9lA=; b=d4oplrjnGsD2HUNTHGRT3S6qb6053RZ8/SgRJjQY6C1o1HoDuX9sgD3WWva9xG2k1j ST6/0i/wNjGtEDDInPRqhlbdlmsAM8lQkLwrRzhJq0xqdJvtX7LJLgns0yKKk5AYmTrX 3ctriflAF7lwamnH1/Tm0Mauety/CKMeC0CDZcDKi7bQWyc1xrMf/0idYkfkD8lDk2UZ quAJZDrcgJJqE4QycFGG0BQdo+Jdr5pJYBnsTceFOKB9ixRVq34WfsjfFH4hmpWtDuPm IJVBIObQHO+Lqpx7rtazfbxEYwcSVUOWLg8DraqUZlamYtdilCjlG41210+m0HPkD+CJ wB8g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=4u5ujwpRmpVegAkhS6oN+wxbAnNgISsXKDIeueKd9lA=; b=F2ds9dAbVm6uA5eIMYIyMGWepUxK4w2Ta1b0cHFLuejTPkKa7KT+oqrSErhf3bB2qR x+uUKl2XLmQ9rngnwQTDPBAIMJayfiFg3qPdAgotgn30kf6EBJIinqXycBgHpf4q+J7D 9OsHhR2hbkp5UsbyEcqlWA4Z9w0CzInSga40C4WCltsTPHq1DRfMkUAcwQl+U8BrR3+b pKTbqaQ4dvG/JzetsD1ydGuD8CiPgPMb/hSUlHQ9cTHQdHDzJQ7KMLlI8ptHpHBMBjfs wRgIVry6i/hd+vZTCMBtMsMqiOI+eXxx7tl8pRmr0p4Jns2YEHoriu/qGWMNlixQ/Lrk p57Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version: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=4u5ujwpRmpVegAkhS6oN+wxbAnNgISsXKDIeueKd9lA=; b=SFRnSZ/5Ph6SQz4tr79r9U5qSSxiCA6tsnd2tZhK1trMz4iCk33I0ZpS3J3l/sPvzp 6+el3v4u0Hlg4zJhSC1PvLNlY67uJ5grHhpLZ8KLw2kr8GLaGZI+Ojq+5YNYV8wXth73 Ycj1yYQdbdXSobFD7AcqH6g4bI2KlYvdcXAFmaESRkG/cOwbHeTRnDgE6au78wMY4rI2 apm6B03FaiS627c/NGA1mF0SN2OYEobTh6Tk0zGd1h+DQ2+0XrBUoTign5T4oThxMkn/ Y9Qh770rAsXkAAd6yGGuTalUbFH4IZOWZXqO3yHqE8d9VVEgqGaObhFCDyN5cmDBMn4C bcVQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM532BpDlYdYqUDwmy7tNgOuA82yUfGv41oV764y4IWuNLIp/1nF5v pHLaCAfd/RHR+0NYtEfqo04= X-Google-Smtp-Source: ABdhPJxGzc/W13al13MUGqiNnVfQD8dQ8ZOnc3hdYzaQNultjzC0f862XMDgJKwzIHxQQup3zW3SXQ== X-Received: by 2002:a17:906:4955:: with SMTP id f21mr2764264ejt.74.1615462846959; Thu, 11 Mar 2021 03:40:46 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a17:906:40d2:: with SMTP id a18ls179576ejk.8.gmail; Thu, 11 Mar 2021 03:40:46 -0800 (PST) X-Received: by 2002:a17:906:3899:: with SMTP id q25mr2633403ejd.157.1615462846190; Thu, 11 Mar 2021 03:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615462846; cv=none; d=google.com; s=arc-20160816; b=kFxD7cIP40Ei0cpu5ziXfg7tHxToJywpD6PDDDJOajOYYYVY9Xfm8o4IJFeh4KfNQm DMSIx3CeYyxCsc822l5+nrNFDzQCmBTHbnK/NO+zSnYAIObu5nVjLmptn2ubj7cTwwfP XJseFzp/ciTe+w7Zmf+wOppN6UqiPGx00fMG+N3gmBXFYb5PpGFd3FLTAGf884LBNwm9 sEKVrvb4/EGMDlxzRCPpi2lIKyaGpXKaJ4eHResAAaqt6SoQ+VrVYKviSzVSU+0UEbMh tLB+cPbSTUFiaR2usjWC4+LMQ8+JsqogAfH8LGovBsaaZcgX/lFzEO7sR7BQdrQcnl0H 5TDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=HfPTjjdotJB1rFLlP5sXdoMYb/48WrsdVlHPXryMqwk=; b=ae8wFxdklX8Oav+7TKx1J9pDsDRi5ElJT+S35LaZvcZcAXx0OeUDtdBO74JvCMLlsZ undfqO9cDqtJaCd9u48KZgegTdoPigDyjZkdFmBgL7N+2t1p2wr0zFBHwFGxWA+opEky bS5nIWP9Fg5K563ywKu/fOera2TPdHWQHKbOGaujLZK33ugFVqXve/Mj4jERZwxMVkF2 4OMUpQZ0WgmsV3CYsnFXZmYfLjtwzvvhjIv0fxUYwk/I34sdOv3m0p3XvpzD47tZA9YU UA6dBpp3uF9YFT1CDJr+XDngq4FiNPiLhZvtbwqt2+tXx6lSb2VXRAQ0uKk5pi996KtE poNg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id f25si90094edx.4.2021.03.11.03.40.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Mar 2021 03:40:46 -0800 (PST) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4Dx6T96rFJz1rwn0; Thu, 11 Mar 2021 12:40:45 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Dx6T96bwPz1qr4j; Thu, 11 Mar 2021 12:40:45 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Pnx1KwaVW6VD; Thu, 11 Mar 2021 12:40:45 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Thu, 11 Mar 2021 12:40:45 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id A8F32454016E; Thu, 11 Mar 2021 12:40:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X60GtVlFFQ38; Thu, 11 Mar 2021 12:40:42 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id AF3F84542874; Thu, 11 Mar 2021 12:40:34 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 6/6] IPC: extend to set accepted versions Date: Thu, 11 Mar 2021 12:40:31 +0100 Message-Id: <20210311114031.71507-6-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311114031.71507-1-sbabic@denx.de> References: <20210311114031.71507-1-sbabic@denx.de> MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de 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: , Add IPC to set minimum, maximum and if the current version should not be reinstalled. Signed-off-by: Stefano Babic --- core/network_thread.c | 6 ++++++ core/stream_interface.c | 20 ++++++++++++++++++++ include/installer_priv.h | 2 +- include/network_ipc.h | 12 ++++++++++-- include/util.h | 5 +++++ ipc/network_ipc-if.c | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 3 deletions(-) diff --git a/core/network_thread.c b/core/network_thread.c index c49dba5..168ae5d 100644 --- a/core/network_thread.c +++ b/core/network_thread.c @@ -513,6 +513,12 @@ void *network_thread (void *data) #endif msg.type = NACK; break; + case SET_VERSIONS_RANGE: + msg.type = ACK; + set_version_range(msg.data.versions.minimum_version, + msg.data.versions.maximum_version, + msg.data.versions.current_version); + break; case SET_UPDATE_STATE: value = *(update_state_t *)msg.data.msg; msg.type = (is_valid_state(value) && diff --git a/core/stream_interface.c b/core/stream_interface.c index a68f557..3b2c03b 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -689,3 +689,23 @@ int get_install_info(sourcetype *source, char *buf, size_t len) return len; } + +void set_version_range(const char *minversion, + const char *maxversion, const char *current) +{ + if (minversion && strnlen(minversion, SWUPDATE_GENERAL_STRING_SIZE)) { + strlcpy(inst.software->minimum_version, minversion, + sizeof(inst.software->minimum_version)); + inst.software->no_downgrading = true; + } + if (maxversion && strnlen(maxversion, SWUPDATE_GENERAL_STRING_SIZE)) { + strlcpy(inst.software->maximum_version, maxversion, + sizeof(inst.software->maximum_version)); + inst.software->check_max_version = true; + } + if (current && strnlen(current, SWUPDATE_GENERAL_STRING_SIZE)) { + strlcpy(inst.software->current_version, current, + sizeof(inst.software->current_version)); + inst.software->no_reinstalling = true; + } +} diff --git a/include/installer_priv.h b/include/installer_priv.h index d406f27..fc02255 100644 --- a/include/installer_priv.h +++ b/include/installer_priv.h @@ -18,7 +18,7 @@ struct installer { int last_error; /* error code if installation failed */ char errormsg[64]; /* error message if installation failed */ struct swupdate_request req; - struct swupdate_cfg const *software; + struct swupdate_cfg *software; }; #endif diff --git a/include/network_ipc.h b/include/network_ipc.h index 2939cdc..1a3d957 100644 --- a/include/network_ipc.h +++ b/include/network_ipc.h @@ -36,7 +36,8 @@ typedef enum { SET_AES_KEY, SET_UPDATE_STATE, /* set bootloader ustate */ GET_UPDATE_STATE, - REQ_INSTALL_EXT + REQ_INSTALL_EXT, + SET_VERSIONS_RANGE } msgtype; /* @@ -101,6 +102,11 @@ typedef union { char key_ascii[65]; /* Key size in ASCII (256 bit, 32 bytes bin) + termination */ char ivt_ascii[33]; /* Key size in ASCII (16 bytes bin) + termination */ } aeskeymsg; + struct { + char minimum_version[256]; + char maximum_version[256]; + char current_version[256]; + } versions; } msgdata; typedef struct { @@ -129,7 +135,9 @@ int swupdate_async_start(writedata wr_func, getstatus status_func, terminated end_func, void *priv, ssize_t size); int swupdate_set_aes(char *key, char *ivt); - +int swupdate_set_version_range(const char *minversion, + const char *maxversion, + const char *currentversion); #ifdef __cplusplus } // extern "C" #endif diff --git a/include/util.h b/include/util.h index ad2e90c..2987203 100644 --- a/include/util.h +++ b/include/util.h @@ -230,6 +230,11 @@ int get_install_info(sourcetype *source, char *buf, size_t len); void get_install_swset(char *buf, size_t len); void get_install_running_mode(char *buf, size_t len); +/* Setting global information */ +void set_version_range(const char *minversion, + const char *maxversion, + const char *current); + unsigned long long ustrtoull(const char *cp, unsigned int base); const char* get_tmpdir(void); diff --git a/ipc/network_ipc-if.c b/ipc/network_ipc-if.c index f09c417..20a442e 100644 --- a/ipc/network_ipc-if.c +++ b/ipc/network_ipc-if.c @@ -172,6 +172,41 @@ int swupdate_set_aes(char *key, char *ivt) return ipc_send_cmd(&msg); } +/* + * Set via IPC the range of accepted versions + * Versions are string and they can use semver + */ +int swupdate_set_version_range(const char *minversion, + const char *maxversion, + const char *currentversion) +{ + ipc_message msg; + + memset(&msg, 0, sizeof(msg)); + msg.magic = IPC_MAGIC; + msg.type = SET_VERSIONS_RANGE; + + if (minversion) { + strncpy(msg.data.versions.minimum_version, + minversion, + sizeof(msg.data.versions.minimum_version)); + } + + if (maxversion) { + strncpy(msg.data.versions.maximum_version, + maxversion, + sizeof(msg.data.versions.maximum_version)); + } + + if (currentversion) { + strncpy(msg.data.versions.current_version, + currentversion, + sizeof(msg.data.versions.maximum_version)); + } + + return ipc_send_cmd(&msg); +} + void swupdate_prepare_req(struct swupdate_request *req) { if (!req) return;