From patchwork Mon Oct 9 15:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1845313 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=USeQdcpH; dkim-atps=neutral Authentication-Results: legolas.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+bncbaabb3fzscuqmgqebrykbri@googlegroups.com; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S431F25mRz1yqP for ; Tue, 10 Oct 2023 02:32:00 +1100 (AEDT) Received: by mail-wm1-x340.google.com with SMTP id 5b1f17b1804b1-4067f186039sf35469145e9.3 for ; Mon, 09 Oct 2023 08:32:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696865517; cv=pass; d=google.com; s=arc-20160816; b=w7BCwkPSSW9PbKkzsXodrTqnDBwP5Ne7y9wulJg3uNGnqfzzgH/ELKe38Bwi5w2M2y nMUdAv+bFFSbt80yt7QDCzMocEI/VLUcVnl958rKl8cG2LikA3+Xec4d1q3yQpI70s3m qINTyOeFps6ZICFhNJd86F3/KhGddwaMoLI4ystX9SAqCZDgYHEPPo5GBe0hS9zPuTDv SV5AE0CH8kzQayEn4IkdAD/J1CYK5FYJ1aVxMRMXAEORhsrTrN31HYk8meuY9L+u3fPa J69LRGo1Dx6MrnIxlt90tVhhVAQLEObZjc+CueJE9S67QUqptJy85i2dYPrMtwz/IJOr zt9w== 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=f+Psuvpd2CeYUvLRpWM8K5Klmf2SXu8j3L1YKv0FUBo=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=mB3JEc2tuzV9bwTbaCUOSj59Xpjvl9J7BFYexPUUhkFwLZfwkBozTb69JtKPb0Iu9O WXDQPP+zdcj5QN6HBW4NIUoYPSS7hQBGH/j0ofHJP9xxndFxarK4R/yvFawjFyagMaK2 qEXQCwWTOmDO3zdG6rAjbXWcA9XVPqUq0554xtHacRoutIghyROFY7SCO9udYvK8+ag9 SFuTvu2pvj2BO4rL/hJYtQuCAuCN39+gW89dqpTqSmoqB2vPyYAb7tJJ4rxG4Y9VVueS LVlIo8KmxIaZcst3cUN6PPAfN/okgFvfg/55GzYbrNASB4PqUFSBuhiYZll79LLfgKUL 31Jg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 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=1696865517; x=1697470317; 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=f+Psuvpd2CeYUvLRpWM8K5Klmf2SXu8j3L1YKv0FUBo=; b=USeQdcpH4EeGlP1rF4g4kxadtQkOGAeLPYtjfUXGzdfmYAs9/Sdr6dKDNMAE7DA3Os z2YGVgbZNQ+du+fObp81vboXyXoa3ZacYFF4IalJviACfCOj+141VyskrTyX11EODnQL 1dzU2a0HFit0P0KvxbHAxoh+mLxgUPp9OUi2zThggqCNEe6/w7vqQgH0WXC/Qzj7GYQn 9qgNX4uzy9+LARHsKqslYF8Bvgjmqpeok2/OQVBqWyCKd3yw4QVzpbiMl1fi2yB54AL0 p/074CBJtj2gGA9LAezMfWwhPIOgXG6V+W5sUKOYdTFMfNdbmWLg7gv0tKJi87kEl4cX e5YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865517; x=1697470317; 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=f+Psuvpd2CeYUvLRpWM8K5Klmf2SXu8j3L1YKv0FUBo=; b=DbOHelTnSftTOaZPtsR6bHZj15BNTXLSXag+y5MoSsmRnIgfazSYn6/23kZy9tbBL2 CHclCpfjZIQXgIB0lB7Ja/+KKNN9YewZ8TcvvckQI8I1GieUTk2hztyqod/N61yDKJNd NdSWBaFPuPaX+ODmcFNRG0/GNDdXmrFA9srh30sgfUDc8oKdavOix/RtPf3ipj4K/5Rr VrsfbFWVhC8X+EunTMki7w5ERkOpsQy6bh1feQqoiRGrczSNsHvN9V0zuIso6IuG/BBX A8KDkS0OeZmUUOW8roXcH3XunJYAZzWZ5kuwC2CQ7MQx8yGW1cfg1OsCqxd82n/N3dY5 dYHg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YynOHo8ybt8eZVWmagGMHneOTZembcb/8LuFvW0HINJ6ZkFWHt4 fx4bJpu+EnZfqhr+0W8IfZs= X-Google-Smtp-Source: AGHT+IF6rXNhefm4oa12o8Y4QBcQdFO6XT5xtA9PKyfcVblR4vIThjcrrjE5VgFbkC1K40IedySNNQ== X-Received: by 2002:a5d:4cc3:0:b0:31f:e761:d47c with SMTP id c3-20020a5d4cc3000000b0031fe761d47cmr13435145wrt.32.1696865517192; Mon, 09 Oct 2023 08:31:57 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:4452:0:b0:324:8791:f9d5 with SMTP id x18-20020a5d4452000000b003248791f9d5ls1206991wrr.1.-pod-prod-09-eu; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) X-Received: by 2002:adf:db12:0:b0:323:1d8a:3d87 with SMTP id s18-20020adfdb12000000b003231d8a3d87mr13548738wri.4.1696865515214; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696865515; cv=none; d=google.com; s=arc-20160816; b=ExEpkr4rXrYXK9nKbOYgCLr6IAOHE9AsOqC6/hbM+4l+cPTvmFtDyNkaZ4SETK9fBA ZJ8EAWzVeQ8BAUOAn8X7yWV2Tx10RmGAdAR8IW7GECOJ8Q4NyCIl64XwkIDk9po1vs8k xvq2h6tXZxY9j6ov5FMSaQQ7lKqoPD4VPcVMS+kKc5Vja7EDDsfhk4xLJp0ahW2aX/C5 wjbOwSt6ql8YFY1R5hhF5/ontiWcgT2X4lSOu4ZLdm89Y2VNvpK43NCDSDPn4kHDpQpc bPls5soKKhYjesQVdxwF+IOrhdGj/kQxm4vVUBOqdTYDOR1K0bUHqlJitGyTmjPb+xZA /8kw== 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=s3uSHVYjjkmQsiMoyu18nmyWJpRw6zeVOfY9RX/OlCM=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=yWw+GbJoEogZxcUXlGqh33vEUDRipCCv2cuF19lnjwWHObXQ4u5/2p7YjTrSq6uRbW K/2shf14JDMldBOLGQzsCC/GznIkClgNEJD3wjTSyzwmGtADeqgqiHvUqkhC7Q9wF01u z2V92qDJMFQUYS7DgiEB7qg2zA8UO/SP9ulKeC5e0J791vpMwf2OCLmo7G/HXCPmvk5n r/TBzAtArTxx8PjVbUYaSD1XRDy/p3gyxiCP148hbV83BoWwq9QuAXgYZurqIRdQjfUt dKbS7CWUxC1iruNYJ/NoFvdteTEXE+OtFevy60uUV5XmnBXxQP/vd8IpGgF/tFJu1oxN tPaQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.73]) by gmr-mx.google.com with ESMTPS id b1-20020a05600003c100b0031aef8a5defsi353637wrg.1.2023.10.09.08.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) client-ip=217.72.192.73; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1N9MlG-1rbOBC3GBY-015Ftd; Mon, 09 Oct 2023 17:31:54 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 1/7] Always link libubootenv Date: Mon, 9 Oct 2023 17:31:46 +0200 Message-Id: <20231009153152.416365-2-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009153152.416365-1-stefano.babic@swupdate.org> References: <20231009153152.416365-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:bg7cWxq76JFamzGJhoQwU2XdJQOsagB7DVLPJGeQ+RezydXVbCq 8GTsYxw6A3gc+IphrodfIMVPqPVjT0QMy/eyDqYT3iFu/LH92m2yhHphul5VATfbgoQtDaZ BrcivUdHSP1w0NqUfBB6rCblFKMdpRh3iAzvLnR9Ctf5vib0joasNgalBWqjQ7Qv8JrBoL0 uAwO6EOcgxq1oF2MpbhYw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:shfPe7mAFKs=;SSe5FfpXqYK6MuZgc8yBmL8Of39 U1kY89YxPJ0J1GZVunQMWQoUWGqsjzZf99QOdFWzw5jKqxlAE6DIhrIkQ8WtoM30EclgxvHek XVrzmmogAUJ4y+EfQOe1l9607vPMqmZEVBYuollIs/wagISIFiBC3ZUzoJUgzNRPXrt8k61jO jD4EeNxwICuCybvsIx2OERn4u7ifjHSm17TIhFw0d8eqv28bx2VJOeemt4H58weEzx1styA2V mSgtpCSIXsDvgOUxNnBPetykVN0Tq3zAzMsEwsk1I+9yYNZ5Arik9Oz+ZtqyFjaII51i3PxXN R9OwLc9quUke1MxEvY2Lt4TBbdr68HYF7jD3jLuxxaVhLzFaLEmMsQXKWnU1/kSZE9Gla9vG4 r1Ih/+6WnnMxNu5s0fmK1QirpwZtHRO1j1vIQyKfQrIQjjXCLhkphE2WO7qpOiL78RK6bmaIu qzGdLVnDaDFS5dvDBYJNhdF5AYIpLot6PQ3djBlMjDdvBaVygXOJ0xZkVlvV/OX7qvJfA4kYy N0Z4xuBz5LCoEHTBKwueKJgiDKg5O+djg0asz+lwfqBTmbiC4nX5rmui3DXg1xB1x3cZNgyAu KzNP73NKxz4ZyfnpJhSrorn0KD6Rb7ls3poEQqqfXhdHNWnqdkmg8J638TnYwQvrH6O4k6/Bg HoklctD1KgYF6elOstVI6HOfUOStaYvcbXYR+AncufS2AW9LbrF0v9CXpAgqT7gEkjgMHJ9v4 Z/SSYcbsU1Eovsp/ENpN8NIZCCc2G5IDxpbwe9xYRHOPachpg9SnFdJoWKP2+xWiUfn0cRZVi dNR7vT3WuKD2qgoTyEynqc31x7eOweBWsff1CQvKvzoNbQhBKbew0pwtvCtLgP8qsIZm+ibbC 1bMJzM59wQO8mOg== 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 217.72.192.73 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: , Library can be used to store an arbitrary set of variables and not only the U-Boot's environment. This will be used to save application variables and SWUpdate's state. Signed-off-by: Stefano Babic --- Makefile.flags | 5 +---- bootloader/uboot.c | 25 +++++++------------------ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Makefile.flags b/Makefile.flags index 2d27a8f8..fa9936a1 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -106,7 +106,7 @@ export SYSROOT=$(CONFIG_SYSROOT) endif # Links always pthread -LDLIBS += pthread +LDLIBS += pthread ubootenv # lua ifneq ($(CONFIG_LUA),) LDFLAGS_swupdate += -Wl,-E @@ -219,9 +219,6 @@ endif ifeq ($(CONFIG_BOOTLOADER_STATIC_LINKED),y) -ifeq ($(CONFIG_UBOOT),y) -LDLIBS += ubootenv -endif ifeq ($(CONFIG_BOOTLOADER_EBG),y) LDLIBS += ebgenv endif diff --git a/bootloader/uboot.c b/bootloader/uboot.c index 7f0e04a6..4be034df 100644 --- a/bootloader/uboot.c +++ b/bootloader/uboot.c @@ -126,9 +126,15 @@ static bootloader uboot = { .apply_list = &do_apply_list }; +/* + * libubootenv is not only used as interface to U-Boot. + * It is also used to save SWUpdate's persistent variables that + * survives after a restart of the device but should not be + * considered by the bootloader. That requires libubootenv + * is always linked. + */ static bootloader* probe(void) { -#if defined(BOOTLOADER_STATIC_LINKED) libuboot.open = libuboot_open; libuboot.close = libuboot_close; libuboot.exit = libuboot_exit; @@ -138,23 +144,6 @@ static bootloader* probe(void) libuboot.load_file = libuboot_load_file; libuboot.set_env = libuboot_set_env; libuboot.env_store = libuboot_env_store; -#else - void* handle = dlopen("libubootenv.so.0", RTLD_NOW | RTLD_GLOBAL); - if (!handle) { - return NULL; - } - - (void)dlerror(); - load_symbol(handle, &libuboot.open, "libuboot_open"); - load_symbol(handle, &libuboot.close, "libuboot_close"); - load_symbol(handle, &libuboot.exit, "libuboot_exit"); - load_symbol(handle, &libuboot.initialize, "libuboot_initialize"); - load_symbol(handle, &libuboot.get_env, "libuboot_get_env"); - load_symbol(handle, &libuboot.read_config, "libuboot_read_config"); - load_symbol(handle, &libuboot.load_file, "libuboot_load_file"); - load_symbol(handle, &libuboot.set_env, "libuboot_set_env"); - load_symbol(handle, &libuboot.env_store, "libuboot_env_store"); -#endif return &uboot; } From patchwork Mon Oct 9 15:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1845316 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=lfkeoUGu; dkim-atps=neutral Authentication-Results: legolas.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+bncbaabb3fzscuqmgqebrykbri@googlegroups.com; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S431F5mQcz20cr for ; Tue, 10 Oct 2023 02:32:01 +1100 (AEDT) Received: by mail-wr1-x43a.google.com with SMTP id ffacd0b85a97d-3247f646affsf2147831f8f.1 for ; Mon, 09 Oct 2023 08:32:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696865517; cv=pass; d=google.com; s=arc-20160816; b=Msdi++z2zyUB1PEL3uRE2e/5Ds9xSVBPTE0Jq2b/RSjCMYxeQvvF1ntQsiRFzmtQKI kSEwA38fqibaLIoKood7Evr6AXJmzmFVD0FFTG+0A40UwelC59BRJhULdnYXZsralMam KDqJWSWZbBstT1aI2bRcVn8YHGYE8WGQ4ecr5ms3o20PFW/M4Rh3yPDUczA+j3BBhieG R3raD5anqJn9iVXn1WJAuTWOfFsfxK+P8eLOy23LZWZGUVZoN6exhu9KBKuFyXJFD9bc Qw2khVELu2umr+9KhKZktu7FbGjXRGtKFGM9PWoPYSEOBQEDVz3+tXoqxLDIhPPOfkzO wlYA== 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=Y6C7zo9BG8HgKz9FowiLCCZXbL36PqMzapPk6rNp8gE=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=oEMPQ+btKzHG+2fOapdx6Nf3XMPaxRkKP2NTWYbuXXbZwg/YelMKL0BoIhZYVSFM4B YWmr/fEvd6Cyqp/AmCkg7ytkyCSj3IBb+AVhejypSAf08GEz1l8VrGMeCOGhrzKp1m5n QpcXS0iY7kAs5XAXu7Ryt7W9ACeq7Uxca0vLwHmZLgoj090EIl9TwTWB5Ir87OEmE0UF iguBZa6NZU3A2UHb4yUyCb2SKhmRE5dQvUPeQRsCL8t08MPhYvyRR5O4ndSHPeFPag0q mPRlHHLRvB+hQSMbLedn679OJER6aUJRZReVMQVACeaHwTczx4+4LGhplrzp6AWfcIFg RUwA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.13 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=1696865517; x=1697470317; 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=Y6C7zo9BG8HgKz9FowiLCCZXbL36PqMzapPk6rNp8gE=; b=lfkeoUGu5kugfTCNfmjkNzM2dVYzuNlsCoZwM3wp/tYiezfcyL0v/cc8cFL0CbZFV/ WdrDVwVZWIlJWDiINEVshIb9AKd2JRvie9E6Pf+rpm/H9nDa4uQyyou0uo1ASWzfpKoF bksxSkVEN93ycCmwNeDL8tP3884RCDB3BXe9N/p4+FZgooAn16BrnsEMXHL0C2oKxQwG ty9ntwgPIpV/acXm+U08XROclGQ7f2E9xz6oCh+7wW4lIwsk3+G/4NtME1XnQkBCy8x8 adbydHH/XJMEos1rG2D1yr/6iINY+xI2oku2Ttcvicu0ZOU8ThNg9eFmQ8jcrqUGj7q4 /hQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865517; x=1697470317; 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=Y6C7zo9BG8HgKz9FowiLCCZXbL36PqMzapPk6rNp8gE=; b=PfNiVMcYME0vAUM3xnEFa7kQL0oTWXYTW731D6C3IJXLs/zOXhW8H3z29VNW7qivWF 1R54JAHG/H9mOkDTPxs3eRIvbRwbdi42rOGYfqWGdFRdhbQ4O02J+bTxXHKwdGDFJKVZ v0YY3SVUxKu8DKpKaB9yT2LJDtPCBxTZSoLGXAoJnqMsXZKahddPEI/7zhxsPZ6TH2Kx 2MDITw27s1v8Xa+gl2D3/vXBMQNr162vi948Vzy1LYV3fb/jRxEUhmP7sDgWQTeIF2pm SYcrm1lyH6+6bt7d+71YTjh6W9S5RiVR10/YTmApwiEAYfwCRE7ZgHUhQ6lopKMiXf67 rWtw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yy6+zuQ1F2zDbBMTRaUDQYnQ8i1gL0p9abRzg7dCSbmRNA5tiJY sW19J1uTNizw1+tKCoM80UQ= X-Google-Smtp-Source: AGHT+IG3mJW/b3yGtR5C7LqvfASymWK3lutncySXoQNofFgYT+0Q02uZFb86v60xZdW9964IR8dAsw== X-Received: by 2002:a5d:4d0a:0:b0:323:1738:1c35 with SMTP id z10-20020a5d4d0a000000b0032317381c35mr9740447wrt.26.1696865517174; Mon, 09 Oct 2023 08:31:57 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:ee8f:0:b0:312:831e:dc1b with SMTP id b15-20020adfee8f000000b00312831edc1bls426934wro.2.-pod-prod-00-eu; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) X-Received: by 2002:a5d:658e:0:b0:329:6b53:2c82 with SMTP id q14-20020a5d658e000000b003296b532c82mr7590437wru.31.1696865515383; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696865515; cv=none; d=google.com; s=arc-20160816; b=RhjTWgCMiLGjPPx1OYrNkTWdjfjPq7PKc8kmG3A9Ji6bItiwt4xe0HyP4YUhkVgtAm 2oSTeM5kAcauqpStcGnFmHkN80ECBsg78wMlf4kwhFYUzvpEw/8p/gLULrZQqgh1NnXY QlXWXfA8jTn//UDo8c8JW4D8XiwYvN1c79ZwfzxgkUL+yIHwEbPTbfbH6P0T+WcrsoDB IGHBjZJLbIzbG+OEnIjIy1odsTyZqOlhKtP2cep28t+rou4k2XLkyrogrhRE0T8rfBSf CbqNB+kTwMVvvUy/fz1QFLrTRFK8WNN28Zd+bevY/KrJQoBfNyc9aYgc44zym1PDxRqL +Rew== 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=eRCwqeeu2hgdV9vJdFG55hvglzbb5WhN4iHLB0i/pgQ=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Xt5eEuXs4LzdJxD4OtFk45IkM/Ffqda29YPPrSqnAXbSi4at6QB+tYln2srOt6bc08 2Wz4zn+76KsXO18FKuVMZI2MDSp9c5IwGXLqMO5zbT6Sg3SRcqLeoPdsDm8732XfbNrF FoBOM822cElE/1ycACE89unEtYQ6NFfRUco+9FueWF/JwBb6UD74YFeFzGFUiYstVZB7 IF3swh6yDdwiOumRP9PP04dGsDb3adJnUhra0ajyu9shl8hQ74B3V6O+sqhuDpvfXqCL IFpX8ifYqKWyvo5HDf9aGQlcY4aXAF231r5KAPsdoOpnwd7B/45+IvTjHZwbu7ia0ep8 hQIA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.13 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.13]) by gmr-mx.google.com with ESMTPS id ay17-20020a5d6f11000000b00325960b967dsi362523wrb.3.2023.10.09.08.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.13 as permitted sender) client-ip=212.227.17.13; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MD9Kp-1qhNuN3r5l-0098tU; Mon, 09 Oct 2023 17:31:54 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 2/7] installer: factorize function for preparing env script Date: Mon, 9 Oct 2023 17:31:47 +0200 Message-Id: <20231009153152.416365-3-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009153152.416365-1-stefano.babic@swupdate.org> References: <20231009153152.416365-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:p1UhTFdPFxSE7YfohPGC705yUNcYCR6hxQkDfarYZSVFnM+TZBB DTQT8CocE1NYjGUqolmk+uedCb5nJFcwFWRLk3aWB+F65gxSr/Os1tS9rtZ819f3I7q603E qKeLCvNwz5CWH8x1NLHaJHTNOWrwAIpApxWCb+C/enSTIwTlOTlDjuGn8X5pWCUmuY7Kme5 SbUxlnXpUwctT17h67ydw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:bvhKb25ICVU=;Yy+G+tVhqM2/SgFYx68IgO9j9x3 lQO7roSjgMUBXEAJQqc5Ifsz6wcGBzOxsWGXxlIKmCzFYICVTzMQOlb7qgJ9Yi3cOrnqoYA7H A3dYYvAEf9WefbnvctMY2bnyH31BoNK5sQqW/hjXQp+vqR7Aoc7CFdFiJ7cyPe/ziVDWKCQiC UcAPtBdF17ropB0tliOUc4Q1Hv7jYZG6mAD1OaXeYN/Z1fg7d0M+Uc/sqcgifj6Tknt0GoTUz U/ekkJXHzm/3v1pXSxVvhNxKwcglEq99f433zboxGyhKND8cqzNCJ/+/SVLBIyCbywthzYsEH EMWKQASEOUWa28POotwEMFkZ2MWzyntZvAS1ScoAKIUUvfv+13HbwWvuwIQi7RX0UI/+CT0Km o5bNJKmk9jNDd9IsXbIOd8lUppyA9zFdi5usQNr7EMauhAx+IfFJTAWyJzXiu9WSBCV34yT0A 7/HFLIoFpXePRBiiO5WqtD72d2XsYOil6PgZvGhNCU+qW0W1dd+M+E8fbWwm6+Ot0VBokoNp4 BP4mXFu2H93VNEg5mzx8t0hLfaZOhEFgA9H0YgkAHNHsHTdcr+PtEXMZVVhEod6cse0imgcRG k6avpSMlJsXDv0xrhN72sPK12a1B3aCDbK5oQKRR7WO5I+96mdXgYCAg89boyQHwDfb4qpncE c66NH+zSUY19Pp3yQ9gwrtTpckrzK5sx983TMlzQRN4q5WOE8m1X/zIHmC39VYG9+soXoD0Id HGSOny0rdwOCZfKht3cLjI7Da+TcZ2kjN8hzNTF+QYiddGzyDJRVj+CvEYrkJyoAzFcSBzGif JoVDwBvBHZDkuHOJZYfu4p4sqbcV805XdGksL0V/5vfrn2gDUkPF+MKE/0sHZt4x9ILxSAV99 bGVVWu9w4TE+pbw== 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.13 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: , This can be reused for vars that do not belong to the bootloader. Extract the function as preparation for general purpose vars. Signed-off-by: Stefano Babic --- core/installer.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/installer.c b/core/installer.c index 768503fb..0088d1a3 100644 --- a/core/installer.c +++ b/core/installer.c @@ -155,10 +155,9 @@ static int extract_scripts(struct imglist *head) return 0; } -static int update_bootloader_env(struct swupdate_cfg *cfg, const char *script) +static int prepare_var_script(struct dict *dict, const char *script) { int fd; - int ret = 0; struct dict_entry *bootvar; char buf[MAX_BOOT_SCRIPT_LINE_LENGTH]; @@ -166,7 +165,7 @@ static int update_bootloader_env(struct swupdate_cfg *cfg, const char *script) if (fd < 0) return -1; - LIST_FOREACH(bootvar, &cfg->bootloader, next) { + LIST_FOREACH(bootvar, dict, next) { char *key = dict_entry_get_key(bootvar); char *value = dict_entry_get_value(bootvar); @@ -181,6 +180,17 @@ static int update_bootloader_env(struct swupdate_cfg *cfg, const char *script) } close(fd); + return 0; +} + +static int update_bootloader_env(struct swupdate_cfg *cfg, const char *script) +{ + int ret = 0; + + ret = prepare_var_script(&cfg->bootloader, script); + if (ret) + return ret; + if ((ret = bootloader_apply_list(script)) < 0) { ERROR("Bootloader-specific error %d updating its environment", ret); } From patchwork Mon Oct 9 15:31:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1845314 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=xhvl1jVN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53c; helo=mail-ed1-x53c.google.com; envelope-from=swupdate+bncbaabb3fzscuqmgqebrykbri@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x53c.google.com (mail-ed1-x53c.google.com [IPv6:2a00:1450:4864:20::53c]) (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 4S431F4VPdz20Vh for ; Tue, 10 Oct 2023 02:32:01 +1100 (AEDT) Received: by mail-ed1-x53c.google.com with SMTP id 4fb4d7f45d1cf-537ec211f15sf3761375a12.1 for ; Mon, 09 Oct 2023 08:32:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696865518; cv=pass; d=google.com; s=arc-20160816; b=H0iF+K8mQf2hRkteWdyw2bcIayBWP9XrcK+EaGS61jcA4/kypavX+ZUmpLKz7kMCRT ePBZdY2xXtA7qUIaCwHR5DeqY3dg5uo1CWMFR333IhJ/fdL/+QstA60dd34rNY6+EMOw obt1sbPrawCwEruc+HnoUw0ORLcg8StXccibGv2FEGNi3NQP4080LhHJpkTAWCpNQQ0z JAKNTRWbmHiQ0g79BLbr4uMimwFmVSYjd0mHCw50X9khvk2cfJBEenm54FjZYI9Gc0F0 0WF6s/M1jyQzq0ZoI47UNWB91rDP+hr/d+zawOH7o4rzPULQj9RcYyru9uWm+CRqGs6+ ualA== 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=ZDlVxTyYU3RjQtZndUpO4tsbV/7CLAd2r/l5jvXwaqY=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Ld0ELwXO3R2eiqMw/ij8mD89wMfs3c7P1YdvD3M58+qhLhOICY3JWy+SVvtmN0brDX q/mpQcgPAZ8iOeEsy/f/6Q1MucwKDJnKoxxSaYf3FY6U+t58Or1dqrMlzzSbXXB3xqf5 dcbvVD7kXGbTYJdYyLOqpy7ZqjqhX9Cj1asuj3ScQ9V3txu8m9zDPKiWJIOOc2Hogo20 OzQCSCfeSMLGsh+hhPHeLyWAutTTY6jKCinB5Idz++S4++TCqQHFfDMrMDqtnqQuyUh0 OzMB5CRa7SCO1yNrUI+7UGCQaqMqq7dCzTp3bgih+Yd1UBc8SkyDQefSSww4igCEIJUX WZJg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 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=1696865518; x=1697470318; 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=ZDlVxTyYU3RjQtZndUpO4tsbV/7CLAd2r/l5jvXwaqY=; b=xhvl1jVNLftOBZOb9qX0gZ44yr4W0/pyRTEQAAInEAepCdMKDia12+MPODEIxQISTP Zenn0mVvG9vB6wDRR/pGSp9g9dmeAcKGRcbegSR5ujPiWkNVoWZyPv8S8j5XE8el+DQ7 z+ekRPv3GPAWzgw12KjRjvB/YFxB53y8dAFP0iYcnmSt1zRFad4DVxYEHACkhO2s15J4 m2kf3ow147UJK1zcATVuePIwPzOTcpnsA6S904k5QZSnOdqrLuvvT8r3hlmiT1l9Bpi1 6NgWV+0mSVVgQnm/IWS+SVte9JCGY3ok8M65ePauTYYJFpNnbAqrOPeo2ehgMe1HK/D0 e7yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865518; x=1697470318; 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=ZDlVxTyYU3RjQtZndUpO4tsbV/7CLAd2r/l5jvXwaqY=; b=MgWRu31yiRzz2WSjeyn0tf5NA8LBj2dhQvaPz7YkzItZTzRsTtIlMejou3rov9nK7+ ejZtzYB2DTu/V2Zu8BFDzSnzpzfJLbS7th5aMCPwot298BRV3g3FtDLx0xzg1zeK2KeP 0+e0dYLc9dbbjO1DseuCPH//cDb19Wqcfk2rl1QAwHtYP8qrmxaYHWFydSqEKJ5fWwIJ ota55PsjTUM0xwR2voBGSfBf3qB60b41nU2mC+K6dXwl6fv+VuJOmcf3DH1o5rgaI5M7 3xWnkDQ2j0e3lcD7vh0RnWc6LOJbSLlpZRuUJJBOS0me/RE4MVWhlitPxEADucDVv3Yq NUqA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yw7uO4anX2JhENysKzArtKPxh8z05v382VptZfxDkn01/6n0CcU /ioM94PkzrzFZaoqyy1K9LE= X-Google-Smtp-Source: AGHT+IGnqW4suAdoDzkfS1HuPFoVjWCGKxmWA+VPRWgRHe1Fnf9rpiwKbb8lkUjEAtUWWHVe3Df8Aw== X-Received: by 2002:aa7:c44d:0:b0:522:2ce0:d80a with SMTP id n13-20020aa7c44d000000b005222ce0d80amr13612963edr.35.1696865517331; Mon, 09 Oct 2023 08:31:57 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:1d84:b0:53a:a59e:de80 with SMTP id dk4-20020a0564021d8400b0053aa59ede80ls741768edb.2.-pod-prod-09-eu; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) X-Received: by 2002:aa7:c68e:0:b0:530:a186:f8a8 with SMTP id n14-20020aa7c68e000000b00530a186f8a8mr14569683edq.37.1696865515618; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696865515; cv=none; d=google.com; s=arc-20160816; b=DtDTNMqDRRanZrXysNHgN3dIuUZncwiwFhnZIQA9YD47Z/1UJ3VVSuWrb25Nji3D2Z XqeYJAKsL1vFbnBw+jW2PG7AvjI8OakEvAEF+YPdN3Ze2MZc3DoxWcgFTmVZ31r3oiD/ CPDSUnxJb5jGnoCzN5DRZkyO0cxkiOLUREkf5AKa/wSCl3OpwbVAeNco2Qq1+0BOYxpN WIkmSo2LGYveiUUg81gPH68HWa9oPO8oo5cGOS7Hg6mToqAUMsnbaIFrMlPakMOaxJFN NlyopjymzDlo2UYHtOZvrL8pXh6myQtsoFyNflxpm4JW+60Kac6vtxzVzr8YYDg1kAD1 oZfQ== 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=Efa54lr/Gg8W/XzvpUUVgjHBovYvdE9SzDMdXLEKwrA=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=DFjEEMWswnrAG38hwNaC7gZiJEgGlgN6283ZLQgvR1sVtwjcR6vZvktwx5ZDNyg3hH on6uB5sWYYzZM009bKOtq0n/4bZh9akFr+q0zDRNcQXCfa4rSy8OMJD9SAJpim0mf8Xw IpKlDF/gt2QT2jh9ZrbmEg4c+YWQ3DRjP4YtNBLdT7HwpjkqnGbNeYKtBIhK3nAhLXab w6J8jtfrFLMaPg9G5KjFxjJSAmXcbqypKpY1CPDX3Z/Jjscgk5nKUUW0qSnV806xjj9a JQI7VyqXFNP/W1U7fD+4+9KR8wIVCVtzIsUXveqXW32V2hYaZ3OHwmunLd1vQi1TeqPU SE+A== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.74]) by gmr-mx.google.com with ESMTPS id b17-20020a0564021f1100b005378cb9a578si584071edb.2.2023.10.09.08.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) client-ip=217.72.192.74; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MmDAc-1rGRXn0Gp6-00iCjJ; Mon, 09 Oct 2023 17:31:55 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/7] Add "vars" section in sw-description Date: Mon, 9 Oct 2023 17:31:48 +0200 Message-Id: <20231009153152.416365-4-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009153152.416365-1-stefano.babic@swupdate.org> References: <20231009153152.416365-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:lvl7tm+c3aHkcyAjeiBX7qQVSMfuK76wkAWXElkmf6r/NJKEbpO /zmDmk+ujD3kJ7W15bEreRfVROA/Zj9RhhOqF6zsiRky6EJMqyry/IVLCrZKnzoyd7384+9 /Z8/O75M5bX0fzb6CkvQ3BPnx0FmeTgJjeEuQ9rN0bFt1SKP2louk1uTGouV6vG48pW3YyD Q+eG8udztEBkUhxGjAhyQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:PZ/zEAr6hlY=;RFU5JmSME83oKZjpURIKOuwsB7v n1zBdxlIcI9dxQKncG5XxPWK8TcH2oXhF/kB8HOsTD+31VbFDY4eEwk4z/Gr/xje030+cPwdk QUpF64gpiK58GRUggzLikmV5tucgHUPz+MKl7lvq4KRGm4LzZVAA7uOAg8lzz2augTzXbqrZ0 RkSpI+C1LJiWlmgRWe9EGNo+4Twpywxixzyntqvbl6s3GOLte439BO6drzXfQF65kBXgGmRBp 4Uml95iRCsDjDEBDtGd8Nbf5FMCdUOqjvb5sGuu0w2vtTsmXCkDZkHelAocybAG5AK2Yxvy5u ++XfceJxfiWGGPkFQ+FuR0uKpAONF0/k5LCBQFAbJTUdxooMcWe9FAcSBOM/ZuAFk/xPb3LYX DVtzWe0o0QZ1JCwYosHsmSTHgOsqdnmVPwmgBcy0UsZHb9YfMv/Fgz806tZV94yFsOCwf6WbY pJwRZ/HF2pGY71ktI+MEvB6M3wgHbjWqOri6Bh64s7YRNet5k6rK3y6nvAbf2jvv+IZ41q159 a/QuF6joYEN5i/t560BNDdkosBJwOvUkazkhAi4DN0tE8nQE5aBGc5zVrZuQTdLI4uPgCfoEg Xl+lEd4RTlBGz8YoRrJBxBe1nIaDdQmEWYx5u0J1jVw2sEdcpHCiyMNNMQjN93a6CFfqOLapG RFveq3VN1qXZYfQJtUnv0JLDxiRWFZtleyOyRteK1oPb8VfqO9tEPJVr/VV1jy5at2l/KGY7P Vk1adN6OjN6LaLLsvOMI8r1QdhaNx0+j22AbnJDBugMiWuSuBhmUvQuNrrQktdP1lBELR9oCe 5j2k4HUIO/DBj91aNK8jDMyYe/4PFH57uRFHdozBUc/TLeDYflWtEnuEXXwmRiGErcz37qLoY JqKRYPjij+p3YoWxiv0H9I/PmUDd8qg8rZPQ= 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 217.72.192.74 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: , The vars section will help to maintain a list of configuration variables that can be set during an update, but are not relevant for the bootloader. They are not stored in the bootloader's environment and SWUpdate makes usage of libubootenv to store them with an own namespace. This requires libubootenv 0.35 and higher. Signed-off-by: Stefano Babic --- include/swupdate.h | 2 ++ parser/parser.c | 84 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/include/swupdate.h b/include/swupdate.h index 9e48d04a..8b8894d9 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -65,6 +65,7 @@ struct swupdate_cfg { char current_version[SWUPDATE_GENERAL_STRING_SIZE]; char mtdblacklist[SWUPDATE_GENERAL_STRING_SIZE]; char forced_signer_name[SWUPDATE_GENERAL_STRING_SIZE]; + char namespace_for_vars[SWUPDATE_GENERAL_STRING_SIZE]; bool syslog_enabled; bool no_downgrading; bool no_reinstalling; @@ -81,6 +82,7 @@ struct swupdate_cfg { struct imglist scripts; struct imglist bootscripts; struct dict bootloader; + struct dict vars; struct dict accepted_set; struct proclist extprocs; void *dgst; /* Structure for signed images */ diff --git a/parser/parser.c b/parser/parser.c index 52661384..cbb11962 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -224,6 +224,11 @@ static bool get_common_fields(parsertype p, void *cfg, struct swupdate_cfg *swcf } } + if((setting = find_node(p, cfg, "namespace-for-vars", swcfg)) != NULL) { + GET_FIELD_STRING(p, setting, NULL, swcfg->namespace_for_vars); + TRACE("Namespaced used to store SWUpdate's vars: %s", swcfg->namespace_for_vars); + } + return true; } @@ -719,6 +724,82 @@ static int parse_bootloader(parsertype p, void *cfg, struct swupdate_cfg *swcfg, return _parse_bootloader(p, cfg, setting, nodes, swcfg, L); } +static int _parse_vars(parsertype p, void *cfg, void *setting, const char **nodes, struct swupdate_cfg *swcfg, lua_State *L) +{ + void *elem; + int count, i, skip, err; + struct img_type dummy; + + if (setting == NULL) { + return 0; + } + + count = get_array_length(p, setting); + + for(i = (count - 1); i >= 0; --i) { + elem = get_elem_from_idx(p, setting, i); + + if (!elem) + continue; + + if (exist_field_string(p, elem, "ref")) { + err = parser_follow_link(p, cfg, elem, nodes, swcfg, _parse_bootloader, L); + if (err) + return err; + continue; + } + + /* + * dummy is just used for hooks + */ + memset(&dummy, 0, sizeof(dummy)); + + /* + * Check for mandatory field + */ + if (!exist_field_string(p, elem, "name")) { + ERROR("vars must have name field"); + return -1; + } + + /* + * Call directly get_field_string with size 0 + * to let allocate the place for the strings + */ + GET_FIELD_STRING(p, elem, "name", dummy.id.name); + GET_FIELD_STRING(p, elem, "value", dummy.id.version); + skip = run_embscript(p, elem, &dummy, L, swcfg->embscript); + if (skip < 0) + return -1; + if (skip) + continue; + + /* + * Store the variable in dictionary + */ + dict_set_value(&swcfg->vars, dummy.id.name, dummy.id.version); + + TRACE("SWUpdate var: %s = %s", + dummy.id.name, + dict_get_value(&swcfg->vars, dummy.id.name)); + } + + return 0; +} + +static int parse_vars(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_State *L) +{ + void *setting; + const char *nodes[MAX_PARSED_NODES]; + + setting = find_node_and_path(p, cfg, "vars", swcfg, nodes); + + if (!setting) + return 0; + + return _parse_vars(p, cfg, setting, nodes, swcfg, L); +} + static int _parse_images(parsertype p, void *cfg, void *setting, const char **nodes, struct swupdate_cfg *swcfg, lua_State *L) { void *elem; @@ -941,7 +1022,8 @@ static int parser(parsertype p, void *cfg, struct swupdate_cfg *swcfg) parse_files(p, cfg, swcfg, L) || parse_images(p, cfg, swcfg, L) || parse_scripts(p, cfg, swcfg, L) || - parse_bootloader(p, cfg, swcfg, L); + parse_bootloader(p, cfg, swcfg, L) || + parse_vars(p, cfg, swcfg, L); /* * Move the partitions at the beginning to be processed From patchwork Mon Oct 9 15:31:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1845317 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=w9EwP8dF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23e; helo=mail-lj1-x23e.google.com; envelope-from=swupdate+bncbaabb3nzscuqmgqewtekzuy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23e.google.com (mail-lj1-x23e.google.com [IPv6:2a00:1450:4864:20::23e]) (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 4S431G647Vz1yqP for ; Tue, 10 Oct 2023 02:32:02 +1100 (AEDT) Received: by mail-lj1-x23e.google.com with SMTP id 38308e7fff4ca-2bfe9ed93easf37615311fa.0 for ; Mon, 09 Oct 2023 08:32:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696865519; cv=pass; d=google.com; s=arc-20160816; b=WXt+ebMAjGLNaBvs/LGs1sVZrO+Pes7vDzcHg4jTS2KU1OKeRD9/Uo72EwNnPXYPOI 20UZGIXqmrV4ZeAOMYpnyebxrqLvkXp+CKlAXMpHPbsl+71xzExT0CrSy85NN/SlObyx fko3wDGwRivNHIk3luHmwdv53zvhfCIp6X1a+Xn3FRlQ2xCQB5bRbNF2Ymkiw/GRHHZh Yn89JTilDf7UW5Yjmu6C1eAeYJ2X5oWNpuL+frJt09q3LIoKtM3ejy9cIk6ZkPXiyf5p 4MH/syQ/vGmGwdTjlKB/PLXwbrcXocOV714Rnfh3xgwz83W2dC45d7l4sKtVH7I7BGn9 +wWQ== 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=H23gSz+IU7cfNR9LZBQnNTL/vQRGZDoPgyVK8G5H7iI=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Q8BlP5ZvTA82ESQrAUFfI76PZO/5KkO88XyVdl8tlgpmpoj/WFUYA9tEsEB+Q+NFAi XyZ/1iFYkNUjebYFkrTAWFLCPO1MBO2hLPYUBb5hkxI8nhBTwh0Dvovh4/rIT2E9qt9Y 6vR0kc7d5BzHLS7j+T8/LSwOSUOosSZr+A/Tj+kIszCRTprXfZ9E3/lWZihKQDnVvS3Q VV0QndSpWd15FIDYz9vq4fAL9MDX1XjElSrnhAFW1rAliSXu8PiUwNy9Y4wsD1peBp3w oGaIKpiQRB1LGrEuqIMI0sJP3alP9gWlJwDSsSKNobsvE/w5VpPdaLvygyOmhD1efWNe 68+Q== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 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=1696865519; x=1697470319; 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=H23gSz+IU7cfNR9LZBQnNTL/vQRGZDoPgyVK8G5H7iI=; b=w9EwP8dFWRRDsgWFOMimuZkcuiC3zo2Hq4me4UecArOOfI4oT6ri42Sy9quxvcn2R5 rye8Urxq6/Qxmm9m9iqRIE2qDS7ZRazc87QPDs+kE4Sw4XivB8rHhdMNUbP+bxDKRX5j xHgrybkjrQhPSLiSNh/0fPPrbKPFNnEhIbSxN5sIIfwN5UIWFGZiFGeU/G6shnR+0r6W OVdqBO913pqzC2+Zlt7OdrP+QrlowFi3dHN5BzZk/OD46aQGfNaadsYNZ5YNqe4if4g1 zo/nm/wvOGfy3VinpOW2/C0GJZfYkOmBgcy/l1j69mzWLOc6uzq+6CcwOnaFxOr7XvKw ntYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865519; x=1697470319; 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=H23gSz+IU7cfNR9LZBQnNTL/vQRGZDoPgyVK8G5H7iI=; b=wy6ZvnAnclNCBw3sj3UsiiDJcZMFOLAF641DARoq4+W8qopTA9wD4kAy6I1+BG2vVR Uo84dtcduUVQhn+lulOf0qrufz7nTfNqowiN0I8NUwVXifrsydIslgZNSzz6opWKP4iR gieLGL2lLnMeK2NGEHq85OYXxxV0hzDzs4a5DOaRo4pyL1O/5p9FiGO75zqyZm2ao8g9 mHutjW+6Obj/DK16k8Ik6fjBjJy5cVMs4ygz2jpqd/Aqx8rd5PukZMFcDqStjoscpHQ6 S9x3F72//BIv80VEgQCkRWNrU/5BBvm78P89RXn2OZwJJAmTiGZjwImuXC4N3lCOrSGd RFzg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Ywqs0VRvrCSfExSTugtGqbx5M1RwNdaE63x2ezUgT0nZjemW4bf +RSHKkAgHse3nDTIaKPPwuE= X-Google-Smtp-Source: AGHT+IEM1vmTVByFNluLE3CkAuSHrYLZAzlD6IxmcSzgmIWcKmXDw/K5ONX/HD8rv4A22R9Kv6fNEA== X-Received: by 2002:a2e:b551:0:b0:2c2:7c75:bcd8 with SMTP id a17-20020a2eb551000000b002c27c75bcd8mr8760457ljn.3.1696865518084; Mon, 09 Oct 2023 08:31:58 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:bc06:0:b0:2bf:fb2c:fd70 with SMTP id b6-20020a2ebc06000000b002bffb2cfd70ls231993ljf.2.-pod-prod-00-eu; Mon, 09 Oct 2023 08:31:56 -0700 (PDT) X-Received: by 2002:a2e:9347:0:b0:2c0:7d6:570b with SMTP id m7-20020a2e9347000000b002c007d6570bmr8579238ljh.26.1696865515994; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696865515; cv=none; d=google.com; s=arc-20160816; b=nxhNpXKhLFXl2AzdBGi/W+OOColJr/Pfqm+hDGat4ZZVw3w+RXFJW7AUz4M55pOl6r r43WH7dbfe81P4v0tmV56WnAS9LLGRoQ1dX53vkKtUvLCaqrAZsDnLsGhZKOMR4PGGjB GSXT9faoVpNJvG3IVqNq4DLrX8JlEVUT/mdjfyYqG0VnFooafaHSBL/4n0UphQeS1YBY HT2np+LiAd6/rBpGtjXpKD62tZ+6kNj8/4tWg3dmGCdCZBhCF5eJDdOTbYFhMRjfc+49 HrPztA4foOCmO5x5qnQJ1tl52tJwF1fQFiAVFdcjjkgAFOC2tHjJIL87hI4cZh3m0L5c PAww== 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=SSW19CsTFctnkXHyKAeU+O+ZcfeBo2zQ/8FrPA7Qg6o=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=TQtB1Z2E9F88/NGCbzu/wKhO6aAv2rUZC8WPYijtw7PiMJz7GGcEm5zt+vcELYPP8w 7m/OC57GdWHTyvJ2KTCPkK7CaUcyApPvlYNci1N0lMw2q95n9yZ+Af+O13cYe5ESlVGA hxteZ68w+WYhOz0j5jJ1EcIucTWZPi9OFzyRTOpolwKkauIh/Q1L1PRpjn8lWmlCfqOr r5YnxlxC4j6hkYX/6gwO72QGducDhLWqIvzQbmrv68Bva/beHsDCJx6gKBfhjg+twVtq 37J5/aw+UkakRZEhABncsq7vnbxqlTt7L+IxStli1FlIQjTe6IC3Y4Wwlc29g4ACL9er P/Ug== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.73]) by gmr-mx.google.com with ESMTPS id m7-20020a2e8707000000b002c12145a0cbsi409101lji.7.2023.10.09.08.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) client-ip=217.72.192.73; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1N8GIg-1rcUdn0sfg-0149Qv; Mon, 09 Oct 2023 17:31:55 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 4/7] Acquire namespace for vars from config file Date: Mon, 9 Oct 2023 17:31:49 +0200 Message-Id: <20231009153152.416365-5-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009153152.416365-1-stefano.babic@swupdate.org> References: <20231009153152.416365-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:g5lRl7ly1f87iuO2VpBCAtdNTkKjArUNgAweSe3Ggg79xk+mfQA wl1xTpt9NF/HKXWWRUfTFs2NC1I1AoEf3qmiOHHg85Cnc0QRObbNp/JCr+Fj6z+G78jot6H yFndAn1MKFyyT3CTlxFTMPwFA+AzVOKeTwBOceFhB4b4ghMx4hyAniCq2uy7A4kYoxs5hPV M9iHWGPqzUPYVevuduuoQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:QSR7MRQPqSQ=;2IaQIlgLyfdtCiBaMgYkLLRABSM 0kbaK2zJ9fZfr1bnigzzyJjrqhsX3HkpkrBhVRf/h9kIt6dGQVSgXoib2ssrIsGn5viaC/23e rjVaIYDA5E46qVcBZT9AwowL69EhoyunxEuMpPwilstlC7f7NJnL/qtnOkNywrNhBOMHxw9S5 hUjVjInJ7hZYgD9+NTN2qBo3OJ9pE/odoI1IIYVVuWpOzVdbiTVQCnGNDer4OhpP8v8B3aRNd XxxLJYEBZNYIoLIejdunOBbqIwRvPtZbcRQthQAUIbVq3Kj04fj1reET/z3CUgP5eLJpdB1RC 7ZeZlgvkZHHLPzwhCfb8OOf5m/1Fck9CI4kQ4SSf1kA300TqRFZZIzA5ww1UJMdo814cWkm52 NsBvCHKa/5e+8NUvhtRM150yoTCrgCnBLHRxnKH+qgq9+zK3Bv4Mfw2BF89w7WSE4JPp/vtSw X4lVxHd5RMFhf2oEeKYM7KNgz39HJKHU3+pGUIiYalNpGVZoLP4CI10zZb8baqbFeBX9WAUWS zgYy+7/4cy0nyC0HDPBj8wKxdMFNpjxcyNPrrA7Qugumjawxgp47mFjHSQ78EnCS5f4YhghA6 IQIBjOcixWCbzRKoahdaEpj8/bVphIwuUDU7TkfBV/sBh6SnbYgltBk0Oe8Q5/Wf+AkSpDx1y QiUJMownm/2YR7OWPcSQDkOJAOpQyYBdbSJZTokBhD/y1t1GC6DZr1XxuJ0cIr7ChljhBjTkQ w3ZllhCyAJsIUkqhDaRDtjSTxS46p3kwh/7xdI01EMWsdczl5LuAc0ISonGZX3uAHqGpURYuE zeEAZ246t5R8lpaamY4Qs4v9qi3pn7TmEXdHygTVjfvI7Tin8IdawjIN9UoNbKrhd9U0sOziC Y8TExa/Mw8QburQ== 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 217.72.192.73 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: , Allow to set the "namespace" used by libubootenv to store application varables from the configuration file, adding the attribute "namespace-vars". Signed-off-by: Stefano Babic --- core/swupdate.c | 2 ++ examples/configuration/swupdate.cfg | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/core/swupdate.c b/core/swupdate.c index 6b536b83..07e5ef70 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -314,6 +314,8 @@ static int read_globals_settings(void *elem, void *data) "postupdatecmd", sw->postupdatecmd); GET_FIELD_STRING(LIBCFG_PARSER, elem, "preupdatecmd", sw->preupdatecmd); + GET_FIELD_STRING(LIBCFG_PARSER, elem, + "namespace-vars", sw->namespace_for_vars); 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/examples/configuration/swupdate.cfg b/examples/configuration/swupdate.cfg index 46bf1f4c..c9053ddf 100644 --- a/examples/configuration/swupdate.cfg +++ b/examples/configuration/swupdate.cfg @@ -48,6 +48,10 @@ # Possible values are ebg, grub, uboot, and none for # EFI Boot Guard, U-Boot, GRUB, and the Environment in RAM bootloader, # respectively, given the respective bootloader support is compiled-in. +# +# namespace-vars : namespace used by libubootenv for application/SWUpdate persistent +# variables. This can be overridden in sw-description. +# It is one set in libubootenv configuration file. globals : { From patchwork Mon Oct 9 15:31:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1845319 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=YjXued6b; dkim-atps=neutral Authentication-Results: legolas.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+bncbaabb3vzscuqmgqeq37yc5i@googlegroups.com; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S431J2VV4z20Vh for ; Tue, 10 Oct 2023 02:32:04 +1100 (AEDT) Received: by mail-lj1-x23b.google.com with SMTP id 38308e7fff4ca-2c12c3e4595sf38288401fa.1 for ; Mon, 09 Oct 2023 08:32:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696865520; cv=pass; d=google.com; s=arc-20160816; b=e3cBlaTS5RJURMHWdr35G5zOYg1+YH+mGEDUCGSx9dT5Q2n3d2AjMLM+4DXgawMXBh PEgabKETaOmJC0GHtWRclGt6G3Y7abVAUkyfz6dQV96DhhhcKKuR1xUxtMnQL99lTt+W im6O/zTHWpXB4Ag7b0TgslnT7pCrw/zfPRfLZeD/9LHfDBe6tNbm2omQmLdtV9/z9Csa BY0ZlhY3Kw6y+PUojPiEMcO+e6Mkr0tA/PDonddh/rVCoXrT71uaBhLntaWDxulsfIsH 2LNawOf1ECly8X3kuUnuOXhQhT+PiDlavDeJTI6zL+KxoI34fw8VYRB9M95M8H5Cp5wb G6XA== 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=AtrhKIyAqkPIjGxfCN3R0Z8mYlR2cqYvi5u9/BRRWhY=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=u0pH0wWam9RJqPshbJt/AT/B3WSTsTLmom5RBElkOyaGloyr/aa86tNosXpyogfYXS pePvlOQO1g3YUBdj+UKjvB4aY/QMMVsGqe+x9h1+RVbv2OsMlFDU32mEmt6Q6yo0hIKX +rddcnCyp0rcoivuyGeIOjXvnFIxO5Em2cAQ9WHqmuu8LvNt3eAerzbVQjVi12HeMdWk oI1I3NoCvG0gV/B58EauMBBNPCgfE05VA05nEmjQgA4lkHFVbe7xQPiuJx0zpDnuzv2Z TifLmtHkkDUctAgA4dfwjgP853+RF4mOvpfELIJjTcLoa/Im9DCDJiRr3rPsO5ob/zeM 4GcQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.13 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=1696865520; x=1697470320; 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=AtrhKIyAqkPIjGxfCN3R0Z8mYlR2cqYvi5u9/BRRWhY=; b=YjXued6b6sgGqv2dx2HyHBg2pkQbF+qug313WA18t75eqxqCdiP1VwUMFbMyN2ksok 8Ue2bdSNI3tOlMq9CN7w1+NYeLIDZOYxHRNvoAiWSX4W6lSK3taEuGLljzuRnvl/PtmO uVqGqUppMbo6HBnH7k+rVrH94E9CzNJ9Azs7Mqk4OkHE3tW63p70l631Wv4A/G7rkgYI A4xa5X0rTO52mcHv852LIaXYHt/eBNGegcs75Cbzh6Yla/EmRwpz/QZpRLg1GfNG2wq7 xawrLsjyv+mJbQU0nU29qR4GQJbzbhQDKM46hElyAyvrNzXqWw7CXQ8SrbgC0khiJM+n T4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865520; x=1697470320; 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=AtrhKIyAqkPIjGxfCN3R0Z8mYlR2cqYvi5u9/BRRWhY=; b=bU95FWNAUGqqwUUunIM7O6+QVOoOmuoqL5Bz1WqeSuDTCsxYUJwx+woSCAMAfUvqZ2 OZ12mjUe7VC1eDqL2nYAPpVTa5JpxnQas3yzigUEv3BEGj6djBn/PU69EjCziuD1HRHo 4sPkXxVm3CqjCWt59vFJLNYqq6e40gP7rqJKP0ETAxLwesOxSJ9rXDUS/QhLFl8UnGku KkyRxXrT/dDG73EGO/QICNA1L5QYITxX6t8XgP/Sk/Ih+2iolEuHqFxrLe7f5Ya6eQv0 WzPJivJ28OuZi8gsAubBKAq9oLUXcBr+X9MdPOUXrfdTRC8l9QKfwwJrKFlFvv0pvscD SXLw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yyxreh/pVeaOkihSrhjN+oXviU+bZ0kyA0JybCssg60RsvHOaXu t1GMz69x48RX+Txiz+urrwM= X-Google-Smtp-Source: AGHT+IECQGkNMzgH2+ONQQhD4vo5IR0zu7fNJFYM/v2FkTsimLLwENUIrXNbwe5PnsFwvtB1dYBEyQ== X-Received: by 2002:a2e:330f:0:b0:2bc:df3f:7140 with SMTP id d15-20020a2e330f000000b002bcdf3f7140mr13022260ljc.17.1696865519061; Mon, 09 Oct 2023 08:31:59 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:c99:b0:2b9:6182:b0a4 with SMTP id bz25-20020a05651c0c9900b002b96182b0a4ls1539784ljb.2.-pod-prod-05-eu; Mon, 09 Oct 2023 08:31:56 -0700 (PDT) X-Received: by 2002:a19:f516:0:b0:4fe:19ef:8791 with SMTP id j22-20020a19f516000000b004fe19ef8791mr12127715lfb.38.1696865516137; Mon, 09 Oct 2023 08:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696865516; cv=none; d=google.com; s=arc-20160816; b=F4qivaFKolovzWDM0kUTS3FxonikjTrEpr1OZ6reFOdBW4YXWU8GjyNrwbmAnGjYDo 4zLxA0L+NWArj98BO/g4AYUfnfvxFFOHFZBFxuU/Sb8E2aD0ytC2gdPR5ExoLsIITHbA vdmkjNSwhtZegOZx56+qKflloBD6QFZ/uhti3A0f3EN55qE4imrolUJLGCh8hRwm3VjW yIuvo6FMdr4RPZ0EwYpYrfAFrqIf5CczLw8evwkOuO1HClEsea3FKNdX731bAKictm8M JGCpBsstP1izV02BHTd8Tf2P7y42EusFHyyvWnQPKWXBpxTFc043qa/ESsv8S7vMHTHC nN6w== 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=6Y2foYKYSImxOc+m1DYqJvGMgkiLv4V19ri3VblK6M0=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=TcbVvTxIgjRROelRXkjGo3CkMK+LQ7g9UfguKLImxsAZ96OC9IiVn7XhQnfd9SiF31 KXNHINniD3YJPUGAFYUj3fPopsgz5UzwL9MydXuvGLLSSt9L2R7bWybjAvRtjLsDG2UG Q8KY2d/TL3XCUpBBL16SpgvTHUSo+LZu+okPJhTFr5uTdST0OYbEhcps4ZLGNKT4UOmT 9m4wfrBXJht6nmJ5DFzR/9TRZfBHPKnnquLAHzfIEgjGJhZX/o1EACMnh9eoxFR8zmg1 dyk6lPmhpr2KeAaHgL1jmclhS81eP4SJXgxh9Mo9jU5iC6b+9eQxtIHO2a4KMsg9gkdG y+9g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.13 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.13]) by gmr-mx.google.com with ESMTPS id o6-20020ac25e26000000b005056618eed7si351981lfg.4.2023.10.09.08.31.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.13 as permitted sender) client-ip=212.227.17.13; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MFsd7-1qnPFs1VeR-00HQMY; Mon, 09 Oct 2023 17:31:55 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 5/7] util: add getter/setter for libuboot config Date: Mon, 9 Oct 2023 17:31:50 +0200 Message-Id: <20231009153152.416365-6-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009153152.416365-1-stefano.babic@swupdate.org> References: <20231009153152.416365-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:HgFKiJcCmk3Spck2xehndokVYdxvV09XvYF7jbFZ+TarP02UleW AQ4jSglb2OxKG2G5Fez1By/j+h1Idjnr4Ju67Lmpul+JItPSP1bXAYkVceEe51AWppSDbNX gySIbUIWFm2lhMfYaX7NdH88cr5MKs6qb71ThD0IXHERmejiRTTbSPPb5FjvW1/K1Bsn2my 6MYhOlZJbp3JVJNgr3hnA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:CPGs/PaR+Io=;kT6kXd2tbxaHcPYnIVaL8YIdrxk 12SoT7ydFr9CNQDoZv2zIGnFMxX05FKMDz5emb/lOPqyPF/R8mVKQ48p13n0yYPstOUwBkATA u2oxbXf+93j1jnEz+1JV16o4T/d+SWp/y1Z7ktrgFgHZP5Cs2Pat0Qz9sc//JkMEFFrJoqpAZ 5HHKxsrkxJn+54HcgJxrxM1ha6kedAlfEfOCGgkUNb1HO4JMu+qmpFOrqvegxMFbOgg8Uu/h4 NDPxUVUe/GLEmlkebLgWSwMSv6sFllOWnRyGL0PeHA6vm6dS2Df5g4rxhzNuuaisYGftZwvkf wCz8kTNaIyps15eQszgkEIadL+3sY3UqjryQW/iwwKWAPPsrF4gq7OYnxhHYN8lxitfLSqyZF bXciMwgDdYZHx2VbMzEad9LYNH++x3fuB6QyVtXZEWwANPjssDaensq2ycRE2AL0FPD1Foikk +aSzp/qTN8JwidHe/rPaW9r3A5Y6FbJLOgK3ZIkEe/uPHQ/wla8PymKLNKwj4ErQeQ5uO0ogl z50NenpiRR81tCUD3wPF/R5HxPd4l+m+YBu+wkkOWH5r8jybsqUTQyZcK3AINtBBuZ4xJDPVG 8+RAsV/4U7niT9op6Ti0cqoGIe37iNRU+BoKtQowato0UZOrQ6FGv4Jlrbvhwtg/zHfnS5LnD BeUXicK14ttVQ6Z2/LeePzix0aWDcJJa7r5I+iT44kmGAxXiwllvFQOKl0wr3N925vX6vAfk+ YCKnpiCqfHLp7APz/qFgMuL16wDNJ0BCgsBLfV5+p1vYuguPkI7jq4LPVWH2YMqWJVdsAztgO 1XrmGd8AavOR366L/8mMj/Ycteaf43PCUcqXnX5jlRTiNgZQKYoRh410KDIWFeY8fG5ecvkg5 ownX5pEZHuI/3NW0s92TQZGtMgObQfgr56oQ= 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.13 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: , This is to introduce a runtime setup for libubootenv configuration file that overrides CONFIG_UBOOT_FWENV. Signed-off-by: Stefano Babic --- core/util.c | 27 +++++++++++++++++++++++++++ include/util.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/core/util.c b/core/util.c index 9ab0a17d..afe447fb 100644 --- a/core/util.c +++ b/core/util.c @@ -53,6 +53,12 @@ struct decryption_key { static struct decryption_key *aes_key = NULL; +/* + * Configuration file for fw_env.config + */ + +static char *fwenv_config = NULL; + char *sdup(const char *str) { char *p; if ((p = (char *) malloc(strlen(str) + 1)) != NULL) { @@ -573,6 +579,27 @@ int set_aes_ivt(const char *ivt) return 0; } +const char *get_fwenv_config(void) { + if (!fwenv_config) +#if defined(CONFIG_UBOOT) + return CONFIG_UBOOT_FWENV; +#else + return NULL; +#endif + return fwenv_config; +} + +void set_fwenv_config(const char *fname) { + if (!fname) + return; + + if (fwenv_config) + free(fwenv_config); + + fwenv_config = strdup(fname); +} + + char** string_split(const char* in, const char d) { char** result = 0; diff --git a/include/util.h b/include/util.h index 5f4cdc01..b50b58ec 100644 --- a/include/util.h +++ b/include/util.h @@ -234,6 +234,10 @@ long long get_output_size(struct img_type *img, bool strict); bool img_check_free_space(struct img_type *img, int fd); bool check_same_file(int fd1, int fd2); +/* location for libubootenv configuration file */ +const char *get_fwenv_config(void); +void set_fwenv_config(const char *fname); + /* Decryption key functions */ int load_decryption_key(char *fname); unsigned char *get_aes_key(void); From patchwork Mon Oct 9 15:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1845318 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=DQ58rW3w; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33b; helo=mail-wm1-x33b.google.com; envelope-from=swupdate+bncbaabb3vzscuqmgqeq37yc5i@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x33b.google.com (mail-wm1-x33b.google.com [IPv6:2a00:1450:4864:20::33b]) (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 4S431G6FpVz26jR for ; Tue, 10 Oct 2023 02:32:02 +1100 (AEDT) Received: by mail-wm1-x33b.google.com with SMTP id 5b1f17b1804b1-40590e6bd67sf33026135e9.2 for ; Mon, 09 Oct 2023 08:32:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696865519; cv=pass; d=google.com; s=arc-20160816; b=b6T6ly0I1LRdLg+rDtAquSYtZyYbPEmVTrQBTBHCtRgNm8EKBzNQcfmrj31O4530mb WkwePQKUcoigD2q2KSp0Pt6sIJAxrE5DN6KSzS57N46fnT29kD6DKgy0DTaCapI12DT7 Ru2xHEFRhs2CtnowcffKvwg9VTS4LI/JeGfluOLBKzCpsR/RkA+XegG7h7KuCjbPxuhS toAvmnqCRPQjNNahsEKTyylmYQppsbiHyIKh9200R7b5OAEQqaLkk05Rr/cICFNdFBC3 9E0XHf15imtwZhBpmO4QGxpFJZk5GXTx7fzuSz+Ol1H+uYA2Hl86lrKcx5be2pFwiD29 zn4w== 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=1BEcgjCaUm3bxb1iTWmOBTQNaxqHJoyiBQ7b8MjwD7Y=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=IQsLxhj0+L+MNqJ/4xTy2ckNbLt6ZJEz3VcHBnwrRz4fPRoijdfqUyn5BAMZmZrZ6j yRHCtSHMPNiTgcoL98a70xESjRNAKLsPnJqMPIZsgBrY44WSwQWbVXL3/JYXhr4ViaWU 67jULth/AcmgYNslOaHP/jKiffJf4KehlyWPcmENAgCmsH7uCoGwgyCON2T2G6CDFs4H jzr4NdytCx2XjhvJsZdo48TRO7dGK1mcD1ewiIg0qegx5wuDyu1RGgI7+f0IfCTeaqGx 8ir4f6JN7xgmHnE+rW8qOmaAPYtaB6Cg01LyWz0RuLsMMgK4iA+Y4vUm0rUjf2dnUVwz WFpw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 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=1696865519; x=1697470319; 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=1BEcgjCaUm3bxb1iTWmOBTQNaxqHJoyiBQ7b8MjwD7Y=; b=DQ58rW3wTPsBmS8WvI8fNEDsCrckcQJ+fHObKRdBT49/GDL2NucpFxrgRjuLEGXUgI Xi7S1/jSFrH4MyR1hwd9RBtRShg/3SZToHyyTok/FqTzSQ/x0rq/kdf3qR/bTXkkpdZB jPjOqLIO3oauDAx8NScBrUwfG7yp9CEqUR2vJQ+6eWcfX0X8qEHc8GA1jbFrsqiqm+YJ s5k+BjlV28oDKDtqkY2NQvsY53b8SeNIOzi4GGEnXkDk+z6LOjNx8ehee04JaV+Adlbk V2T/XxV7N5TOQM3HPWBcaOujR+v/djpZt0dV7E5X785CvMOUkyK+CSslL2KOK2PggsQD 1bsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865519; x=1697470319; 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=1BEcgjCaUm3bxb1iTWmOBTQNaxqHJoyiBQ7b8MjwD7Y=; b=O/0DAkEmoWXpZ1PD8Xkaky7V6bs0Ih0F+ebz2yy3RYf4Zi/EjOKFbKRxV2s2Fufyb0 yNqc8pNguPA1JokLQfPLxfZyWyHtisW9nLNMDzBhXS1nTM0ep3USmT0bFat3zCMfavua 7Kq7FC0s21Mt9i+7bD68FxHN9Va0BjD133inTCtFUYRlqUqLdOiHshkH3+qfa0VTWPwg /914njR9xbX+B/FJVXpCIjuLn5gg8bXGFZzK7nIMRGZ785WAtSGwXfbKYrtzHbXJV1eZ 1ftK7FC4WynmUIcTpcEs1EXoyZnxDq7dKBYNq8rMa2E3WgzC69pvfns5niOt3/1R8sbK KaiQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0Yyen3nsw/4UYRefkp/jpiJtU20UrETD4mcb/73EgHiC0S+MLteN 2D5DhGVVImRrXQrks+fMHu8= X-Google-Smtp-Source: AGHT+IHscPe/+wbG9b7vxMphFqNnV9yvUVSjNocPCdS3ajaqLHIvXvTDTF4sqgm3vjhgsm0dJ0Xoxw== X-Received: by 2002:adf:e3ca:0:b0:317:5b76:826 with SMTP id k10-20020adfe3ca000000b003175b760826mr12928848wrm.0.1696865518601; Mon, 09 Oct 2023 08:31:58 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:1c0f:b0:3fe:e8cf:2cdd with SMTP id j15-20020a05600c1c0f00b003fee8cf2cddls294545wms.2.-pod-prod-03-eu; Mon, 09 Oct 2023 08:31:56 -0700 (PDT) X-Received: by 2002:a05:600c:3d93:b0:406:f832:6513 with SMTP id bi19-20020a05600c3d9300b00406f8326513mr9629384wmb.3.1696865515945; Mon, 09 Oct 2023 08:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696865515; cv=none; d=google.com; s=arc-20160816; b=nHptuwDFkMJ6Fh7RgdBdZd9WbUdi+2kzQYKbtoAcWFXIpkdQ20UkAX37vkI+0rKsOa E3o6vGg32TKaogTbQpCx7wktMC5A2GH5b2cqkEyz6BIoCyL+PmhlTuvf69GqPycMUTMK HyOVPQbKWMe3c34O1ZGdhGbcoj/0N+r2CiJz2+BtDKYAD3z7zPGQA9s8ugqOOTbZogyq AzEAiAIm9kXnu2ZtmjAI45vl6Qy7rrnFQ2NfLEJwXg0JMZyfiHWjs8U73VaC7YCdLBX6 UhgFQmxmlali8nK85w0/GveFOAptw67h0sMk2kF4iwMyh09lFi/PGXQfDNBOV9B9IOIP ynkQ== 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=RQIWYsHkJKlibe74c9+K2ngrx5zqGk5EfzLoKzvw0qk=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=vBBOR9hKCwtKsp0+TR8c/NRAsWYRkABZ+Txed+UYdOOmB2Xd5Vy3355mN16+0NFeVP XxUhwQ8wCFl7RetHofTM31dKsGbM+Qo7DbiOL4aLsIA5kcxxf8kaeJ3ct5kxvI4ZFWCM Qyb7+HACOGL7BkIfPQRIn1wftNkzKCDqNfw2otTQqVI+5LvAte53wN25nplcV1CUdLRi K0mKAsDqiw7yK1i+f0Q6Zyzul/MSgTexJNnP5xgrRcPhQspQ/zYIT1/wBaM60++SGcoh VPH1YP6Rp5xZSMp4iq5eP7Ve8KEtjz8WpkPQXuaVn7lbSmUGCSymfykdmiM/LMHDSWaF 9UWg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.75]) by gmr-mx.google.com with ESMTPS id fm18-20020a05600c0c1200b00405c7dd428csi676723wmb.2.2023.10.09.08.31.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) client-ip=217.72.192.75; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1N1wdj-1raZtK25Wb-012DU8; Mon, 09 Oct 2023 17:31:55 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 6/7] Add attribute in swupdate.cfg to get fw_env.config Date: Mon, 9 Oct 2023 17:31:51 +0200 Message-Id: <20231009153152.416365-7-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009153152.416365-1-stefano.babic@swupdate.org> References: <20231009153152.416365-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:d9++Ld5nsOHAQVY65Wd98VuFkP8gSMAFTRvFm3Oiq4Y+4t7suVZ JjI3twdxN9x8kE7jUoYCreZjzGkQGtcMaSZqVRc7K9pZENSUIm9GhVtmoTbzk2xSS3vNDpR k4oR7Wi5kJPLx3R4gXUVrjmzBM+FvIdBXaHSEzjlIOH6cZL/CKVu0tZwVPIF72g49+ClS/+ g+MpWftYtN+CGrHElgODg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:wGcfnJFa1uU=;fBJULLoIoM6/I45hHH1wHcNYdbC rPDeOwDD97KUVN6ehGOsMsHPnj1f+mgRsUaDi+Cd4tNHS8WVBpnnSmm1kkuRrThhsysOCYijz fd+qC/Ljb05usZPswgvVVr9n7NmhXzjp2bED7OzuBBFLjfv850lGxzdgOHsMVDxMzOtthJo/3 543dkHjxq8nTnV2etuTEAF5Ho3uCJ9XXGdocu8cE4R5WabCwC0bdTZhwAeO3muOdLRh4lnI9n 7Y6ZwUWxM6LcvZMj5w7j2+1UP3lm21aJ4pY3RwbpscXdluzdu3dV2tQ9mnbB99jJBfCgw1+m6 Yy1hs/eq0sTtnkIL0/H8iiH4FZijAZIgIM1+KiC4PpfaVfl5c2jmFrKbWuJYqZ0wIC+qMMOcy xC3a/q6Bsp137/i2iHXpHfzn6fH4j6+b2fNQMeoStoZxziY2CH711H/1nlQWMqV9rf8L46kba lUQXCRnS0k3yQqVYxeJwWOGizEPDnsGeH6bWodAn9Wu9wPYLErxSQVd9e/VlXyGNn6kiUp6uE UBazlWYe1DPOgd+wkeftOBLzDdsZKKVNG6ZX4rHyfNhAnHo1/s34z5ATa+z/J7FT8dcvduk5i pZrcC4xzy4sN+9hiqq4roN7GgKCkowG/thp79YUH/X6MZaIwa7cvTxj0BpM2fpjInA93txrZE bRZp3TaBOm6EK9ZqL9ijr9JPbiyap/D82GiIC2sSJ6NNGily2Llg8iJ0ClAhuPVUJe58hUUCv GOVf1TRq/8cKptPi3GxYG/N+sCj8DLs5pF4nJXCKDERTnbLW3/Toh0sUVZfpZwLrDS/VyurKh uzmXpkkYdn/0g9rVp5x3AZURch91G2vtmXGT7FxM+tjiTlo3+/1btvDVH7ZIjwdPbbET+sHAL VQVwaeSuY6fBrYw== 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 217.72.192.75 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: , Add a way to override the compile option CONFIG_UBOOT_FWENV at runtime. Signed-off-by: Stefano Babic --- bootloader/uboot.c | 4 ++-- core/swupdate.c | 7 +++++++ examples/configuration/swupdate.cfg | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bootloader/uboot.c b/bootloader/uboot.c index 4be034df..a4802775 100644 --- a/bootloader/uboot.c +++ b/bootloader/uboot.c @@ -42,9 +42,9 @@ static int bootloader_initialize(struct uboot_ctx **ctx) int ret; const char *namespace = NULL; - ret = libuboot_read_config_ext(ctx, CONFIG_UBOOT_FWENV); + ret = libuboot_read_config_ext(ctx, get_fwenv_config()); if (ret) { - ERROR("Cannot initialize environment from %s", CONFIG_UBOOT_FWENV); + ERROR("Cannot initialize environment from %s", get_fwenv_config()); return -EINVAL; } diff --git a/core/swupdate.c b/core/swupdate.c index 07e5ef70..be78282f 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -321,6 +321,13 @@ static int read_globals_settings(void *elem, void *data) get_field(LIBCFG_PARSER, elem, "syslog", &sw->syslog_enabled); GET_FIELD_STRING(LIBCFG_PARSER, elem, "no-downgrading", sw->minimum_version); + tmp[0] = '\0'; + GET_FIELD_STRING(LIBCFG_PARSER, elem, + "fwenv-config-location", tmp); + if (strlen(tmp)) { + set_fwenv_config(tmp); + tmp[0] = '\0'; + } if (strlen(sw->minimum_version)) sw->no_downgrading = true; GET_FIELD_STRING(LIBCFG_PARSER, elem, diff --git a/examples/configuration/swupdate.cfg b/examples/configuration/swupdate.cfg index c9053ddf..16532c26 100644 --- a/examples/configuration/swupdate.cfg +++ b/examples/configuration/swupdate.cfg @@ -48,10 +48,10 @@ # Possible values are ebg, grub, uboot, and none for # EFI Boot Guard, U-Boot, GRUB, and the Environment in RAM bootloader, # respectively, given the respective bootloader support is compiled-in. -# # namespace-vars : namespace used by libubootenv for application/SWUpdate persistent # variables. This can be overridden in sw-description. # It is one set in libubootenv configuration file. +# fwenv-config-location : path of the configuration file for libubootenv globals : { From patchwork Mon Oct 9 15:31:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1845320 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=LGriOWqo; dkim-atps=neutral Authentication-Results: legolas.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+bncbaabb3vzscuqmgqeq37yc5i@googlegroups.com; receiver=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S431J2tTkz20cr for ; Tue, 10 Oct 2023 02:32:03 +1100 (AEDT) Received: by mail-lj1-x23b.google.com with SMTP id 38308e7fff4ca-2c135cf124csf38214421fa.2 for ; Mon, 09 Oct 2023 08:32:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696865520; cv=pass; d=google.com; s=arc-20160816; b=nSjCh2Urfgteo4EMFHbHDSeh/llVZeo/Q/UehkKFZhgiezmikFSzArUVGvyYc0l4LF N43U3X1FFRSVv0fc8gNeAg5+tBZ2kj/IeF4iMoEQG/oBCnsFvl44hO0dWTODIqRgOK4r g3OxaZh6yuA4VMgt+2muPDF4goT63POYr6+r5tb387YnJIvvp8V2B/rhsxPPQqwyymye 2fZtcfFeJRmulVSc7XZrm2P+P3fl2BMIDAFMR+OfSUEuov/hC19U1CAlluUzS7HW/qNW Vy0UQk0hQLvWDPHhm574hCZs08wlf5NqhL0MusghDpo56OxU95Cs1QOAcIEpoyziMn7g dO2Q== 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=IAQ7elK3SIY6BF0e0FxCgTxWOuEdGHZuspkKhFqSP80=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=KXmt8XJ+x7K/aASUxjzSXn82HciPuYA1kliPVNhjT32KOcoZKcuzQc+srm19O2Y08w aMHABjqOPJhqZsHecs3+gCuMUbQNyiF785Ny/kXvAdVLG3txtgiueAjJRQI37ixKLjRa KaamXJqoiwN8YYdXkv4Ji8iRjrRxsunKmfH8rzdMMueJ3DP4YmHYKnMUFl9S/2pfXQlZ 6tZtQ+KsLKPlq1wMiUiAZnZCNH4afKtuA9gwrVXI+QPUrSRSjvWCwPJW/vyrSxIp6PDk uhjPfE668VI9I3hngB0nya/tARU/Iml5GsZ6iZKJRqPS+BI0PhOVEL6BugWBYaGT+5ZK IWAg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 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=1696865520; x=1697470320; 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=IAQ7elK3SIY6BF0e0FxCgTxWOuEdGHZuspkKhFqSP80=; b=LGriOWqo/aE0iQF6R+KFwVPEKEQGLlxtvEyV2MEGg+DQovDUZqV4EfZkFsP44W3fBK Iqvz5rexmiXGEBkMEm8yUOL2d+d6zchUogG6gcpBl3klG/zmV/nqCrJUhDjRg99AxvVM OA3E8L1CLowpB2MRyNlPbHWiWc6Esxoxigpmoc46+XEiDkNqcwByI7aQWGE0QvR9xcte scQsJvHKcJcO7Lr5SFhiFUmDAADzz5/JjEfA4Q1tS+lcdd/X88LdLbelmfUUOR17dVok X7pwOVEPxsDWXq4n4zN6ksh8otjrLWfqUxMWMb+qKQjRBpVCA7mOAV1/fg+IiVf4TNgQ y/Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696865520; x=1697470320; 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=IAQ7elK3SIY6BF0e0FxCgTxWOuEdGHZuspkKhFqSP80=; b=Tgtu7SJ6t45+CSuOpJoKzCviabcKQ+i5u/tGoexrX+1IlRhHkxi04HGiFcBpk7GtG6 9CElImD3m7DrEahGbdcx8efb65SG9rY6URM/T9S04u0gs9x3n5UB9fUrbAbfT/VscCIs iGxplhn6kt6xb0oADFl3ljyoCwkBSwlsUym8yVuKeiOo1qZXZKExYbsuUB3Dwja07H5o TyyHgTShgT9zCti+f/ZP9cWjHAhubFA+6VQZGxYuN9F7NNS/vDjduIQMXCvgycIRwvd7 Iwu06UwnFAxYSqdlGEfbX2R9SVwAKowAL9H5mEA0wcoaaSOvvIjDJ0bnBx1CcARqbpFe kRWA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YyOfW1H2Z2iLiOMRnzLneDZH0BA6CqJA5NOdMNnh46kLojiRrkN T46aSD8KjMI/ykjdijTL7uc= X-Google-Smtp-Source: AGHT+IG/ZcgiMu3J5Hk7xBR/zVppGA2aSB9TEIDjsMkm3bVwtyCbEvXgmUf+oN5FJLd1m+e7etlxJg== X-Received: by 2002:a05:651c:22c:b0:2bc:f1d3:b54c with SMTP id z12-20020a05651c022c00b002bcf1d3b54cmr15192974ljn.20.1696865519196; Mon, 09 Oct 2023 08:31:59 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:9d93:0:b0:2bf:f55d:1df9 with SMTP id c19-20020a2e9d93000000b002bff55d1df9ls1538978ljj.1.-pod-prod-05-eu; Mon, 09 Oct 2023 08:31:57 -0700 (PDT) X-Received: by 2002:a19:2d56:0:b0:505:8075:7c17 with SMTP id t22-20020a192d56000000b0050580757c17mr12206948lft.22.1696865516413; Mon, 09 Oct 2023 08:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696865516; cv=none; d=google.com; s=arc-20160816; b=r8I9mUqPrJ0Vb7qYnPVySgPTpsk7i1IExbAb1EQ+GhcbVqr8hOKpV91wIpaPB6mqnY Oix2O7bsUMfXriZaim4G3SAwuPtfrHnu+19mEsn2+yGNzl6mknJYF201mBCXPfZiETbS VLPBH6Q6LZlpnwceA2C6tIgjb7ut3BdbaRa2tTqdRx2MpeV1J1rvcqMQJ5lhQUzFHUUG OHS7KpXR7dgIVDDjMEWjmzTDr2zlrD0dgIEJDEtrP8CD/GfuUFV+1OvqQztd3Af+NmM3 nKHtPvilgat2FRnMs5VCPGgUAeiPC/i+5gLy6WhtlyY0Hd+HHo7HweZC+xpLyWWS4Kxl sdkg== 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=mZY8ZoX7/W53zK/6XxrAzd4CbmbKKUxukqnw0bYCPAo=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Vpgwwdnk5YISTZOf5pkyu4lCAfKicu224WAawmdV9sbO+mkrABUe+OlmxsxDScf14g k1FG97zKgXCn/evvD0ombHE2tAgA2sKrAJcALfdgeWM5ZLZj5yK0seWZmZhfWaebp9vG l0rqR4z+lpw8AHhWDYcyOz1eGaIVnjVRJYJPhAtrGTMLzQPjEAFktIt/TdzTN3m9SR+W tvyqVFhNikw3yaR/i1+9/NOqVfixpy+r+8xzPZxSOruPADu2bwZ9VfOYzweRWJuyQyqs o5w9OWX3vVpy5oLdAN0J6zRLTZUtj45cnj/v1zE2XGvahaUlpFRkhV4KMzaw6saNBf+y pxTA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.75]) by gmr-mx.google.com with ESMTPS id o13-20020a05651205cd00b004ffa201cad8si424135lfo.9.2023.10.09.08.31.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 08:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.75 as permitted sender) client-ip=217.72.192.75; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MmDAc-1rGRXn2g4G-00iCjJ; Mon, 09 Oct 2023 17:31:55 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 7/7] Introduce SWUpdate persistent variables Date: Mon, 9 Oct 2023 17:31:52 +0200 Message-Id: <20231009153152.416365-8-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231009153152.416365-1-stefano.babic@swupdate.org> References: <20231009153152.416365-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:PLBcunKiRK8nH76WxxLNMnRXLes/GdmK+qVtKU0pWGVFTu8n1xF yZAoS0wbhyj+o2Y16TzYevkAREKW/BPkBcvcohXfhE8TAb8UQQy/SMGEyFamp10omGA+/oj bSCc/Kt+msFa5GwNyZi+nbrxVIJvS+8UE9okrHHZYyNYe4fLN5bCaHh1WCLdJJ14k5phMLU n6Q0nuxpmf9aC7V40JMjw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:/PGudx57wUE=;nSxqFemdJP2/9o6D7GiIbzaI+q4 /lPUDJbH1pOu2xxFAwtz7SG2/SLsaECvtQt2ukXcxcn4iGVgeWGoDRZZrsI/6ZWY0Dda6mXnn U1XwdgrDKqGlie2Zv3Oka4PV8+sndUmdjd/urz45XgAK2svdT+2wktjxlfkQiPEDKuWJ1ADJx 1M+7lpIpDJ7rYnT24EvKQ2Q4TkcWmIMoHvQcNbBY3WgmiKdgB8F8fN60ImBbS/9H2ynO6XfE8 kUT1nGio2yWtY9oeQOCt7TZhV5hozyYZo1nNY5eHF+olU7YHIJhQ3mR6Y/n/qHXKLtcgght21 YniCR0bblHKthWn37W2QIi83q2uS26vVppYjDjM78eKvb0HHa8+wTUKjFF2FhKmzOkz+EPWaa NwtqvNLAfudN36nRp2KQcuay0VsCHEn226D7IbCv32WIy80hDVgU3ArwOxX+G6ZltuEDqm+5x XPxmqn0ferjZQo8JnizjR3kpLPqQQckqTq/6KocYlHoKKmWflzTxI1fwUsauCWKsV00++q7Tz Dq710shpP10KmhUBS5NBlTi+Qi3AqgbuIRJ6OuyLiIVMCoJcafVU3fQlkFS8NrMkTaMOnJiLF ZtOjpWssp8IjWtY+CBy5NFaj02PcDLaCmB/6S9P5WZfAiPa2Pm+76EwytC9NlvJfFH39yJVu5 gW9alS/+iGJt1o/N7SrTkepWSozXZ3GYJOpkHXGNCvPLrbKj5ikeGBlKNFb8d3oTBzXc6EcTQ fuCjVtjY+Tj6w4/yKS6iprn2LTn78JU9zXYwNY5RmkBYnPr6ohrEq+pRiq8cO3X8DdSIJ8FuA t1Zxdv8a+DY2MczxRB3Q83Y7rMgCeGACNH49vAsZsK/DXFOScK8UV3jZ0TBI0yTE70UeUitR3 SmeNDaM93hXuLfXHLSYUjjEHoT6nYGeOLJBE= 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 217.72.192.75 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: , The reason for this is that there are many cases where an update does not require a reboot and does not require to involve the bootloader. Using bootloader's environment (mainly used up now) as several side-effects, for example for bootloader that foreseen states but not to set an arbitrary variable to a value (like EBG for example), and there is no need to change something for the bootloader. However, in case the bootloader is not involved, but a reboot is still required, SWUpdate needs to store persistently how the update ran. The libubootenv library is the interface to U-Boot, but it is able to store a U-Boot like environment (variable=value) on different places. Release 0.3.5 is able to handle multiple environment by extending the configuration file, and this can be used to have an environment for bootloader and an environment for SWUpdate. Not that libubootenv does not require U-Boot and can be used on systems with other bootloaders. The patch here store the variables set in sw-descriprion via the "vars" section in a libubootenv namespace configured at start up. Signed-off-by: Stefano Babic --- core/Makefile | 1 + core/installer.c | 38 +++++++++++-- core/swupdate_vars.c | 103 ++++++++++++++++++++++++++++++++++ doc/source/sw-description.rst | 28 +++++++++ include/swupdate_vars.h | 19 +++++++ 5 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 core/swupdate_vars.c create mode 100644 include/swupdate_vars.h diff --git a/core/Makefile b/core/Makefile index 621e6585..8cdf42c0 100644 --- a/core/Makefile +++ b/core/Makefile @@ -27,5 +27,6 @@ obj-y += swupdate.o \ parsing_library.o \ artifacts_versions.o \ swupdate_dict.o \ + swupdate_vars.o \ semver.o \ strlcpy.o diff --git a/core/installer.c b/core/installer.c index 0088d1a3..20b5b51e 100644 --- a/core/installer.c +++ b/core/installer.c @@ -32,6 +32,7 @@ #include "bootloader.h" #include "progress.h" #include "pctl.h" +#include "swupdate_vars.h" /* * function returns: @@ -162,8 +163,10 @@ static int prepare_var_script(struct dict *dict, const char *script) char buf[MAX_BOOT_SCRIPT_LINE_LENGTH]; fd = openfileoutput(script); - if (fd < 0) + if (fd < 0) { + ERROR("Temporary file %s cannot be opened for writing", script); return -1; + } LIST_FOREACH(bootvar, dict, next) { char *key = dict_entry_get_key(bootvar); @@ -194,6 +197,21 @@ static int update_bootloader_env(struct swupdate_cfg *cfg, const char *script) if ((ret = bootloader_apply_list(script)) < 0) { ERROR("Bootloader-specific error %d updating its environment", ret); } + + return ret; +} + +static int update_swupdate_vars(struct swupdate_cfg *cfg, const char *script) +{ + int ret = 0; + + ret = prepare_var_script(&cfg->vars, script); + if (ret) + return ret; + + if ((ret = swupdate_vars_apply_list(script, cfg->namespace_for_vars)) < 0) { + ERROR("Bootloader-specific error %d updating its environment", ret); + } return ret; } @@ -371,10 +389,18 @@ int install_images(struct swupdate_cfg *sw) return ret; } + char* script = alloca(strlen(TMPDIR)+strlen(BOOT_SCRIPT_SUFFIX)+1); + sprintf(script, "%s%s", TMPDIR, BOOT_SCRIPT_SUFFIX); + + if (!LIST_EMPTY(&sw->vars)) { + ret = update_swupdate_vars(sw, script); + if (ret) { + return ret; + } + } + if (!LIST_EMPTY(&sw->bootloader)) { - char* bootscript = alloca(strlen(TMPDIR)+strlen(BOOT_SCRIPT_SUFFIX)+1); - sprintf(bootscript, "%s%s", TMPDIR, BOOT_SCRIPT_SUFFIX); - ret = update_bootloader_env(sw, bootscript); + ret = update_bootloader_env(sw, script); if (ret) { return ret; } @@ -446,7 +472,11 @@ void cleanup_files(struct swupdate_cfg *software) { } } + /* + * drop environment databases + */ dict_drop_db(&software->bootloader); + dict_drop_db(&software->vars); if (asprintf(&fn, "%s%s", TMPDIR, BOOT_SCRIPT_SUFFIX) != ENOMEM_ASPRINTF) { remove_sw_file(fn); diff --git a/core/swupdate_vars.c b/core/swupdate_vars.c new file mode 100644 index 00000000..5d2f95ab --- /dev/null +++ b/core/swupdate_vars.c @@ -0,0 +1,103 @@ +/* + * (C) Copyright 2023 + * Stefano Babic, + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "generated/autoconf.h" +#include "util.h" +#include "dlfcn.h" +#include "bootloader.h" + +#include "swupdate_vars.h" + +static inline void libuboot_cleanup(struct uboot_ctx *ctx) +{ + libuboot_close(ctx); + libuboot_exit(ctx); +} + +int swupdate_vars_initialize(struct uboot_ctx **ctx, const char *namespace) +{ + int ret; + + if (!namespace) + return -EINVAL; + + ret = libuboot_read_config_ext(ctx, get_fwenv_config()); + if (ret) { + ERROR("Cannot initialize environment from %s", get_fwenv_config()); + return -EINVAL; + } + + *ctx = libuboot_get_namespace(*ctx, namespace); + + if (libuboot_open(*ctx) < 0) { + WARN("Cannot read environment, maybe still empty ?"); + } + + return 0; +} + +char *swupdate_vars_get(const char *name, const char *namespace) +{ + int ret; + struct uboot_ctx *ctx = NULL; + char *value = NULL; + + ret = swupdate_vars_initialize(&ctx, namespace); + if (!ret) { + value = libuboot_get_env(ctx, name); + } + libuboot_cleanup(ctx); + + return value; +} + +int swupdate_vars_set(const char *name, const char *value, const char *namespace) +{ + int ret; + struct uboot_ctx *ctx = NULL; + + ret = swupdate_vars_initialize(&ctx, namespace); + if (!ret) { + libuboot_set_env(ctx, name, value); + ret = libuboot_env_store(ctx); + } + + libuboot_cleanup(ctx); + + return ret; +} + +int swupdate_vars_unset(const char *name, const char *namespace) +{ + return swupdate_vars_set(name, NULL, namespace); +} + +int swupdate_vars_apply_list(const char *filename, const char *namespace) +{ + int ret; + struct uboot_ctx *ctx = NULL; + + ret = swupdate_vars_initialize(&ctx, namespace); + if (!ret) { + libuboot_load_file(ctx, filename); + ret = libuboot_env_store(ctx); + } + + libuboot_cleanup(ctx); + + return ret; +} diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 03f6faff..3b910295 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -948,6 +948,34 @@ For backward compatibility with previously built `.swu` images, the "uboot" group name is still supported as an alias. However, its usage is deprecated. +SWUpdate persistent variables +----------------------------- + +Not all updates require to inform the bootloader about the update, and in many cases a +reboot is not required. There are also cases where changing bootloader's environment +is unwanted due to restriction for security. +SWUpdate needs then some information after new software is running to understand if +everything is fine or some actions like a fallback are needed. SWUpdate can store +such as information in variables (like shell variables), that can be stored persistently. +The library `libubootenv` provide a way for saving such kind as database in a power-cut safe mode. +It uses the algorythm originally implemented in the U-Boot bootloader. It is then guaranteed +that the system will always have a valid instance of the environment. The library supports multiple +environment databases at the same time, identifies with `namespaces`. +SWUpdate should be configured to set the namespace used for own variables. This is done by setting +the attribute *namespace-vars* in the runtime configuration file (swupdate.cfg). See also +example/configuration/swupdate.cfg for details. + +The format is the same used with bootloader for single variable: + + vars: ( + { + name = ; + value = ; + } + ) + +SWUpdate will set these variables all at once like the bootloader variables. These environment +is stored just before writing the bootloader environment, that is always the last step in an update. Board specific settings ----------------------- diff --git a/include/swupdate_vars.h b/include/swupdate_vars.h new file mode 100644 index 00000000..0334f427 --- /dev/null +++ b/include/swupdate_vars.h @@ -0,0 +1,19 @@ +/* + * (C) Copyright 2023 + * Stefano Babic, + * + * SPDX-License-Identifier: GPL-2.0-only + */ + +#ifndef _SWVARS_H +#define _SWVARS_H + +#include + +int swupdate_vars_initialize(struct uboot_ctx **ctx, const char *namespace); +int swupdate_vars_apply_list(const char *filename, const char *namespace); +char *swupdate_vars_get(const char *name, const char *namespace); +int swupdate_vars_set(const char *name, const char *value, const char *namespace); +int swupdate_vars_unset(const char *name, const char *namespace); + +#endif