From patchwork Mon Oct 16 16:57:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1849477 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=sj3dtV1B; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33e; helo=mail-wm1-x33e.google.com; envelope-from=swupdate+bncbaabbcoxwwuqmgqeqsubk5q@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x33e.google.com (mail-wm1-x33e.google.com [IPv6:2a00:1450:4864:20::33e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S8Nb41BF4z23k1 for ; Tue, 17 Oct 2023 03:57:51 +1100 (AEDT) Received: by mail-wm1-x33e.google.com with SMTP id 5b1f17b1804b1-4077ee09a4esf12960895e9.1 for ; Mon, 16 Oct 2023 09:57:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697475466; cv=pass; d=google.com; s=arc-20160816; b=nz+dfyuL9Ch3iEwlz9BHcRy7+3oaPfMgXMtQankfu7fQyLIpFwxtNJxs8iSVlAhiL9 kowIEHgtgIP60YC2xic36qrw95M5Eb1hOAg2O7QxWJcuOhsbnRufTEmNnbF4ln24mUHe OofBm0yWwiuIKxd0rSORCVHf7JCWe3Hqs8gmI9mNWm2dR6P66eicserCjEHVkdxnAbV5 qA7pP/dIQDogMhULBGK1Wpu432fkqqRJ5VJJomGcyk11B014t+hxnK1b9hi2/bqukkwk g8Z5fQfn/zu3S5+lutrmk63cOi97heLVpraRpZJXK7JsMe0X4SsUKo22WC93smZudakb 2PdQ== 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:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=bAFbLs7mTPtsp+j9KeqP1zWCKfszDVeRL35mGAF2VWE=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=EaCYYvpDKFVvxweec8/e3QvCU+oFtVojIX4T7SH8T84TZLMMzFkrTRjBkLS1LLn8Qx 7xQKEU/K3DESrkyceZn5zwHu8j1Cn5QE0DIBB507PV8F+E/cc1VROvuNAflJc9a5kJF2 IH7fT052NhZFl8lVo1vXvSLF2q88XVTUc4HDhw3RFl7FLsKSjFc1Jsis1v1CxCrSFnNK HQoS+BUWo4t9c/7fK682Pcb71/HOrmRf7zYRhtQcGXHj1yZTOjADdN/AIwtzWY2zrBk8 48ULtjoC7wiR0vCPrYSuFKbYUH0+bGqM13DirqxAYKtb+FmEajzeg4DeQdaNYLBWqMcf Iq0g== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1697475466; x=1698080266; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=bAFbLs7mTPtsp+j9KeqP1zWCKfszDVeRL35mGAF2VWE=; b=sj3dtV1BO/moyEujQl6YFIPHNv+AGnFx0O5r7J6tgDXkcI4y3Zku1g0RZgx+kOOWFs 1oYLCaTNM9CmMYDQQdxicz2dEhuMqlz6e3b1V1DJnnUPFrR9SELXxxk6AYR1lDXn2WZh V6TqYb+DzbktWYJ1ST38JjRM92OEsTKz8nlASoIiFh/SpPoEGsYoM1dfBO1C2R/6tIbT h7xEEULHFjffZNa3ugn9N8DJRac7XcAN/cn2sr4V0Kl7gNSuWixlh96CXym0WdfdGfVX ppF/6G+EwpbpoXpDzezP8X1+3zuC3F3voAPae4IX0X6plpIZuV1LL+RGSgzSv5wEAl9n ckaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697475466; x=1698080266; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=bAFbLs7mTPtsp+j9KeqP1zWCKfszDVeRL35mGAF2VWE=; b=MkIwP8Vp2SOvUgQDR7nejx0ZFM5dEtxAmugCphNAZYOWx0za92ViOtmCjysBgylXMQ GlMeShPrcQnebHdpXBAM3ujF+YJzYmcW2JadzEPQT968IaaYz5sdePad+ezvOpPM7QCi PRSEE+0kt14voOHpQeceTZ3qHc/gTIXTFoN3scSlhspg+drswlGvFm6fzYFlc2BLsDjr /eG3YjwXiJteSBmrB7+vC3B6jJe1EpAZUqJyGof0oCZ2dFhCVzQ+MKlXRdrT1Had1ibs 6dDvimBCabGbPWPJZt4C2o+fAzM5smKpjBJlwOoaN3qHJ1AnpkdAxcuS2jm5oJ5K+72F dyug== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yy6mO397Rdua/Eem7/8b5aUNvJOiDwKYN0KbBTkGULiMycmnVHz 4zoznQfCF5sIRqpOqXy8n8w= X-Google-Smtp-Source: AGHT+IFpTSF1fKalo3x623Um6TMMjQZ3JwAgZ+imKBRvQrjhk6H+oA8BZ8eMvi7uCZfKfvkR6N2Mnw== X-Received: by 2002:adf:f551:0:b0:32d:9718:b32a with SMTP id j17-20020adff551000000b0032d9718b32amr34915wrp.0.1697475465891; Mon, 16 Oct 2023 09:57:45 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:d1e8:0:b0:329:22d9:9fe8 with SMTP id g8-20020adfd1e8000000b0032922d99fe8ls523566wrd.0.-pod-prod-08-eu; Mon, 16 Oct 2023 09:57:44 -0700 (PDT) X-Received: by 2002:adf:e50f:0:b0:32d:a435:3ec3 with SMTP id j15-20020adfe50f000000b0032da4353ec3mr16158wrm.4.1697475464378; Mon, 16 Oct 2023 09:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697475464; cv=none; d=google.com; s=arc-20160816; b=mTS/P0Kw0FI6+e9EGssZ2hYXOPHzSQ5V/HxvxD8YZAt8v+FCOVGPTTHgrKGUYi+1De RNfcDLjESxegxc4bB90EG8AUjcbI6XU3hEbLoH1JNOX/qEkLlDWA7QpT8OSb9absoGgW 5/ymcy6y5rHNE3o0ZtzMcRs5U6jiHoxlFHNP4QkHdV/1cbZVv7jTXYeibsU0kW/tt1mn 1+IlbaGWi62aciv4Uo6V20Eg3a5Nx0g0QJhaywxy1qqTnwr2Oq9luG70kpUP2LiZsuya 8O5iLJfoFB4RYyTrarZwtU8o1hQDBRPsgDt1/V0qtjSwNGWRwYM7QeTiXm67g0EEdN2t lI4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from; bh=FA2yo59mzoz76T7dhL5eTb4a0jvcwBo/SuTUve/g1yw=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=N9099L6GM1qDd7E3nhAS4CVqQRKPbbhPsaisICQFGKLiQuq5FUlLqfSpsaH1JM0Jsg MJ2fOqUh5xwxo2Kno0xAWX2uZ0Hi3RgYq92aQDQHunyf2JWUEJPMF/eh35YirsnRhMyH GMvzi0d5c4idgcD9Jz+rQ3CBz5KOp9dZrC/vip8731rKtV36bRt/5dF405QrdUSz6NPf P1bXhyCWruV0/lFUM7okRweQJnOlvyo9uf822WJsaUMW8lK7u0kvCZzAzJZyoy7pJ9eW NvYARC9b2mJyEkkcFjXk2iC61eiRyQX0xsCNV+6AL3KdPgruECVi7hez1QvuYaj8yVJV +ONQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.24]) by gmr-mx.google.com with ESMTPS id bx26-20020a5d5b1a000000b0031c3528356asi1282026wrb.2.2023.10.16.09.57.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:57:44 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) client-ip=212.227.17.24; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MOiLp-1rBLdw39cV-00QEDB; Mon, 16 Oct 2023 18:57:43 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 04/12] Store globally namespace for swupdate_vars Date: Mon, 16 Oct 2023 18:57:32 +0200 Message-Id: <20231016165740.1374614-4-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231016165740.1374614-1-stefano.babic@swupdate.org> References: <20231016165740.1374614-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:aKQQ9BfLHcKvYw2WHhD8xYPxbJRUWxPqO9I83jTzliOtQJfLeu0 xB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xPw/ICs29U2pW0qB7FP2AO13s+BspbuxqHCM/Yj/23N9T +8P+DdvzvU9Z/B9JbrG4epCBZJxpc9vxwyy0= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org 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: , Namespace (see also libubootenv) for SWUpdate's own variable is defined in configuration file. At the moment, SWUpdate will support to write just into a single namespace. Most processes do not need to know it, and it is ok to define a default mechanism to retrieve the namespace. This patch adds a singleton for namespace. AWupdate will store the selected namespace at the startup and will use it in calls where the namespace is not set. Signed-off-by: Stefano Babic --- core/swupdate.c | 6 ++++++ core/swupdate_vars.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/core/swupdate.c b/core/swupdate.c index 50a34fec..1625ca95 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -50,6 +50,7 @@ #include "bootloader.h" #include "versions.h" #include "hw-compatibility.h" +#include "swupdate_vars.h" #ifdef CONFIG_SYSTEMD #include @@ -318,6 +319,11 @@ static int read_globals_settings(void *elem, void *data) "preupdatecmd", sw->preupdatecmd); GET_FIELD_STRING(LIBCFG_PARSER, elem, "namespace-vars", sw->namespace_for_vars); + if (strlen(sw->namespace_for_vars)) { + if (!swupdate_set_default_namespace(sw->namespace_for_vars)) + WARN("Default Namaspace for SWUpdate vars cannot be set, possible side-effects"); + } + 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); diff --git a/core/swupdate_vars.c b/core/swupdate_vars.c index 5d2f95ab..4dd97ff7 100644 --- a/core/swupdate_vars.c +++ b/core/swupdate_vars.c @@ -101,3 +101,13 @@ int swupdate_vars_apply_list(const char *filename, const char *namespace) return ret; } + +bool swupdate_set_default_namespace(const char *namespace) +{ + if (namespace_default) + free(namespace_default); + + namespace_default = strdup(namespace); + + return namespace_default != NULL; +}