Skip to content

meta-lxatac-software: tacd{,-webinterface}: implement native RAUC update polling #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: scarthgap
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
From 7a68ed8f8865cd5ad8562ee3f5aa8189c5908baa Mon Sep 17 00:00:00 2001
From: Jan Luebbe <[email protected]>
Date: Thu, 20 Feb 2025 16:14:09 +0100
Subject: [PATCH 01/23] refactor RaucBundleAccessArgs->http_info_headers from
GStrv to GPtrArray

Keeping it as a GPtrArray makes it it easy to modify after the initial
creation and also avoids the need to keep a trailing NULL pointer. In a
follow-up commit, we'll make assemble_info_headers usable for bundle
inspection as well.

Signed-off-by: Jan Luebbe <[email protected]>
---
include/bundle.h | 2 +-
include/nbd.h | 2 +-
src/bundle.c | 5 +++--
src/install.c | 7 +++----
src/nbd.c | 5 +++--
5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/bundle.h b/include/bundle.h
index eb64944d..6e14bdfb 100644
--- a/include/bundle.h
+++ b/include/bundle.h
@@ -29,7 +29,7 @@ typedef struct {
gchar *tls_ca;
gboolean tls_no_verify;
GStrv http_headers;
- GStrv http_info_headers;
+ GPtrArray *http_info_headers;
} RaucBundleAccessArgs;

typedef struct {
diff --git a/include/nbd.h b/include/nbd.h
index fd0b2428..8fe2846d 100644
--- a/include/nbd.h
+++ b/include/nbd.h
@@ -39,7 +39,7 @@ typedef struct {
gchar *tls_ca; /* local file */
gboolean tls_no_verify;
GStrv headers; /* array of strings such as 'Foo: bar' */
- GStrv info_headers; /* array of strings such as 'Foo: bar' */
+ GPtrArray *info_headers; /* array of strings such as 'Foo: bar' */

/* discovered information */
guint64 data_size; /* bundle size */
diff --git a/src/bundle.c b/src/bundle.c
index 59cd036d..96d31cdc 100644
--- a/src/bundle.c
+++ b/src/bundle.c
@@ -2343,7 +2343,8 @@ gboolean check_bundle(const gchar *bundlename, RaucBundle **bundle, CheckBundleP
ibundle->nbd_srv->tls_ca = g_strdup(access_args->tls_ca);
ibundle->nbd_srv->tls_no_verify = access_args->tls_no_verify;
ibundle->nbd_srv->headers = g_strdupv(access_args->http_headers);
- ibundle->nbd_srv->info_headers = g_strdupv(access_args->http_info_headers);
+ if (access_args->http_info_headers)
+ ibundle->nbd_srv->info_headers = g_ptr_array_ref(access_args->http_info_headers);
}
if (!ibundle->nbd_srv->tls_cert)
ibundle->nbd_srv->tls_cert = g_strdup(r_context()->config->streaming_tls_cert);
@@ -3283,7 +3284,7 @@ void clear_bundle_access_args(RaucBundleAccessArgs *access_args)
g_free(access_args->tls_key);
g_free(access_args->tls_ca);
g_strfreev(access_args->http_headers);
- g_strfreev(access_args->http_info_headers);
+ g_clear_pointer(&access_args->http_info_headers, g_ptr_array_unref);
}

memset(access_args, 0, sizeof(*access_args));
diff --git a/src/install.c b/src/install.c
index 3b292fe8..49852a04 100644
--- a/src/install.c
+++ b/src/install.c
@@ -1526,9 +1526,9 @@ static gchar *system_info_to_header(const gchar *key, const gchar *value)
return g_strdup_printf("RAUC-%s: %s", header_key, value);
}

-static gchar **assemble_info_headers(RaucInstallArgs *args)
+static GPtrArray *assemble_info_headers(RaucInstallArgs *args)
{
- GPtrArray *headers = g_ptr_array_new_with_free_func(g_free);
+ g_autoptr(GPtrArray) headers = g_ptr_array_new_with_free_func(g_free);

g_return_val_if_fail(args, NULL);

@@ -1569,9 +1569,8 @@ no_std_headers:
g_ptr_array_add(headers, header);
}
}
- g_ptr_array_add(headers, NULL);

- return (gchar**) g_ptr_array_free(headers, FALSE);
+ return g_steal_pointer(&headers);
}

gboolean do_install_bundle(RaucInstallArgs *args, GError **error)
diff --git a/src/nbd.c b/src/nbd.c
index d9677bb3..518bbc60 100644
--- a/src/nbd.c
+++ b/src/nbd.c
@@ -86,7 +86,7 @@ void r_nbd_free_server(RaucNBDServer *nbd_srv)
g_free(nbd_srv->tls_key);
g_free(nbd_srv->tls_ca);
g_strfreev(nbd_srv->headers);
- g_strfreev(nbd_srv->info_headers);
+ g_clear_pointer(&nbd_srv->info_headers, g_ptr_array_unref);
g_free(nbd_srv->effective_url);
g_free(nbd_srv);
}
@@ -1032,7 +1032,8 @@ static gboolean nbd_configure(RaucNBDServer *nbd_srv, GError **error)
if (nbd_srv->headers)
g_variant_dict_insert(&dict, "headers", "^as", nbd_srv->headers);
if (nbd_srv->info_headers)
- g_variant_dict_insert(&dict, "info-headers", "^as", nbd_srv->info_headers);
+ g_variant_dict_insert(&dict, "info-headers", "@as",
+ g_variant_new_strv((const gchar **)nbd_srv->info_headers->pdata, nbd_srv->info_headers->len));
v = g_variant_dict_end(&dict);
{
g_autofree gchar *tmp = g_variant_print(v, TRUE);
--
2.39.5

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From ac528c5b8c20de71497439e297d5655551aa4555 Mon Sep 17 00:00:00 2001
From: Jan Luebbe <[email protected]>
Date: Tue, 25 Feb 2025 10:31:16 +0100
Subject: [PATCH 02/23] src/install: refactor assemble_info_headers to avoid
access to install args

We want to use this function for all streaming bundle accesses, not just
installations.

Signed-off-by: Jan Luebbe <[email protected]>
---
src/install.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/install.c b/src/install.c
index 49852a04..ac4c39fd 100644
--- a/src/install.c
+++ b/src/install.c
@@ -1526,12 +1526,10 @@ static gchar *system_info_to_header(const gchar *key, const gchar *value)
return g_strdup_printf("RAUC-%s: %s", header_key, value);
}

-static GPtrArray *assemble_info_headers(RaucInstallArgs *args)
+static GPtrArray *assemble_info_headers(const gchar *transaction)
{
g_autoptr(GPtrArray) headers = g_ptr_array_new_with_free_func(g_free);

- g_return_val_if_fail(args, NULL);
-
if (!r_context()->config->enabled_headers)
goto no_std_headers;

@@ -1546,8 +1544,8 @@ static GPtrArray *assemble_info_headers(RaucInstallArgs *args)
if (g_strcmp0(*header, "variant") == 0)
g_ptr_array_add(headers, g_strdup_printf("RAUC-Variant: %s", r_context()->config->system_variant));
/* Add per-installation information */
- if (g_strcmp0(*header, "transaction-id") == 0)
- g_ptr_array_add(headers, g_strdup_printf("RAUC-Transaction-ID: %s", args->transaction));
+ if (g_strcmp0(*header, "transaction-id") == 0 && transaction != NULL)
+ g_ptr_array_add(headers, g_strdup_printf("RAUC-Transaction-ID: %s", transaction));
/* Add live information */
if (g_strcmp0(*header, "uptime") == 0) {
g_autofree gchar *uptime = get_uptime();
@@ -1604,7 +1602,7 @@ gboolean do_install_bundle(RaucInstallArgs *args, GError **error)
// TODO: mount info in context ?
install_args_update(args, "Checking and mounting bundle...");

- args->access_args.http_info_headers = assemble_info_headers(args);
+ args->access_args.http_info_headers = assemble_info_headers(args->transaction);

res = check_bundle(bundlefile, &bundle, CHECK_BUNDLE_DEFAULT, &args->access_args, &ierror);
if (!res) {
--
2.39.5

Loading