From patchwork Wed Jun 5 10:47:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "vincent....@gmail.com" X-Patchwork-Id: 1943800 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=MotsfFoH; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=REOl9NBW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::539; helo=mail-ed1-x539.google.com; envelope-from=swupdate+bncbdylnjxztmcrbsmeqgzqmgqeum64irq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x539.google.com (mail-ed1-x539.google.com [IPv6:2a00:1450:4864:20::539]) (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 4VvPLW1bfHz20WK for ; Wed, 5 Jun 2024 20:47:47 +1000 (AEST) Received: by mail-ed1-x539.google.com with SMTP id 4fb4d7f45d1cf-57a678615f0sf1906792a12.2 for ; Wed, 05 Jun 2024 03:47:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717584459; cv=pass; d=google.com; s=arc-20160816; b=Qo7H9o3n8Ylbj/6OkHHv8AfX/9R1Hf0R7PK7EAs3tWGZA9/TJakGn3nDkrIxMNkQQg XLX50IIs/FK3dzfXdTCBQn+/cx+LR1flJjaVuyKwtsC9hXt1ZVLmJ2yCQ+yD1ojbunM1 E3jvuIyqM/XutfKDbdMVRUqHf1qV7s9n8178MRhEgwY+7iM1Yr/nfYNqpjR0uYi5dBbq Kdqp4NAuvHnKBb9zudT9XiPMTqjxAag6EmhjQjQkMbL/ZgJQIIP9VyDsBz3V+/nx8Vqs kTa2RnjZytPKspAZPU8l2wQUIjIdBvINunFahxFciYDLGvtqpelX3qnv8m1mY7mz6jny iTwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=IRmx32TgALW/QgoEgedWrr+axoYQoCV8Bnk2u9MioJY=; fh=0bJLiSKK7Qj39Sv8MYsQA3siGpmkvtdCaP9U/cgLYog=; b=C3vdPv+hiWxLsC9nwK4soxA2Uwx9NDESnmJA2nY0E/Ke49quAFgERP3XFwbEybbI2d 0IzKaBbtjkWAFTRGygDfvvDGU5yHOqIeA/cmnatFV6HaQHSX5/4GTMFfW+7lTyCsWE9t +RdNO/hUAU02EtiwB9u2bpznIJxA8pARzJvhkdVFFGzT100r4RM6Gf90AvhMDgTJVC3I U3BosCtZ5kVikXpADGvvbyFhPrbuouVCJOUPVgGO8KVRgzDJfSPIFxVRv2h37+aDHcrb b6kCpdF8P4d7jshwMjngpMiGeglHZYeD1gDUVqt5gwNZjdnJprfnrZp8RWysfFLTg8RW RPIA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nZ4ipehM; spf=pass (google.com: domain of vincent.prince.fr@gmail.com designates 2a00:1450:4864:20::132 as permitted sender) smtp.mailfrom=vincent.prince.fr@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1717584459; x=1718189259; 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:mime-version:message-id:date:subject:cc:to:from :sender:from:to:cc:subject:date:message-id:reply-to; bh=IRmx32TgALW/QgoEgedWrr+axoYQoCV8Bnk2u9MioJY=; b=MotsfFoHQMRVz8MDpg3KfMhm46azIC25oz1eUgb532gSJUo4oY+LdiYNCBb2gDKekB OqlrvwFmOlaQ7m8MAi0/8H4/Byvvp7fEgq0Sxm3XghZI5EMtqGvtc01KBzPH3nAXqi9b QkEt6WYrwmERTEsV+STRBxHQSiR+T25ff7TvgOf937yVwfeZVIYs0RADUYuu+geqvic4 RvBw0jRqAxzpzOt4VaSgVegpi+QMlI5eR84wSkaQe+956M5KCubEn36CzLcHq5cNJKzM QIquvXLN0fv1rwN3a0OACZjfYv0WEYdxcCs5QGxH3tOXCW7qPec46ymuNRFfhNJqppvY NlVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717584459; x=1718189259; 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:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=IRmx32TgALW/QgoEgedWrr+axoYQoCV8Bnk2u9MioJY=; b=REOl9NBWrgszf9msq5YwYNw2e3A3WtrX0eAAzlt4EkQabi7tXm/lJgVi2vZReU/HRz dcQ9Wx0n+m5P5g+fUNgYpv0vLoTV0NwcMgTE4+R1lNVZJMa4SMqMLgdDuN55KrDGu+xz N5djGoAL5GPz0XY1LRIZRHCGJkbN3mcA/gRFOYosJtJbnR/tVFumPfNrKYgMRNg6ImMz c4Moatza0KTAGPTlIFTqmozVG4Ny0MOzi4ijyPIQbJMUoCzp/A7hqkCV+bB1rn7l3L6o kdNm2n6dwkQ2ZfZmAofIFqqrbSmouxz3MwhQ2aq45yO7n5rlFPKYGex5dUqAPX9/FbcR wviQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717584459; x=1718189259; 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:mime-version :message-id:date:subject:cc:to:from:x-beenthere:x-gm-message-state :sender:from:to:cc:subject:date:message-id:reply-to; bh=IRmx32TgALW/QgoEgedWrr+axoYQoCV8Bnk2u9MioJY=; b=lyJVLyzRBJFMrWAuzuZI5ihcEpOV3LOY53AXfnIdFhkkwcYPZj1lJZ47nHfh3+a219 RiV5QPbK8gmLdzp5YYddonkY/pBVDz29mrst9rlVASbiCUhpKNff3YfJjhGGMO+hbIlE xdlgemM2W74dKMnXNGvMqoqJh0lu6H+MjKDGjASsiMgEObQ7uERu8cdrTEOKih5sHjLY L8RmQ4DwuproLyI5j66bKkor1sGbTVfVKWi3hB2kXA3RLKIuXZD3cBKALIg5Zy3qQRPj FSEhgFqUl3wDQj23i4vlM6yI72EJSl4mCcgLvhZqCZO0zGzS+Pnob1E16wUtzHYxvRPv PH7g== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUByAff5fDMcIqOj1DmpTra+mIf3ULSo3K9uH9WotuzvwWD3SymfeJhTs7jVQbMPcPYbKtLvCOuXQ16R3LRd0sN7A3TMjFFB783oGoVqQ== X-Gm-Message-State: AOJu0YyQGxNT0pPc62Xs1ikfyR0rwdcToO1Kh+dTzjjmhYvjIy56v2ka aIakVMRaBXML2QRavb32bThN0/Q+BF9I4vs9bnc+RdP/oA8cLPM6 X-Google-Smtp-Source: AGHT+IH4S2Ip5f01WrHvUFyuzPUbB7UKgOFVf4NKloXDk1R1imEoKwyohst/IBU3ss47LRsnDsHb3w== X-Received: by 2002:a50:99c7:0:b0:579:eb77:6d85 with SMTP id 4fb4d7f45d1cf-57a8b7c7cfbmr1698977a12.27.1717584458745; Wed, 05 Jun 2024 03:47:38 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:5309:b0:57a:5e7b:3e17 with SMTP id 4fb4d7f45d1cf-57a5e7b3fd9ls1729814a12.1.-pod-prod-08-eu; Wed, 05 Jun 2024 03:47:36 -0700 (PDT) X-Received: by 2002:a50:8717:0:b0:57a:857d:ea66 with SMTP id 4fb4d7f45d1cf-57a8b5288c2mr2063714a12.0.1717584455977; Wed, 05 Jun 2024 03:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717584455; cv=none; d=google.com; s=arc-20160816; b=zRqa4eWEMgeWClfvZXDqAZa7xG2mNNR72EzvK5O6KscSKHP0YKJ8RuRKbr36I/MvIk OJ7/5sIBRRiRPZiT2f7ZRWOlmDA1xmDj+Vd4HAYLCXGANhMDc8/2WCPLy57Md/xvqNxc TWXGjQm2o3vMkZrRmpnXKP7ScgNeYjHmyFliyvXJGblqZoNJRBbLyHVjN4dUAMm0H6HV 2zjDR2tY3horSrlDvPzebYaGC9RepAuz/M3aMf9f3rVZfFmUV0d5LC/cmEoeDpwM/nR7 A8bRh8ETFxqESd2FqxBuRel/c4CD+hR1m2HhEAOw9OgFXWws6Pmyc62Hy3dpX7u1YqKP FEkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=kWA5cTv8QJOkYprK9Hqh+uS8Jy4NJoVkL6TfRtE+5aU=; fh=PDuZKrEujWZeM7B6eqWfpnot+99ybB5FvAMlwJHVrVE=; b=XCI8clFQXQA0AenAU7YgWCXz+5s5NlOJ17jUl92goqUxsy8bUsKcs56nloVZtIV55C rMZtBiC0TwYb3g1SlHe3TPWvveFhMQh8JLwSV9jhq3vNFzoOK2kT+3RPn06IEripwzmv UY+AMyWvo1OFBPGvRG0uBfUE/5In+1mLcV4BjdJ1PxaruCrZ16maITehtwAMJeAq7yGH Q7NEzQZeL5tTn1yJ19rL8hgWtcQ0zaiaUBFO4JRphfwSZ+tuitbEkoeeM9trj1rnv4DV ysOyeBwKAJAfIySccbx9tvzKGK62PO6U4Uzrbnq5nea9w4PN+VRiUcZtIoBYsofbfXai kHOg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nZ4ipehM; spf=pass (google.com: domain of vincent.prince.fr@gmail.com designates 2a00:1450:4864:20::132 as permitted sender) smtp.mailfrom=vincent.prince.fr@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com. [2a00:1450:4864:20::132]) by gmr-mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31cced43si238612a12.5.2024.06.05.03.47.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jun 2024 03:47:35 -0700 (PDT) Received-SPF: pass (google.com: domain of vincent.prince.fr@gmail.com designates 2a00:1450:4864:20::132 as permitted sender) client-ip=2a00:1450:4864:20::132; Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-52b912198a6so4356720e87.0 for ; Wed, 05 Jun 2024 03:47:35 -0700 (PDT) X-Received: by 2002:a19:6a16:0:b0:524:652e:1696 with SMTP id 2adb3069b0e04-52bab510a77mr1625188e87.60.1717584454997; Wed, 05 Jun 2024 03:47:34 -0700 (PDT) Received: from cubedev-vpr.corporate.saft.org ([147.161.181.115]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd066ff17sm14049248f8f.116.2024.06.05.03.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 03:47:34 -0700 (PDT) From: Vincent Prince To: swupdate@googlegroups.com Cc: Vincent Prince Subject: [swupdate] [PATCH] suricatta: save action_id in grubenv when in use Date: Wed, 5 Jun 2024 12:47:32 +0200 Message-Id: <20240605104732.5335-1-vincent.prince.fr@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Original-Sender: vincent.prince.fr@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nZ4ipehM; spf=pass (google.com: domain of vincent.prince.fr@gmail.com designates 2a00:1450:4864:20::132 as permitted sender) smtp.mailfrom=vincent.prince.fr@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , When GRUB is selected as bootloader, use GRUB environment file to save action_id instead of using libubootenv methods Signed-off-by: Vincent Prince --- suricatta/server_hawkbit.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/suricatta/server_hawkbit.c b/suricatta/server_hawkbit.c index 9c3e9741..f2a6edf7 100644 --- a/suricatta/server_hawkbit.c +++ b/suricatta/server_hawkbit.c @@ -32,6 +32,7 @@ #include "swupdate_settings.h" #include "swupdate_dict.h" #include "swupdate_vars.h" +#include "bootloader.h" #define INITIAL_STATUS_REPORT_WAIT_DELAY 10 @@ -868,7 +869,14 @@ static void get_action_id_from_env(int *action_id) * stored. */ *action_id = -1; - char *action_str = swupdate_vars_get("action_id", NULL); + char *action_str = NULL; + + if (is_bootloader(BOOTLOADER_GRUB)) { + action_str = bootloader_env_get("action_id"); + } else { + action_str = swupdate_vars_get("action_id", NULL); + } + if (action_str) { int tmp = ustrtoull(action_str, NULL, 10); if (errno) @@ -882,6 +890,8 @@ static void get_action_id_from_env(int *action_id) TRACE("Retrieve action_id from previous run: %d", *action_id); } free(action_str); + } else { + INFO("'action_id' not found in environment."); } } @@ -951,7 +961,11 @@ server_op_res_t server_handle_initial_state(update_state_t stateovrrd) /* * Everything fine, reset action_id if any */ - swupdate_vars_set("action_id", NULL, NULL); + if (is_bootloader(BOOTLOADER_GRUB)) { + bootloader_env_unset("action_id"); + } else { + swupdate_vars_set("action_id", NULL, NULL); + } /* NOTE (Re-)setting STATE_KEY=STATE_OK == '0' instead of deleting it * as it may be required for the switchback/recovery U-Boot logics. @@ -1112,9 +1126,17 @@ server_op_res_t server_process_update_artifact(int action_id, ERROR("OOM reached when saving action_id"); return SERVER_EERR; } - if (swupdate_vars_set("action_id", action_id_str, NULL)) { - WARN("Action_id cannot be stored, do yourself"); - } + + int ret; + if (is_bootloader(BOOTLOADER_GRUB)) { + ret = bootloader_env_set("action_id", action_id_str); + } else { + ret = swupdate_vars_set("action_id", action_id_str, NULL); + } + if (ret) { + WARN("Action_id cannot be stored, do yourself"); + } + free(action_id_str); for (int json_data_artifact_count = 0;