Skip to content

eBPF-based security platform

treewide: drop the shirudo_ prefix from internal function names

Daniel Borkmann4a8a295308b6
diff --git a/Makefile.shirudo b/Makefile.shirudo
index 270aaa2a..75c37c99 100644
--- a/Makefile.shirudo
+++ b/Makefile.shirudo
@@ -586,7 +586,7 @@ build/verity-tests/shirudo-image-fault: testing/helper/image-fault.c \
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(RPATH_LDFLAGS) \
$(VERITY_TEST_LDFLAGS) -o $@ $(filter-out %.h,$^) \
-Wl,--wrap=main,--wrap=Esys_PCR_Extend \
- -Wl,--wrap=shirudo_config_root_begin,--wrap=shirudo_config_root_end \
+ -Wl,--wrap=config_root_begin,--wrap=config_root_end \
$(STATIC_LIBS) $(VERITY_TEST_LIBS)
verity-test-helpers: $(VERITY_TEST_HELPERS) build/verity-tests/shirudo-image-fault
@@ -847,7 +847,7 @@ testing/helper/test-image-cleanup: testing/helper/test-image-cleanup.c \
@printf ' CC $@\n'
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(RPATH_LDFLAGS) -o $@ \
$(filter-out %.h util/image_runtime.c,$^) \
- -Wl,--wrap=shirudo_dm_verity_remove,--wrap=usleep \
+ -Wl,--wrap=dm_verity_remove,--wrap=usleep \
$(STATIC_LIBS) $(DYNAMIC_LIBS)
testing/helper/test-mode-objects: testing/helper/test-mode-objects.c \
diff --git a/builtin-attest.c b/builtin-attest.c
index 81919ae4..dd7d2b22 100644
--- a/builtin-attest.c
+++ b/builtin-attest.c
@@ -551,7 +551,7 @@ static int cmd_attest_verify(int argc, const char **argv)
if (parse_u64(a + 20, strlen(a + 20), 15, &pcr) ||
x.have_config_pcr ||
- shirudo_config_measure_pcr_valid(pcr))
+ config_measure_pcr_valid(pcr))
goto out;
x.config_pcr = pcr;
x.have_config_pcr = true;
@@ -819,9 +819,9 @@ static int cmd_attest_evidence(int argc, const char **argv)
}
request = challenge_path ? &challenge : NULL;
- ret = shirudo_attest_evidence_config(nonce, nonce_len, mask, request,
- shirudo_image_update_context(),
- &doc, &len, &cap);
+ ret = attest_evidence_config(nonce, nonce_len, mask, request,
+ image_update_context(),
+ &doc, &len, &cap);
if (ret == -ENXIO) {
pr_err("attest: no TPM answered (tpm_error)");
return 1;
diff --git a/builtin-bpm.c b/builtin-bpm.c
index ec94def3..93abd509 100644
--- a/builtin-bpm.c
+++ b/builtin-bpm.c
@@ -289,7 +289,7 @@ static int source_path(const char *name, char *out, size_t out_sz)
*/
static int stream_untrusted(FILE *fp, const char *path)
{
- if (shirudo_image_config_active())
+ if (image_config_active())
return 0;
return check_trusted(fileno(fp), path, false);
}
@@ -299,9 +299,9 @@ static FILE *source_open(const char *path)
{
int fd;
- if (!shirudo_image_config_active())
+ if (!image_config_active())
return fopen(path, "r");
- fd = shirudo_image_open_relative(path + 1, O_RDONLY);
+ fd = image_open_relative(path + 1, O_RDONLY);
if (fd < 0) {
errno = -fd;
return NULL;
@@ -313,10 +313,10 @@ static DIR *registries_opendir(void)
{
int fd;
- if (!shirudo_image_config_active())
+ if (!image_config_active())
return opendir(BPM_REGISTRIES_DIR);
- fd = shirudo_image_open(SHIRUDO_IMAGE_REGISTRIES,
- O_RDONLY | O_DIRECTORY);
+ fd = image_open(SHIRUDO_IMAGE_REGISTRIES,
+ O_RDONLY | O_DIRECTORY);
if (fd < 0) {
errno = -fd;
return NULL;
@@ -328,9 +328,9 @@ static FILE *tree_conf_open(void)
{
int fd;
- if (!shirudo_image_config_active())
+ if (!image_config_active())
return fopen(BPM_TREE_ETC_PATH, "r");
- fd = shirudo_image_open(SHIRUDO_IMAGE_TREE_CONF, O_RDONLY);
+ fd = image_open(SHIRUDO_IMAGE_TREE_CONF, O_RDONLY);
if (fd < 0) {
errno = -fd;
return NULL;
@@ -372,7 +372,7 @@ static int load_source(const char *name, struct bpm_source *s)
if (!s->endpoint[0] || !s->key_file[0])
return -EINVAL;
/* With a config image the key file is the image's, named from its root. */
- if (shirudo_image_config_active()) {
+ if (image_config_active()) {
if (!strncmp(s->key_file, "/etc/shirudo/bpm/keys/", 22))
memmove(s->key_file, s->key_file + 1,
strlen(s->key_file));
@@ -388,9 +388,9 @@ static int verify_with_source_key(const struct bpm_source *s,
{
int fd, ret;
- if (!shirudo_image_config_active())
+ if (!image_config_active())
return bpm_verify_cms(data, len, sig, sig_len, s->key_file);
- fd = shirudo_image_open_relative(s->key_file, O_RDONLY);
+ fd = image_open_relative(s->key_file, O_RDONLY);
if (fd < 0)
return fd;
ret = bpm_verify_cms_fd(data, len, sig, sig_len, fd);
@@ -1337,18 +1337,18 @@ static int package_install(const struct bpm_source *s, const struct bpm_index_en
}
sort_old_pairs(old_unloads, old_loads, nold);
for (int old_i = 0; old_i < nold; old_i++) {
- if (shirudo_upatch_remove(old_unloads[old_i])) {
+ if (upatch_remove(old_unloads[old_i])) {
ret = -EIO;
for (int restore_i = nold_removed - 1;
restore_i >= 0; restore_i--)
- (void)shirudo_upatch_install(old_loads[restore_i]);
+ (void)upatch_install(old_loads[restore_i]);
goto out;
}
nold_removed++;
}
}
for (int loaded_i = 0; loaded_i < nloaded; loaded_i++) {
- if (shirudo_upatch_install(loaded[loaded_i])) {
+ if (upatch_install(loaded[loaded_i])) {
ret = -EIO;
goto rollback;
}
@@ -1392,10 +1392,10 @@ rollback:
memcpy(unload + dir_len + 1 + name_len - strlen(".upatch"),
".unload.upatch", strlen(".unload.upatch") + 1);
}
- (void)shirudo_upatch_remove(unload);
+ (void)upatch_remove(unload);
}
for (int restore_i = nold - 1; restore_i >= 0; restore_i--)
- (void)shirudo_upatch_install(old_loads[restore_i]);
+ (void)upatch_install(old_loads[restore_i]);
out:
bpm_buffer_free(&manifest);
if (ret && archive[0])
@@ -1468,7 +1468,7 @@ static int cmd_bpm_config(int argc, const char **argv)
closedir(d);
return 0;
}
- if (shirudo_image_config_active() &&
+ if (image_config_active() &&
(!strcmp(argv[2], "add") || !strcmp(argv[2], "remove") ||
!strcmp(argv[2], "rm"))) {
pr_err("image mode: change repository definitions and keys in "
@@ -2166,9 +2166,9 @@ static int cmd_bpm_tree_sync(int argc, const char **argv)
goto out;
}
if (!strcmp(op->op, "add")) {
- ret = shirudo_upatch_install(artifact);
+ ret = upatch_install(artifact);
} else if (!strcmp(op->op, "delete")) {
- ret = shirudo_upatch_remove(artifact);
+ ret = upatch_remove(artifact);
} else {
ret = -EINVAL;
goto out;
@@ -2324,7 +2324,7 @@ static int package_uninstall(const struct bpm_state_entry *st)
goto out;
qsort(unloads, (size_t)n, PATH_MAX, path_compare_desc);
for (int i = 0; i < n; i++) {
- if (shirudo_upatch_remove(unloads[i])) {
+ if (upatch_remove(unloads[i])) {
pr_err("bpm uninstall: unload %s failed", unloads[i]);
ret = -EIO;
goto out;
@@ -2392,7 +2392,7 @@ static int bpm_exec_operator(const char *sub, int argc, const char **argv)
helper_argv[2] = sub;
for (int i = 3; i < argc + 1; i++)
helper_argv[i] = argv[i - 1];
- ret = shirudo_build_exec(label, (char **)helper_argv);
+ ret = build_exec(label, (char **)helper_argv);
xfree(helper_argv, ((size_t)argc + 2) * sizeof(*helper_argv));
return ret;
}
@@ -2500,7 +2500,7 @@ static int cmd_bpm_key(int argc, const char **argv)
print_help(&bpm_key_help);
return 2;
}
- if (!strcmp(sub, "add") && shirudo_image_config_active()) {
+ if (!strcmp(sub, "add") && image_config_active()) {
pr_err("image mode: add vouched BPF signers to the signed "
"config selected for boot and reboot to enroll them");
return 1;
@@ -2530,11 +2530,11 @@ static int cmd_bpm_key(int argc, const char **argv)
int cmd_bpm(int argc, const char **argv)
{
- const struct shirudo_help *help = shirudo_build_available() ?
+ const struct shirudo_help *help = build_available() ?
&bpm_operator_help : &bpm_target_help;
- const struct shirudo_help_item *subcmds = shirudo_build_available() ?
+ const struct shirudo_help_item *subcmds = build_available() ?
bpm_subcmds : bpm_target_subcmds;
- size_t n_subcmds = shirudo_build_available() ? ARRAY_SIZE(bpm_subcmds) :
+ size_t n_subcmds = build_available() ? ARRAY_SIZE(bpm_subcmds) :
ARRAY_SIZE(bpm_target_subcmds);
const char *sub;
diff --git a/builtin-build.c b/builtin-build.c
index c3a92746..1f1ed237 100644
--- a/builtin-build.c
+++ b/builtin-build.c
@@ -78,7 +78,7 @@ static bool on_path(const char *name)
return false;
}
-bool shirudo_build_available(void)
+bool build_available(void)
{
bool use_path;
const char *helper = resolve_helper(&use_path);
@@ -88,7 +88,7 @@ bool shirudo_build_available(void)
return use_path ? on_path(helper) : access(helper, X_OK) == 0;
}
-int shirudo_build_exec(const char *label, char **argv)
+int build_exec(const char *label, char **argv)
{
bool use_path;
const char *path = resolve_helper(&use_path);
@@ -119,5 +119,5 @@ int cmd_build(int argc, const char **argv)
print_help(&build_help);
return 0;
}
- return shirudo_build_exec("build", (char **)argv);
+ return build_exec("build", (char **)argv);
}
diff --git a/builtin-config.c b/builtin-config.c
index a2335cd1..f8733964 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -36,7 +36,7 @@ static void usage(void)
int cmd_config(int argc, const char **argv)
{
- bool image_mode = shirudo_image_config_active();
+ bool image_mode = image_config_active();
struct shirudo_config cfg;
bool file_present;
int ret;
diff --git a/builtin-image.c b/builtin-image.c
index 29bbe5a3..b65fbd81 100644
--- a/builtin-image.c
+++ b/builtin-image.c
@@ -44,15 +44,15 @@ int cmd_image(int argc, const char **argv)
helper[1] = "image";
for (i = 1; i < argc; i++)
helper[i + 1] = (char *)argv[i];
- ret = shirudo_build_exec(!strcmp(argv[1], "build") ?
- "image build" : "image verify", helper);
+ ret = build_exec(!strcmp(argv[1], "build") ?
+ "image build" : "image verify", helper);
xfree(helper, bytes);
return ret;
}
if (!strcmp(argv[1], "update") && argc == 3) {
- ret = shirudo_image_update(argv[2]);
+ ret = image_update(argv[2]);
} else if (!strcmp(argv[1], "status") && argc == 2) {
- ret = shirudo_image_status();
+ ret = image_status();
} else {
image_help();
return 2;
diff --git a/builtin-init.c b/builtin-init.c
index 3dfcb683..6dfde2a6 100644
--- a/builtin-init.c
+++ b/builtin-init.c
@@ -202,11 +202,11 @@ static int init_keyring(void)
if (!identity_read(&id)) {
if (id.keyring_type != SIG_KEYRING_BPF ||
id.keyring_serial != ring ||
- memcmp(id.runtime_root, shirudo_image_runtime_root(), 32))
+ memcmp(id.runtime_root, image_runtime_root(), 32))
return -EKEYREJECTED;
return 0;
}
- ret = shirudo_image_boot_keys(&set);
+ ret = image_boot_keys(&set);
if (ret)
return ret;
ret = init_bpf_keyring(ring, &set);
@@ -497,7 +497,7 @@ static int dm_verity_anchor(struct shirudo_identity *id)
key_serial_t ring;
int err;
- ring = shirudo_keyring_dm_verity_serial();
+ ring = keyring_dm_verity_serial();
if (ring <= 0) {
err = ring ? ring : -ENOKEY;
pr_err("resolve the dm-verity keyring serial: %s",
@@ -663,7 +663,7 @@ static int init_lsm(void)
}
id.run_dev = kernel_dev_t(st.st_dev);
- memcpy(id.runtime_root, shirudo_image_runtime_root(), 32);
+ memcpy(id.runtime_root, image_runtime_root(), 32);
/*
* The trust anchor lsm/bpf_prog_load enforces: only a load the
@@ -1356,7 +1356,7 @@ static int run_init(void)
int ret;
/* Only the run that brings enforcement up may label an unlabelled tree. */
- ret = shirudo_enforcement_active();
+ ret = enforcement_active();
if (ret < 0)
return init_phase_error(ret, "reading the enforcement state");
bootstrap = ret == 0;
@@ -1367,7 +1367,7 @@ static int run_init(void)
ret = init_keyring();
if (ret)
return init_phase_error(ret, "BPF keyring initialization");
- ret = shirudo_image_boot_keys_close();
+ ret = image_boot_keys_close();
if (ret)
return init_phase_error(ret, "closing the boot key image");
@@ -1386,10 +1386,10 @@ static int run_init(void)
ret = seal_label_tree(bootstrap);
if (ret)
return init_phase_error(ret, "sealing initialized state");
- ret = shirudo_image_runtime_mount();
+ ret = image_runtime_mount();
if (ret)
return init_phase_error(ret, "mounting the authenticated runtime");
- ret = shirudo_image_boot();
+ ret = image_boot();
if (ret)
return init_phase_error(ret, "loading authenticated boot settings");
ret = keys_load(RUNTIME_DIR "/keys",
@@ -1425,7 +1425,7 @@ static int run_init(void)
return init_phase_error(ret, "binding the TPM register");
}
- ret = shirudo_image_boot_complete();
+ ret = image_boot_complete();
if (ret)
return init_phase_error(ret, "completing authenticated boot");
@@ -1456,7 +1456,7 @@ int cmd_init(int argc, const char **argv)
}
initrd_mode = in_initrd();
- ret = shirudo_image_bootstrap_load();
+ ret = image_bootstrap_load();
if (ret < 0) {
pr_err("init: authenticated image settings: %s", strerror(-ret));
return 1;
@@ -1476,7 +1476,7 @@ int cmd_init(int argc, const char **argv)
if (initrd_mode && initrd_enter())
return 1;
ret = run_init();
- shirudo_image_leave();
+ image_leave();
if (initrd_mode)
initrd_leave();
return ret ? 1 : 0;
diff --git a/builtin-keys.c b/builtin-keys.c
index 62734ccc..39735794 100644
--- a/builtin-keys.c
+++ b/builtin-keys.c
@@ -577,7 +577,7 @@ static int keys_add(int argc, const char **argv)
print_help(&keys_add_help);
return 2;
}
- if (shirudo_image_config_active()) {
+ if (image_config_active()) {
pr_err("target: add vouched BPF signers to the signed "
"config selected for boot and reboot to enroll them");
return 1;
@@ -791,7 +791,7 @@ static int purge_signed_by(const __u8 *der, size_t der_sz,
upatch_close(&u);
if (signed_by != 1)
continue;
- prc = shirudo_upatch_purge(name, "key_revoke");
+ prc = upatch_purge(name, "key_revoke");
if (prc < 0) {
pr_err("keys revoke: purge %s: %s", name,
strerror(-prc));
@@ -810,7 +810,7 @@ static int purge_signed_by(const __u8 *der, size_t der_sz,
return ret ? ret : purged;
}
-int shirudo_keys_revoke_image(const __u8 *der, size_t size, bool boot)
+int keys_revoke_image(const __u8 *der, size_t size, bool boot)
{
struct shirudo_trusted_cert cert = {};
key_serial_t ring, key;
@@ -872,7 +872,7 @@ static int keys_vouch(int argc, const char **argv)
helper_argv[2] = "vouch";
for (int i = 1; i < argc; i++)
helper_argv[i + 2] = argv[i];
- ret = shirudo_build_exec("keys vouch", (char **)helper_argv);
+ ret = build_exec("keys vouch", (char **)helper_argv);
xfree(helper_argv, sz);
return ret;
}
@@ -927,7 +927,7 @@ static int keys_show(int argc, const char **argv)
}
}
- keys_dir = shirudo_image_config_active() ? RUNTIME_DIR "/keys" :
+ keys_dir = image_config_active() ? RUNTIME_DIR "/keys" :
keys_dir_resolve(keys_dir_arg);
ret = key_paths(keys_dir, pkey_path, sizeof(pkey_path),
@@ -979,7 +979,7 @@ static int keys_show(int argc, const char **argv)
id.key_serials,
id.n_keys < IDENTITY_KEYS_MAX ?
id.n_keys : IDENTITY_KEYS_MAX },
- { ".dm-verity", shirudo_keyring_dm_verity_serial,
+ { ".dm-verity", keyring_dm_verity_serial,
id.dm_verity_ring, &id.dm_verity_key,
id.dm_verity_key > 0 },
};
diff --git a/builtin-status.c b/builtin-status.c
index 0de0cad7..48a69e14 100644
--- a/builtin-status.c
+++ b/builtin-status.c
@@ -649,8 +649,8 @@ static void keyring_view_dm_verity(struct status_keyring *k,
if (k->links[i].serial == ident->dm_verity_key)
k->key_missing = false;
}
- k->certs_rc = shirudo_image_bootstrap_read(RUNTIME_CONF_PATH,
- &boot, false);
+ k->certs_rc = image_bootstrap_read(RUNTIME_CONF_PATH,
+ &boot, false);
if (!k->certs_rc && !boot.certificate[0])
k->certs_rc = -ENOENT;
if (!k->certs_rc)
@@ -998,7 +998,7 @@ int cmd_status(int argc, const char **argv)
if (!bpf.links_rc)
certs_enrolled = (int)bpf.n_asymmetric;
dmv.pinned = keyring_pinned < 0 ? keyring_pinned : ident.dm_verity_ring;
- dmv.serial = dmv.pinned >= 1 ? shirudo_keyring_dm_verity_serial() :
+ dmv.serial = dmv.pinned >= 1 ? keyring_dm_verity_serial() :
-ENOKEY;
keyring_view_dm_verity(&dmv, &ident);
mode = lsm_attached ? "production" : "inactive";
@@ -1012,7 +1012,7 @@ int cmd_status(int argc, const char **argv)
gather_assets(&assets);
tamper_rc = tamper_read(&tamper);
- config_state = shirudo_image_config_state(config_root);
+ config_state = image_config_state(config_root);
if (config_state != -ENODEV)
hex_encode(config_root, sizeof(config_root), config_root_hex);
@@ -1377,15 +1377,15 @@ int cmd_status(int argc, const char **argv)
int err;
severity_number =
- shirudo_status_otel_severity(otel_status,
- &severity_text);
- err = shirudo_otel_send_log_json(&otel_opts,
- "shirudo.keepalive",
- "shirudo.keepalive",
- severity_number,
- severity_text,
- otel_status,
- shirudo_version_id,
+ status_otel_severity(otel_status,
+ &severity_text);
+ err = otel_send_log_json(&otel_opts,
+ "shirudo.keepalive",
+ "shirudo.keepalive",
+ severity_number,
+ severity_text,
+ otel_status,
+ shirudo_version_id,
refused, json_buf,
strlen(json_buf));
if (err) {
diff --git a/builtin-upatch.c b/builtin-upatch.c
index 489b69b8..4e1f7525 100644
--- a/builtin-upatch.c
+++ b/builtin-upatch.c
@@ -2964,7 +2964,7 @@ done:
return ret;
}
-int shirudo_upatch_purge(const char *name, const char *reason)
+int upatch_purge(const char *name, const char *reason)
{
__u8 payload[UPATCH_PAYLOAD_HASH_LEN] = {};
char persisted[PATH_MAX];
@@ -3014,14 +3014,14 @@ int shirudo_upatch_purge(const char *name, const char *reason)
}
/* Package installs take the same path as the upatch commands. */
-int shirudo_upatch_install(const char *path)
+int upatch_install(const char *path)
{
const char *argv[] = { "load", "--no-precheck", path };
return cmd_upatch_load(3, argv);
}
-int shirudo_upatch_remove(const char *path)
+int upatch_remove(const char *path)
{
const char *argv[] = { "unload", "--no-precheck", path };
@@ -3194,11 +3194,11 @@ static int export_one_map(const char *upatch, const char *map,
err = upatch_decode_map_signal(&v, &decoder_signal);
if (err == -ENODATA)
- err = shirudo_upatch_maps_otel_send(&v, SHIRUDO_OTEL_AUTO,
- otel_opts);
+ err = upatch_maps_otel_send(&v, SHIRUDO_OTEL_AUTO,
+ otel_opts);
else if (!err)
- err = shirudo_upatch_maps_otel_send_decoded(&v, decoder_signal,
- otel_opts);
+ err = upatch_maps_otel_send_decoded(&v, decoder_signal,
+ otel_opts);
if (err) {
pr_err("upatch map: OTLP export %s/%s: %s", upatch, map,
strerror(-err));
diff --git a/builtin.h b/builtin.h
index 71bf623c..1cebc8c6 100644
--- a/builtin.h
+++ b/builtin.h
@@ -18,8 +18,8 @@ int cmd_build(int argc, const char **argv);
* The operator package's helper: whether it is there, and the one exec
* site, which returns only on failure.
*/
-bool shirudo_build_available(void);
-int shirudo_build_exec(const char *label, char **argv);
+bool build_available(void);
+int build_exec(const char *label, char **argv);
/* Target-side. */
int cmd_init(int argc, const char **argv);
diff --git a/shirudo.c b/shirudo.c
index ac31f326..04f57788 100644
--- a/shirudo.c
+++ b/shirudo.c
@@ -169,14 +169,14 @@ int main(int argc, const char **argv)
return 1;
}
- ret = shirudo_image_enter(c->name, argc - 1, argv + 1);
+ ret = image_enter(c->name, argc - 1, argv + 1);
if (ret) {
fprintf(stderr, "shirudo: image state: %s\n", strerror(-ret));
- shirudo_image_leave();
+ image_leave();
return 1;
}
ret = c->fn(argc - 1, argv + 1);
- shirudo_image_leave();
+ image_leave();
return ret;
}
diff --git a/testing/fuzz/fuzz-beefile.c b/testing/fuzz/fuzz-beefile.c
index 7941d3e5..c714ab0c 100644
--- a/testing/fuzz/fuzz-beefile.c
+++ b/testing/fuzz/fuzz-beefile.c
@@ -16,57 +16,57 @@
#include "tools/shirudo-build/vmlinux.h"
/* What bpm build does with a parsed Beefile is out of reach from here. */
-int shirudo_build_bpm_push(int argc, char **argv)
+int build_bpm_push(int argc, char **argv)
{
return -ENOSYS;
}
-int shirudo_build_bpm_tree(int argc, char **argv)
+int build_bpm_tree(int argc, char **argv)
{
return -ENOSYS;
}
-int shirudo_build_check_keys(const char *pkey, const char *cert)
+int build_check_keys(const char *pkey, const char *cert)
{
return -ENOSYS;
}
-int shirudo_build_compile(const char *source, const char *output,
- const char *vmlinux_h, const char *extra_cflags,
- const char *shirudo_bpf_incdir)
+int build_compile(const char *source, const char *output,
+ const char *vmlinux_h, const char *extra_cflags,
+ const char *shirudo_bpf_incdir)
{
return -ENOSYS;
}
-const char *shirudo_build_locate_vmlinux(const char *override)
+const char *build_locate_vmlinux(const char *override)
{
return NULL;
}
-int shirudo_build_package_load(const char *bpf_o, const char *src_path,
- const char *out_upatch, const char *upatch_name,
- const char *pkey_path, const char *cert_path)
+int build_package_load(const char *bpf_o, const char *src_path,
+ const char *out_upatch, const char *upatch_name,
+ const char *pkey_path, const char *cert_path)
{
return -ENOSYS;
}
-int shirudo_build_package_unload(const char *name,
- const __u8 payload_sha256[32],
- const char *out_upatch,
- const char *pkey_path, const char *cert_path)
+int build_package_unload(const char *name,
+ const __u8 payload_sha256[32],
+ const char *out_upatch,
+ const char *pkey_path, const char *cert_path)
{
return -ENOSYS;
}
-int shirudo_build_package_patch_rodata(const char *input, const char *output,
- const char *symbol, const __u8 *value,
- size_t value_len, const char *pkey_path,
- const char *cert_path)
+int build_package_patch_rodata(const char *input, const char *output,
+ const char *symbol, const __u8 *value,
+ size_t value_len, const char *pkey_path,
+ const char *cert_path)
{
return -ENOSYS;
}
-int shirudo_build_package_verify(const char *input, const char *cert_path)
+int build_package_verify(const char *input, const char *cert_path)
{
return -ENOSYS;
}
diff --git a/testing/helper/image-cleanup.h b/testing/helper/image-cleanup.h
index d6930fc7..c030653c 100644
--- a/testing/helper/image-cleanup.h
+++ b/testing/helper/image-cleanup.h
@@ -8,8 +8,8 @@
#include "util/dm_verity.h"
-int __wrap_shirudo_dm_verity_remove(struct shirudo_dm_verity *device,
- bool deferred);
+int __wrap_dm_verity_remove(struct shirudo_dm_verity *device,
+ bool deferred);
int __wrap_usleep(useconds_t usec);
#endif /* SHIRUDO_TEST_IMAGE_CLEANUP_H */
diff --git a/testing/helper/image-fault.c b/testing/helper/image-fault.c
index fe71a2a1..ecef41d6 100644
--- a/testing/helper/image-fault.c
+++ b/testing/helper/image-fault.c
@@ -33,13 +33,13 @@ static enum root_test_mode root_mode;
static __u32 begin_calls, end_calls;
static int consumed_valid = -1;
-int __wrap_shirudo_config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard)
+int __wrap_config_root_begin(const __u8 root[32],
+ struct shirudo_config_root_guard *guard)
{
__u8 wrong[32];
if (root_mode == ROOT_NORMAL)
- return __real_shirudo_config_root_begin(root, guard);
+ return __real_config_root_begin(root, guard);
begin_calls++;
if (root_mode == ROOT_MISSING) {
guard->map_fd = -1;
@@ -49,10 +49,10 @@ int __wrap_shirudo_config_root_begin(const __u8 root[32],
memcpy(wrong, root, sizeof(wrong));
if (root_mode == ROOT_WRONG)
wrong[0] ^= 1;
- return __real_shirudo_config_root_begin(wrong, guard);
+ return __real_config_root_begin(wrong, guard);
}
-int __wrap_shirudo_config_root_end(struct shirudo_config_root_guard *guard)
+int __wrap_config_root_end(struct shirudo_config_root_guard *guard)
{
struct shirudo_expected_root expected = {};
int ret = 0, cleanup;
@@ -65,7 +65,7 @@ int __wrap_shirudo_config_root_end(struct shirudo_config_root_guard *guard)
ret = -errno;
consumed_valid = expected.valid;
}
- cleanup = __real_shirudo_config_root_end(guard);
+ cleanup = __real_config_root_end(guard);
return ret ? ret : cleanup;
}
@@ -150,7 +150,7 @@ out_block:
static int config_root_test(const char *mode, const char *prefix)
{
- struct shirudo_config_image_open opened;
+ struct config_image_open opened;
struct shirudo_dm_verity device;
bool created = false;
int ret, cleanup;
@@ -164,12 +164,12 @@ static int config_root_test(const char *mode, const char *prefix)
root_mode = ROOT_MATCH;
else
return 2;
- ret = shirudo_config_image_open(prefix, &opened);
+ ret = config_image_open(prefix, &opened);
if (ret)
goto done;
snprintf(name, sizeof(name), "shirudo-verify-root-test-%ld",
(long)getpid());
- ret = shirudo_dm_verity_create(&opened, name, &device);
+ ret = dm_verity_create(&opened, name, &device);
created = !ret;
if (!ret && (begin_calls != 1 || end_calls != 1 ||
consumed_valid != (root_mode == ROOT_WRONG ? 1 : 0)))
@@ -177,16 +177,16 @@ static int config_root_test(const char *mode, const char *prefix)
if (!ret)
ret = check_root_cleared();
if (!ret)
- ret = shirudo_dm_verity_verify(&device, &opened);
+ ret = dm_verity_verify(&device, &opened);
if (!ret)
ret = check_classification(&device);
if (created) {
- cleanup = shirudo_dm_verity_remove(&device, true);
- shirudo_dm_verity_close(&device);
+ cleanup = dm_verity_remove(&device, true);
+ dm_verity_close(&device);
if (!ret)
ret = cleanup;
}
- shirudo_config_image_close(&opened);
+ config_image_close(&opened);
done:
if (ret)
fprintf(stderr, "config root test: %s\n", strerror(-ret));
diff --git a/testing/helper/image-fault.h b/testing/helper/image-fault.h
index e19c9f79..7ac05d2a 100644
--- a/testing/helper/image-fault.h
+++ b/testing/helper/image-fault.h
@@ -10,12 +10,12 @@
#include "util/image_guards.h"
-int __real_shirudo_config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard);
-int __wrap_shirudo_config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard);
-int __real_shirudo_config_root_end(struct shirudo_config_root_guard *guard);
-int __wrap_shirudo_config_root_end(struct shirudo_config_root_guard *guard);
+int __real_config_root_begin(const __u8 root[32],
+ struct shirudo_config_root_guard *guard);
+int __wrap_config_root_begin(const __u8 root[32],
+ struct shirudo_config_root_guard *guard);
+int __real_config_root_end(struct shirudo_config_root_guard *guard);
+int __wrap_config_root_end(struct shirudo_config_root_guard *guard);
int __real_main(int argc, const char **argv);
int __wrap_main(int argc, const char **argv);
diff --git a/testing/helper/test-config-attest.c b/testing/helper/test-config-attest.c
index 5878d096..5dfe7416 100644
--- a/testing/helper/test-config-attest.c
+++ b/testing/helper/test-config-attest.c
@@ -28,7 +28,7 @@ static int boot_identity(void *ctx, __u32 *reset, __u32 *restart)
(void)ctx;
ret = tpm_open(&tpm);
if (!ret)
- ret = shirudo_tpm_boot_identity(tpm, reset, restart);
+ ret = tpm_boot_identity(tpm, reset, restart);
tpm_close(tpm);
return ret;
}
@@ -90,16 +90,16 @@ static int render(const char *directory, const char *nonce)
if (strlen(nonce) % 2 || nonce_length > sizeof(bytes) ||
hex_decode(nonce, bytes, nonce_length))
return -EINVAL;
- ret = shirudo_config_update_open(directory, &ops, NULL, &update);
+ ret = config_update_open(directory, &ops, NULL, &update);
if (!ret)
- ret = shirudo_attest_evidence_config(bytes, nonce_length,
- CHAIN_PCR_MASK,
- NULL, &update, &document,
- &length, &capacity);
+ ret = attest_evidence_config(bytes, nonce_length,
+ CHAIN_PCR_MASK,
+ NULL, &update, &document,
+ &length, &capacity);
if (!ret)
ret = write_complete(STDOUT_FILENO, document, length);
xfree(document, capacity);
- shirudo_config_update_close(&update);
+ config_update_close(&update);
return ret;
}
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
return 2;
ret = read_document(argv[2], &document, &length);
if (!ret)
- ret = shirudo_config_evidence_parse(document, length, &config);
+ ret = config_evidence_parse(document, length, &config);
if (ret)
goto out;
if (argc == 8 && !strcmp(argv[1], "replay")) {
@@ -172,9 +172,9 @@ int main(int argc, char **argv)
reset = strtoul(argv[5], NULL, 10);
restart = strtoul(argv[6], NULL, 10);
expected = !strcmp(argv[3], "-") ? NULL : root;
- ret = shirudo_config_evidence_verify(&config, mask, reset,
- restart, pcrs, expected,
- pcr, &reason);
+ ret = config_evidence_verify(&config, mask, reset,
+ restart, pcrs, expected,
+ pcr, &reason);
} else if (strcmp(argv[1], "parse")) {
ret = -EINVAL;
}
@@ -182,7 +182,7 @@ out:
if (reason)
printf("reason=%s\n", reason);
printf("rc=%d\n", ret);
- shirudo_config_evidence_clear(&config);
+ config_evidence_clear(&config);
xfree(document, document ? length + 1 : 0);
return ret ? 1 : 0;
}
diff --git a/testing/helper/test-config-image.c b/testing/helper/test-config-image.c
index 55c6934d..f57b5c15 100644
--- a/testing/helper/test-config-image.c
+++ b/testing/helper/test-config-image.c
@@ -19,14 +19,14 @@ static int header_read(const char *path, struct shirudo_config_image *image)
fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -errno;
- ret = shirudo_config_image_read_header(fd, image);
+ ret = config_image_read_header(fd, image);
close(fd);
return ret;
}
int main(int argc, char **argv)
{
- struct shirudo_config_image_open op = {
+ struct config_image_open op = {
.data_fd = -1,
.hash_fd = -1,
.signature_fd = -1,
@@ -38,9 +38,9 @@ int main(int argc, char **argv)
if (argc == 4 && !strcmp(argv[1], "root")) {
ret = hex_decode(argv[3], root, sizeof(root));
if (!ret)
- ret = shirudo_config_image_open_root(argv[2], root,
- &op);
- shirudo_config_image_close(&op);
+ ret = config_image_open_root(argv[2], root,
+ &op);
+ config_image_close(&op);
} else if (argc == 3 && !strcmp(argv[1], "decode")) {
ret = header_read(argv[2], &image);
if (!ret) {
diff --git a/testing/helper/test-config-update.c b/testing/helper/test-config-update.c
index a361e25c..4f38f251 100644
--- a/testing/helper/test-config-update.c
+++ b/testing/helper/test-config-update.c
@@ -96,7 +96,7 @@ static int test_boot_identity(void *opaque, __u32 *reset, __u32 *restart)
struct test_context *ctx = opaque;
if (ctx->tpm)
- return shirudo_tpm_boot_identity(ctx->tpm, reset, restart);
+ return tpm_boot_identity(ctx->tpm, reset, restart);
*reset = ctx->sim.reset_count;
*restart = ctx->sim.restart_count;
return 0;
@@ -133,7 +133,7 @@ static int test_pcr_extend(void *opaque, __u32 pcr,
if (ctx->tpm)
ret = tpm_pcr_extend(ctx->tpm, pcr, event);
else
- ret = shirudo_chain_fold_checked(ctx->sim.value, event);
+ ret = chain_fold_checked(ctx->sim.value, event);
if (!ret)
ret = simulator_save(ctx);
if (!ret && mode && !strcmp(mode, "ambiguous"))
@@ -173,7 +173,7 @@ static int test_activate(void *opaque,
__u8 live[32];
int ret;
- ret = shirudo_config_update_read(ctx->update, &record);
+ ret = config_update_read(ctx->update, &record);
if (!ret)
ret = test_pcr_read(ctx, record.pcr, live);
if (ret)
@@ -261,7 +261,7 @@ static void inspect(struct test_context *ctx)
hex_encode(value, 32, hex);
printf("pcr_value=%s\n", hex);
}
- ret = shirudo_config_update_read(ctx->update, &record);
+ ret = config_update_read(ctx->update, &record);
printf("state_rc=%d\n", ret);
if (!ret) {
printf("sequence=%llu\npending=%u\nkind=%u\npcr=%u\nreset=%u\n",
@@ -274,7 +274,7 @@ static void inspect(struct test_context *ctx)
hex_encode(record.target.root_hash, 32, hex);
printf("root_hash=%s\n", hex);
}
- ret = shirudo_config_update_events(ctx->update, show_event, &count);
+ ret = config_update_events(ctx->update, show_event, &count);
printf("events_rc=%d\nevents=%u\n", ret, count);
}
@@ -305,8 +305,8 @@ int main(int argc, char **argv)
hex_encode(target.root_hash, sizeof(target.root_hash),
hex);
printf("root_hash=%s\n", hex);
- ret = shirudo_config_measure_event(SHIRUDO_CONFIG_EVENT_BOOT,
- target.root_hash, event);
+ ret = config_measure_event(SHIRUDO_CONFIG_EVENT_BOOT,
+ target.root_hash, event);
if (!ret) {
hex_encode(event, sizeof(event), hex);
printf("boot_event=%s\n", hex);
@@ -325,19 +325,19 @@ int main(int argc, char **argv)
if (getenv("SHIRUDO_TEST_CONFIG_LOCK_WAIT_MS"))
ops.lock_wait_ms = strtoul(getenv("SHIRUDO_TEST_CONFIG_LOCK_WAIT_MS"),
NULL, 10);
- ret = shirudo_config_update_open(argv[1], &ops, &ctx, &update);
+ ret = config_update_open(argv[1], &ops, &ctx, &update);
if (ret)
goto out;
if (!strcmp(argv[2], "boot")) {
- ret = shirudo_config_update_boot(&update, &target, pcr);
+ ret = config_update_boot(&update, &target, pcr);
if (!ret && !getenv("SHIRUDO_TEST_CONFIG_BOOT_PENDING"))
- ret = shirudo_config_update_complete_boot(&update);
+ ret = config_update_complete_boot(&update);
} else if (!strcmp(argv[2], "update")) {
- ret = shirudo_config_update_begin(&update, &target, pcr);
+ ret = config_update_begin(&update, &target, pcr);
} else if (!strcmp(argv[2], "complete")) {
- ret = shirudo_config_update_complete_boot(&update);
+ ret = config_update_complete_boot(&update);
} else if (!strcmp(argv[2], "check")) {
- ret = shirudo_config_update_check(&update, NULL);
+ ret = config_update_check(&update, NULL);
} else if (!strcmp(argv[2], "inspect")) {
ret = 0;
} else if (!strcmp(argv[2], "reset")) {
@@ -352,14 +352,14 @@ int main(int argc, char **argv)
memset(ctx.sim.value, 0x55, sizeof(ctx.sim.value));
ret = simulator_save(&ctx);
} else if (!strcmp(argv[2], "lock")) {
- ret = shirudo_config_update_open(argv[1], &test_ops, &ctx,
- &second);
- shirudo_config_update_close(&second);
+ ret = config_update_open(argv[1], &test_ops, &ctx,
+ &second);
+ config_update_close(&second);
} else {
ret = -EINVAL;
}
inspect(&ctx);
- shirudo_config_update_close(&update);
+ config_update_close(&update);
out:
if (ctx.tpm)
tpm_close(ctx.tpm);
diff --git a/testing/helper/test-image-cleanup.c b/testing/helper/test-image-cleanup.c
index f419ec22..d0381e41 100644
--- a/testing/helper/test-image-cleanup.c
+++ b/testing/helper/test-image-cleanup.c
@@ -11,8 +11,8 @@ static __u32 busy_calls, remove_calls, sleep_calls;
static int remove_result;
static bool invalid_call;
-int __wrap_shirudo_dm_verity_remove(struct shirudo_dm_verity *device,
- bool deferred)
+int __wrap_dm_verity_remove(struct shirudo_dm_verity *device,
+ bool deferred)
{
if (device != &candidate || deferred || remove_calls != sleep_calls)
invalid_call = true;
diff --git a/testing/helper/test-image-cli.c b/testing/helper/test-image-cli.c
index 17dd1dcb..20b06029 100644
--- a/testing/helper/test-image-cli.c
+++ b/testing/helper/test-image-cli.c
@@ -43,7 +43,7 @@ int main(int argc, const char **argv)
memcpy(bootstrap.tpm_owner_auth, "bootstrap-owner", 15);
bootstrap.tpm_owner_auth_len = 15;
strscpy(bootstrap.tpm_tcti, "bootstrap-tcti", sizeof(bootstrap.tpm_tcti));
- ret = shirudo_image_config_set(&bootstrap, fd);
+ ret = image_config_set(&bootstrap, fd);
}
close(fd);
if (ret)
@@ -60,8 +60,8 @@ int main(int argc, const char **argv)
ret = load_source(argv[3], &source);
if (!ret) {
char content[64];
- int kfd = shirudo_image_open_relative(source.key_file,
- O_RDONLY);
+ int kfd = image_open_relative(source.key_file,
+ O_RDONLY);
FILE *file = kfd < 0 ? NULL : fdopen(kfd, "r");
if (!file) {
@@ -88,6 +88,6 @@ int main(int argc, const char **argv)
} else {
ret = 2;
}
- shirudo_image_config_clear();
+ image_config_clear();
return ret ? 1 : 0;
}
diff --git a/testing/helper/test-image-config.c b/testing/helper/test-image-config.c
index 4348a81a..e89171f6 100644
--- a/testing/helper/test-image-config.c
+++ b/testing/helper/test-image-config.c
@@ -18,9 +18,9 @@ static int read_bootstrap(int argc, char **argv)
char root[65];
int ret;
- ret = shirudo_image_bootstrap_read(argv[2], &boot, true);
+ ret = image_bootstrap_read(argv[2], &boot, true);
if (!ret && argc == 4)
- ret = shirudo_image_bootstrap_read(argv[3], &boot, false);
+ ret = image_bootstrap_read(argv[3], &boot, false);
if (!ret) {
hex_encode(boot.runtime_root, 32, root);
printf("runtime=%s\nroot=%s\nconfig=%s\ncertificate=%s\npcr=%u\n",
@@ -51,27 +51,27 @@ int main(int argc, char **argv)
snprintf(bootstrap.tpm_tcti, sizeof(bootstrap.tpm_tcti),
"bootstrap-tcti");
if (!strcmp(argv[1], "validate")) {
- ret = shirudo_image_config_validate(fd);
+ ret = image_config_validate(fd);
} else if (!strcmp(argv[1], "effective")) {
- ret = shirudo_image_config_set(&bootstrap, fd);
- if (!ret && !shirudo_image_config_get(&effective))
+ ret = image_config_set(&bootstrap, fd);
+ if (!ret && !image_config_get(&effective))
ret = -EIO;
if (!ret) {
printf("owner=%.*s\ntcti=%s\nlimit=%llu\n",
(int)effective.tpm_owner_auth_len,
effective.tpm_owner_auth, effective.tpm_tcti,
effective.eventlog_max_bytes);
- ret = shirudo_image_open(SHIRUDO_IMAGE_REGISTRIES,
- O_RDONLY | O_DIRECTORY);
+ ret = image_open(SHIRUDO_IMAGE_REGISTRIES,
+ O_RDONLY | O_DIRECTORY);
printf("registries=%s\n", ret >= 0 ? "open" : "missing");
if (ret >= 0)
close(ret);
ret = 0;
}
} else if (!strcmp(argv[1], "relative") && argc == 4) {
- ret = shirudo_image_config_set(&bootstrap, fd);
+ ret = image_config_set(&bootstrap, fd);
if (!ret)
- ret = shirudo_image_open_relative(argv[3], O_RDONLY);
+ ret = image_open_relative(argv[3], O_RDONLY);
if (ret >= 0) {
printf("resolved=open\n");
close(ret);
@@ -81,7 +81,7 @@ int main(int argc, char **argv)
ret = -EINVAL;
}
out:
- shirudo_image_config_clear();
+ image_config_clear();
close(fd);
printf("rc=%d\n", ret);
return ret ? 1 : 0;
diff --git a/testing/helper/test-image-keys.c b/testing/helper/test-image-keys.c
index 0e6e1da5..21fda11c 100644
--- a/testing/helper/test-image-keys.c
+++ b/testing/helper/test-image-keys.c
@@ -57,7 +57,7 @@ int keyring_holds_cert(key_serial_t ring, const __u8 *der,
return 0;
}
-int shirudo_keys_revoke_image(const __u8 *der, size_t size, bool boot)
+int keys_revoke_image(const __u8 *der, size_t size, bool boot)
{
(void)der;
(void)size;
@@ -89,7 +89,7 @@ static int pcr_extend(void *opaque, __u32 pcr, const __u8 event[32])
(void)pcr;
ctx->extends++;
- return shirudo_chain_fold_checked(ctx->pcr, event);
+ return chain_fold_checked(ctx->pcr, event);
}
static int prepare(void *opaque,
@@ -98,7 +98,7 @@ static int prepare(void *opaque,
struct test_context *ctx = opaque;
(void)target;
- return ctx->live ? shirudo_keys_check_image_set(ctx->set) : 0;
+ return ctx->live ? keys_check_image_set(ctx->set) : 0;
}
static int activate(void *opaque,
@@ -138,14 +138,14 @@ static int live_update(const char *directory, struct shirudo_trusted_set *set)
struct test_context ctx = { .set = set };
int ret;
- ret = shirudo_config_update_open(directory, &ops, &ctx, &update);
+ ret = config_update_open(directory, &ops, &ctx, &update);
if (ret)
return ret;
strcpy(target.prefix, "/verified/boot");
memset(target.root_hash, 1, 32);
- ret = shirudo_config_update_boot(&update, &target, 15);
+ ret = config_update_boot(&update, &target, 15);
if (!ret)
- ret = shirudo_config_update_complete_boot(&update);
+ ret = config_update_complete_boot(&update);
ctx.live = true;
ctx.interrupt = !!getenv("SHIRUDO_TEST_IMAGE_INTERRUPT");
ctx.extends = 0;
@@ -153,10 +153,10 @@ static int live_update(const char *directory, struct shirudo_trusted_set *set)
strcpy(target.prefix, "/verified/live");
memset(target.root_hash, 2, 32);
if (!ret)
- ret = shirudo_config_update_begin(&update, &target, 15);
+ ret = config_update_begin(&update, &target, 15);
printf("extends=%u activations=%u\n", ctx.extends, ctx.activations);
- shirudo_config_update_close(&update);
+ config_update_close(&update);
return ret;
}
@@ -170,7 +170,7 @@ int main(int argc, char **argv)
fd = open(argv[2], O_RDONLY | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
if (fd < 0)
return 2;
- ret = shirudo_keys_validate_image_set(argv[1], fd, &set);
+ ret = keys_validate_image_set(argv[1], fd, &set);
if (!ret && argc >= 5) {
held = argv + 4;
held_count = argc - 4;
diff --git a/testing/helper/test-keys.c b/testing/helper/test-keys.c
index 127da140..ca5062c7 100644
--- a/testing/helper/test-keys.c
+++ b/testing/helper/test-keys.c
@@ -69,7 +69,7 @@ int main(int argc, char **argv)
root = open(argv[2], O_RDONLY | O_DIRECTORY | O_CLOEXEC);
if (root < 0)
return 1;
- ret = shirudo_keys_load_image_at(primary, root, true, &set);
+ ret = keys_load_image_at(primary, root, true, &set);
close(root);
} else {
ret = keys_load(argv[2], NULL,
diff --git a/testing/helper/test-otel-map.c b/testing/helper/test-otel-map.c
index 83561ca4..7b8b4a91 100644
--- a/testing/helper/test-otel-map.c
+++ b/testing/helper/test-otel-map.c
@@ -222,8 +222,8 @@ static int print_classification(__u32 type, bool is_signed, bool with_btf,
if (ret)
return 1;
f.view.serialized = serialized;
- ret = shirudo_upatch_maps_otel_classify(&f.view, &signal, reason,
- sizeof(reason));
+ ret = upatch_maps_otel_classify(&f.view, &signal, reason,
+ sizeof(reason));
if (!ret)
printf("%s:%s\n", signal == SHIRUDO_OTEL_METRIC ?
"metric" : "log", reason);
@@ -246,13 +246,13 @@ static int print_payload(bool metric, bool counter, bool with_location)
ret = make_decoder(metric, counter, false, decoder_path,
sizeof(decoder_path));
if (!ret && metric)
- ret = shirudo_upatch_maps_otel_build_metric_file(decoder_path,
- &f.view,
- &buf, &len);
+ ret = upatch_maps_otel_build_metric_file(decoder_path,
+ &f.view,
+ &buf, &len);
else if (!ret)
- ret = shirudo_upatch_maps_otel_build_log_file(decoder_path,
- &f.view, &buf,
- &len);
+ ret = upatch_maps_otel_build_log_file(decoder_path,
+ &f.view, &buf,
+ &len);
if (!ret && buf)
fwrite(buf, 1, len, stdout);
if (buf)
@@ -301,8 +301,8 @@ static int send_log_limits(const char *url, __u32 retries, __u32 record_max,
ret = make_decoder(false, false, false, decoder_path,
sizeof(decoder_path));
if (!ret)
- ret = shirudo_upatch_maps_otel_send_file(decoder_path, &f.view,
- SHIRUDO_OTEL_FORCE_LOG, &opts);
+ ret = upatch_maps_otel_send_file(decoder_path, &f.view,
+ SHIRUDO_OTEL_FORCE_LOG, &opts);
if (decoder_path[0])
unlink(decoder_path);
fixture_destroy(&f);
@@ -326,8 +326,8 @@ static int send_log(const char *url, __u32 retries, bool insecure)
ret = make_decoder(false, false, false, decoder_path,
sizeof(decoder_path));
if (!ret)
- ret = shirudo_upatch_maps_otel_send_file(decoder_path, &f.view,
- SHIRUDO_OTEL_FORCE_LOG, &opts);
+ ret = upatch_maps_otel_send_file(decoder_path, &f.view,
+ SHIRUDO_OTEL_FORCE_LOG, &opts);
if (decoder_path[0])
unlink(decoder_path);
fixture_destroy(&f);
@@ -372,8 +372,8 @@ static int send_auto(const char *base, bool is_signed)
ret = make_decoder(!is_signed, !is_signed, false, decoder_path,
sizeof(decoder_path));
if (!ret)
- ret = shirudo_upatch_maps_otel_send_file(decoder_path, &f.view,
- SHIRUDO_OTEL_AUTO, &opts);
+ ret = upatch_maps_otel_send_file(decoder_path, &f.view,
+ SHIRUDO_OTEL_AUTO, &opts);
if (decoder_path[0])
unlink(decoder_path);
fixture_destroy(&f);
@@ -395,8 +395,8 @@ static int send_metric(const char *url)
ret = make_decoder(true, false, false, decoder_path,
sizeof(decoder_path));
if (!ret)
- ret = shirudo_upatch_maps_otel_send_file(decoder_path, &f.view,
- SHIRUDO_OTEL_FORCE_METRIC, &opts);
+ ret = upatch_maps_otel_send_file(decoder_path, &f.view,
+ SHIRUDO_OTEL_FORCE_METRIC, &opts);
if (decoder_path[0])
unlink(decoder_path);
fixture_destroy(&f);
@@ -413,13 +413,13 @@ static int send_status(const char *url, const char *status)
char body[256];
int severity, n;
- severity = shirudo_status_otel_severity(status, &severity_text);
+ severity = status_otel_severity(status, &severity_text);
n = snprintf(body, sizeof(body),
"{\"schema\":1,\"status\":\"%s\",\"conditions\":[],\"tpm\":{}}",
status);
if (n < 0 || (size_t)n >= sizeof(body))
return 1;
- return shirudo_otel_send_log_json(&opts, "shirudo.keepalive",
+ return otel_send_log_json(&opts, "shirudo.keepalive",
"shirudo.keepalive", severity,
severity_text, status, "test-version", 2,
body, (size_t)n) != 0;
@@ -440,8 +440,8 @@ static int send_metric_env(void)
ret = make_decoder(true, false, false, decoder_path,
sizeof(decoder_path));
if (!ret)
- ret = shirudo_upatch_maps_otel_send_file(decoder_path, &f.view,
- SHIRUDO_OTEL_FORCE_METRIC, &opts);
+ ret = upatch_maps_otel_send_file(decoder_path, &f.view,
+ SHIRUDO_OTEL_FORCE_METRIC, &opts);
if (decoder_path[0])
unlink(decoder_path);
fixture_destroy(&f);
@@ -518,8 +518,8 @@ static int send_s3(const char *endpoint, __u32 retries, bool large)
ret = make_decoder(false, false, true, decoder_path,
sizeof(decoder_path));
if (!ret)
- ret = shirudo_upatch_maps_otel_send_file(decoder_path, &f.view,
- SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send_file(decoder_path, &f.view,
+ SHIRUDO_OTEL_S3, &opts);
if (decoder_path[0])
unlink(decoder_path);
large_serialized_destroy(&f);
@@ -539,25 +539,25 @@ static int tenant_validation(void)
if (fixture_init(&f, BPF_MAP_TYPE_PERCPU_ARRAY, false, true))
return 1;
opts.tenant_id = "bad tenant";
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
- &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
+ &opts);
failed += ret != -EINVAL;
opts.tenant_id = NULL;
setenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS",
"X-Tenant-ID=bad%20tenant", 1);
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
- &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
+ &opts);
failed += ret != -EINVAL;
setenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS",
"X-Tenant-ID=one,x-tenant-id=two", 1);
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
- &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
+ &opts);
failed += ret != -EINVAL;
opts.tenant_id = "tenant-cli-1234";
setenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS",
"X-Tenant-ID=ignored%20invalid", 1);
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
- &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
+ &opts);
failed += ret == -EINVAL;
unsetenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS");
fixture_destroy(&f);
@@ -582,50 +582,50 @@ static int s3_validation(void)
unsetenv("AWS_SECRET_ACCESS_KEY");
unsetenv("AWS_SESSION_TOKEN");
unsetenv("AWS_CA_BUNDLE");
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EACCES)
goto fail;
setenv("AWS_ACCESS_KEY_ID", "test", 1);
setenv("AWS_SECRET_ACCESS_KEY", "bad\nsecret", 1);
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EACCES)
goto fail;
setenv("AWS_SECRET_ACCESS_KEY", "secret", 1);
setenv("AWS_ACCESS_KEY_ID", "bad:key", 1);
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EACCES)
goto fail;
setenv("AWS_ACCESS_KEY_ID", "test", 1);
setenv("AWS_REGION", "not_a_region", 1);
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EINVAL)
goto fail;
unsetenv("AWS_REGION");
opts.s3_uri = "s3://test-bucket/../escape";
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EINVAL)
goto fail;
opts.s3_uri = "s3://test-bucket/prefix?query";
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EINVAL)
goto fail;
opts.s3_uri = "s3://BAD_BUCKET/prefix";
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EINVAL)
goto fail;
opts.s3_uri = "s3://test-bucket/prefix";
f.view.truncated = true;
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
f.view.truncated = false;
if (ret != -E2BIG)
goto fail;
f.view.skipped = true;
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
f.view.skipped = false;
if (ret != -EOPNOTSUPP)
goto fail;
setenv("AWS_ENDPOINT_URL_S3", "http://storage.example", 1);
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_S3, &opts);
if (ret != -EPERM)
goto fail;
fixture_destroy(&f);
@@ -646,8 +646,8 @@ static int security_check(void)
if (fixture_init(&f, BPF_MAP_TYPE_PERCPU_ARRAY, false, true))
return 1;
- ret = shirudo_upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
- &opts);
+ ret = upatch_maps_otel_send(&f.view, SHIRUDO_OTEL_FORCE_LOG,
+ &opts);
fixture_destroy(&f);
return ret != -EPERM;
}
@@ -670,7 +670,7 @@ int main(int argc, char **argv)
if (argc == 4 && strcmp(argv[1], "retry-after") == 0) {
__u64 seconds;
time_t now = (time_t)strtoll(argv[3], NULL, 10);
- int ret = shirudo_otel_retry_after(argv[2], now, &seconds);
+ int ret = otel_retry_after(argv[2], now, &seconds);
if (!ret)
printf("%llu\n", seconds);
diff --git a/testing/helper/test-register-cli.c b/testing/helper/test-register-cli.c
index 3ef86c56..b9acb85b 100644
--- a/testing/helper/test-register-cli.c
+++ b/testing/helper/test-register-cli.c
@@ -18,7 +18,7 @@ int main(int argc, const char **argv)
return 1;
if (argc > 2 && !strcmp(argv[1], "attest") && !strcmp(argv[2], "predict"))
return cmd_attest(argc - 1, argv + 1);
- if (shirudo_enforcement_active() != 0) {
+ if (enforcement_active() != 0) {
fputs("register CLI fixture requires an uninitialized target\n", stderr);
return 1;
}
diff --git a/testing/helper/test-register.c b/testing/helper/test-register.c
index b8157985..952d0502 100644
--- a/testing/helper/test-register.c
+++ b/testing/helper/test-register.c
@@ -606,10 +606,10 @@ int main(int argc, char **argv)
fprintf(stderr, "evidence: bad challenge\n");
return 2;
}
- ret = shirudo_attest_evidence_config(nonce, nonce_len,
- ATTEST_PCR_DEFAULT,
- argc == 4 ? &challenge : NULL,
- NULL, &doc, &len, &cap);
+ ret = attest_evidence_config(nonce, nonce_len,
+ ATTEST_PCR_DEFAULT,
+ argc == 4 ? &challenge : NULL,
+ NULL, &doc, &len, &cap);
if (ret) {
fprintf(stderr, "evidence: %s\n", strerror(-ret));
return 1;
diff --git a/tools/shirudo-build/bpm-build.c b/tools/shirudo-build/bpm-build.c
index 0f2eaae8..8ddea057 100644
--- a/tools/shirudo-build/bpm-build.c
+++ b/tools/shirudo-build/bpm-build.c
@@ -840,9 +840,9 @@ static int build_rodata_apply(const struct bpm_build_spec *spec,
UPATCH_FILE_MAX);
if (ret)
goto out;
- ret = shirudo_build_package_patch_rodata(load, patched,
- rodata->symbol, value,
- value_len, pkey, cert);
+ ret = build_package_patch_rodata(load, patched,
+ rodata->symbol, value,
+ value_len, pkey, cert);
if (!ret && rename(patched, load))
ret = -errno;
out:
@@ -1181,7 +1181,7 @@ static int build_upatches(struct bpm_build_spec *spec, const char *pkey,
strscpy(u->unload_path, unload, sizeof(u->unload_path));
if (build_ends_with(source, ".bpf.c")) {
if (!vmlinux_h) {
- vmlinux_h = shirudo_build_locate_vmlinux(NULL);
+ vmlinux_h = build_locate_vmlinux(NULL);
if (!vmlinux_h) {
pr_err("bpm build: vmlinux.h not found (tried "
"./vmlinux.h, ./vendor/linux/vmlinux.h, %s)",
@@ -1191,8 +1191,8 @@ static int build_upatches(struct bpm_build_spec *spec, const char *pkey,
}
if (strsprintf(object, sizeof(object), "%s.bpf.o", load) < 0)
return -ENAMETOOLONG;
- ret = shirudo_build_compile(source, object, vmlinux_h, NULL,
- shirudo_bpf_incdir);
+ ret = build_compile(source, object, vmlinux_h, NULL,
+ shirudo_bpf_incdir);
if (ret) {
pr_err("bpm build: compile %s failed", u->source);
return ret < 0 ? ret : -EIO;
@@ -1205,8 +1205,8 @@ static int build_upatches(struct bpm_build_spec *spec, const char *pkey,
return -EINVAL;
}
build_upatch_name(source, name, sizeof(name));
- ret = shirudo_build_package_load(bpf_o, src_path, load, name, pkey,
- cert);
+ ret = build_package_load(bpf_o, src_path, load, name, pkey,
+ cert);
if (bpf_o == object)
unlink(object);
if (ret)
@@ -1228,8 +1228,8 @@ static int build_upatches(struct bpm_build_spec *spec, const char *pkey,
memcpy(payload, parsed.hdr.payload_sha256, sizeof(payload));
strscpy(u->type, upatch_type_str(&parsed), sizeof(u->type));
upatch_close(&parsed);
- ret = shirudo_build_package_unload(u->name, payload, unload, pkey,
- cert);
+ ret = build_package_unload(u->name, payload, unload, pkey,
+ cert);
if (ret)
return ret < 0 ? ret : -EIO;
}
@@ -1500,7 +1500,7 @@ static void build_usage(void)
"is available only in shirudo-operator and requires signing keys.\n");
}
-static int shirudo_build_bpm_build(int argc, char **argv)
+static int build_bpm_build(int argc, char **argv)
{
const char *context = ".", *file_arg = NULL, *version = NULL;
const char *keys_arg = NULL, *vmlinux_arg = NULL;
@@ -1522,7 +1522,7 @@ static int shirudo_build_bpm_build(int argc, char **argv)
__u8 *body = NULL;
for (int i = 1; i < argc; i++) {
- if (shirudo_build_is_help(argv[i])) {
+ if (build_is_help(argv[i])) {
build_usage();
return 0;
} else if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--file")) {
@@ -1580,7 +1580,7 @@ static int shirudo_build_bpm_build(int argc, char **argv)
sizeof(cert_path));
if (ret)
return ret;
- if (shirudo_build_check_keys(pkey, cert_path))
+ if (build_check_keys(pkey, cert_path))
return -EACCES;
if (vmlinux_arg && !realpath(vmlinux_arg, vmlinux_abs)) {
pr_err("bpm build: cannot resolve vmlinux.h %s: %s",
@@ -1797,7 +1797,7 @@ out:
return ret;
}
-static int shirudo_build_bpm_config_update(int argc, char **argv)
+static int build_bpm_config_update(int argc, char **argv)
{
const char *file_arg = NULL, *base_arg = NULL;
const char *version = NULL, *keys_arg = NULL;
@@ -1819,7 +1819,7 @@ static int shirudo_build_bpm_config_update(int argc, char **argv)
bool downloaded_package = false;
for (int i = 1; i < argc; i++) {
- if (shirudo_build_is_help(argv[i])) {
+ if (build_is_help(argv[i])) {
fprintf(stdout,
"usage: shirudo bpm config update "
"--base-package <package.bee|oci://host/repo:tag> "
@@ -1894,7 +1894,7 @@ static int shirudo_build_bpm_config_update(int argc, char **argv)
sizeof(cert_path));
if (ret)
goto out_base;
- if (shirudo_build_check_keys(pkey, cert_path))
+ if (build_check_keys(pkey, cert_path))
goto key_error;
package_source = !file_arg;
spec = xmalloc(sizeof(*spec));
@@ -2036,7 +2036,7 @@ static int shirudo_build_bpm_config_update(int argc, char **argv)
load);
if (ret)
break;
- ret = shirudo_build_package_verify(load, cert_path);
+ ret = build_package_verify(load, cert_path);
if (ret)
break;
build_upatch_name(upatch->source, expected_name,
@@ -2072,8 +2072,8 @@ static int shirudo_build_bpm_config_update(int argc, char **argv)
upatch_close(&parsed);
strscpy(upatch->load_path, load, sizeof(upatch->load_path));
strscpy(upatch->unload_path, unload, sizeof(upatch->unload_path));
- ret = shirudo_build_package_unload(upatch->name, payload, unload,
- pkey, cert_path);
+ ret = build_package_unload(upatch->name, payload, unload,
+ pkey, cert_path);
}
if (!ret)
ret = build_archive(spec, version, cert_path, fingerprint, out_dir);
@@ -2125,37 +2125,37 @@ static void bpm_usage(FILE *fp)
"through `shirudo bpm`. Each accepts --help.\n");
}
-bool shirudo_build_is_help(const char *arg)
+bool build_is_help(const char *arg)
{
return arg && (!strcmp(arg, "--help") || !strcmp(arg, "-h") ||
!strcmp(arg, "help"));
}
-int shirudo_build_bpm(int argc, char **argv)
+int build_bpm(int argc, char **argv)
{
int ret;
- if (argc < 2 || shirudo_build_is_help(argv[1])) {
+ if (argc < 2 || build_is_help(argv[1])) {
bpm_usage(argc < 2 ? stderr : stdout);
return argc < 2 ? 2 : 0;
}
if (!strcmp(argv[1], "build")) {
- ret = shirudo_build_bpm_build(argc - 1, argv + 1);
+ ret = build_bpm_build(argc - 1, argv + 1);
if (ret < 0 && ret != -EINVAL)
pr_err("bpm build: %s", strerror(-ret));
return ret ? 1 : 0;
}
if (!strcmp(argv[1], "config") && argc >= 3 &&
!strcmp(argv[2], "update")) {
- ret = shirudo_build_bpm_config_update(argc - 2, argv + 2);
+ ret = build_bpm_config_update(argc - 2, argv + 2);
if (ret < 0 && ret != -EINVAL)
pr_err("bpm config update: %s", strerror(-ret));
return ret ? 1 : 0;
}
if (!strcmp(argv[1], "push"))
- return shirudo_build_bpm_push(argc - 1, argv + 1);
+ return build_bpm_push(argc - 1, argv + 1);
if (!strcmp(argv[1], "tree"))
- return shirudo_build_bpm_tree(argc - 1, argv + 1);
+ return build_bpm_tree(argc - 1, argv + 1);
pr_err("shirudo-build bpm: '%s' is not an operator bpm command", argv[1]);
bpm_usage(stderr);
return 2;
diff --git a/tools/shirudo-build/bpm-publish.c b/tools/shirudo-build/bpm-publish.c
index 9cb20e45..9af73c42 100644
--- a/tools/shirudo-build/bpm-publish.c
+++ b/tools/shirudo-build/bpm-publish.c
@@ -674,7 +674,7 @@ static int cmd_bpm_tree_append(int argc, char **argv)
cert = cert_path;
}
}
- if (shirudo_build_check_keys(key, cert))
+ if (build_check_keys(key, cert))
return -EACCES;
if (bpm_trim(raw_repository, repo_ref, sizeof(repo_ref))) {
pr_err("bpm tree append: repository is longer than %zu bytes",
@@ -854,14 +854,14 @@ static void bpm_push_usage(void)
" --keys-dir /var/lib/shirudo/keys\n");
}
-int shirudo_build_bpm_push(int argc, char **argv)
+int build_bpm_push(int argc, char **argv)
{
const char *package = NULL, *repository = NULL, *reference = NULL;
const char *keys_dir_arg = NULL, *index_cert = NULL, *index_key = NULL;
char cert_path[PATH_MAX], key_path[PATH_MAX];
int ret;
- if (argc == 2 && shirudo_build_is_help(argv[1])) {
+ if (argc == 2 && build_is_help(argv[1])) {
bpm_push_usage();
return 0;
}
@@ -910,7 +910,7 @@ int shirudo_build_bpm_push(int argc, char **argv)
pr_err("bpm push: --index-cert and --index-key must be supplied together");
return 2;
}
- if (index_key && shirudo_build_check_keys(index_key, index_cert))
+ if (index_key && build_check_keys(index_key, index_cert))
return 1;
if (curl_global_init(CURL_GLOBAL_DEFAULT) != CURLE_OK)
return publish_fail("initialize curl", -EIO);
@@ -923,15 +923,15 @@ int shirudo_build_bpm_push(int argc, char **argv)
return 0;
}
-int shirudo_build_bpm_tree(int argc, char **argv)
+int build_bpm_tree(int argc, char **argv)
{
int ret;
if (argc < 2 || strcmp(argv[1], "append")) {
tree_append_usage();
- return argc >= 2 && shirudo_build_is_help(argv[1]) ? 0 : 2;
+ return argc >= 2 && build_is_help(argv[1]) ? 0 : 2;
}
- if (argc == 3 && shirudo_build_is_help(argv[2])) {
+ if (argc == 3 && build_is_help(argv[2])) {
tree_append_usage();
return 0;
}
diff --git a/tools/shirudo-build/bpm.h b/tools/shirudo-build/bpm.h
index 65e96b2b..1ec292cd 100644
--- a/tools/shirudo-build/bpm.h
+++ b/tools/shirudo-build/bpm.h
@@ -90,13 +90,13 @@ int bpm_build_parse_beefile(const __u8 *body, size_t len,
struct bpm_build_spec *spec);
void bpm_build_spec_free(struct bpm_build_spec *spec);
-int shirudo_build_bpm(int argc, char **argv);
-int shirudo_build_bpm_push(int argc, char **argv);
-int shirudo_build_bpm_tree(int argc, char **argv);
-bool shirudo_build_is_help(const char *arg);
+int build_bpm(int argc, char **argv);
+int build_bpm_push(int argc, char **argv);
+int build_bpm_tree(int argc, char **argv);
+bool build_is_help(const char *arg);
-int shirudo_build_check_keys(const char *pkey, const char *cert);
+int build_check_keys(const char *pkey, const char *cert);
-int shirudo_build_keys_vouch(int argc, char **argv);
+int build_keys_vouch(int argc, char **argv);
#endif /* SHIRUDO_BUILD_BPM_H */
diff --git a/tools/shirudo-build/compile.c b/tools/shirudo-build/compile.c
index 35f1fc6d..8e232f6f 100644
--- a/tools/shirudo-build/compile.c
+++ b/tools/shirudo-build/compile.c
@@ -66,9 +66,9 @@ static const char *locate_shirudo_bpf_headers(void)
return NULL;
}
-int shirudo_build_compile(const char *source, const char *output,
- const char *vmlinux_h, const char *extra_cflags,
- const char *shirudo_bpf_incdir)
+int build_compile(const char *source, const char *output,
+ const char *vmlinux_h, const char *extra_cflags,
+ const char *shirudo_bpf_incdir)
{
const char *argv[BUILD_MAX_ARGS] = {};
char inc_vmlinux[1024 + 8];
diff --git a/tools/shirudo-build/compile.h b/tools/shirudo-build/compile.h
index 863d2d7c..44499cfb 100644
--- a/tools/shirudo-build/compile.h
+++ b/tools/shirudo-build/compile.h
@@ -8,9 +8,9 @@
#ifndef SHIRUDO_BUILD_COMPILE_H
#define SHIRUDO_BUILD_COMPILE_H
-int shirudo_build_compile(const char *source, const char *output,
- const char *vmlinux_h,
- const char *extra_cflags,
- const char *shirudo_bpf_incdir);
+int build_compile(const char *source, const char *output,
+ const char *vmlinux_h,
+ const char *extra_cflags,
+ const char *shirudo_bpf_incdir);
#endif /* SHIRUDO_BUILD_COMPILE_H */
diff --git a/tools/shirudo-build/image.c b/tools/shirudo-build/image.c
index a851971b..d35ecab3 100644
--- a/tools/shirudo-build/image.c
+++ b/tools/shirudo-build/image.c
@@ -136,7 +136,7 @@ static int verify_root_signature(const char root[65], const __u8 *signature,
static int verify_image(const char *prefix, const char *cert)
{
- struct shirudo_config_image_open image = {
+ struct config_image_open image = {
.data_fd = -1, .hash_fd = -1, .signature_fd = -1,
};
__u8 signature[CONFIG_IMAGE_SIG_MAX + 1];
@@ -145,7 +145,7 @@ static int verify_image(const char *prefix, const char *cert)
ssize_t n;
int ret;
- ret = shirudo_config_image_open(prefix, &image);
+ ret = config_image_open(prefix, &image);
if (ret)
return ret;
while (size < sizeof(signature)) {
@@ -173,7 +173,7 @@ static int verify_image(const char *prefix, const char *cert)
if (!ret)
puts(root);
out:
- shirudo_config_image_close(&image);
+ config_image_close(&image);
return ret;
}
@@ -188,7 +188,7 @@ static int sign_root(const char *input, const char *output, const char *pkey,
ssize_t size;
int fd, ret;
- if (shirudo_build_check_keys(pkey, cert))
+ if (build_check_keys(pkey, cert))
return -EKEYREJECTED;
fd = open(input, O_RDONLY | O_NOFOLLOW | O_CLOEXEC | O_NONBLOCK);
if (fd < 0)
diff --git a/tools/shirudo-build/package.c b/tools/shirudo-build/package.c
index 89589cd6..c7d51218 100644
--- a/tools/shirudo-build/package.c
+++ b/tools/shirudo-build/package.c
@@ -344,12 +344,12 @@ out:
return ret;
}
-static int shirudo_build_package_resign(const char *original,
- const char *modified,
- const char *output,
- const struct shirudo_data_range *ranges,
- size_t nr_ranges, const char *pkey_path,
- const char *cert_path)
+static int build_package_resign(const char *original,
+ const char *modified,
+ const char *output,
+ const struct shirudo_data_range *ranges,
+ size_t nr_ranges, const char *pkey_path,
+ const char *cert_path)
{
static const char *const symbols[] = {
"obs_watch_v4", "obs_watch_v6",
@@ -360,8 +360,8 @@ static int shirudo_build_package_resign(const char *original,
pkey_path, cert_path);
}
-int shirudo_build_package_patch_rodata(const char *input, const char *output,
- const char *symbol, const __u8 *value,
+int build_package_patch_rodata(const char *input, const char *output,
+ const char *symbol, const __u8 *value,
size_t value_len, const char *pkey_path,
const char *cert_path)
{
@@ -433,7 +433,7 @@ out:
return ret;
}
-int shirudo_build_package_verify(const char *input, const char *cert_path)
+int build_package_verify(const char *input, const char *cert_path)
{
struct shirudo_upatch upatch = {};
int ret;
@@ -447,7 +447,7 @@ int shirudo_build_package_verify(const char *input, const char *cert_path)
return ret;
}
-int shirudo_build_upatch_cli(int argc, char **argv)
+int build_upatch_cli(int argc, char **argv)
{
const char *keys_dir = NULL, *original = NULL, *modified = NULL;
const char *output = NULL;
@@ -533,8 +533,8 @@ int shirudo_build_upatch_cli(int argc, char **argv)
cert = cert_buf;
}
}
- ret = shirudo_build_package_resign(original, modified, output,
- ranges, nr_ranges, pkey, cert);
+ ret = build_package_resign(original, modified, output,
+ ranges, nr_ranges, pkey, cert);
if (ret)
pr_err("upatch rewrite-rodata: %s", strerror(-ret));
return ret ? 1 : 0;
@@ -1750,9 +1750,9 @@ static int check_upatch_name(const char *name)
return -EINVAL;
}
-int shirudo_build_package_load(const char *bpf_o, const char *src_path,
- const char *out_path, const char *upatch_name,
- const char *pkey_path, const char *cert_path)
+int build_package_load(const char *bpf_o, const char *src_path,
+ const char *out_path, const char *upatch_name,
+ const char *pkey_path, const char *cert_path)
{
struct bpf_object *obj;
int handler_ids[2] = {-1, -1};
@@ -1796,11 +1796,11 @@ static struct bpf_map *find_rodata(struct bpf_object *obj)
return NULL;
}
-int shirudo_build_package_unload(const char *upatch_name,
- const __u8 payload_sha256[32],
- const char *out_upatch,
- const char *pkey_path,
- const char *cert_path)
+int build_package_unload(const char *upatch_name,
+ const __u8 payload_sha256[32],
+ const char *out_upatch,
+ const char *pkey_path,
+ const char *cert_path)
{
const struct shirudo_embedded_bpf *blob = unload_blob();
struct shirudo_unload_params params = {};
diff --git a/tools/shirudo-build/package.h b/tools/shirudo-build/package.h
index b9531fcd..59883cbf 100644
--- a/tools/shirudo-build/package.h
+++ b/tools/shirudo-build/package.h
@@ -10,21 +10,21 @@
#include <shirudo/misc.h>
-int shirudo_build_package_load(const char *bpf_o, const char *src_path,
- const char *out_upatch, const char *upatch_name,
- const char *pkey_path, const char *cert_path);
+int build_package_load(const char *bpf_o, const char *src_path,
+ const char *out_upatch, const char *upatch_name,
+ const char *pkey_path, const char *cert_path);
-int shirudo_build_package_unload(const char *name,
- const __u8 payload_sha256[32],
- const char *out_upatch,
- const char *pkey_path,
- const char *cert_path);
+int build_package_unload(const char *name,
+ const __u8 payload_sha256[32],
+ const char *out_upatch,
+ const char *pkey_path,
+ const char *cert_path);
-int shirudo_build_package_patch_rodata(const char *input, const char *output,
- const char *symbol, const __u8 *value,
+int build_package_patch_rodata(const char *input, const char *output,
+ const char *symbol, const __u8 *value,
size_t value_len, const char *pkey_path,
const char *cert_path);
-int shirudo_build_package_verify(const char *input, const char *cert_path);
-int shirudo_build_upatch_cli(int argc, char **argv);
+int build_package_verify(const char *input, const char *cert_path);
+int build_upatch_cli(int argc, char **argv);
#endif /* SHIRUDO_BUILD_PACKAGE_H */
diff --git a/tools/shirudo-build/shirudo-build.c b/tools/shirudo-build/shirudo-build.c
index bfab754c..a50d9134 100644
--- a/tools/shirudo-build/shirudo-build.c
+++ b/tools/shirudo-build/shirudo-build.c
@@ -145,7 +145,7 @@ static int compile_to_temp(const char *source, const char *vmlinux_h,
return -errno;
close(fd);
- ret = shirudo_build_compile(source, tmpl, vmlinux_h, extra_cflags, NULL);
+ ret = build_compile(source, tmpl, vmlinux_h, extra_cflags, NULL);
if (ret) {
unlink(tmpl);
return ret;
@@ -158,7 +158,7 @@ static int compile_to_temp(const char *source, const char *vmlinux_h,
return 0;
}
-int shirudo_build_check_keys(const char *pkey, const char *cert)
+int build_check_keys(const char *pkey, const char *cert)
{
int fd = open_signing_key(pkey);
@@ -214,12 +214,12 @@ int main(int argc, char **argv)
if (argc >= 2 && strcmp(argv[1], "image") == 0)
return shirudo_build_image(argc - 1, argv + 1);
if (argc >= 2 && strcmp(argv[1], "upatch") == 0)
- return shirudo_build_upatch_cli(argc - 1, argv + 1);
+ return build_upatch_cli(argc - 1, argv + 1);
if (argc >= 2 && strcmp(argv[1], "bpm") == 0)
- return shirudo_build_bpm(argc - 1, argv + 1);
+ return build_bpm(argc - 1, argv + 1);
if (argc >= 3 && strcmp(argv[1], "keys") == 0 &&
strcmp(argv[2], "vouch") == 0)
- return shirudo_build_keys_vouch(argc - 2, argv + 2);
+ return build_keys_vouch(argc - 2, argv + 2);
for (i = 1; i < argc; i++) {
const char *a = argv[i];
@@ -289,7 +289,7 @@ int main(int argc, char **argv)
}
}
- if (shirudo_build_check_keys(pkey, cert))
+ if (build_check_keys(pkey, cert))
return 1;
if (unload_name) {
@@ -347,8 +347,8 @@ int main(int argc, char **argv)
pr_info("writing %s (no -o given)", output);
}
- ret = shirudo_build_package_unload(unload_name, payload_sha256,
- output, pkey, cert);
+ ret = build_package_unload(unload_name, payload_sha256,
+ output, pkey, cert);
if (ret == 0 && emit_artifacts) {
printf("emitted:\n");
printf(" upatch: %s\n", output);
@@ -381,7 +381,7 @@ int main(int argc, char **argv)
if (ends_with(input, ".bpf.c")) {
const char *vmlinux_h =
- shirudo_build_locate_vmlinux(vmlinux_override);
+ build_locate_vmlinux(vmlinux_override);
if (!vmlinux_h) {
pr_err("vmlinux.h not found (tried %s, ./vmlinux.h, "
"./vendor/linux/vmlinux.h, %s)",
@@ -397,8 +397,8 @@ int main(int argc, char **argv)
output, strerror(-ret));
return 1;
}
- ret = shirudo_build_compile(input, artifact_buf,
- vmlinux_h, extra_cflags, NULL);
+ ret = build_compile(input, artifact_buf,
+ vmlinux_h, extra_cflags, NULL);
if (ret) {
pr_err("compile %s: %d", input, ret);
return 1;
@@ -425,8 +425,8 @@ int main(int argc, char **argv)
if (!name)
name = derive_name(input, name_buf, sizeof(name_buf));
- ret = shirudo_build_package_load(bpf_o, src_path, output, name,
- pkey, cert);
+ ret = build_package_load(bpf_o, src_path, output, name,
+ pkey, cert);
if (temp_bpf_o) {
unlink(temp_bpf_o);
diff --git a/tools/shirudo-build/vmlinux.c b/tools/shirudo-build/vmlinux.c
index aaa13410..8740c530 100644
--- a/tools/shirudo-build/vmlinux.c
+++ b/tools/shirudo-build/vmlinux.c
@@ -14,7 +14,7 @@
#define VMLINUX_PATH "/usr/local/share/shirudo/vmlinux.h"
#endif
-const char *shirudo_build_locate_vmlinux(const char *override)
+const char *build_locate_vmlinux(const char *override)
{
if (override)
return access(override, R_OK) == 0 ? override : NULL;
diff --git a/tools/shirudo-build/vmlinux.h b/tools/shirudo-build/vmlinux.h
index ed3ca140..7b5a4297 100644
--- a/tools/shirudo-build/vmlinux.h
+++ b/tools/shirudo-build/vmlinux.h
@@ -8,6 +8,6 @@
#ifndef SHIRUDO_BUILD_VMLINUX_H
#define SHIRUDO_BUILD_VMLINUX_H
-const char *shirudo_build_locate_vmlinux(const char *override);
+const char *build_locate_vmlinux(const char *override);
#endif /* SHIRUDO_BUILD_VMLINUX_H */
diff --git a/tools/shirudo-build/vouch.c b/tools/shirudo-build/vouch.c
index 631ee264..7b9f4b42 100644
--- a/tools/shirudo-build/vouch.c
+++ b/tools/shirudo-build/vouch.c
@@ -77,7 +77,7 @@ static int write_file(const char *path, const void *data, size_t len)
return ret;
}
-int shirudo_build_keys_vouch(int argc, char **argv)
+int build_keys_vouch(int argc, char **argv)
{
const char *pkey = SIGNING_KEY_PATH, *cert = CERT_PATH;
const char *keys_dir_arg = NULL, *input = NULL, *output = NULL;
@@ -146,7 +146,7 @@ int shirudo_build_keys_vouch(int argc, char **argv)
cert = cert_path;
}
}
- if (shirudo_build_check_keys(pkey, cert))
+ if (build_check_keys(pkey, cert))
return 1;
if (!output) {
if (strsprintf(out_path, sizeof(out_path), "%s.vouch", input) < 0) {
diff --git a/util/attest.c b/util/attest.c
index 5bab355c..b8bc485d 100644
--- a/util/attest.c
+++ b/util/attest.c
@@ -141,11 +141,11 @@ static bool quote_covers(const struct shirudo_tpm_attestation *quote,
return ct_eq(digest, a.pcr_digest, 32);
}
-int shirudo_attest_evidence_config(const __u8 *nonce, size_t nonce_len,
- __u32 pcr_mask,
- const struct shirudo_attest_challenge *c,
- struct shirudo_config_update *update,
- char **out, size_t *len, size_t *cap)
+int attest_evidence_config(const __u8 *nonce, size_t nonce_len,
+ __u32 pcr_mask,
+ const struct shirudo_attest_challenge *c,
+ struct shirudo_config_update *update,
+ char **out, size_t *len, size_t *cap)
{
const struct shirudo_attest_challenge *challenge = c;
struct shirudo_tpm_key ak = { .handle = 0 }, ek = { .handle = 0 };
@@ -174,7 +174,7 @@ int shirudo_attest_evidence_config(const __u8 *nonce, size_t nonce_len,
(pcr_mask & ~0x00FFFFFFu))
return -EINVAL;
- ret = shirudo_config_evidence_collect(update, &config);
+ ret = config_evidence_collect(update, &config);
if (ret)
return ret;
if (config.present)
@@ -354,7 +354,7 @@ int shirudo_attest_evidence_config(const __u8 *nonce, size_t nonce_len,
json_arr_open(&e, "eventlog");
eventlog_boot_lines(emit_line, &e);
json_arr_close(&e);
- ret = shirudo_config_evidence_emit(&e, &config);
+ ret = config_evidence_emit(&e, &config);
if (ret)
goto out;
if (cred_len) {
@@ -392,7 +392,7 @@ out:
tpm_key_flush(tpm, &ak);
tpm_close(tpm);
}
- shirudo_config_evidence_clear(&config);
+ config_evidence_clear(&config);
xfree(ek_cert, ek_cert ? EK_CERT_MAX : 0);
xfree(ek_b64, ek_b64_cap);
xfree(fw, fw_cap);
@@ -891,7 +891,7 @@ int attest_verify(const char *evidence, size_t len,
have_cred = cred_sub[0].seen;
}
- ret = shirudo_config_evidence_parse(evidence, len, &config);
+ ret = config_evidence_parse(evidence, len, &config);
if (ret == -EKEYREJECTED)
say(&rep, false, "config: the events are one boot event followed by updates in sequence");
if (ret)
@@ -1066,11 +1066,11 @@ int attest_verify(const char *evidence, size_t len,
int pcr;
pcr = expect->have_config_pcr ? (int)expect->config_pcr : -1;
- ret = shirudo_config_evidence_verify(&config, quote.pcr_mask,
- quote.reset_count,
- quote.restart_count,
- p->pcrs, root, pcr,
- &reason);
+ ret = config_evidence_verify(&config, quote.pcr_mask,
+ quote.reset_count,
+ quote.restart_count,
+ p->pcrs, root, pcr,
+ &reason);
say(&rep, !ret, "config: %s", reason);
if (config.present && !expect->have_config_root)
note(&rep, "config root has no operator approval; use "
@@ -1236,7 +1236,7 @@ int attest_verify(const char *evidence, size_t len,
}
ret = rep.failed ? -EKEYREJECTED : 0;
out:
- shirudo_config_evidence_clear(&config);
+ config_evidence_clear(&config);
xfree(p->recs, RECORDS_MAX * sizeof(*p->recs));
xfree(p, sizeof(*p));
return ret;
diff --git a/util/attest.h b/util/attest.h
index bccecd73..fb947dcf 100644
--- a/util/attest.h
+++ b/util/attest.h
@@ -50,11 +50,11 @@ struct shirudo_config_update;
* -ENXIO when no TPM answers, -ENODEV when no register is bound this
* boot, -EKEYREJECTED when the TPM refuses the challenge.
*/
-int shirudo_attest_evidence_config(const __u8 *nonce, size_t nonce_len,
- __u32 pcr_mask,
- const struct shirudo_attest_challenge *c,
- struct shirudo_config_update *update,
- char **out, size_t *len, size_t *cap);
+int attest_evidence_config(const __u8 *nonce, size_t nonce_len,
+ __u32 pcr_mask,
+ const struct shirudo_attest_challenge *c,
+ struct shirudo_config_update *update,
+ char **out, size_t *len, size_t *cap);
/*
* Operator side. The credential the target has to recover is handed
diff --git a/util/bpm_tree_state.c b/util/bpm_tree_state.c
index 8f71e7e9..383eec57 100644
--- a/util/bpm_tree_state.c
+++ b/util/bpm_tree_state.c
@@ -73,9 +73,9 @@ bool tree_configured(void)
{
int fd;
- if (!shirudo_image_config_active())
+ if (!image_config_active())
return access(BPM_TREE_ETC_PATH, R_OK) == 0;
- fd = shirudo_image_open(SHIRUDO_IMAGE_TREE_CONF, O_RDONLY);
+ fd = image_open(SHIRUDO_IMAGE_TREE_CONF, O_RDONLY);
if (fd < 0)
return false;
close(fd);
@@ -446,9 +446,9 @@ int tree_selector_matches(const struct shirudo_tree_selector *s)
}
}
if (s->n_labels) {
- if (shirudo_image_config_active()) {
- int fd = shirudo_image_open(SHIRUDO_IMAGE_NODE_LABELS,
- O_RDONLY);
+ if (image_config_active()) {
+ int fd = image_open(SHIRUDO_IMAGE_NODE_LABELS,
+ O_RDONLY);
if (fd == -ENOENT)
return 0;
diff --git a/util/chain.c b/util/chain.c
index 6a37ac7a..c459851a 100644
--- a/util/chain.c
+++ b/util/chain.c
@@ -151,7 +151,7 @@ void chain_tree_event(__s64 seq, const __u8 operation_digest[32],
shirudo_sha256(buf, taglen + 40, event);
}
-int shirudo_chain_fold_checked(__u8 chain[32], const __u8 event[32])
+int chain_fold_checked(__u8 chain[32], const __u8 event[32])
{
__u8 cat[64];
@@ -162,7 +162,7 @@ int shirudo_chain_fold_checked(__u8 chain[32], const __u8 event[32])
void chain_fold(__u8 chain[32], const __u8 event[32])
{
- if (shirudo_chain_fold_checked(chain, event))
+ if (chain_fold_checked(chain, event))
memset(chain, 0, 32);
}
@@ -268,7 +268,7 @@ int chain_tpm_bound(struct shirudo_tpm *tpm)
struct shirudo_tpm_key ak = {};
int ret;
- ret = shirudo_enforcement_active();
+ ret = enforcement_active();
if (ret <= 0)
return ret;
ret = identity_read(&id);
diff --git a/util/chain.h b/util/chain.h
index 7e6e134b..fb661758 100644
--- a/util/chain.h
+++ b/util/chain.h
@@ -64,7 +64,7 @@ int chain_upatch_event(const char *tag, const char *name,
const __u8 payload[32], __u8 event[32]);
void chain_tree_event(__s64 seq, const __u8 operation_digest[32],
__u8 event[32]);
-int shirudo_chain_fold_checked(__u8 chain[32], const __u8 event[32]);
+int chain_fold_checked(__u8 chain[32], const __u8 event[32]);
void chain_fold(__u8 chain[32], const __u8 event[32]);
/* The PCR record anchoring a register name: nvpcr-init:shirudo:0x..:<name>. */
diff --git a/util/conditions.h b/util/conditions.h
index 0f52fded..2343a2d7 100644
--- a/util/conditions.h
+++ b/util/conditions.h
@@ -44,7 +44,7 @@ struct shirudo_conditions_input {
int cm_seen;
const char *nv_index;
int config_seen;
- int config_state; /* shirudo_image_config_state() */
+ int config_state; /* image_config_state() */
const char *config_root; /* hex, when config_seen */
};
diff --git a/util/config.c b/util/config.c
index debc7e1a..b4bea087 100644
--- a/util/config.c
+++ b/util/config.c
@@ -352,7 +352,7 @@ int config_load(struct shirudo_config *cfg)
const char *env;
int ret;
- if (shirudo_image_config_get(cfg))
+ if (image_config_get(cfg))
return 0;
ret = config_load_path(cfg, CONF_PATH);
if (ret && ret != -ENOENT)
diff --git a/util/config_attest.c b/util/config_attest.c
index d776a87f..d5cac488 100644
--- a/util/config_attest.c
+++ b/util/config_attest.c
@@ -56,10 +56,10 @@ static int replay(const struct shirudo_config_evidence *view, __u8 out[32])
event->kind != (i ? SHIRUDO_CONFIG_EVENT_UPDATE :
SHIRUDO_CONFIG_EVENT_BOOT))
return -EKEYREJECTED;
- ret = shirudo_config_measure_event(event->kind, event->root_hash,
- digest);
+ ret = config_measure_event(event->kind, event->root_hash,
+ digest);
if (!ret)
- ret = shirudo_chain_fold_checked(out, digest);
+ ret = chain_fold_checked(out, digest);
if (ret)
return ret;
sequence = event->sequence;
@@ -85,8 +85,8 @@ static int collect_event(const struct shirudo_config_update_record *record,
return append_event(view, &event);
}
-int shirudo_config_evidence_collect(struct shirudo_config_update *update,
- struct shirudo_config_evidence *out)
+int config_evidence_collect(struct shirudo_config_update *update,
+ struct shirudo_config_evidence *out)
{
struct shirudo_config_update_record active;
const struct shirudo_config_evidence_event *last;
@@ -95,14 +95,14 @@ int shirudo_config_evidence_collect(struct shirudo_config_update *update,
memset(out, 0, sizeof(*out));
if (!update)
return 0;
- ret = shirudo_config_update_check(update, &active);
+ ret = config_update_check(update, &active);
if (ret)
return ret;
out->pcr = active.pcr;
out->reset_count = active.reset_count;
out->restart_count = active.restart_count;
memcpy(out->initial_pcr, active.initial_pcr, 32);
- ret = shirudo_config_update_events(update, collect_event, out);
+ ret = config_update_events(update, collect_event, out);
if (!ret)
ret = replay(out, out->value);
if (!ret) {
@@ -112,14 +112,14 @@ int shirudo_config_evidence_collect(struct shirudo_config_update *update,
ret = -EUCLEAN;
}
if (ret) {
- shirudo_config_evidence_clear(out);
+ config_evidence_clear(out);
return ret;
}
out->present = true;
return 0;
}
-void shirudo_config_evidence_clear(struct shirudo_config_evidence *view)
+void config_evidence_clear(struct shirudo_config_evidence *view)
{
if (!view)
return;
@@ -136,8 +136,8 @@ static void emit_hash(struct shirudo_json_emit *emit, const char *key,
json_kv_string(emit, key, hex);
}
-int shirudo_config_evidence_emit(struct shirudo_json_emit *emit,
- const struct shirudo_config_evidence *view)
+int config_evidence_emit(struct shirudo_json_emit *emit,
+ const struct shirudo_config_evidence *view)
{
size_t i;
@@ -195,8 +195,8 @@ static int on_event(void *opaque)
return append_event(parser->view, &event);
}
-int shirudo_config_evidence_parse(const char *evidence, size_t length,
- struct shirudo_config_evidence *out)
+int config_evidence_parse(const char *evidence, size_t length,
+ struct shirudo_config_evidence *out)
{
struct config_parser parser = { .view = out };
struct shirudo_json_array sink = { on_event, &parser };
@@ -242,7 +242,7 @@ int shirudo_config_evidence_parse(const char *evidence, size_t length,
}
if (schema != 1 || reset < 0 || reset > UINT32_MAX || restart < 0 ||
restart > UINT32_MAX || pcr < 0 || pcr > 15 ||
- shirudo_config_measure_pcr_valid(pcr) || strlen(initial) != 64 ||
+ config_measure_pcr_valid(pcr) || strlen(initial) != 64 ||
hex_decode(initial, out->initial_pcr, 32)) {
ret = -EINVAL;
goto fail;
@@ -256,15 +256,15 @@ int shirudo_config_evidence_parse(const char *evidence, size_t length,
out->present = true;
return 0;
fail:
- shirudo_config_evidence_clear(out);
+ config_evidence_clear(out);
return ret;
}
-int shirudo_config_evidence_verify(const struct shirudo_config_evidence *view,
- __u32 quote_mask, __u32 reset,
- __u32 restart, const __u8 pcrs[24][32],
- const __u8 *expected_root,
- int expected_pcr, const char **reason)
+int config_evidence_verify(const struct shirudo_config_evidence *view,
+ __u32 quote_mask, __u32 reset,
+ __u32 restart, const __u8 pcrs[24][32],
+ const __u8 *expected_root,
+ int expected_pcr, const char **reason)
{
__u8 value[32];
int ret;
@@ -274,7 +274,7 @@ int shirudo_config_evidence_verify(const struct shirudo_config_evidence *view,
*reason = "configuration evidence is missing";
return expected_root || expected_pcr >= 0 ? -EKEYREJECTED : 0;
}
- if (shirudo_config_measure_pcr_valid(view->pcr) ||
+ if (config_measure_pcr_valid(view->pcr) ||
!(quote_mask & (1u << view->pcr)) ||
(expected_pcr >= 0 && view->pcr != (__u32)expected_pcr)) {
*reason = "config PCR is unquoted or unexpected";
diff --git a/util/config_attest.h b/util/config_attest.h
index b9fa047b..1a33623a 100644
--- a/util/config_attest.h
+++ b/util/config_attest.h
@@ -34,17 +34,17 @@ struct shirudo_config_evidence {
bool present;
};
-int shirudo_config_evidence_collect(struct shirudo_config_update *update,
- struct shirudo_config_evidence *out);
-void shirudo_config_evidence_clear(struct shirudo_config_evidence *view);
-int shirudo_config_evidence_emit(struct shirudo_json_emit *emit,
- const struct shirudo_config_evidence *view);
-int shirudo_config_evidence_parse(const char *evidence, size_t length,
- struct shirudo_config_evidence *out);
-int shirudo_config_evidence_verify(const struct shirudo_config_evidence *view,
- __u32 quote_mask, __u32 reset,
- __u32 restart, const __u8 pcrs[24][32],
- const __u8 *expected_root,
- int expected_pcr, const char **reason);
+int config_evidence_collect(struct shirudo_config_update *update,
+ struct shirudo_config_evidence *out);
+void config_evidence_clear(struct shirudo_config_evidence *view);
+int config_evidence_emit(struct shirudo_json_emit *emit,
+ const struct shirudo_config_evidence *view);
+int config_evidence_parse(const char *evidence, size_t length,
+ struct shirudo_config_evidence *out);
+int config_evidence_verify(const struct shirudo_config_evidence *view,
+ __u32 quote_mask, __u32 reset,
+ __u32 restart, const __u8 pcrs[24][32],
+ const __u8 *expected_root,
+ int expected_pcr, const char **reason);
#endif /* SHIRUDO_CONFIG_ATTEST_H */
diff --git a/util/config_image.c b/util/config_image.c
index 0025e03e..2808d558 100644
--- a/util/config_image.c
+++ b/util/config_image.c
@@ -103,8 +103,8 @@ static int validate_superblock(const struct verity_superblock *header)
return 0;
}
-int shirudo_config_image_read_header(int hash_fd,
- struct shirudo_config_image *out)
+int config_image_read_header(int hash_fd,
+ struct shirudo_config_image *out)
{
struct shirudo_config_image image = {};
struct verity_superblock header;
@@ -126,8 +126,8 @@ int shirudo_config_image_read_header(int hash_fd,
return 0;
}
-int shirudo_config_image_check_files(int data_fd, int hash_fd,
- const struct shirudo_config_image *image)
+int config_image_check_files(int data_fd, int hash_fd,
+ const struct shirudo_config_image *image)
{
__u64 data_size, hash_size, blocks;
int ret;
@@ -186,7 +186,7 @@ static int read_root(const char *prefix, __u8 root[32])
return hex_decode(text, root, 32);
}
-void shirudo_config_image_close(struct shirudo_config_image_open *image)
+void config_image_close(struct config_image_open *image)
{
if (!image)
return;
@@ -202,9 +202,9 @@ void shirudo_config_image_close(struct shirudo_config_image_open *image)
}
static int open_image(const char *prefix, const __u8 *expected_root,
- struct shirudo_config_image_open *out)
+ struct config_image_open *out)
{
- struct shirudo_config_image_open image = {
+ struct config_image_open image = {
.data_fd = -1, .hash_fd = -1, .signature_fd = -1,
};
__u64 size;
@@ -221,14 +221,14 @@ static int open_image(const char *prefix, const __u8 *expected_root,
ret = image.hash_fd;
goto out;
}
- ret = shirudo_config_image_read_header(image.hash_fd,
- &image.image);
+ ret = config_image_read_header(image.hash_fd,
+ &image.image);
if (!ret)
ret = read_root(prefix, image.image.root_hash);
if (!ret)
- ret = shirudo_config_image_check_files(image.data_fd,
- image.hash_fd,
- &image.image);
+ ret = config_image_check_files(image.data_fd,
+ image.hash_fd,
+ &image.image);
if (ret)
goto out;
if (expected_root) {
@@ -244,21 +244,21 @@ static int open_image(const char *prefix, const __u8 *expected_root,
}
out:
if (ret)
- shirudo_config_image_close(&image);
+ config_image_close(&image);
else
*out = image;
return ret;
}
-int shirudo_config_image_open(const char *prefix,
- struct shirudo_config_image_open *out)
+int config_image_open(const char *prefix,
+ struct config_image_open *out)
{
return open_image(prefix, NULL, out);
}
-int shirudo_config_image_open_root(const char *prefix,
- const __u8 expected_root[32],
- struct shirudo_config_image_open *out)
+int config_image_open_root(const char *prefix,
+ const __u8 expected_root[32],
+ struct config_image_open *out)
{
return expected_root ? open_image(prefix, expected_root, out) : -EINVAL;
}
diff --git a/util/config_image.h b/util/config_image.h
index d513ff11..cc0ef726 100644
--- a/util/config_image.h
+++ b/util/config_image.h
@@ -23,7 +23,7 @@ struct shirudo_config_image {
__u8 root_hash[32];
};
-struct shirudo_config_image_open {
+struct config_image_open {
struct shirudo_config_image image;
int data_fd;
int hash_fd;
@@ -31,16 +31,16 @@ struct shirudo_config_image_open {
};
/* Read the standard veritysetup superblock; no trust decision is made. */
-int shirudo_config_image_read_header(int hash_fd,
- struct shirudo_config_image *out);
-int shirudo_config_image_check_files(int data_fd, int hash_fd,
- const struct shirudo_config_image *image);
+int config_image_read_header(int hash_fd,
+ struct shirudo_config_image *out);
+int config_image_check_files(int data_fd, int hash_fd,
+ const struct shirudo_config_image *image);
/* Hold config inputs for kernel root-signature and mapped-data verification. */
-int shirudo_config_image_open(const char *prefix,
- struct shirudo_config_image_open *out);
-int shirudo_config_image_open_root(const char *prefix,
- const __u8 expected_root[32],
- struct shirudo_config_image_open *out);
-void shirudo_config_image_close(struct shirudo_config_image_open *image);
+int config_image_open(const char *prefix,
+ struct config_image_open *out);
+int config_image_open_root(const char *prefix,
+ const __u8 expected_root[32],
+ struct config_image_open *out);
+void config_image_close(struct config_image_open *image);
#endif /* SHIRUDO_CONFIG_IMAGE_H */
diff --git a/util/config_measure.c b/util/config_measure.c
index 08e5807b..bce1224e 100644
--- a/util/config_measure.c
+++ b/util/config_measure.c
@@ -9,13 +9,13 @@
#include "config_measure.h"
#include "crypto.h"
-int shirudo_config_measure_pcr_valid(__u32 pcr)
+int config_measure_pcr_valid(__u32 pcr)
{
return pcr < 16 && pcr != 9 && pcr != 11 ? 0 : -EINVAL;
}
-int shirudo_config_measure_event(enum shirudo_config_event_kind kind,
- const __u8 root_hash[32], __u8 out[32])
+int config_measure_event(enum shirudo_config_event_kind kind,
+ const __u8 root_hash[32], __u8 out[32])
{
static const char domain[] = "shirudo-config-root-v1";
__u8 data[sizeof(domain) + 4 + 32];
diff --git a/util/config_measure.h b/util/config_measure.h
index ba6f24b2..b9d75df4 100644
--- a/util/config_measure.h
+++ b/util/config_measure.h
@@ -10,8 +10,8 @@
#include "config_update.h"
-int shirudo_config_measure_pcr_valid(__u32 pcr);
-int shirudo_config_measure_event(enum shirudo_config_event_kind kind,
- const __u8 root_hash[32], __u8 out[32]);
+int config_measure_pcr_valid(__u32 pcr);
+int config_measure_event(enum shirudo_config_event_kind kind,
+ const __u8 root_hash[32], __u8 out[32]);
#endif /* SHIRUDO_CONFIG_MEASURE_H */
diff --git a/util/config_update.c b/util/config_update.c
index 99c4fc7f..89b39821 100644
--- a/util/config_update.c
+++ b/util/config_update.c
@@ -105,7 +105,7 @@ static int record_decode(const char *data, size_t length, bool state,
return -EBADMSG;
if (schema != 1 || sequence <= 0 || reset < 0 ||
reset > UINT32_MAX || restart < 0 || restart > UINT32_MAX ||
- pcr < 0 || pcr > 15 || shirudo_config_measure_pcr_valid(pcr) ||
+ pcr < 0 || pcr > 15 || config_measure_pcr_valid(pcr) ||
(kind != SHIRUDO_CONFIG_EVENT_BOOT &&
kind != SHIRUDO_CONFIG_EVENT_UPDATE) ||
hex_decode(root, record->target.root_hash, 32) ||
@@ -168,9 +168,9 @@ static int lock_wait(int fd, __u32 wait_ms)
}
}
-int shirudo_config_update_open(const char *directory,
- const struct shirudo_config_update_ops *ops,
- void *ctx, struct shirudo_config_update *out)
+int config_update_open(const char *directory,
+ const struct shirudo_config_update_ops *ops,
+ void *ctx, struct shirudo_config_update *out)
{
struct stat st;
int ret;
@@ -228,11 +228,11 @@ int shirudo_config_update_open(const char *directory,
}
return 0;
fail:
- shirudo_config_update_close(out);
+ config_update_close(out);
return ret;
}
-void shirudo_config_update_close(struct shirudo_config_update *update)
+void config_update_close(struct shirudo_config_update *update)
{
if (!update)
return;
@@ -244,8 +244,8 @@ void shirudo_config_update_close(struct shirudo_config_update *update)
update->lock_fd = -1;
}
-int shirudo_config_update_read(struct shirudo_config_update *update,
- struct shirudo_config_update_record *out)
+int config_update_read(struct shirudo_config_update *update,
+ struct shirudo_config_update_record *out)
{
char wire[RECORD_MAX];
struct stat st;
@@ -407,10 +407,10 @@ static int events_scan(struct shirudo_config_update *update,
if (!ret && record.kind == SHIRUDO_CONFIG_EVENT_BOOT)
memcpy(running, record.initial_pcr, 32);
if (!ret)
- ret = shirudo_config_measure_event(record.kind,
- root, digest);
+ ret = config_measure_event(record.kind,
+ root, digest);
if (!ret)
- ret = shirudo_chain_fold_checked(running, digest);
+ ret = chain_fold_checked(running, digest);
if (!ret && consume)
ret = consume(&record, ctx);
if (ret)
@@ -435,8 +435,8 @@ static int events_scan(struct shirudo_config_update *update,
return ret;
}
-int shirudo_config_update_events(struct shirudo_config_update *update,
- shirudo_config_cb consume, void *ctx)
+int config_update_events(struct shirudo_config_update *update,
+ shirudo_config_cb consume, void *ctx)
{
struct shirudo_config_update_record last;
@@ -523,13 +523,13 @@ static int check_record(struct shirudo_config_update *update,
return ret;
}
-int shirudo_config_update_check(struct shirudo_config_update *update,
- struct shirudo_config_update_record *out)
+int config_update_check(struct shirudo_config_update *update,
+ struct shirudo_config_update_record *out)
{
struct shirudo_config_update_record record;
int ret;
- ret = shirudo_config_update_read(update, &record);
+ ret = config_update_read(update, &record);
if (!ret && record.pending)
ret = -EINPROGRESS;
if (!ret)
@@ -544,7 +544,7 @@ static int complete(struct shirudo_config_update *update)
struct shirudo_config_update_record record;
int ret, restore;
- ret = shirudo_config_update_read(update, &record);
+ ret = config_update_read(update, &record);
if (!ret)
ret = check_record(update, &record);
if (ret)
@@ -592,11 +592,11 @@ static int begin_event(struct shirudo_config_update *update,
if (!ret)
ret = event_follows(previous, &record);
if (!ret)
- ret = shirudo_config_measure_event(kind, target->root_hash,
- event);
+ ret = config_measure_event(kind, target->root_hash,
+ event);
memcpy(expected, before, 32);
if (!ret)
- ret = shirudo_chain_fold_checked(expected, event);
+ ret = chain_fold_checked(expected, event);
if (!ret)
ret = state_save(update, &record, true);
if (!ret)
@@ -628,17 +628,17 @@ static int begin_event(struct shirudo_config_update *update,
return complete(update);
}
-int shirudo_config_update_begin(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *t,
- __u32 pcr)
+int config_update_begin(struct shirudo_config_update *update,
+ const struct shirudo_config_update_target *t,
+ __u32 pcr)
{
struct shirudo_config_update_record previous;
int ret;
if (!update || update->dir_fd < 0 || target_valid(t) ||
- shirudo_config_measure_pcr_valid(pcr))
+ config_measure_pcr_valid(pcr))
return -EINVAL;
- ret = shirudo_config_update_check(update, &previous);
+ ret = config_update_check(update, &previous);
if (ret)
return ret;
if (pcr != previous.pcr)
@@ -649,19 +649,19 @@ int shirudo_config_update_begin(struct shirudo_config_update *update,
SHIRUDO_CONFIG_EVENT_UPDATE);
}
-int shirudo_config_update_boot(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *t,
- __u32 pcr)
+int config_update_boot(struct shirudo_config_update *update,
+ const struct shirudo_config_update_target *t,
+ __u32 pcr)
{
struct shirudo_config_update_record previous = {}, last;
__u32 reset, restart;
int ret;
if (!update || update->dir_fd < 0 || target_valid(t) ||
- shirudo_config_measure_pcr_valid(pcr))
+ config_measure_pcr_valid(pcr))
return -EINVAL;
update->boot_pending = false;
- ret = shirudo_config_update_read(update, &previous);
+ ret = config_update_read(update, &previous);
if (ret && ret != -ENOENT)
return ret;
ret = update->ops->boot_identity(update->ctx, &reset, &restart);
@@ -674,7 +674,7 @@ int shirudo_config_update_boot(struct shirudo_config_update *update,
if (previous.pcr != pcr ||
memcmp(t->root_hash, previous.target.root_hash, 32))
return -EBUSY;
- return shirudo_config_update_check(update, NULL);
+ return config_update_check(update, NULL);
}
if (previous.sequence &&
(strcmp(t->prefix, previous.target.prefix) ||
@@ -694,14 +694,14 @@ int shirudo_config_update_boot(struct shirudo_config_update *update,
SHIRUDO_CONFIG_EVENT_BOOT);
}
-int shirudo_config_update_complete_boot(struct shirudo_config_update *update)
+int config_update_complete_boot(struct shirudo_config_update *update)
{
int ret;
if (!update || update->dir_fd < 0)
return -EINVAL;
if (!update->boot_pending)
- return shirudo_config_update_check(update, NULL);
+ return config_update_check(update, NULL);
update->boot_pending = false;
ret = complete(update);
return ret;
diff --git a/util/config_update.h b/util/config_update.h
index e969115e..0cbe5905 100644
--- a/util/config_update.h
+++ b/util/config_update.h
@@ -71,25 +71,25 @@ struct shirudo_config_update {
};
/* Holds the update lock until close. The directory must already exist. */
-int shirudo_config_update_open(const char *directory,
- const struct shirudo_config_update_ops *ops,
- void *ctx, struct shirudo_config_update *out);
-void shirudo_config_update_close(struct shirudo_config_update *update);
-int shirudo_config_update_read(struct shirudo_config_update *update,
- struct shirudo_config_update_record *out);
-int shirudo_config_update_begin(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *t,
- __u32 pcr);
+int config_update_open(const char *directory,
+ const struct shirudo_config_update_ops *ops,
+ void *ctx, struct shirudo_config_update *out);
+void config_update_close(struct shirudo_config_update *update);
+int config_update_read(struct shirudo_config_update *update,
+ struct shirudo_config_update_record *out);
+int config_update_begin(struct shirudo_config_update *update,
+ const struct shirudo_config_update_target *t,
+ __u32 pcr);
/* Boot leaves intent pending until upatch restoration and NV init succeed. */
-int shirudo_config_update_boot(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *t,
- __u32 pcr);
-int shirudo_config_update_complete_boot(struct shirudo_config_update *update);
+int config_update_boot(struct shirudo_config_update *update,
+ const struct shirudo_config_update_target *t,
+ __u32 pcr);
+int config_update_complete_boot(struct shirudo_config_update *update);
/* Refuses pending updates and PCR drift; callers also validate live mounts. */
-int shirudo_config_update_check(struct shirudo_config_update *update,
- struct shirudo_config_update_record *out);
+int config_update_check(struct shirudo_config_update *update,
+ struct shirudo_config_update_record *out);
/* Events describe selections, not a proof that activation completed. */
-int shirudo_config_update_events(struct shirudo_config_update *update,
- shirudo_config_cb consume, void *ctx);
+int config_update_events(struct shirudo_config_update *update,
+ shirudo_config_cb consume, void *ctx);
#endif /* SHIRUDO_CONFIG_UPDATE_H */
diff --git a/util/dm_verity.c b/util/dm_verity.c
index 6602f3db..9d1496c6 100644
--- a/util/dm_verity.c
+++ b/util/dm_verity.c
@@ -92,7 +92,7 @@ static int dm_control_open(void)
return fd;
}
-int shirudo_dm_verity_list(shirudo_dm_verity_cb callback, void *ctx)
+int dm_verity_list(shirudo_dm_verity_cb callback, void *ctx)
{
const size_t header = offsetof(struct dm_name_list, name);
const size_t capacity = 64 * 1024;
@@ -304,9 +304,9 @@ static int check_table(union dm_buffer *buf,
return 0;
}
-int shirudo_dm_verity_inspect(const char *name,
- const struct shirudo_config_image *image,
- struct shirudo_dm_verity *out)
+int dm_verity_inspect(const char *name,
+ const struct shirudo_config_image *image,
+ struct shirudo_dm_verity *out)
{
struct shirudo_dm_verity device = {.data_loop_fd = -1,
.hash_loop_fd = -1};
@@ -335,7 +335,7 @@ int shirudo_dm_verity_inspect(const char *name,
return ret;
}
-void shirudo_dm_verity_close(struct shirudo_dm_verity *device)
+void dm_verity_close(struct shirudo_dm_verity *device)
{
if (!device)
return;
@@ -347,7 +347,7 @@ void shirudo_dm_verity_close(struct shirudo_dm_verity *device)
device->hash_loop_fd = -1;
}
-int shirudo_dm_verity_remove(struct shirudo_dm_verity *device, bool deferred)
+int dm_verity_remove(struct shirudo_dm_verity *device, bool deferred)
{
union dm_buffer buf;
int control, ret;
@@ -363,7 +363,7 @@ int shirudo_dm_verity_remove(struct shirudo_dm_verity *device, bool deferred)
ret = dm_command(control, DM_DEV_REMOVE, &buf);
close(control);
if (!ret)
- shirudo_dm_verity_close(device);
+ dm_verity_close(device);
return ret;
}
@@ -422,8 +422,8 @@ static key_serial_t signature_key(int fd, char description[64])
return key;
}
-int shirudo_dm_verity_create(const struct shirudo_config_image_open *image,
- const char *name, struct shirudo_dm_verity *out)
+int dm_verity_create(const struct config_image_open *image,
+ const char *name, struct shirudo_dm_verity *out)
{
struct shirudo_dm_verity device = {.data_loop_fd = -1,
.hash_loop_fd = -1};
@@ -442,8 +442,8 @@ int shirudo_dm_verity_create(const struct shirudo_config_image_open *image,
if (!image || !out || !dm_name_ok(name))
return -EINVAL;
*out = device;
- ret = shirudo_config_image_check_files(image->data_fd, image->hash_fd,
- &image->image);
+ ret = config_image_check_files(image->data_fd, image->hash_fd,
+ &image->image);
if (ret)
return ret;
device.image = image->image;
@@ -513,7 +513,7 @@ int shirudo_dm_verity_create(const struct shirudo_config_image_open *image,
target->next = (sizeof(*target) + n + 1 + 7) & ~7u;
buf.io.data_size = buf.io.data_start + target->next;
if (image->image.signed_root) {
- ret = shirudo_config_root_begin(image->image.root_hash, &guard);
+ ret = config_root_begin(image->image.root_hash, &guard);
if (ret)
goto out;
}
@@ -533,7 +533,7 @@ int shirudo_dm_verity_create(const struct shirudo_config_image_open *image,
if (!ret)
ret = device_path(&device, buf.io.dev);
out:
- cleanup = shirudo_config_root_end(&guard);
+ cleanup = config_root_end(&guard);
if (!ret)
ret = cleanup;
if (key >= 0)
@@ -543,7 +543,7 @@ out:
dm_init(&buf, name);
(void)dm_command(control, DM_DEV_REMOVE, &buf);
}
- shirudo_dm_verity_close(&device);
+ dm_verity_close(&device);
} else {
*out = device;
}
@@ -593,8 +593,8 @@ static int loop_check(int loop_fd, int file_fd, __u64 bytes)
}
/* Direct reads verify all logical data, including blocks outside live files. */
-int shirudo_dm_verity_verify(const struct shirudo_dm_verity *device,
- const struct shirudo_config_image_open *image)
+int dm_verity_verify(const struct shirudo_dm_verity *device,
+ const struct config_image_open *image)
{
_Alignas(4096) __u8 buffer[65536];
int data = -1, hashes = -1, fd = -1;
@@ -607,12 +607,12 @@ int shirudo_dm_verity_verify(const struct shirudo_dm_verity *device,
if (!device || !image)
return -EINVAL;
- ret = shirudo_config_image_check_files(image->data_fd, image->hash_fd,
- &image->image);
+ ret = config_image_check_files(image->data_fd, image->hash_fd,
+ &image->image);
if (ret)
return ret;
bytes = image->image.data_blocks * CONFIG_IMAGE_BLOCK_SIZE;
- ret = shirudo_dm_verity_inspect(device->name, &image->image, &checked);
+ ret = dm_verity_inspect(device->name, &image->image, &checked);
if (ret)
return ret;
if (checked.device != device->device ||
@@ -667,7 +667,7 @@ int shirudo_dm_verity_verify(const struct shirudo_dm_verity *device,
}
offset += n;
}
- ret = shirudo_dm_verity_inspect(device->name, &image->image, &checked);
+ ret = dm_verity_inspect(device->name, &image->image, &checked);
if (!ret && (checked.device != device->device ||
checked.data_device != device->data_device ||
checked.hash_device != device->hash_device))
@@ -687,8 +687,8 @@ out:
return ret;
}
-int shirudo_dm_verity_mount(const struct shirudo_dm_verity *device,
- const char *mountpoint, bool executable)
+int dm_verity_mount(const struct shirudo_dm_verity *device,
+ const char *mountpoint, bool executable)
{
__u64 flags = MS_RDONLY | MS_NODEV | MS_NOSUID;
struct shirudo_dm_verity checked;
@@ -697,7 +697,7 @@ int shirudo_dm_verity_mount(const struct shirudo_dm_verity *device,
if (!device || !mountpoint || mountpoint[0] != '/')
return -EINVAL;
- ret = shirudo_dm_verity_inspect(device->name, &device->image, &checked);
+ ret = dm_verity_inspect(device->name, &device->image, &checked);
if (ret)
return ret;
if (checked.device != device->device)
@@ -711,8 +711,8 @@ int shirudo_dm_verity_mount(const struct shirudo_dm_verity *device,
else if (st.st_dev != device->device)
ret = -ESTALE;
else
- ret = shirudo_dm_verity_inspect(device->name, &device->image,
- &checked);
+ ret = dm_verity_inspect(device->name, &device->image,
+ &checked);
if (ret)
(void)umount2(mountpoint, 0);
return ret;
diff --git a/util/dm_verity.h b/util/dm_verity.h
index 232755da..b7ea433b 100644
--- a/util/dm_verity.h
+++ b/util/dm_verity.h
@@ -23,19 +23,19 @@ struct shirudo_dm_verity {
typedef int (*shirudo_dm_verity_cb)(const char *name, dev_t device, void *ctx);
-int shirudo_dm_verity_list(shirudo_dm_verity_cb callback, void *ctx);
-int shirudo_dm_verity_create(const struct shirudo_config_image_open *image,
- const char *name, struct shirudo_dm_verity *out);
+int dm_verity_list(shirudo_dm_verity_cb callback, void *ctx);
+int dm_verity_create(const struct config_image_open *image,
+ const char *name, struct shirudo_dm_verity *out);
/* Require the active readonly table to match the image parameters exactly. */
-int shirudo_dm_verity_inspect(const char *name,
- const struct shirudo_config_image *image,
- struct shirudo_dm_verity *out);
+int dm_verity_inspect(const char *name,
+ const struct shirudo_config_image *image,
+ struct shirudo_dm_verity *out);
/* Read every data block through the mapping bound to these retained files. */
-int shirudo_dm_verity_verify(const struct shirudo_dm_verity *device,
- const struct shirudo_config_image_open *image);
-int shirudo_dm_verity_mount(const struct shirudo_dm_verity *device,
- const char *mountpoint, bool executable);
-int shirudo_dm_verity_remove(struct shirudo_dm_verity *device, bool deferred);
-void shirudo_dm_verity_close(struct shirudo_dm_verity *device);
+int dm_verity_verify(const struct shirudo_dm_verity *device,
+ const struct config_image_open *image);
+int dm_verity_mount(const struct shirudo_dm_verity *device,
+ const char *mountpoint, bool executable);
+int dm_verity_remove(struct shirudo_dm_verity *device, bool deferred);
+void dm_verity_close(struct shirudo_dm_verity *device);
#endif /* SHIRUDO_DM_VERITY_H */
diff --git a/util/eventlog.c b/util/eventlog.c
index 8345d297..f8a4a0a7 100644
--- a/util/eventlog.c
+++ b/util/eventlog.c
@@ -33,7 +33,7 @@
const char *eventlog_path(void)
{
- const char *env = shirudo_image_config_active() ? NULL :
+ const char *env = image_config_active() ? NULL :
getenv("SHIRUDO_EVENTLOG_PATH");
return env && *env ? env : EVENTLOG_PATH;
@@ -41,7 +41,7 @@ const char *eventlog_path(void)
const char *eventlog_pending_path(void)
{
- const char *env = shirudo_image_config_active() ? NULL :
+ const char *env = image_config_active() ? NULL :
getenv("SHIRUDO_EVENTLOG_PENDING_PATH");
return env && *env ? env : EVENTLOG_PENDING_PATH;
diff --git a/util/help.c b/util/help.c
index 4d4c7585..a2eea4ef 100644
--- a/util/help.c
+++ b/util/help.c
@@ -120,9 +120,9 @@ void print_help(const struct shirudo_help *h)
}
static void
-shirudo_help_unknown_subcommand(const char *cmd_label, const char *bad,
- const struct shirudo_help_item *subcmds,
- size_t n_subcmds)
+help_unknown_subcommand(const char *cmd_label, const char *bad,
+ const struct shirudo_help_item *subcmds,
+ size_t n_subcmds)
{
struct shirudo_suggestion sugg[4];
const char *names[SUBCMD_MAX];
@@ -162,8 +162,8 @@ const char *resolve_subcommand(const char *cmd_label,
size_t i, n_names = 0, n;
if (!subcmds || !n_subcmds) {
- shirudo_help_unknown_subcommand(cmd_label, input,
- subcmds, n_subcmds);
+ help_unknown_subcommand(cmd_label, input,
+ subcmds, n_subcmds);
return NULL;
}
for (i = 0; i < n_subcmds && n_names < ARRAY_SIZE(names); i++)
@@ -174,8 +174,8 @@ const char *resolve_subcommand(const char *cmd_label,
if (n == 1)
return names[matches[0]];
if (n == 0) {
- shirudo_help_unknown_subcommand(cmd_label, input,
- subcmds, n_subcmds);
+ help_unknown_subcommand(cmd_label, input,
+ subcmds, n_subcmds);
return NULL;
}
fprintf(stderr, "%s: '%s' is ambiguous; matches:\n", cmd_label, input);
diff --git a/util/identity.c b/util/identity.c
index fe9eb4cb..e58a754e 100644
--- a/util/identity.c
+++ b/util/identity.c
@@ -20,7 +20,7 @@
#include "identity.h"
#include "paths.h"
-int shirudo_enforcement_active(void)
+int enforcement_active(void)
{
int ret = prctl(PR_GET_ENFORCEMENT, 0, 0, 0, 0);
diff --git a/util/identity.h b/util/identity.h
index e52fa2ff..82d980cb 100644
--- a/util/identity.h
+++ b/util/identity.h
@@ -80,7 +80,7 @@ BUILD_BUG_ON(sizeof(struct shirudo_mount_record) != 8);
* when init has not run, another -errno when the pin cannot be read.
*/
/* 1 when enforcement is active, 0 before init, otherwise -errno. */
-int shirudo_enforcement_active(void);
+int enforcement_active(void);
int identity_read(struct shirudo_identity *out);
#endif /* SHIRUDO_UTIL_IDENTITY_H */
diff --git a/util/image_bootstrap.c b/util/image_bootstrap.c
index fa6424a0..45ca3bdd 100644
--- a/util/image_bootstrap.c
+++ b/util/image_bootstrap.c
@@ -18,7 +18,7 @@
#include "malloc.h"
#include "paths.h"
-bool shirudo_image_path_valid(const char *path)
+bool image_path_valid(const char *path)
{
return path && path[0] == '/' && !strstr(path, "/../") &&
!strstr(path, "/./") && !strstr(path, "//") &&
@@ -74,14 +74,14 @@ static int bootstrap_parse(FILE *file, struct shirudo_image_bootstrap *boot,
}
boot->have_root = true;
} else if (!strcmp(key, "runtime.image") && initial) {
- if (!shirudo_image_path_valid(value) ||
+ if (!image_path_valid(value) ||
boot->runtime[0])
ret = -EINVAL;
else if (strscpy(boot->runtime, value,
sizeof(boot->runtime)) < 0)
ret = -ENAMETOOLONG;
} else if (!strcmp(key, "config.image")) {
- if (!shirudo_image_path_valid(value))
+ if (!image_path_valid(value))
ret = -EINVAL;
else if (strscpy(boot->config, value,
sizeof(boot->config)) < 0)
@@ -89,7 +89,7 @@ static int bootstrap_parse(FILE *file, struct shirudo_image_bootstrap *boot,
} else if (!strcmp(key, "config.verification_key")) {
if (strncmp(value, RUNTIME_DIR "/",
sizeof(RUNTIME_DIR)) ||
- !shirudo_image_path_valid(value))
+ !image_path_valid(value))
ret = -EPERM;
else if (strscpy(boot->certificate, value,
sizeof(boot->certificate)) < 0)
@@ -98,7 +98,7 @@ static int bootstrap_parse(FILE *file, struct shirudo_image_bootstrap *boot,
__u64 pcr;
if (parse_u64(value, strlen(value), 23, &pcr) ||
- shirudo_config_measure_pcr_valid(pcr)) {
+ config_measure_pcr_valid(pcr)) {
ret = -EINVAL;
} else {
boot->pcr = pcr;
@@ -118,9 +118,9 @@ static int bootstrap_parse(FILE *file, struct shirudo_image_bootstrap *boot,
return ret;
}
-int shirudo_image_bootstrap_read(const char *path,
- struct shirudo_image_bootstrap *boot,
- bool initial)
+int image_bootstrap_read(const char *path,
+ struct shirudo_image_bootstrap *boot,
+ bool initial)
{
FILE *file = fopen(path, "re");
@@ -130,9 +130,9 @@ int shirudo_image_bootstrap_read(const char *path,
}
/* A copy of the descriptor is read from its start; the caller keeps its own. */
-int shirudo_image_bootstrap_read_fd(int fd,
- struct shirudo_image_bootstrap *boot,
- bool initial)
+int image_bootstrap_read_fd(int fd,
+ struct shirudo_image_bootstrap *boot,
+ bool initial)
{
int copy, ret;
FILE *file;
diff --git a/util/image_bootstrap.h b/util/image_bootstrap.h
index a9973bd1..935192a2 100644
--- a/util/image_bootstrap.h
+++ b/util/image_bootstrap.h
@@ -20,13 +20,13 @@ struct shirudo_image_bootstrap {
bool have_pcr;
};
-bool shirudo_image_path_valid(const char *path);
+bool image_path_valid(const char *path);
/* Only the authenticated initrd may supply runtime.image and root_hash. */
-int shirudo_image_bootstrap_read(const char *path,
- struct shirudo_image_bootstrap *boot,
- bool initial);
-int shirudo_image_bootstrap_read_fd(int fd,
- struct shirudo_image_bootstrap *boot,
- bool initial);
+int image_bootstrap_read(const char *path,
+ struct shirudo_image_bootstrap *boot,
+ bool initial);
+int image_bootstrap_read_fd(int fd,
+ struct shirudo_image_bootstrap *boot,
+ bool initial);
#endif /* SHIRUDO_IMAGE_BOOTSTRAP_H */
diff --git a/util/image_cache.c b/util/image_cache.c
index be8a59e9..e09f0ec0 100644
--- a/util/image_cache.c
+++ b/util/image_cache.c
@@ -146,7 +146,7 @@ static int fetch_file(const char *source, const char *destination, __u64 max)
}
/* Verify downloads before publishing their root-hash-named cache files. */
-static int verify_incoming(const struct shirudo_config_image_open *opened,
+static int verify_incoming(const struct config_image_open *opened,
const char *staging)
{
struct shirudo_dm_verity device = {
@@ -158,20 +158,20 @@ static int verify_incoming(const struct shirudo_config_image_open *opened,
if (strsprintf(name, sizeof(name), "shirudo-verify-%s", strrchr(staging, '/') + 1) < 0)
return -ENAMETOOLONG;
- ret = shirudo_dm_verity_create(opened, name, &device);
+ ret = dm_verity_create(opened, name, &device);
if (ret)
return ret;
- ret = shirudo_dm_verity_verify(&device, opened);
- cleanup = shirudo_dm_verity_remove(&device, true);
+ ret = dm_verity_verify(&device, opened);
+ cleanup = dm_verity_remove(&device, true);
if (cleanup)
pr_warn("image: cannot remove incoming mapping: %s",
strerror(-cleanup));
- shirudo_dm_verity_close(&device);
+ dm_verity_close(&device);
return ret ? ret : cleanup;
}
-int shirudo_image_cache_fetch(const char *source,
- struct shirudo_config_update_target *target)
+int image_cache_fetch(const char *source,
+ struct shirudo_config_update_target *target)
{
static const struct {
const char *suffix;
@@ -182,7 +182,7 @@ int shirudo_image_cache_fetch(const char *source,
{ ".img", CONFIG_IMAGE_MAX_BYTES },
{ ".verity", CONFIG_IMAGE_MAX_BYTES },
};
- struct shirudo_config_image_open opened;
+ struct config_image_open opened;
char staging[] = IMAGE_CACHE_DIR "/incoming-XXXXXX";
char incoming[PATH_MAX], from[PATH_MAX], to[PATH_MAX];
char hex[65];
@@ -208,7 +208,7 @@ int shirudo_image_cache_fetch(const char *source,
if (ret)
goto out;
}
- ret = shirudo_config_image_open(incoming, &opened);
+ ret = config_image_open(incoming, &opened);
if (ret)
goto out;
ret = verify_incoming(&opened, staging);
@@ -219,7 +219,7 @@ int shirudo_image_cache_fetch(const char *source,
IMAGE_CACHE_DIR, hex) < 0)
ret = -ENAMETOOLONG;
}
- shirudo_config_image_close(&opened);
+ config_image_close(&opened);
if (ret)
goto out;
for (i = 0; i < ARRAY_SIZE(files); i++) {
@@ -239,11 +239,11 @@ int shirudo_image_cache_fetch(const char *source,
ret = -errno;
goto out;
}
- ret = shirudo_config_image_open(target->prefix, &opened);
+ ret = config_image_open(target->prefix, &opened);
if (!ret) {
if (memcmp(opened.image.root_hash, target->root_hash, 32))
ret = -EKEYREJECTED;
- shirudo_config_image_close(&opened);
+ config_image_close(&opened);
}
out:
if (dir >= 0)
diff --git a/util/image_cache.h b/util/image_cache.h
index 76f6952c..ec8205e9 100644
--- a/util/image_cache.h
+++ b/util/image_cache.h
@@ -7,7 +7,7 @@
struct shirudo_config_update_target;
/* The caller holds the update lock and owns the sealed cache directory. */
-int shirudo_image_cache_fetch(const char *source,
- struct shirudo_config_update_target *target);
+int image_cache_fetch(const char *source,
+ struct shirudo_config_update_target *target);
#endif /* SHIRUDO_IMAGE_CACHE_H */
diff --git a/util/image_config.c b/util/image_config.c
index a6638861..19f3b613 100644
--- a/util/image_config.c
+++ b/util/image_config.c
@@ -33,12 +33,12 @@ static struct shirudo_config effective;
static bool active;
static int config_fd = -1;
-bool shirudo_image_config_active(void)
+bool image_config_active(void)
{
return active;
}
-int shirudo_image_config_get(struct shirudo_config *out)
+int image_config_get(struct shirudo_config *out)
{
if (!active)
return 0;
@@ -46,7 +46,7 @@ int shirudo_image_config_get(struct shirudo_config *out)
return 1;
}
-int shirudo_image_config_root_fd(void)
+int image_config_root_fd(void)
{
return config_fd;
}
@@ -56,14 +56,14 @@ int shirudo_image_config_root_fd(void)
* never through a path: a path, /proc/<pid>/fd included, is root's to
* mount over before the exec.
*/
-int shirudo_image_open(enum shirudo_image_path which, int flags)
+int image_open(enum shirudo_image_path which, int flags)
{
if (which >= SHIRUDO_IMAGE_PATH_COUNT || config_fd < 0)
return -ENOENT;
return open_beneath(config_fd, relative[which], flags);
}
-int shirudo_image_open_relative(const char *path, int flags)
+int image_open_relative(const char *path, int flags)
{
if (config_fd < 0 || !path || path[0] == '/' || strstr(path, ".."))
return -EINVAL;
@@ -206,7 +206,7 @@ static int validate_settings(int root_fd)
return ret;
}
-int shirudo_image_config_validate(int root_fd)
+int image_config_validate(int root_fd)
{
struct shirudo_config candidate;
__u32 entries = 0;
@@ -230,15 +230,15 @@ int shirudo_image_config_validate(int root_fd)
return ret;
}
-int shirudo_image_config_set(const struct shirudo_config *bootstrap,
- int root_fd)
+int image_config_set(const struct shirudo_config *bootstrap,
+ int root_fd)
{
struct shirudo_config candidate;
int fd = -1, ret;
candidate = *bootstrap;
if (root_fd >= 0) {
- ret = shirudo_image_config_validate(root_fd);
+ ret = image_config_validate(root_fd);
if (ret)
return ret;
fd = fcntl(root_fd, F_DUPFD_CLOEXEC, 3);
@@ -269,7 +269,7 @@ int shirudo_image_config_set(const struct shirudo_config *bootstrap,
return 0;
}
-void shirudo_image_config_clear(void)
+void image_config_clear(void)
{
if (config_fd >= 0)
close(config_fd);
diff --git a/util/image_config.h b/util/image_config.h
index 0fa6aa0f..5716d5b6 100644
--- a/util/image_config.h
+++ b/util/image_config.h
@@ -21,15 +21,15 @@ enum shirudo_image_path {
SHIRUDO_IMAGE_PATH_COUNT,
};
-bool shirudo_image_config_active(void);
-int shirudo_image_config_get(struct shirudo_config *out);
-int shirudo_image_config_set(const struct shirudo_config *bootstrap,
- int root_fd);
-int shirudo_image_config_validate(int root_fd);
-void shirudo_image_config_clear(void);
+bool image_config_active(void);
+int image_config_get(struct shirudo_config *out);
+int image_config_set(const struct shirudo_config *bootstrap,
+ int root_fd);
+int image_config_validate(int root_fd);
+void image_config_clear(void);
/* An entry of the config image, opened from its verified root; -errno. */
-int shirudo_image_open(enum shirudo_image_path which, int flags);
-int shirudo_image_open_relative(const char *path, int flags);
-int shirudo_image_config_root_fd(void);
+int image_open(enum shirudo_image_path which, int flags);
+int image_open_relative(const char *path, int flags);
+int image_config_root_fd(void);
#endif /* SHIRUDO_IMAGE_CONFIG_H */
diff --git a/util/image_guards.c b/util/image_guards.c
index 043850f8..e078d31d 100644
--- a/util/image_guards.c
+++ b/util/image_guards.c
@@ -161,8 +161,8 @@ const struct shirudo_guard_map shirudo_guard_maps[SHIRUDO_GUARD_MAP_COUNT] = {
};
/* Initial authenticated boot creates mappings before these guards exist. */
-int shirudo_config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard)
+int config_root_begin(const __u8 root[32],
+ struct shirudo_config_root_guard *guard)
{
struct shirudo_expected_root previous = {}, expected = { .valid = 1 };
const struct shirudo_guard_map *map =
@@ -173,7 +173,7 @@ int shirudo_config_root_begin(const __u8 root[32],
.map_fd = -1,
.task_fd = -1,
};
- mode = shirudo_enforcement_active();
+ mode = enforcement_active();
if (!mode)
return 0;
if (mode < 0)
@@ -212,7 +212,7 @@ fail:
}
/* Clear through retained FDs on every exit; report failure to clear. */
-int shirudo_config_root_end(struct shirudo_config_root_guard *guard)
+int config_root_end(struct shirudo_config_root_guard *guard)
{
struct shirudo_expected_root empty = {};
int ret = 0;
@@ -395,7 +395,7 @@ static int guard_link(const struct shirudo_image_guard *guard,
}
/* Authenticated initrd bootstrap precedes every hostile task. */
-int shirudo_image_guards_ready(void)
+int image_guards_ready(void)
{
const struct {
const struct shirudo_image_guard *guards;
diff --git a/util/image_guards.h b/util/image_guards.h
index 9a3d392c..afee050b 100644
--- a/util/image_guards.h
+++ b/util/image_guards.h
@@ -70,9 +70,9 @@ struct shirudo_config_root_guard {
int task_fd;
};
-int shirudo_config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard);
-int shirudo_config_root_end(struct shirudo_config_root_guard *guard);
-int shirudo_image_guards_ready(void);
+int config_root_begin(const __u8 root[32],
+ struct shirudo_config_root_guard *guard);
+int config_root_end(struct shirudo_config_root_guard *guard);
+int image_guards_ready(void);
#endif /* SHIRUDO_IMAGE_GUARDS_H */
diff --git a/util/image_keys.c b/util/image_keys.c
index 5253934e..9d7c49a7 100644
--- a/util/image_keys.c
+++ b/util/image_keys.c
@@ -92,7 +92,7 @@ static int revocations(int root_fd, bool apply, bool boot)
if (!ret && memcmp(expected, fingerprint, 32))
ret = -EKEYREJECTED;
if (!ret && apply)
- ret = shirudo_keys_revoke_image(der, size, boot);
+ ret = keys_revoke_image(der, size, boot);
xfree(der, size);
if (ret)
break;
@@ -104,12 +104,12 @@ static int revocations(int root_fd, bool apply, bool boot)
return ret;
}
-int shirudo_keys_validate_image_set(const char *primary, int root_fd,
- struct shirudo_trusted_set *set)
+int keys_validate_image_set(const char *primary, int root_fd,
+ struct shirudo_trusted_set *set)
{
int ret;
- ret = shirudo_image_config_validate(root_fd);
+ ret = image_config_validate(root_fd);
if (ret) {
pr_err("image trust set: validate config image: %s",
strerror(-ret));
@@ -121,7 +121,7 @@ int shirudo_keys_validate_image_set(const char *primary, int root_fd,
strerror(-ret));
return ret;
}
- ret = shirudo_keys_load_image_root(primary, root_fd, true, set);
+ ret = keys_load_image_root(primary, root_fd, true, set);
if (ret) {
pr_err("image trust set: load certificates: %s",
strerror(-ret));
@@ -135,7 +135,7 @@ int shirudo_keys_validate_image_set(const char *primary, int root_fd,
return 0;
}
-int shirudo_keys_check_image_set(const struct shirudo_trusted_set *set)
+int keys_check_image_set(const struct shirudo_trusted_set *set)
{
key_serial_t keyring;
size_t i;
@@ -158,20 +158,20 @@ int shirudo_keys_check_image_set(const struct shirudo_trusted_set *set)
return 0;
}
-int shirudo_keys_validate_image(int root_fd)
+int keys_validate_image(int root_fd)
{
struct shirudo_trusted_set set;
int ret;
- ret = shirudo_keys_validate_image_set(RUNTIME_CERT_PATH,
- root_fd, &set);
- return ret ? ret : shirudo_keys_check_image_set(&set);
+ ret = keys_validate_image_set(RUNTIME_CERT_PATH,
+ root_fd, &set);
+ return ret ? ret : keys_check_image_set(&set);
}
-int shirudo_keys_apply_image(int root_fd, bool boot)
+int keys_apply_image(int root_fd, bool boot)
{
int ret;
- ret = shirudo_keys_validate_image(root_fd);
+ ret = keys_validate_image(root_fd);
return ret ? ret : revocations(root_fd, true, boot);
}
diff --git a/util/image_keys.h b/util/image_keys.h
index fa1dc2ad..38bbd2d0 100644
--- a/util/image_keys.h
+++ b/util/image_keys.h
@@ -11,12 +11,12 @@
struct shirudo_trusted_set;
-int shirudo_keys_validate_image_set(const char *primary, int root_fd,
- struct shirudo_trusted_set *set);
-int shirudo_keys_check_image_set(const struct shirudo_trusted_set *set);
-int shirudo_keys_validate_image(int root_fd);
+int keys_validate_image_set(const char *primary, int root_fd,
+ struct shirudo_trusted_set *set);
+int keys_check_image_set(const struct shirudo_trusted_set *set);
+int keys_validate_image(int root_fd);
-int shirudo_keys_apply_image(int root_fd, bool boot);
-int shirudo_keys_revoke_image(const __u8 *der, size_t size, bool boot);
+int keys_apply_image(int root_fd, bool boot);
+int keys_revoke_image(const __u8 *der, size_t size, bool boot);
#endif /* SHIRUDO_IMAGE_KEYS_H */
diff --git a/util/image_runtime.c b/util/image_runtime.c
index aec15980..a5c46fd9 100644
--- a/util/image_runtime.c
+++ b/util/image_runtime.c
@@ -51,7 +51,7 @@ struct image_context {
struct shirudo_config_update_target boot_target;
struct shirudo_dm_verity boot_runtime;
struct shirudo_config_update update;
- struct shirudo_config_image_open candidate;
+ struct config_image_open candidate;
struct shirudo_dm_verity candidate_device;
struct shirudo_config bootstrap_config;
struct shirudo_image_bootstrap bootstrap;
@@ -75,7 +75,7 @@ static struct image_context image = {
static int load_runtime_config(bool trusted_boot);
static int current_config(void);
-struct shirudo_config_update *shirudo_image_update_context(void)
+struct shirudo_config_update *image_update_context(void)
{
return image.update.lock_fd >= 0 ? &image.update : NULL;
}
@@ -103,14 +103,14 @@ static int reject_overrides(void)
return 0;
}
-int shirudo_image_bootstrap_load(void)
+int image_bootstrap_load(void)
{
struct shirudo_identity identity;
int mode, ret;
if (image.loaded)
return 1;
- mode = shirudo_enforcement_active();
+ mode = enforcement_active();
if (mode < 0)
return mode;
ret = identity_read(&identity);
@@ -123,8 +123,8 @@ int shirudo_image_bootstrap_load(void)
image.bootstrap.have_root = true;
ret = load_runtime_config(false);
} else {
- ret = shirudo_image_bootstrap_read(CONF_PATH,
- &image.bootstrap, true);
+ ret = image_bootstrap_read(CONF_PATH,
+ &image.bootstrap, true);
if (!ret &&
(!image.bootstrap.runtime[0] || !image.bootstrap.have_root))
ret = -EINVAL;
@@ -137,13 +137,13 @@ int shirudo_image_bootstrap_load(void)
ret = reject_overrides();
if (ret)
return ret;
- ret = shirudo_image_config_set(&image.bootstrap_config, -1);
+ ret = image_config_set(&image.bootstrap_config, -1);
if (!ret)
image.loaded = true;
return ret ? ret : 1;
}
-const __u8 *shirudo_image_runtime_root(void)
+const __u8 *image_runtime_root(void)
{
return image.loaded ? image.bootstrap.runtime_root : NULL;
}
@@ -259,7 +259,7 @@ static int load_runtime_config(bool trusted_boot)
int fd, ret;
if (!trusted_boot) {
- ret = shirudo_image_guards_ready();
+ ret = image_guards_ready();
if (ret)
return ret;
}
@@ -274,7 +274,7 @@ static int load_runtime_config(bool trusted_boot)
fd = open_runtime_file(RUNTIME_CONF_PATH, root.st_dev);
if (fd < 0)
return fd;
- ret = shirudo_image_bootstrap_read_fd(fd, &image.bootstrap, false);
+ ret = image_bootstrap_read_fd(fd, &image.bootstrap, false);
if (!ret)
ret = config_load_fd(&image.bootstrap_config, fd,
RUNTIME_CONF_PATH);
@@ -284,7 +284,7 @@ static int load_runtime_config(bool trusted_boot)
if (!image.bootstrap.config[0] || !image.bootstrap.certificate[0] ||
!image.bootstrap.have_pcr)
return -EINVAL;
- ret = shirudo_image_config_set(&image.bootstrap_config, -1);
+ ret = image_config_set(&image.bootstrap_config, -1);
if (ret)
return ret;
@@ -311,7 +311,7 @@ static int load_runtime_config(bool trusted_boot)
static int mount_runtime(bool trusted_boot)
{
const char *step = "open runtime image";
- struct shirudo_config_image_open opened = {
+ struct config_image_open opened = {
.data_fd = -1,
.hash_fd = -1,
.signature_fd = -1,
@@ -329,43 +329,43 @@ static int mount_runtime(bool trusted_boot)
if (!trusted_boot && !stat(RUNTIME_DIR, &st) &&
!runtime_observed(st.st_dev))
return load_runtime_config(trusted_boot);
- ret = shirudo_config_image_open_root(image.bootstrap.runtime,
- image.bootstrap.runtime_root,
- &opened);
+ ret = config_image_open_root(image.bootstrap.runtime,
+ image.bootstrap.runtime_root,
+ &opened);
if (!ret) {
step = "prepare runtime mountpoint";
ret = mkdir_owned(RUNTIME_DIR);
}
if (!ret) {
step = "create runtime dm-verity mapping";
- ret = shirudo_dm_verity_create(&opened, "shirudo-runtime",
- &device);
+ ret = dm_verity_create(&opened, "shirudo-runtime",
+ &device);
created = !ret;
}
if (ret == -EEXIST) {
step = "inspect runtime dm-verity mapping";
- ret = shirudo_dm_verity_inspect("shirudo-runtime", &opened.image,
- &device);
+ ret = dm_verity_inspect("shirudo-runtime", &opened.image,
+ &device);
}
if (!ret) {
step = "verify runtime image";
- ret = shirudo_dm_verity_verify(&device, &opened);
+ ret = dm_verity_verify(&device, &opened);
}
if (!ret) {
step = "mount runtime image";
- ret = shirudo_dm_verity_mount(&device, RUNTIME_DIR,
- true);
+ ret = dm_verity_mount(&device, RUNTIME_DIR,
+ true);
}
if (ret && created) {
- cleanup = shirudo_dm_verity_remove(&device, false);
+ cleanup = dm_verity_remove(&device, false);
if (cleanup)
pr_warn("image: cannot remove runtime mapping: %s",
strerror(-cleanup));
}
- shirudo_dm_verity_close(&device);
+ dm_verity_close(&device);
if (!ret && trusted_boot)
image.boot_runtime = device;
- shirudo_config_image_close(&opened);
+ config_image_close(&opened);
if (!ret) {
step = "load runtime config";
ret = load_runtime_config(trusted_boot);
@@ -378,7 +378,7 @@ static int mount_runtime(bool trusted_boot)
return ret;
}
-int shirudo_image_runtime_mount(void)
+int image_runtime_mount(void)
{
return mount_runtime(false);
}
@@ -396,7 +396,7 @@ static int boot_identity(void *ctx, __u32 *reset, __u32 *restart)
{
struct image_context *current = ctx;
- return shirudo_tpm_boot_identity(current->tpm, reset, restart);
+ return tpm_boot_identity(current->tpm, reset, restart);
}
static int pcr_read(void *ctx, __u32 pcr, __u8 out[32])
@@ -429,7 +429,7 @@ static int collect_mapping(const char *name, dev_t device, void *ctx)
return -ENAMETOOLONG;
strscpy(retired.name, name, sizeof(retired.name));
retired.device = device;
- ret = shirudo_dm_verity_remove(&retired, false);
+ ret = dm_verity_remove(&retired, false);
if (ret && ret != -EBUSY && ret != -ENXIO && ret != -ENODEV)
pr_warn("image: cannot remove retired mapping %s: %s", name,
strerror(-ret));
@@ -446,7 +446,7 @@ static void collect_mappings(void)
return;
if (!stat(CONFIG_IMAGE_DIR, &st))
active = st.st_dev;
- ret = shirudo_dm_verity_list(collect_mapping, &active);
+ ret = dm_verity_list(collect_mapping, &active);
if (ret)
pr_warn("image: cannot collect retired mappings: %s",
strerror(-ret));
@@ -462,8 +462,8 @@ static void close_candidate(void)
errno != EINVAL && errno != ENOENT)
pr_warn("image: cannot release candidate mount: %s",
strerror(errno));
- shirudo_dm_verity_close(&image.candidate_device);
- shirudo_config_image_close(&image.candidate);
+ dm_verity_close(&image.candidate_device);
+ config_image_close(&image.candidate);
}
static int remove_candidate(struct shirudo_dm_verity *device)
@@ -472,7 +472,7 @@ static int remove_candidate(struct shirudo_dm_verity *device)
int ret;
for (attempt = 0; attempt < 100; attempt++) {
- ret = shirudo_dm_verity_remove(device, false);
+ ret = dm_verity_remove(device, false);
if (ret != -EBUSY)
return ret;
if (attempt < 99)
@@ -485,7 +485,7 @@ static int candidate_keys(int fd)
{
int ret;
- ret = shirudo_keys_validate_image(fd);
+ ret = keys_validate_image(fd);
if (ret == -ENOKEY)
pr_err("image: BPF signer was not enrolled at boot; "
"reboot with the new trusted key set required");
@@ -509,7 +509,7 @@ static int mount_candidate(struct image_context *current)
return -errno;
ret = mkdir_owned(mountpoint);
if (!ret)
- ret = shirudo_dm_verity_mount(device, mountpoint, false);
+ ret = dm_verity_mount(device, mountpoint, false);
if (ret)
return ret;
current->candidate_fd = open(mountpoint,
@@ -532,9 +532,9 @@ static int prepare_config(struct image_context *current,
collect_mappings();
if (strncmp(target->prefix, IMAGE_CACHE_DIR "/",
sizeof(IMAGE_CACHE_DIR)) ||
- !shirudo_image_path_valid(target->prefix))
+ !image_path_valid(target->prefix))
return -EPERM;
- ret = shirudo_config_image_open(target->prefix, &current->candidate);
+ ret = config_image_open(target->prefix, &current->candidate);
if (ret)
return ret;
if (memcmp(target->root_hash, current->candidate.image.root_hash, 32))
@@ -542,15 +542,15 @@ static int prepare_config(struct image_context *current,
ret = mapping_name(target->root_hash, name);
if (ret)
return ret;
- ret = shirudo_dm_verity_inspect(name, &current->candidate.image,
- device);
+ ret = dm_verity_inspect(name, &current->candidate.image,
+ device);
if (ret == -ENXIO || ret == -ENODEV || ret == -ENOENT) {
- ret = shirudo_dm_verity_create(&current->candidate, name,
- device);
+ ret = dm_verity_create(&current->candidate, name,
+ device);
created = !ret;
}
if (!ret)
- ret = shirudo_dm_verity_verify(device, &current->candidate);
+ ret = dm_verity_verify(device, &current->candidate);
if (!ret && !trusted_boot)
ret = device_observed(current->candidate_device.device,
current->candidate.image.root_hash,
@@ -562,7 +562,7 @@ static int prepare_config(struct image_context *current,
goto out;
ret = mount_flags(current->candidate_fd, false);
if (!ret)
- ret = shirudo_image_config_validate(current->candidate_fd);
+ ret = image_config_validate(current->candidate_fd);
if (!ret && !trusted_boot)
ret = candidate_keys(current->candidate_fd);
out:
@@ -581,7 +581,7 @@ static int activate_config(struct image_context *current, bool boot)
struct stat st;
int fd, ret;
- ret = shirudo_keys_apply_image(current->candidate_fd, boot);
+ ret = keys_apply_image(current->candidate_fd, boot);
if (ret)
return ret;
ret = mkdir_owned(CONFIG_IMAGE_DIR);
@@ -593,8 +593,8 @@ static int activate_config(struct image_context *current, bool boot)
if (umount2(CONFIG_IMAGE_DIR, MNT_DETACH) &&
errno != EINVAL)
return -errno;
- ret = shirudo_dm_verity_mount(&current->candidate_device,
- CONFIG_IMAGE_DIR, false);
+ ret = dm_verity_mount(&current->candidate_device,
+ CONFIG_IMAGE_DIR, false);
if (ret)
return ret;
}
@@ -608,7 +608,7 @@ static int activate_config(struct image_context *current, bool boot)
else
ret = mount_flags(fd, false);
if (!ret)
- ret = shirudo_image_config_set(&current->bootstrap_config, fd);
+ ret = image_config_set(&current->bootstrap_config, fd);
close(fd);
return ret;
}
@@ -664,26 +664,26 @@ static int open_update(void)
if (!ret)
ret = chain_tpm_bound(image.tpm);
if (!ret)
- ret = shirudo_config_update_open(CONFIG_UPDATE_DIR,
- &update_ops, &image,
- &image.update);
+ ret = config_update_open(CONFIG_UPDATE_DIR,
+ &update_ops, &image,
+ &image.update);
return ret;
}
static int boot_target(struct shirudo_config_update_target *target)
{
struct shirudo_config_update_record previous;
- struct shirudo_config_image_open opened;
+ struct config_image_open opened;
const char *prefix;
bool selected;
int ret;
- ret = shirudo_config_update_read(&image.update, &previous);
+ ret = config_update_read(&image.update, &previous);
selected = !ret;
prefix = selected ? previous.target.prefix : image.bootstrap.config;
if (ret && ret != -ENOENT)
return ret;
- ret = shirudo_config_image_open(prefix, &opened);
+ ret = config_image_open(prefix, &opened);
if (ret)
return ret;
if (selected && memcmp(previous.target.root_hash,
@@ -693,7 +693,7 @@ static int boot_target(struct shirudo_config_update_target *target)
strscpy(target->prefix, prefix, sizeof(target->prefix));
memcpy(target->root_hash, opened.image.root_hash, 32);
}
- shirudo_config_image_close(&opened);
+ config_image_close(&opened);
return ret;
}
@@ -714,7 +714,7 @@ static int seal_config_key(key_serial_t ring, const __u8 *der, size_t size)
key_serial_t key;
int ret;
- key = shirudo_keyring_dm_verity_add_cert(der, size);
+ key = keyring_dm_verity_add_cert(der, size);
if (key < 0 && key != -EPERM && key != -EACCES)
return boot_keys_error("add config verification certificate",
(int)key);
@@ -723,7 +723,7 @@ static int seal_config_key(key_serial_t ring, const __u8 *der, size_t size)
"boot with dm_verity.keyring_unsealed=1",
-ENOKEY);
if (key >= 0) {
- ret = shirudo_keyring_dm_verity_seal();
+ ret = keyring_dm_verity_seal();
if (ret == -EEXIST)
return boot_keys_error("seal dm-verity keyring restricted "
"by another task (tampered)",
@@ -750,7 +750,7 @@ static int enroll_config_key(void)
keys_read_der_fd(image.certificate_fd, &der, &size);
if (ret)
return boot_keys_error("read config verification certificate", ret);
- ring = shirudo_keyring_dm_verity_serial();
+ ring = keyring_dm_verity_serial();
if (ring < 0) {
ret = (int)ring;
xfree(der, size);
@@ -762,7 +762,7 @@ static int enroll_config_key(void)
}
/* The authenticated initrd validates the boot set before installing guards. */
-int shirudo_image_boot_keys(struct shirudo_trusted_set *set)
+int image_boot_keys(struct shirudo_trusted_set *set)
{
struct shirudo_trusted_cert primary = { .primary = true };
size_t i;
@@ -785,8 +785,8 @@ int shirudo_image_boot_keys(struct shirudo_trusted_set *set)
ret = prepare_config(&image, &image.boot_target, true);
if (ret)
return boot_keys_error("prepare boot config", ret);
- ret = shirudo_keys_validate_image_set(RUNTIME_CERT_PATH,
- image.candidate_fd, set);
+ ret = keys_validate_image_set(RUNTIME_CERT_PATH,
+ image.candidate_fd, set);
if (ret)
return boot_keys_error("validate BPF trust set", ret);
/* Guard loaders need the initial signer until activation. */
@@ -808,13 +808,13 @@ int shirudo_image_boot_keys(struct shirudo_trusted_set *set)
return 0;
}
-int shirudo_image_boot_keys_close(void)
+int image_boot_keys_close(void)
{
int ret = 0, err;
if (!image.boot_keys_open)
return 0;
- shirudo_image_config_clear();
+ image_config_clear();
if (image.candidate_fd >= 0)
close(image.candidate_fd);
image.candidate_fd = -1;
@@ -825,16 +825,16 @@ int shirudo_image_boot_keys_close(void)
errno != ENOENT)
ret = -errno;
if (image.candidate_device.name[0]) {
- err = shirudo_dm_verity_remove(&image.candidate_device, false);
+ err = dm_verity_remove(&image.candidate_device, false);
if (!ret && err && err != -ENXIO && err != -ENODEV)
ret = err;
}
- shirudo_config_image_close(&image.candidate);
+ config_image_close(&image.candidate);
if (umount(RUNTIME_DIR) && errno != EINVAL && errno != ENOENT &&
!ret)
ret = -errno;
if (image.boot_runtime.name[0]) {
- err = shirudo_dm_verity_remove(&image.boot_runtime, false);
+ err = dm_verity_remove(&image.boot_runtime, false);
if (!ret && err && err != -ENXIO && err != -ENODEV)
ret = err;
}
@@ -842,7 +842,7 @@ int shirudo_image_boot_keys_close(void)
return ret;
}
-int shirudo_image_boot(void)
+int image_boot(void)
{
struct shirudo_config_update_target target = {};
int ret;
@@ -859,8 +859,8 @@ int shirudo_image_boot(void)
}
/* Boot and live updates record key revocations differently. */
image.update.ops = &boot_ops;
- ret = shirudo_config_update_boot(&image.update, &target,
- image.bootstrap.pcr);
+ ret = config_update_boot(&image.update, &target,
+ image.bootstrap.pcr);
image.update.ops = &update_ops;
if (ret == -EINPROGRESS)
pr_err("image: activation is pending; further changes are blocked");
@@ -869,13 +869,13 @@ int shirudo_image_boot(void)
static int config_mount_check(const struct shirudo_config_update_record *record)
{
- struct shirudo_config_image_open opened;
+ struct config_image_open opened;
struct shirudo_dm_verity device;
struct stat st;
char name[128];
int fd, ret;
- ret = shirudo_config_image_open(record->target.prefix, &opened);
+ ret = config_image_open(record->target.prefix, &opened);
if (ret)
return ret;
if (memcmp(record->target.root_hash, opened.image.root_hash, 32))
@@ -883,8 +883,8 @@ static int config_mount_check(const struct shirudo_config_update_record *record)
if (!ret)
ret = mapping_name(record->target.root_hash, name);
if (!ret)
- ret = shirudo_dm_verity_inspect(name, &opened.image, &device);
- shirudo_config_image_close(&opened);
+ ret = dm_verity_inspect(name, &opened.image, &device);
+ config_image_close(&opened);
if (ret)
return ret;
if (stat(CONFIG_IMAGE_DIR, &st) || st.st_dev != device.device) {
@@ -902,23 +902,23 @@ static int config_mount_check(const struct shirudo_config_update_record *record)
}
ret = mount_flags(fd, false);
if (!ret)
- ret = shirudo_image_config_set(&image.bootstrap_config, fd);
+ ret = image_config_set(&image.bootstrap_config, fd);
close(fd);
out:
- shirudo_dm_verity_close(&device);
+ dm_verity_close(&device);
return ret;
}
-int shirudo_image_boot_complete(void)
+int image_boot_complete(void)
{
struct shirudo_config_update_record record;
int ret;
- ret = shirudo_config_update_read(&image.update, &record);
+ ret = config_update_read(&image.update, &record);
if (!ret)
ret = config_mount_check(&record);
if (!ret)
- ret = shirudo_config_update_complete_boot(&image.update);
+ ret = config_update_complete_boot(&image.update);
return ret;
}
@@ -929,7 +929,7 @@ static int current_config(void)
ret = open_update();
if (!ret)
- ret = shirudo_config_update_check(&image.update, &record);
+ ret = config_update_check(&image.update, &record);
return ret ? ret : config_mount_check(&record);
}
@@ -945,12 +945,12 @@ static int status_config(int state)
image.config_state = state;
if (state == -EINPROGRESS &&
- !shirudo_config_update_read(&image.update, &record))
+ !config_update_read(&image.update, &record))
(void)config_mount_check(&record);
return 0;
}
-int shirudo_image_enter(const char *command, int argc, const char **argv)
+int image_enter(const char *command, int argc, const char **argv)
{
struct shirudo_identity identity;
int mode, ret;
@@ -964,7 +964,7 @@ int shirudo_image_enter(const char *command, int argc, const char **argv)
!strcmp(command, "build") || !strcmp(command, "help") ||
!strcmp(command, "version"))
return 0;
- mode = shirudo_enforcement_active();
+ mode = enforcement_active();
if (mode < 0)
return mode;
ret = identity_read(&identity);
@@ -974,7 +974,7 @@ int shirudo_image_enter(const char *command, int argc, const char **argv)
return ret == -ENOENT || ret == -EPERM || ret == -EACCES ? 0 : ret;
if (!mode)
return -EPROTO;
- ret = shirudo_image_bootstrap_load();
+ ret = image_bootstrap_load();
if (ret < 0)
return ret;
ret = load_runtime_config(false);
@@ -996,20 +996,20 @@ int shirudo_image_enter(const char *command, int argc, const char **argv)
return ret;
}
-int shirudo_image_config_state(__u8 root[32])
+int image_config_state(__u8 root[32])
{
struct shirudo_config_update_record record;
if (image.update.lock_fd < 0)
return -ENODEV;
- if (shirudo_config_update_read(&image.update, &record))
+ if (config_update_read(&image.update, &record))
memset(root, 0, 32);
else
memcpy(root, record.target.root_hash, 32);
return image.config_state;
}
-int shirudo_image_status(void)
+int image_status(void)
{
struct shirudo_config_update_record record;
char buffer[512], root[65];
@@ -1021,7 +1021,7 @@ int shirudo_image_status(void)
if (image.update.lock_fd < 0)
return -ENODEV;
- ret = shirudo_config_update_read(&image.update, &record);
+ ret = config_update_read(&image.update, &record);
if (ret)
return ret;
hex_encode(record.target.root_hash, 32, root);
@@ -1041,14 +1041,14 @@ int shirudo_image_status(void)
return ret;
}
-void shirudo_image_leave(void)
+void image_leave(void)
{
- (void)shirudo_image_boot_keys_close();
- shirudo_image_config_clear();
+ (void)image_boot_keys_close();
+ image_config_clear();
close_candidate();
collect_mappings();
if (image.update.lock_fd >= 0)
- shirudo_config_update_close(&image.update);
+ config_update_close(&image.update);
tpm_close(image.tpm);
image.tpm = NULL;
if (image.certificate_fd >= 0)
@@ -1057,7 +1057,7 @@ void shirudo_image_leave(void)
explicit_bzero(&image.bootstrap_config, sizeof(image.bootstrap_config));
}
-int shirudo_image_update(const char *prefix)
+int image_update(const char *prefix)
{
struct shirudo_config_update_target target = {};
int ret;
@@ -1068,9 +1068,9 @@ int shirudo_image_update(const char *prefix)
if (!ret)
ret = mkdir_owned(IMAGE_CACHE_DIR);
if (!ret)
- ret = shirudo_image_cache_fetch(prefix, &target);
+ ret = image_cache_fetch(prefix, &target);
if (!ret)
- ret = shirudo_config_update_begin(&image.update, &target,
- image.bootstrap.pcr);
+ ret = config_update_begin(&image.update, &target,
+ image.bootstrap.pcr);
return ret;
}
diff --git a/util/image_runtime.h b/util/image_runtime.h
index 511b1da2..37ba4a1c 100644
--- a/util/image_runtime.h
+++ b/util/image_runtime.h
@@ -11,18 +11,18 @@
struct shirudo_config_update;
struct shirudo_trusted_set;
-struct shirudo_config_update *shirudo_image_update_context(void);
-int shirudo_image_bootstrap_load(void);
-const __u8 *shirudo_image_runtime_root(void);
-int shirudo_image_runtime_mount(void);
-int shirudo_image_boot_keys(struct shirudo_trusted_set *set);
-int shirudo_image_boot_keys_close(void);
-int shirudo_image_boot(void);
-int shirudo_image_boot_complete(void);
-int shirudo_image_enter(const char *command, int argc, const char **argv);
-void shirudo_image_leave(void);
-int shirudo_image_update(const char *prefix);
-int shirudo_image_status(void);
+struct shirudo_config_update *image_update_context(void);
+int image_bootstrap_load(void);
+const __u8 *image_runtime_root(void);
+int image_runtime_mount(void);
+int image_boot_keys(struct shirudo_trusted_set *set);
+int image_boot_keys_close(void);
+int image_boot(void);
+int image_boot_complete(void);
+int image_enter(const char *command, int argc, const char **argv);
+void image_leave(void);
+int image_update(const char *prefix);
+int image_status(void);
/*
* The config state status reports: 0 with the selected config active,
@@ -30,6 +30,6 @@ int shirudo_image_status(void);
* other commands refuse on; -ENODEV without activation state. root is the
* selected or pending config's, zero when unknown.
*/
-int shirudo_image_config_state(__u8 root[32]);
+int image_config_state(__u8 root[32]);
#endif /* SHIRUDO_IMAGE_RUNTIME_H */
diff --git a/util/initrd.c b/util/initrd.c
index e74a8c90..b9878f32 100644
--- a/util/initrd.c
+++ b/util/initrd.c
@@ -14,7 +14,7 @@
bool in_initrd(void)
{
- const char *env = shirudo_image_config_active() ? NULL :
+ const char *env = image_config_active() ? NULL :
getenv("SHIRUDO_INITRD_RELEASE");
return access(env && *env ? env : "/etc/initrd-release", F_OK) == 0;
@@ -22,7 +22,7 @@ bool in_initrd(void)
const char *sysroot(void)
{
- const char *env = shirudo_image_config_active() ? NULL :
+ const char *env = image_config_active() ? NULL :
getenv("SHIRUDO_SYSROOT");
return env && *env ? env : "/sysroot";
@@ -30,7 +30,7 @@ const char *sysroot(void)
const char *shirudo_keys_dir(void)
{
- if (shirudo_image_config_root_fd() >= 0)
+ if (image_config_root_fd() >= 0)
return RUNTIME_DIR "/keys";
return in_initrd() ? INITRD_KEYS_DIR :
KEYS_DIR;
@@ -38,7 +38,7 @@ const char *shirudo_keys_dir(void)
const char *shirudo_cert_path(void)
{
- if (shirudo_image_config_root_fd() >= 0)
+ if (image_config_root_fd() >= 0)
return RUNTIME_CERT_PATH;
return in_initrd() ? INITRD_CERT_PATH :
CERT_PATH;
diff --git a/util/keyring.c b/util/keyring.c
index 9726a605..4b5360a8 100644
--- a/util/keyring.c
+++ b/util/keyring.c
@@ -339,7 +339,7 @@ int keyring_bpf_seal(void)
}
/* Resolve the kernel-owned ring directly, without a name-based search. */
-key_serial_t shirudo_keyring_dm_verity_serial(void)
+key_serial_t keyring_dm_verity_serial(void)
{
long ret = sys_keyctl(KEYCTL_GET_KEYRING_ID,
KEY_SPEC_DM_VERITY_KEYRING, 0, 0, 0);
@@ -347,8 +347,8 @@ key_serial_t shirudo_keyring_dm_verity_serial(void)
return ret < 0 ? -errno : (key_serial_t)ret;
}
-key_serial_t shirudo_keyring_dm_verity_add_cert(const __u8 *cert,
- size_t cert_len)
+key_serial_t keyring_dm_verity_add_cert(const __u8 *cert,
+ size_t cert_len)
{
long ret = sys_add_key("asymmetric", NULL, cert, cert_len,
KEY_SPEC_DM_VERITY_KEYRING);
@@ -356,7 +356,7 @@ key_serial_t shirudo_keyring_dm_verity_add_cert(const __u8 *cert,
return ret < 0 ? -errno : (key_serial_t)ret;
}
-int shirudo_keyring_dm_verity_seal(void)
+int keyring_dm_verity_seal(void)
{
/* No restriction type: reject every subsequent addition. */
if (sys_keyctl(KEYCTL_RESTRICT_KEYRING, KEY_SPEC_DM_VERITY_KEYRING,
diff --git a/util/keyring.h b/util/keyring.h
index 93eea54a..76c52e30 100644
--- a/util/keyring.h
+++ b/util/keyring.h
@@ -104,9 +104,9 @@ int keyring_bpf_seal(void);
#endif
/* Resolve the special ID; never fall back to a same-named user keyring. */
-key_serial_t shirudo_keyring_dm_verity_serial(void);
-key_serial_t shirudo_keyring_dm_verity_add_cert(const __u8 *cert,
- size_t cert_len);
-int shirudo_keyring_dm_verity_seal(void);
+key_serial_t keyring_dm_verity_serial(void);
+key_serial_t keyring_dm_verity_add_cert(const __u8 *cert,
+ size_t cert_len);
+int keyring_dm_verity_seal(void);
#endif /* SHIRUDO_KEYRING_H */
diff --git a/util/keys.c b/util/keys.c
index fdec272f..e6d81d12 100644
--- a/util/keys.c
+++ b/util/keys.c
@@ -659,16 +659,16 @@ out:
return ret;
}
-int shirudo_keys_load_image_at(const char *primary, int keys_fd,
- bool with_trusted,
- struct shirudo_trusted_set *set)
+int keys_load_image_at(const char *primary, int keys_fd,
+ bool with_trusted,
+ struct shirudo_trusted_set *set)
{
return load_set_at(primary, keys_fd, "keys", with_trusted, set);
}
-int shirudo_keys_load_image_root(const char *primary, int root_fd,
- bool with_trusted,
- struct shirudo_trusted_set *set)
+int keys_load_image_root(const char *primary, int root_fd,
+ bool with_trusted,
+ struct shirudo_trusted_set *set)
{
int keys_fd, ret;
@@ -678,7 +678,7 @@ int shirudo_keys_load_image_root(const char *primary, int root_fd,
strerror(-keys_fd));
return keys_fd;
}
- ret = shirudo_keys_load_image_at(primary, keys_fd, with_trusted, set);
+ ret = keys_load_image_at(primary, keys_fd, with_trusted, set);
if (keys_fd >= 0)
close(keys_fd);
return ret;
@@ -689,12 +689,12 @@ int keys_load(const char *keys_dir, const char *revoked_dir,
{
char primary[PATH_MAX];
- if (shirudo_image_config_root_fd() >= 0 &&
+ if (image_config_root_fd() >= 0 &&
(!strcmp(keys_dir, KEYS_DIR) ||
!strcmp(keys_dir, RUNTIME_DIR "/keys")))
- return shirudo_keys_load_image_root(RUNTIME_CERT_PATH,
- shirudo_image_config_root_fd(),
- with_trusted, set);
+ return keys_load_image_root(RUNTIME_CERT_PATH,
+ image_config_root_fd(),
+ with_trusted, set);
if (strsprintf(primary, sizeof(primary), "%s/%s", keys_dir, CERT_FILE) < 0)
return -ENAMETOOLONG;
return load_set(primary, keys_dir, revoked_dir, with_trusted, set);
diff --git a/util/keys.h b/util/keys.h
index a064ef23..0b26aefa 100644
--- a/util/keys.h
+++ b/util/keys.h
@@ -59,13 +59,13 @@ int keys_load(const char *keys_dir, const char *revoked_dir,
* The set of a config image, read through its root descriptor; historical
* vouches are validated before revoked signing keys are excluded.
*/
-int shirudo_keys_load_image_at(const char *primary, int keys_fd,
- bool with_trusted,
- struct shirudo_trusted_set *set);
+int keys_load_image_at(const char *primary, int keys_fd,
+ bool with_trusted,
+ struct shirudo_trusted_set *set);
/* The same from the image root, whose keys directory is opened beneath it. */
-int shirudo_keys_load_image_root(const char *primary, int root_fd,
- bool with_trusted,
- struct shirudo_trusted_set *set);
+int keys_load_image_root(const char *primary, int root_fd,
+ bool with_trusted,
+ struct shirudo_trusted_set *set);
struct shirudo_cert;
diff --git a/util/tls_openssl.c b/util/tls_openssl.c
index 99195e07..146fecf9 100644
--- a/util/tls_openssl.c
+++ b/util/tls_openssl.c
@@ -47,7 +47,7 @@ static bool tls_classical_host_allowed(CURL *curl)
size_t host_len;
bool allowed = false;
- if (!shirudo_image_config_get(&cfg) && config_load(&cfg))
+ if (!image_config_get(&cfg) && config_load(&cfg))
return false;
if (!cfg.tls_classical_hosts_valid ||
!cfg.tls_classical_hosts[0])
@@ -98,7 +98,7 @@ out:
return allowed;
}
-static void shirudo_tls_info_callback(const SSL *ssl, int where, int ret)
+static void tls_info_callback(const SSL *ssl, int where, int ret)
{
const char *group, *host;
int group_id;
@@ -123,7 +123,7 @@ void tls_ca_cleanup(struct shirudo_tls_ca *ca)
ca->impl = NULL;
}
-static CURLcode shirudo_sslctx_callback(CURL *curl, void *sslctx, void *userptr)
+static CURLcode sslctx_callback(CURL *curl, void *sslctx, void *userptr)
{
const struct shirudo_tls_ca *ca = userptr;
const char *path = ca ? ca->path : NULL;
@@ -140,7 +140,7 @@ static CURLcode shirudo_sslctx_callback(CURL *curl, void *sslctx, void *userptr)
CURLE_OK)
return CURLE_SSL_CONNECT_ERROR;
groups = TLS_CLASSICAL_GROUPS;
- SSL_CTX_set_info_callback(ctx, shirudo_tls_info_callback);
+ SSL_CTX_set_info_callback(ctx, tls_info_callback);
}
if (SSL_CTX_set_min_proto_version(ctx, TLS1_3_VERSION) != 1 ||
SSL_CTX_set1_groups_list(ctx, groups) != 1) {
@@ -178,7 +178,7 @@ int tls_curl_policy(CURL *curl, struct shirudo_tls_ca *ca)
if (curl_easy_setopt(curl, CURLOPT_SSLVERSION,
(long)CURL_SSLVERSION_TLSv1_3) != CURLE_OK ||
curl_easy_setopt(curl, CURLOPT_SSL_CTX_FUNCTION,
- shirudo_sslctx_callback) != CURLE_OK ||
+ sslctx_callback) != CURLE_OK ||
curl_easy_setopt(curl, CURLOPT_SSL_CTX_DATA, ca) != CURLE_OK)
return -EINVAL;
return 0;
diff --git a/util/tpm.c b/util/tpm.c
index 365dcabc..d00761a0 100644
--- a/util/tpm.c
+++ b/util/tpm.c
@@ -37,14 +37,14 @@ int tpm_tcti(char *buf, size_t size)
const char *tcti;
ssize_t n;
- tcti = shirudo_image_config_active() ? NULL :
+ tcti = image_config_active() ? NULL :
getenv("SHIRUDO_TPM_TCTI");
if ((!tcti || !*tcti) && config_load(&cfg) == 0 &&
cfg.tpm_tcti[0])
tcti = cfg.tpm_tcti;
if (!tcti || !*tcti)
tcti = "device:/dev/tpmrm0";
- if (shirudo_image_config_active() && strncmp(tcti, "device:", 7)) {
+ if (image_config_active() && strncmp(tcti, "device:", 7)) {
explicit_bzero(&cfg, sizeof(cfg));
return -EACCES;
}
@@ -209,8 +209,8 @@ int tpm_pcr_extend(struct shirudo_tpm *t, __u32 pcr,
return 0;
}
-int shirudo_tpm_boot_identity(struct shirudo_tpm *t, __u32 *reset,
- __u32 *restart)
+int tpm_boot_identity(struct shirudo_tpm *t, __u32 *reset,
+ __u32 *restart)
{
TPMS_TIME_INFO *info = NULL;
TSS2_RC ret;
diff --git a/util/tpm.h b/util/tpm.h
index 167b6db5..34cb7887 100644
--- a/util/tpm.h
+++ b/util/tpm.h
@@ -44,8 +44,8 @@ int tpm_pcr_extend(struct shirudo_tpm *t, __u32 pcr,
* of the period a clear-on-reset index lives through.
*/
int tpm_reset_count(struct shirudo_tpm *t, __u32 *out);
-int shirudo_tpm_boot_identity(struct shirudo_tpm *t, __u32 *reset,
- __u32 *restart);
+int tpm_boot_identity(struct shirudo_tpm *t, __u32 *reset,
+ __u32 *restart);
struct tpm_nv_info {
bool defined;
diff --git a/util/tpm_wire.c b/util/tpm_wire.c
index 678c9002..421f7150 100644
--- a/util/tpm_wire.c
+++ b/util/tpm_wire.c
@@ -124,8 +124,8 @@ int tpm_policy_nv_written(const __u8 prev[32], bool written,
}
static void
-shirudo_tpm_pcr_selection(__u32 pcr_mask,
- __u8 out[TPM_PCR_SELECTION_LEN])
+tpm_pcr_selection(__u32 pcr_mask,
+ __u8 out[TPM_PCR_SELECTION_LEN])
{
put_be32(out, 1);
put_be16(out + 4, TPM_ALG_SHA256);
@@ -140,7 +140,7 @@ int tpm_policy_pcr(const __u8 prev[32], __u32 pcr_mask,
{
__u8 sel[TPM_PCR_SELECTION_LEN];
- shirudo_tpm_pcr_selection(pcr_mask, sel);
+ tpm_pcr_selection(pcr_mask, sel);
return policy_hash(prev, TPM_CC_POLICY_PCR, sel, sizeof(sel),
pcr_digest, 32, out);
}
diff --git a/util/upatch.h b/util/upatch.h
index aea2930e..558f9cb7 100644
--- a/util/upatch.h
+++ b/util/upatch.h
@@ -146,11 +146,11 @@ void prog_specs_free(struct shirudo_prog_spec *specs, __u32 nr_progs);
* init, bpm and keys: load, install, unload.
*/
int shirudo_upatch_apply(const char *path);
-int shirudo_upatch_install(const char *path);
-int shirudo_upatch_remove(const char *path);
+int upatch_install(const char *path);
+int upatch_remove(const char *path);
/*
- * shirudo_upatch_install() when the signed payload is valid but its
+ * upatch_install() when the signed payload is valid but its
* kprobe target is not there, because the module that has it is not
* loaded.
*/
@@ -161,6 +161,6 @@ int shirudo_upatch_remove(const char *path);
* that signed the upatch was revoked: 1 when the unload was measured,
* 0 when only the archive went, -errno otherwise.
*/
-int shirudo_upatch_purge(const char *name, const char *reason);
+int upatch_purge(const char *name, const char *reason);
#endif /* SHIRUDO_UTIL_UPATCH_H */
diff --git a/util/upatch_maps_otel.c b/util/upatch_maps_otel.c
index eb94475c..ff158cd8 100644
--- a/util/upatch_maps_otel.c
+++ b/util/upatch_maps_otel.c
@@ -148,9 +148,9 @@ static int metric_type_from_view(const struct shirudo_map_view *v,
return 0;
}
-int shirudo_upatch_maps_otel_classify(const struct shirudo_map_view *v,
- enum shirudo_otel_signal *signal,
- char *reason, size_t reason_sz)
+int upatch_maps_otel_classify(const struct shirudo_map_view *v,
+ enum shirudo_otel_signal *signal,
+ char *reason, size_t reason_sz)
{
struct metric_type mt;
int ret;
@@ -849,9 +849,9 @@ static int build_log_payload(const char *path,
return 0;
}
-int shirudo_upatch_maps_otel_build_log_file(const char *path,
- const struct shirudo_map_view *v,
- char **out, size_t *out_len)
+int upatch_maps_otel_build_log_file(const char *path,
+ const struct shirudo_map_view *v,
+ char **out, size_t *out_len)
{
if (!path)
return -EINVAL;
@@ -1051,9 +1051,9 @@ out:
return ret;
}
-int shirudo_upatch_maps_otel_build_metric_file(const char *path,
- const struct shirudo_map_view *v,
- char **out, size_t *out_len)
+int upatch_maps_otel_build_metric_file(const char *path,
+ const struct shirudo_map_view *v,
+ char **out, size_t *out_len)
{
if (!path)
return -EINVAL;
@@ -1274,7 +1274,7 @@ static size_t response_header(char *ptr, size_t size, size_t nmemb, void *ctx)
if (len < sizeof(value)) {
memcpy(value, p, len);
value[len] = '\0';
- if (!shirudo_otel_retry_after(value, time(NULL), &seconds)) {
+ if (!otel_retry_after(value, time(NULL), &seconds)) {
r->retry_after = seconds;
r->retry_after_valid = true;
}
@@ -1339,7 +1339,7 @@ static bool retryable_http(long code)
return code == 429 || code == 502 || code == 503 || code == 504;
}
-int shirudo_status_otel_severity(const char *status, const char **text)
+int status_otel_severity(const char *status, const char **text)
{
if (strcmp(status, "ok") == 0) {
*text = "INFO";
@@ -1355,7 +1355,7 @@ int shirudo_status_otel_severity(const char *status, const char **text)
return 17;
}
-int shirudo_otel_retry_after(const char *value, time_t now, __u64 *seconds)
+int otel_retry_after(const char *value, time_t now, __u64 *seconds)
{
struct tm date = {};
time_t retry_time;
@@ -1629,8 +1629,8 @@ static int otel_open_common(const char *spec, const struct shirudo_map_view *v,
if (!v || !state)
return -EINVAL;
if (automatic) {
- ret = shirudo_upatch_maps_otel_classify(v, &signal,
- reason, sizeof(reason));
+ ret = upatch_maps_otel_classify(v, &signal,
+ reason, sizeof(reason));
if (ret)
return ret;
fprintf(stderr, "otel: selected %s for %s map %s: %s\n",
@@ -1738,15 +1738,15 @@ static int build_generic_log_payload(const char *scope_name,
return 0;
}
-int shirudo_otel_send_log_json(const struct shirudo_otel_opts *opts,
- const char *scope_name,
- const char *event_name,
- int severity_number,
- const char *severity_text,
- const char *status,
- const char *version_id,
- __s64 tamper_attempts,
- const char *body_json, size_t body_len)
+int otel_send_log_json(const struct shirudo_otel_opts *opts,
+ const char *scope_name,
+ const char *event_name,
+ int severity_number,
+ const char *severity_text,
+ const char *status,
+ const char *version_id,
+ __s64 tamper_attempts,
+ const char *body_json, size_t body_len)
{
char *payload = NULL;
void *state = NULL;
@@ -2535,10 +2535,10 @@ static int otel_s3_close(void *state)
return 0;
}
-int shirudo_upatch_maps_otel_send_file(const char *decoder_path,
- const struct shirudo_map_view *v,
- enum shirudo_otel_mode mode,
- const struct shirudo_otel_opts *opts)
+int upatch_maps_otel_send_file(const char *decoder_path,
+ const struct shirudo_map_view *v,
+ enum shirudo_otel_mode mode,
+ const struct shirudo_otel_opts *opts)
{
const char *endpoint = opts ? opts->endpoint : NULL;
bool automatic = mode == SHIRUDO_OTEL_AUTO;
@@ -2573,28 +2573,28 @@ int shirudo_upatch_maps_otel_send_file(const char *decoder_path,
return ret ? ret : close_rc;
}
-int shirudo_upatch_maps_otel_send(const struct shirudo_map_view *v,
- enum shirudo_otel_mode mode,
- const struct shirudo_otel_opts *opts)
+int upatch_maps_otel_send(const struct shirudo_map_view *v,
+ enum shirudo_otel_mode mode,
+ const struct shirudo_otel_opts *opts)
{
- return shirudo_upatch_maps_otel_send_file(NULL, v, mode, opts);
+ return upatch_maps_otel_send_file(NULL, v, mode, opts);
}
-int shirudo_upatch_maps_otel_send_decoded(const struct shirudo_map_view *v,
- enum shirudo_otel_signal signal,
- const struct shirudo_otel_opts *opts)
+int upatch_maps_otel_send_decoded(const struct shirudo_map_view *v,
+ enum shirudo_otel_signal signal,
+ const struct shirudo_otel_opts *opts)
{
int ret;
if (signal == SHIRUDO_OTEL_LOG)
- ret = shirudo_upatch_maps_otel_send(v, SHIRUDO_OTEL_FORCE_LOG,
- opts);
+ ret = upatch_maps_otel_send(v, SHIRUDO_OTEL_FORCE_LOG,
+ opts);
else if (signal == SHIRUDO_OTEL_METRIC)
- ret = shirudo_upatch_maps_otel_send(v, SHIRUDO_OTEL_FORCE_METRIC,
- opts);
+ ret = upatch_maps_otel_send(v, SHIRUDO_OTEL_FORCE_METRIC,
+ opts);
else
return -EINVAL;
if (ret == -E2BIG && opts && opts->s3_uri)
- return shirudo_upatch_maps_otel_send(v, SHIRUDO_OTEL_S3, opts);
+ return upatch_maps_otel_send(v, SHIRUDO_OTEL_S3, opts);
return ret;
}
diff --git a/util/upatch_maps_otel.h b/util/upatch_maps_otel.h
index 15939ee5..567b9445 100644
--- a/util/upatch_maps_otel.h
+++ b/util/upatch_maps_otel.h
@@ -35,43 +35,43 @@ struct shirudo_otel_opts {
__u32 otlp_max_bytes;
};
-int shirudo_upatch_maps_otel_classify(const struct shirudo_map_view *v,
- enum shirudo_otel_signal *signal,
- char *reason, size_t reason_sz);
-int shirudo_upatch_maps_otel_build_log_file(const char *path,
- const struct shirudo_map_view *v,
- char **out, size_t *out_len);
-int shirudo_upatch_maps_otel_build_metric_file(const char *path,
- const struct shirudo_map_view *v,
- char **out, size_t *out_len);
-int shirudo_upatch_maps_otel_send(const struct shirudo_map_view *v,
- enum shirudo_otel_mode mode,
- const struct shirudo_otel_opts *opts);
-int shirudo_upatch_maps_otel_send_file(const char *path,
+int upatch_maps_otel_classify(const struct shirudo_map_view *v,
+ enum shirudo_otel_signal *signal,
+ char *reason, size_t reason_sz);
+int upatch_maps_otel_build_log_file(const char *path,
+ const struct shirudo_map_view *v,
+ char **out, size_t *out_len);
+int upatch_maps_otel_build_metric_file(const char *path,
const struct shirudo_map_view *v,
- enum shirudo_otel_mode mode,
- const struct shirudo_otel_opts *opts);
+ char **out, size_t *out_len);
+int upatch_maps_otel_send(const struct shirudo_map_view *v,
+ enum shirudo_otel_mode mode,
+ const struct shirudo_otel_opts *opts);
+int upatch_maps_otel_send_file(const char *path,
+ const struct shirudo_map_view *v,
+ enum shirudo_otel_mode mode,
+ const struct shirudo_otel_opts *opts);
/* Export using the matching decoder's signed, static signal selection. */
-int shirudo_upatch_maps_otel_send_decoded(const struct shirudo_map_view *v,
- enum shirudo_otel_signal signal,
- const struct shirudo_otel_opts *opts);
+int upatch_maps_otel_send_decoded(const struct shirudo_map_view *v,
+ enum shirudo_otel_signal signal,
+ const struct shirudo_otel_opts *opts);
/*
* Send an already-built JSON object as the structured body of one OTLP
* log. A tamper_attempts of 0 or more rides along as an attribute; a
* negative one leaves it out.
*/
-int shirudo_otel_send_log_json(const struct shirudo_otel_opts *opts,
- const char *scope_name,
- const char *event_name,
- int severity_number,
- const char *severity_text,
- const char *status,
- const char *version_id,
- __s64 tamper_attempts,
- const char *body_json, size_t body_len);
-int shirudo_otel_retry_after(const char *value, time_t now, __u64 *seconds);
-int shirudo_status_otel_severity(const char *status, const char **text);
+int otel_send_log_json(const struct shirudo_otel_opts *opts,
+ const char *scope_name,
+ const char *event_name,
+ int severity_number,
+ const char *severity_text,
+ const char *status,
+ const char *version_id,
+ __s64 tamper_attempts,
+ const char *body_json, size_t body_len);
+int otel_retry_after(const char *value, time_t now, __u64 *seconds);
+int status_otel_severity(const char *status, const char **text);
#endif /* SHIRUDO_UTIL_UPATCH_MAPS_OTEL_H */