eBPF-based security platform
shirudo-build: share the download of a package pinned by its digest
John Fastabendec1e44a99caf
diff --git a/tools/shirudo-build/bpm-build.c b/tools/shirudo-build/bpm-build.cindex 1ed556bd..ffa385aa 100644--- a/tools/shirudo-build/bpm-build.c+++ b/tools/shirudo-build/bpm-build.c@@ -2087,13 +2087,8 @@ out:return ret;}-/*- * The package of the manifest whose digest the operator named: a tag is- * the registry's to point at any package the key ever signed, an older- * one included, whose loaders config update would sign as a new version.- */-static int build_download_package(const char *reference, const char *want,- char *path)+int build_download_package(const char *cmd, const char *reference,+ const char *want, char *path){struct bpm_oci_client client __cleanup(bpm_oci_client_clear) = {};struct bpm_descriptor layers[8] = {};@@ -2121,7 +2116,7 @@ static int build_download_package(const char *reference, const char *want,if (ret)goto out;if (!bpm_digest_matches(want, digest)) {- pr_err("bpm config update: %s serves manifest sha256:%s, not %s",+ pr_err("%s: %s serves manifest sha256:%s, not %s", cmd,reference, digest, want);ret = -EKEYREJECTED;goto out;@@ -2250,8 +2245,8 @@ static int __build_bpm_config_update(int argc, const char **argv,return -EINVAL;}if (base_digest) {- ret = build_download_package(base_arg, base_digest,- base_package_tmp);+ ret = build_download_package("bpm config update", base_arg,+ base_digest, base_package_tmp);if (ret)return ret;if (strscpy(base_package, base_package_tmp,diff --git a/tools/shirudo-build/bpm.h b/tools/shirudo-build/bpm.hindex 72167f76..f0c80faf 100644--- a/tools/shirudo-build/bpm.h+++ b/tools/shirudo-build/bpm.h@@ -145,6 +145,18 @@ int build_tree_fetch_sealed(struct bpm_oci_client *c, const char *repository,int build_check_keys(const char *pkey, const char *cert);+/*+ * Downloads the package layer of the manifest at reference, an+ * oci://host/repository:tag, into a new file made from the mkstemp()+ * template path, and checks it against want, the manifest digest the+ * operator named: a tag is the registry's to point at any package the+ * key ever signed, an older one included. Messages start with cmd. 0, or+ * a negative errno with no file left behind; -EKEYREJECTED when the+ * registry serves other bytes.+ */+int build_download_package(const char *cmd, const char *reference,+ const char *want, char *path);+/* The file name of source less .bpf.c, .bpf.o or .o. 0 or -E2BIG. */int build_upatch_name(const char *source, char *out, size_t cap);