Skip to content

eBPF-based security platform

treewide: drop the shirudo_ prefix from struct and enum names

Daniel Borkmannb8cafb2877fc
diff --git a/Documentation/concepts/background/luajit.rst b/Documentation/concepts/background/luajit.rst
index 0b9da1a8..eb145f42 100644
--- a/Documentation/concepts/background/luajit.rst
+++ b/Documentation/concepts/background/luajit.rst
@@ -65,7 +65,7 @@ How a decoder reaches the target
--------------------------------
The BPF source declares each decoder in ``.rodata`` with a
-``struct shirudo_decoder_manifest`` from
+``struct decoder_manifest`` from
``bpf/lib/decoder.h``. The manifest starts with the magic
``DECD`` and names the language (``1``, Lua), the host API version, the
input format (``1``), the signal to export (``1`` for a log, ``2`` for a
diff --git a/Documentation/concepts/glossary.rst b/Documentation/concepts/glossary.rst
index cd524763..8abb3c2d 100644
--- a/Documentation/concepts/glossary.rst
+++ b/Documentation/concepts/glossary.rst
@@ -110,7 +110,7 @@ it.
decoder
A Lua function shipped inside an upatch that turns a snapshot of one
map into OTLP log records or metrics. The program declares it with
- a ``struct shirudo_decoder_manifest`` in ``.rodata``,
+ a ``struct decoder_manifest`` in ``.rodata``,
``shirudo-build`` embeds the source in the signed ``DCDB`` section,
and ``shirudo upatch map`` runs it under LuaJIT. See
:doc:`/upatches/write/decoders`.
diff --git a/Documentation/contribute/code/develop-locally/exec-count.bpf.c b/Documentation/contribute/code/develop-locally/exec-count.bpf.c
index 9d441125..248494a1 100644
--- a/Documentation/contribute/code/develop-locally/exec-count.bpf.c
+++ b/Documentation/contribute/code/develop-locally/exec-count.bpf.c
@@ -13,7 +13,7 @@ struct {
__type(value, __u64);
} execs SEC(".maps");
-const struct shirudo_decoder_manifest execs_decoder SEC(".rodata") = {
+const struct decoder_manifest execs_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
diff --git a/Documentation/reference/formats/upatch-format.rst b/Documentation/reference/formats/upatch-format.rst
index 1b5e5463..ff93edeb 100644
--- a/Documentation/reference/formats/upatch-format.rst
+++ b/Documentation/reference/formats/upatch-format.rst
@@ -39,7 +39,7 @@ region through the header only.
- Content
* - header
- offset 0, 360 bytes
- - ``struct shirudo_upatch_header``.
+ - ``struct upatch_header``.
* - ``loader_insns``
- ``loader_insns_off``, ``loader_insns_len``
- The ``BPF_PROG_TYPE_SYSCALL`` loader program that libbpf's
@@ -60,7 +60,7 @@ region through the header only.
Header
------
-``struct shirudo_upatch_header``, 360 bytes, no padding.
+``struct upatch_header``, 360 bytes, no padding.
.. list-table::
:header-rows: 1
@@ -565,7 +565,7 @@ Each decoder entry:
- ``source_len``
- Length of the source, non-zero.
-The writer takes each entry from a ``struct shirudo_decoder_manifest`` that
+The writer takes each entry from a ``struct decoder_manifest`` that
the BPF program declares in ``.rodata`` (``bpf/lib/decoder.h``,
192 bytes, magic ``0x44434544``, the bytes ``DECD``, ``u16`` fields
``version``, ``language``, ``api_version``, ``input_format``,
diff --git a/Documentation/upatches/write/decoders.rst b/Documentation/upatches/write/decoders.rst
index bc588fc1..745326f7 100644
--- a/Documentation/upatches/write/decoders.rst
+++ b/Documentation/upatches/write/decoders.rst
@@ -41,7 +41,7 @@ Declare the decoder
#include "decoder.h"
- const struct shirudo_decoder_manifest watch_stat_decoder SEC(".rodata") = {
+ const struct decoder_manifest watch_stat_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
diff --git a/Documentation/upatches/write/maps-arenas-serializers.rst b/Documentation/upatches/write/maps-arenas-serializers.rst
index 2c85467d..19da849e 100644
--- a/Documentation/upatches/write/maps-arenas-serializers.rst
+++ b/Documentation/upatches/write/maps-arenas-serializers.rst
@@ -107,7 +107,7 @@ Serializer interface
A serializer is a ``SEC("syscall")`` program named
``shirudo_serialize__<map>``. It writes into ``shirudo_ser``, an array map
-with a ``__u32`` key and ``struct shirudo_serial_chunk`` values that the
+with a ``__u32`` key and ``struct serial_chunk`` values that the
upatch defines with 1 to 256 entries. ``bpf/lib/serializer.h``
holds the definitions. The builder refuses a serializer that is not in
``SEC("syscall")``, targets a map that does not exist or is
diff --git a/bpf/admission.h b/bpf/admission.h
index 8ad0555c..354ac672 100644
--- a/bpf/admission.h
+++ b/bpf/admission.h
@@ -10,9 +10,9 @@
* BPF mutations require a task marked by successful exec from the runtime
* image. Verified signed loaders perform their own calls in kernel context.
*/
-static __always_inline int shirudo_self_or_deny(enum shirudo_tamper_point point)
+static __always_inline int shirudo_self_or_deny(enum tamper_point point)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0;
id = bpf_map_lookup_elem(&shirudo_bpffs_sb, &zero);
@@ -25,7 +25,7 @@ SEC("lsm/bpf")
int BPF_PROG(shirudo_lsm_bpf, int cmd, union bpf_attr *attr,
unsigned int size, bool kernel, int ret)
{
- enum shirudo_tamper_point point;
+ enum tamper_point point;
if (ret)
return ret;
@@ -161,7 +161,7 @@ int BPF_PROG(shirudo_lsm_bpf_prog_load, struct bpf_prog *prog,
union bpf_attr *attr, struct bpf_token *token,
bool kernel, int ret)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0, verdict, ktype;
__s32 serial;
@@ -207,7 +207,7 @@ int BPF_PROG(shirudo_lsm_task_prctl, int option, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5,
int ret)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0;
(void)arg3;
@@ -237,7 +237,7 @@ SEC("lsm/bprm_check_security")
int BPF_PROG(shirudo_lsm_bprm_check_security, struct linux_binprm *bprm,
int ret)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0;
if (ret)
@@ -256,9 +256,9 @@ int BPF_PROG(shirudo_lsm_bprm_check_security, struct linux_binprm *bprm,
* runtime task may change their inodes. Count bpffs refusals at `point`.
*/
static __always_inline int shirudo_bpffs_guard(__u32 target_dev,
- enum shirudo_tamper_point point)
+ enum tamper_point point)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0;
id = bpf_map_lookup_elem(&shirudo_bpffs_sb, &zero);
@@ -288,7 +288,7 @@ SEC("lsm/key_permission")
int BPF_PROG(shirudo_lsm_key_permission, key_ref_t key_ref,
const struct cred *cred, enum key_need_perm need, int ret)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0, i;
struct key *key;
bool possessed;
@@ -335,7 +335,7 @@ SEC("lsm/tpm_command")
int BPF_PROG(shirudo_lsm_tpm_command, struct file *file,
const __u8 *command, size_t command_len, int ret)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 code, index;
(void)file;
@@ -519,7 +519,7 @@ int BPF_PROG(shirudo_lsm_inode_removexattr, struct mnt_idmap *idmap,
*/
static __always_inline __u32 shirudo_bpffs_dev(void)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0;
id = bpf_map_lookup_elem(&shirudo_bpffs_sb, &zero);
@@ -528,7 +528,7 @@ static __always_inline __u32 shirudo_bpffs_dev(void)
/* -EPERM, counted at `point`, when sb_dev is the bpffs; else 0. */
static __always_inline int
-shirudo_deny_bpffs_mount(__u32 sb_dev, enum shirudo_tamper_point point)
+shirudo_deny_bpffs_mount(__u32 sb_dev, enum tamper_point point)
{
__u32 bpffs = shirudo_bpffs_dev();
diff --git a/bpf/bpf2.c b/bpf/bpf2.c
index 31763015..552909d0 100644
--- a/bpf/bpf2.c
+++ b/bpf/bpf2.c
@@ -98,7 +98,7 @@ static __always_inline bool shirudo_umount_takes_bpffs(struct mount *m,
*/
static __always_inline int shirudo_umount_above(struct vfsmount *mnt)
{
- struct shirudo_mount_record *rec;
+ struct mount_record *rec;
struct mount *t, *m, *bpffs, *parent;
__u32 zero = 0;
bool sibling;
@@ -153,8 +153,8 @@ deny:
SEC("lsm/file_open")
int BPF_PROG(shirudo_lsm_file_open, struct file *file, int ret)
{
- struct shirudo_sb_id *id = shirudo_policy();
- struct shirudo_mount_record *rec;
+ struct sb_id *id = shirudo_policy();
+ struct mount_record *rec;
struct vfsmount *mnt;
__u32 zero = 0;
@@ -176,7 +176,7 @@ int BPF_PROG(shirudo_lsm_file_open, struct file *file, int ret)
static __always_inline int shirudo_parent_mount(struct super_block *sb,
bool trusted_target)
{
- struct shirudo_sb_id *id = shirudo_policy();
+ struct sb_id *id = shirudo_policy();
if (!sb || !id || !id->run_dev ||
BPF_CORE_READ(sb, s_dev) != id->run_dev)
@@ -187,8 +187,8 @@ static __always_inline int shirudo_parent_mount(struct super_block *sb,
static __always_inline int shirudo_image_mount(struct super_block *sb,
bool replace)
{
- struct shirudo_sb_id *id = shirudo_policy();
- struct shirudo_device *device;
+ struct sb_id *id = shirudo_policy();
+ struct verity_device *device;
struct block_device *bdev;
if (!sb || !id)
@@ -297,9 +297,9 @@ int BPF_PROG(shirudo_lsm_bdev_setintegrity, struct block_device *bdev,
size_t size, int ret)
{
const struct dm_verity_digest___shirudo *digest = value;
- struct shirudo_sb_id *id = shirudo_policy();
- struct shirudo_expected_root *expected;
- struct shirudo_device device = {};
+ struct sb_id *id = shirudo_policy();
+ struct expected_root *expected;
+ struct verity_device device = {};
__u64 cookie = (__u64)bdev;
const unsigned char *root;
const char *algorithm;
@@ -373,7 +373,7 @@ void BPF_PROG(shirudo_lsm_bdev_free_security, struct block_device *bdev)
static __always_inline int shirudo_dm_ioctl(struct file *file,
unsigned int cmd, int ret)
{
- struct shirudo_sb_id *id = shirudo_policy();
+ struct sb_id *id = shirudo_policy();
struct inode *inode;
if (ret || !id || shirudo_task_is_self(id))
diff --git a/bpf/lib/decoder.h b/bpf/lib/decoder.h
index cadea9c1..4c6b74f3 100644
--- a/bpf/lib/decoder.h
+++ b/bpf/lib/decoder.h
@@ -15,7 +15,7 @@
#define UPATCH_DECODER_EXPORT_LOG 1u
#define UPATCH_DECODER_EXPORT_METRIC 2u
-struct shirudo_decoder_manifest {
+struct decoder_manifest {
__u32 magic; /* DECODER_MANIFEST_MAGIC */
__u16 version; /* UPATCH_DECODER_VERSION */
__u16 language; /* SHIRUDO_UPATCH_DECODER_LANG_* */
diff --git a/bpf/lib/identity.h b/bpf/lib/identity.h
index 39b659be..46cf22d0 100644
--- a/bpf/lib/identity.h
+++ b/bpf/lib/identity.h
@@ -6,10 +6,10 @@
#include <shirudo/tpm.h>
-/* Frozen ABI shared with struct shirudo_identity in util/identity.h. */
+/* Frozen ABI shared with struct identity in util/identity.h. */
#define IDENTITY_KEYS_MAX 16
-struct shirudo_sb_id {
+struct sb_id {
__u32 sb_dev;
__u32 run_dev;
__s32 keyring_serial;
@@ -30,11 +30,11 @@ struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, __u32);
- __type(value, struct shirudo_sb_id);
+ __type(value, struct sb_id);
} shirudo_bpffs_sb SEC(".maps");
/* The bpffs mount of init's namespace, as the unmount guard keeps it. */
-struct shirudo_mount_record {
+struct mount_record {
__u64 mount;
};
@@ -42,7 +42,7 @@ struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, __u32);
- __type(value, struct shirudo_mount_record);
+ __type(value, struct mount_record);
} shirudo_mnt_rec SEC(".maps");
#endif /* SHIRUDO_BPF_IDENTITY_H */
diff --git a/bpf/lib/serializer.h b/bpf/lib/serializer.h
index 1060917f..e004ddb8 100644
--- a/bpf/lib/serializer.h
+++ b/bpf/lib/serializer.h
@@ -24,7 +24,7 @@
/*
* Keep the syscall test-run context within the older five-u64 argument
- * limit. Page result metadata lives in struct shirudo_serial_chunk.
+ * limit. Page result metadata lives in struct serial_chunk.
*/
#define SERIAL_CTX_MAX_BYTES 40u
@@ -34,7 +34,7 @@
*/
#define SERIAL_CHUNK_PAYLOAD 4032u
-struct shirudo_serialize_ctx {
+struct serialize_ctx {
__u32 magic;
__u32 version;
__u32 flags;
@@ -45,7 +45,7 @@ struct shirudo_serialize_ctx {
__u64 invocation_id;
};
-struct shirudo_serial_chunk {
+struct serial_chunk {
__u32 magic;
__u32 version;
__u32 flags;
@@ -62,8 +62,8 @@ struct shirudo_serial_chunk {
__u8 data[SERIAL_CHUNK_PAYLOAD];
};
-BUILD_BUG_ON(sizeof(struct shirudo_serialize_ctx) !=
+BUILD_BUG_ON(sizeof(struct serialize_ctx) !=
SERIAL_CTX_MAX_BYTES);
-BUILD_BUG_ON(sizeof(struct shirudo_serial_chunk) != 4096);
+BUILD_BUG_ON(sizeof(struct serial_chunk) != 4096);
#endif /* SHIRUDO_SERIALIZER_H */
diff --git a/bpf/lib/tamper.h b/bpf/lib/tamper.h
index cbc09adf..d61844fe 100644
--- a/bpf/lib/tamper.h
+++ b/bpf/lib/tamper.h
@@ -10,7 +10,7 @@
#ifndef SHIRUDO_TAMPER_H
#define SHIRUDO_TAMPER_H
-enum shirudo_tamper_point {
+enum tamper_point {
SHIRUDO_TAMPER_LOAD_NOT_LOADER,
SHIRUDO_TAMPER_LOAD_UNSIGNED,
SHIRUDO_TAMPER_LOAD_UNVERIFIED,
@@ -58,7 +58,7 @@ struct {
__type(value, __u64);
} shirudo_tamper SEC(".maps");
-static __always_inline int shirudo_tamper_deny(enum shirudo_tamper_point point,
+static __always_inline int shirudo_tamper_deny(enum tamper_point point,
int err)
{
__u32 key = point;
diff --git a/bpf/lsm.h b/bpf/lsm.h
index ad890b9a..bd68a761 100644
--- a/bpf/lsm.h
+++ b/bpf/lsm.h
@@ -43,7 +43,7 @@
#define TASK_TRUSTED 1
#define TASK_BOOTSTRAP 2
-struct shirudo_task_authority {
+struct task_authority {
__u8 trusted;
__u8 candidate_valid;
__u8 candidate_trusted;
@@ -55,10 +55,10 @@ struct {
__uint(type, BPF_MAP_TYPE_TASK_STORAGE);
__uint(map_flags, BPF_F_NO_PREALLOC);
__type(key, int);
- __type(value, struct shirudo_task_authority);
+ __type(value, struct task_authority);
} shirudo_tasks SEC(".maps");
-static __always_inline struct shirudo_sb_id *shirudo_policy(void)
+static __always_inline struct sb_id *shirudo_policy(void)
{
__u32 zero = 0;
@@ -67,7 +67,7 @@ static __always_inline struct shirudo_sb_id *shirudo_policy(void)
static __always_inline bool shirudo_marked(struct task_struct *task)
{
- struct shirudo_task_authority *authority;
+ struct task_authority *authority;
authority = bpf_task_storage_get(&shirudo_tasks, task, NULL, 0);
return authority && authority->trusted;
diff --git a/bpf/seal.c b/bpf/seal.c
index ad333e27..82874817 100644
--- a/bpf/seal.c
+++ b/bpf/seal.c
@@ -30,7 +30,7 @@ int BPF_PROG(shirudo_seal_bprm_check_security,
struct linux_binprm *bprm, int ret)
{
struct task_struct *task = bpf_get_current_task_btf();
- struct shirudo_task_authority *authority;
+ struct task_authority *authority;
struct inode *real_inode;
bool trusted;
@@ -64,7 +64,7 @@ int BPF_PROG(shirudo_seal_mmap_file, struct file *file,
unsigned long reqprot, unsigned long prot,
unsigned long flags, int ret)
{
- struct shirudo_sb_id *id = shirudo_policy();
+ struct sb_id *id = shirudo_policy();
if (ret)
return ret;
@@ -81,7 +81,7 @@ SEC("lsm/file_mprotect")
int BPF_PROG(shirudo_seal_file_mprotect, struct vm_area_struct *vma,
unsigned long reqprot, unsigned long prot, int ret)
{
- struct shirudo_sb_id *id = shirudo_policy();
+ struct sb_id *id = shirudo_policy();
unsigned long old_flags;
if (ret)
diff --git a/bpf/seal.h b/bpf/seal.h
index be4a9381..bf973e3c 100644
--- a/bpf/seal.h
+++ b/bpf/seal.h
@@ -69,9 +69,9 @@ int bpf_inode_init_xattr(struct xattr *xattrs, int *xattr_count__ctx_out,
* Labels identify protected writable targets. Caller authority comes from
* successful runtime exec, never from a label on the caller's binary.
*/
-static __always_inline int seal_caller(enum shirudo_tamper_point point)
+static __always_inline int seal_caller(enum tamper_point point)
{
- struct shirudo_sb_id *id;
+ struct sb_id *id;
__u32 zero = 0;
id = bpf_map_lookup_elem(&shirudo_bpffs_sb, &zero);
@@ -91,7 +91,7 @@ static __always_inline int seal_caller(enum shirudo_tamper_point point)
* caller to be shirudo. 0 = allow, -EACCES = deny.
*/
static __always_inline int seal_verdict(int tlen,
- enum shirudo_tamper_point point)
+ enum tamper_point point)
{
switch (tlen) {
case -ENODATA:
@@ -150,7 +150,7 @@ void BPF_PROG(shirudo_seal_bprm_committed_creds,
const struct linux_binprm *bprm)
{
struct task_struct *task = bpf_get_current_task_btf();
- struct shirudo_task_authority *authority;
+ struct task_authority *authority;
(void)bprm;
authority = bpf_task_storage_get(&shirudo_tasks, task, NULL, 0);
@@ -167,8 +167,8 @@ int BPF_PROG(shirudo_seal_task_alloc, struct task_struct *child,
__u64 clone_flags, int ret)
{
struct task_struct *parent = bpf_get_current_task_btf();
- struct shirudo_task_authority *parent_authority;
- struct shirudo_task_authority *authority;
+ struct task_authority *parent_authority;
+ struct task_authority *authority;
(void)clone_flags;
if (ret)
@@ -344,7 +344,7 @@ int BPF_PROG(shirudo_seal_inode_init_security, struct inode *inode,
}
static __always_inline int seal_dentry(struct dentry *dentry,
- enum shirudo_tamper_point point)
+ enum tamper_point point)
{
struct task_struct *task = bpf_get_current_task_btf();
struct seal_scratch *s = seal_scratch_get(task);
diff --git a/bpf/unload.c b/bpf/unload.c
index 4fa6f4b2..23a52bf6 100644
--- a/bpf/unload.c
+++ b/bpf/unload.c
@@ -12,12 +12,12 @@
#define UPATCH_NAME_MAX 256
#define SHA256_LEN 32
-struct shirudo_unload_params {
+struct unload_params {
char name[UPATCH_NAME_MAX];
__u8 expected_sha256[SHA256_LEN];
};
-volatile const struct shirudo_unload_params shirudo_unload_params = {
+volatile const struct unload_params shirudo_unload_params = {
.name = "<unpatched>",
.expected_sha256 = {},
};
diff --git a/bpf/verity_policy.h b/bpf/verity_policy.h
index 4d4fe532..3feb9a43 100644
--- a/bpf/verity_policy.h
+++ b/bpf/verity_policy.h
@@ -9,7 +9,7 @@
#define DEVICE_RUNTIME 1
#define DEVICE_CONFIG 2
-struct shirudo_device {
+struct verity_device {
__u32 dev;
__u32 kind;
__u8 root[32];
@@ -20,11 +20,11 @@ struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 128);
__type(key, __u64);
- __type(value, struct shirudo_device);
+ __type(value, struct verity_device);
} shirudo_devices SEC(".maps");
/* Trusted userspace records the expected root for the preparing task. */
-struct shirudo_expected_root {
+struct expected_root {
__u8 root[32];
__u32 valid;
};
@@ -33,7 +33,7 @@ struct {
__uint(type, BPF_MAP_TYPE_TASK_STORAGE);
__uint(map_flags, BPF_F_NO_PREALLOC);
__type(key, int);
- __type(value, struct shirudo_expected_root);
+ __type(value, struct expected_root);
} shirudo_roots SEC(".maps");
struct inode *bpf_real_data_inode(struct file *file) __ksym;
@@ -41,29 +41,29 @@ struct inode *bpf_real_data_inode(struct file *file) __ksym;
static __always_inline bool shirudo_bootstrap_task(void)
{
struct task_struct *task = bpf_get_current_task_btf();
- struct shirudo_task_authority *authority;
+ struct task_authority *authority;
authority = bpf_task_storage_get(&shirudo_tasks, task, NULL, 0);
return authority && authority->trusted == TASK_BOOTSTRAP;
}
/* The mark changes only when exec commits, so failed exec keeps authority. */
-static __always_inline bool shirudo_task_is_self(const struct shirudo_sb_id *id)
+static __always_inline bool shirudo_task_is_self(const struct sb_id *id)
{
return shirudo_marked(bpf_get_current_task_btf());
}
static __always_inline bool
-shirudo_protected_filesystem(const struct shirudo_sb_id *id, __u32 dev)
+shirudo_protected_filesystem(const struct sb_id *id, __u32 dev)
{
return dev == id->sb_dev || (id->run_dev && dev == id->run_dev);
}
/* Device pointers can be reused even when the free hook did not run. */
-static __always_inline struct shirudo_device *
+static __always_inline struct verity_device *
shirudo_bdev_device(struct block_device *bdev)
{
- struct shirudo_device *device;
+ struct verity_device *device;
__u64 cookie = (__u64)bdev;
if (!bdev)
@@ -76,7 +76,7 @@ shirudo_bdev_device(struct block_device *bdev)
return device;
}
-static __always_inline struct shirudo_device *
+static __always_inline struct verity_device *
shirudo_inode_device(struct inode *inode)
{
struct block_device *bdev;
@@ -95,7 +95,7 @@ shirudo_inode_device(struct inode *inode)
static __always_inline bool shirudo_file_runtime(struct file *file)
{
- struct shirudo_device *device;
+ struct verity_device *device;
if (!file)
return false;
diff --git a/builtin-attest.c b/builtin-attest.c
index adb902e9..d9bedd49 100644
--- a/builtin-attest.c
+++ b/builtin-attest.c
@@ -39,20 +39,20 @@
#define EVIDENCE_MAX JSON_MAX_BYTES
#define EVENTS_MAX 256
-static const struct shirudo_help_item attest_subcmds[] = {
+static const struct help_item attest_subcmds[] = {
{ "verify", "check an evidence document against the expected state" },
{ "predict", "compute the register value a set of upatches yields" },
{ "challenge", "make a credential challenge for a target's attestation key" },
};
-static const struct shirudo_help_item attest_options[] = {
+static const struct help_item attest_options[] = {
{ "--nonce=<hex>", "freshness value from the verifier (up to 64 bytes)" },
{ "--pcrs=<list>", "PCRs to quote, comma separated (default 0-7,9,11-15)" },
{ "--challenge=<path>", "a challenge from the verifier to activate while attesting" },
{ "--out=<path>", "write the evidence there (0600) instead of stdout" },
};
-static const struct shirudo_help_item verify_options[] = {
+static const struct help_item verify_options[] = {
{ "--evidence=<path>", "the document a target produced" },
{ "--nonce=<hex>", "the nonce that document was requested with" },
{ "--ak-name=<hex>", "the attestation key name pinned at enrollment" },
@@ -72,7 +72,7 @@ static const struct shirudo_help_item verify_options[] = {
{ "--require-initrd", "fail unless init bound the register from the initrd" },
};
-static const struct shirudo_help_item challenge_options[] = {
+static const struct help_item challenge_options[] = {
{ "--evidence=<path>", "a document the target produced, carrying its keys" },
{ "--ak-name=<hex>", "the attestation key name the challenge is for" },
{ "--ek-ca=<bundle>", "PEM issuers the endorsement certificate must chain to" },
@@ -81,7 +81,7 @@ static const struct shirudo_help_item challenge_options[] = {
{ "--out=<path>", "write the challenge there (0600)" },
};
-static const struct shirudo_help_item predict_options[] = {
+static const struct help_item predict_options[] = {
{ "--cert=<cert.der>", "a certificate the target enrols (repeatable)" },
{ "--upatch=<file>", "an installed artifact (repeatable)" },
{ "--expect=<name>=<hex>", "an installed upatch by name and payload digest" },
@@ -92,7 +92,7 @@ static const struct shirudo_help_item predict_options[] = {
{ "--writer-public=<hex>", "init record's 384-byte RSA modulus (with --bind-pcr)" },
};
-static const struct shirudo_help_section attest_help_sections[] = {
+static const struct help_section attest_help_sections[] = {
{ "subcommands:", attest_subcmds, ARRAY_SIZE(attest_subcmds) },
{ "evidence options (target):", attest_options,
ARRAY_SIZE(attest_options) },
@@ -104,7 +104,7 @@ static const struct shirudo_help_section attest_help_sections[] = {
ARRAY_SIZE(challenge_options) },
};
-static const struct shirudo_help attest_help = {
+static const struct help attest_help = {
.usage = "shirudo attest [--nonce=<hex>] [--pcrs=<list>] "
"[--challenge=<path>] [--out=<path>]\n"
" shirudo attest verify --evidence=<path> --nonce=<hex> "
@@ -176,14 +176,14 @@ static int parse_pcr_value(const char *arg, __u64 *pcr, const char **value)
}
struct members {
- struct shirudo_measured_upatch *set;
+ struct measured_upatch *set;
size_t n;
};
static int member_add_file(struct members *m, const char *path)
{
- struct shirudo_measured_upatch *e;
- struct shirudo_upatch u;
+ struct measured_upatch *e;
+ struct upatch u;
int ret;
if (m->n >= ATTEST_MEMBERS_MAX)
@@ -204,7 +204,7 @@ static int member_add_file(struct members *m, const char *path)
static int member_add_spec(struct members *m, const char *spec)
{
- struct shirudo_measured_upatch *e;
+ struct measured_upatch *e;
const char *eq = strchr(spec, '=');
__u8 payload[32];
@@ -476,7 +476,7 @@ static int read_evidence(const char *path, char **out, size_t *len)
static int cmd_attest_verify(int argc, const char **argv)
{
- struct shirudo_attest_expect x = {};
+ struct attest_expect x = {};
__u8 nonce[ATTEST_NONCE_MAX], cert_sha[32], set_digest[32];
__u8 cert_shas[KEYS_MAX][32];
size_t n_certs = 0;
@@ -670,7 +670,7 @@ out:
static int cmd_attest_challenge(int argc, const char **argv)
{
- struct shirudo_attest_challenge_policy pol = {};
+ struct attest_challenge_policy pol = {};
__u8 credential[TPM_CREDENTIAL_LEN];
__u8 ak_name[TPM_NAME_LEN], ek_name[TPM_NAME_LEN];
const char *evidence_path = NULL, *out_path = NULL;
@@ -772,8 +772,8 @@ out:
static int cmd_attest_evidence(int argc, const char **argv)
{
- const struct shirudo_attest_challenge *request;
- struct shirudo_attest_challenge challenge = {};
+ const struct attest_challenge *request;
+ struct attest_challenge challenge = {};
__u8 nonce[ATTEST_NONCE_MAX];
__u32 mask = ATTEST_PCR_DEFAULT;
const char *out_path = NULL, *challenge_path = NULL;
diff --git a/builtin-bpm.c b/builtin-bpm.c
index f3ece4cc..37a245cb 100644
--- a/builtin-bpm.c
+++ b/builtin-bpm.c
@@ -449,7 +449,7 @@ static int cache_path(const char *source, char *out, size_t sz)
static int sha256_file_hex(const char *path, char *hex, size_t hex_sz)
{
- struct shirudo_sha256_ctx ctx;
+ struct sha256_ctx ctx;
__u8 digest[CRYPTO_SHA256_LEN];
__u8 buf[65536];
ssize_t nr;
@@ -631,7 +631,7 @@ static int print_package_upatch_data(const char *source, const char *member,
__u8 *beefile = NULL, *bytes = NULL;
const char *archive = source;
char package_dir[101];
- struct shirudo_upatch u = {};
+ struct upatch u = {};
int ret;
if (!bpm_archive_rel_ok(member) || strncmp(member, "upatches/", 9) ||
@@ -692,7 +692,7 @@ out:
static int cert_matches_active(const char *path)
{
- struct shirudo_cert a = {}, b = {};
+ struct cert a = {}, b = {};
__u8 da[CRYPTO_SHA256_LEN], db[CRYPTO_SHA256_LEN];
int ret = -EINVAL;
@@ -709,7 +709,7 @@ static int cert_matches_active(const char *path)
static int key_file_fingerprint(const char *path, char hex[65])
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
__u8 digest[CRYPTO_SHA256_LEN];
int ret;
@@ -929,8 +929,8 @@ static int state_read(struct bpm_state_entry *st, int *n)
size_t len;
int ret;
struct state_sink sink = { .items = st };
- struct shirudo_json_array arr = { on_state_entry, &sink };
- struct shirudo_json_field sub[4], root[1];
+ struct json_array arr = { on_state_entry, &sink };
+ struct json_field sub[4], root[1];
__s64 unused = 0;
ret = read_file(BPM_STATE_PATH, 8u * 1024u * 1024u,
@@ -941,25 +941,25 @@ static int state_read(struct bpm_state_entry *st, int *n)
}
if (ret)
return ret;
- sub[0] = (struct shirudo_json_field){
+ sub[0] = (struct json_field){
.key = "name", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.name, .dst_cap = sizeof(sink.scratch.name),
};
- sub[1] = (struct shirudo_json_field){
+ sub[1] = (struct json_field){
.key = "version", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.version,
.dst_cap = sizeof(sink.scratch.version),
};
- sub[2] = (struct shirudo_json_field){
+ sub[2] = (struct json_field){
.key = "source", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.source,
.dst_cap = sizeof(sink.scratch.source),
};
- sub[3] = (struct shirudo_json_field){
+ sub[3] = (struct json_field){
.key = "path", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.path, .dst_cap = sizeof(sink.scratch.path),
};
- root[0] = (struct shirudo_json_field){
+ root[0] = (struct json_field){
.key = "packages", .type = SHIRUDO_JSON_T_ARRAY,
.dst = &arr, .sub = sub, .n_sub = ARRAY_SIZE(sub),
};
@@ -975,7 +975,7 @@ static int state_read(struct bpm_state_entry *st, int *n)
static int state_write(const struct bpm_state_entry *st, int n)
{
char buf[1024 * 1024];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
int ret;
json_obj_open(&e);
@@ -1494,7 +1494,7 @@ static int cmd_bpm_config(int argc, const char **argv)
struct bpm_source s = {};
const char *key = NULL;
char managed[PATH_MAX];
- struct shirudo_cert cert = {};
+ struct cert cert = {};
if (strscpy(s.name, argv[3], sizeof(s.name)) < 0 ||
strscpy(s.endpoint, argv[4], sizeof(s.endpoint)) < 0) {
@@ -1584,7 +1584,7 @@ static bool tree_digest_valid(const char *digest)
}
static int tree_fetch_publication(const struct bpm_tree_config *cfg,
- struct shirudo_tree_publication *pub,
+ struct tree_publication *pub,
char *manifest_digest, size_t digest_sz)
{
struct bpm_oci_client c = {};
@@ -1602,7 +1602,7 @@ static int tree_fetch_publication(const struct bpm_tree_config *cfg,
static int tree_verify_upatch(const char *path, const char *expected,
const char *id, bool unload)
{
- struct shirudo_upatch u;
+ struct upatch u;
char name[UPATCH_NAME_MAX + 1];
char actual[65];
int ret = upatch_open(path, &u);
@@ -1620,7 +1620,7 @@ static int tree_verify_upatch(const char *path, const char *expected,
return ret;
}
-static int tree_pull_artifact(const struct shirudo_tree_operation *op,
+static int tree_pull_artifact(const struct tree_operation *op,
char *path, size_t path_sz)
{
struct bpm_oci_client c = {};
@@ -1702,13 +1702,13 @@ out:
return ret;
}
-static int tree_write_report(const char *path, const struct shirudo_tree_state *s,
+static int tree_write_report(const char *path, const struct tree_state *s,
int selected, int skipped, int applied,
int module_skipped, int dry_run,
int tpm_available)
{
char buf[4096];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
json_obj_open(&e);
json_kv_int(&e, "schema", 1);
@@ -1745,10 +1745,10 @@ static int tree_write_report(const char *path, const struct shirudo_tree_state *
return 0;
}
-static int tree_write_pending(const struct shirudo_tree_operation *op)
+static int tree_write_pending(const struct tree_operation *op)
{
char buf[1024];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
int ret;
json_obj_open(&e);
@@ -1804,7 +1804,7 @@ static int tree_read_pending(struct bpm_tree_pending *pending)
__u8 *body;
size_t len;
__s64 schema = 0;
- struct shirudo_json_field fields[] = {
+ struct json_field fields[] = {
{ "schema", SHIRUDO_JSON_T_INT, &schema, 0, 0, NULL, 0 },
{ "seq", SHIRUDO_JSON_T_INT, &pending->seq, 0, 0, NULL, 0 },
{ "id", SHIRUDO_JSON_T_STRING, pending->id,
@@ -1831,11 +1831,11 @@ static int tree_read_pending(struct bpm_tree_pending *pending)
* tree's own projection stays a file chain; the register is what an
* operator attests.
*/
-static int tree_measure_locked(const struct shirudo_tree_operation *op,
+static int tree_measure_locked(const struct tree_operation *op,
const __u8 operation_digest[32])
{
__u8 event[32], chain[32];
- struct shirudo_json_emit e;
+ struct json_emit e;
char line[4096], chain_hex[65];
int ret;
@@ -1845,7 +1845,7 @@ static int tree_measure_locked(const struct shirudo_tree_operation *op,
return ret;
hex_encode(chain, 32, chain_hex);
- e = (struct shirudo_json_emit){ .buf = line, .cap = sizeof(line) };
+ e = (struct json_emit){ .buf = line, .cap = sizeof(line) };
eventlog_record_open(&e, "tree_op", event);
json_obj_open_key(&e, "tree");
json_kv_int(&e, "seq", op->seq);
@@ -1860,7 +1860,7 @@ static int tree_measure_locked(const struct shirudo_tree_operation *op,
return eventlog_append(line);
}
-static int tree_measure_operation(const struct shirudo_tree_operation *op,
+static int tree_measure_operation(const struct tree_operation *op,
const __u8 operation_digest[32])
{
int lock, ret;
@@ -1877,11 +1877,11 @@ static int tree_measure_operation(const struct shirudo_tree_operation *op,
* Complete the only non-idempotent window: the process may have
* appended the event before the sealed cursor was committed.
*/
-static int tree_recover_pending(const struct shirudo_tree_publication *pub,
- struct shirudo_tree_state *state)
+static int tree_recover_pending(const struct tree_publication *pub,
+ struct tree_state *state)
{
struct bpm_tree_pending pending = {};
- const struct shirudo_tree_operation *op = NULL;
+ const struct tree_operation *op = NULL;
__u8 digest[32], previous[32], next[32], replay[32];
bool applied = false, event_present = false;
int ret;
@@ -1940,7 +1940,7 @@ static int tree_recover_pending(const struct shirudo_tree_publication *pub,
return 0;
}
-static int tree_validate_operation(const struct shirudo_tree_operation *op)
+static int tree_validate_operation(const struct tree_operation *op)
{
__u8 digest[32];
char expected_digest[72];
@@ -1964,7 +1964,7 @@ static int tree_validate_operation(const struct shirudo_tree_operation *op)
}
static void tree_sync_report_error(const char *phase,
- const struct shirudo_tree_operation *op, int ret)
+ const struct tree_operation *op, int ret)
{
int err;
@@ -1992,8 +1992,8 @@ static void tree_sync_report_error(const char *phase,
static int cmd_bpm_tree_sync(int argc, const char **argv)
{
struct bpm_tree_config cfg;
- struct shirudo_tree_publication pub = {};
- struct shirudo_tree_state state = {};
+ struct tree_publication pub = {};
+ struct tree_state state = {};
char manifest_digest[BPM_MAX_DIGEST];
char report[PATH_MAX] = {};
bool dry_run = false, have_state = false;
@@ -2121,7 +2121,7 @@ static int cmd_bpm_tree_sync(int argc, const char **argv)
}
tpm_available = chain_bound();
for (int i = 0; i < pub.n_operations; i++) {
- struct shirudo_tree_operation *op = &pub.operations[i];
+ struct tree_operation *op = &pub.operations[i];
__u8 digest[32], previous[32], next[32];
char artifact[PATH_MAX];
bool skipped_module = false;
@@ -2343,7 +2343,7 @@ out:
return ret;
}
-static const struct shirudo_help_item bpm_subcmds[] = {
+static const struct help_item bpm_subcmds[] = {
{ "config", "manage package inputs and OCI repositories" },
{ "repo", "refresh signed repository indexes" },
{ "tree", "synchronize or publish the signed upatch tree" },
@@ -2358,7 +2358,7 @@ static const struct shirudo_help_item bpm_subcmds[] = {
{ "uninstall", "unload and remove an installed package" },
};
-static const struct shirudo_help_item bpm_target_subcmds[] = {
+static const struct help_item bpm_target_subcmds[] = {
{ "config", "register and manage OCI repositories" },
{ "repo", "refresh signed repository indexes" },
{ "tree", "synchronize the optional signed upatch tree" },
@@ -2397,19 +2397,19 @@ static int bpm_exec_operator(const char *sub, int argc, const char **argv)
return ret;
}
-static const struct shirudo_help bpm_target_help = {
+static const struct help bpm_target_help = {
.usage = "shirudo bpm <config|repo|tree|key|pull|info|install|upgrade|list|uninstall>",
.summary = "Manage signed target-local BPM packages backed by OCI repositories.",
- .sections = (const struct shirudo_help_section[]) {
+ .sections = (const struct help_section[]) {
{ "subcommands:", bpm_target_subcmds, ARRAY_SIZE(bpm_target_subcmds) },
},
.n_sections = 1,
};
-static const struct shirudo_help bpm_operator_help = {
+static const struct help bpm_operator_help = {
.usage = "shirudo bpm <config|repo|tree|key|pull|info|push|build|install|upgrade|list|uninstall>",
.summary = "Manage signed OCI packages and publish packages from the operator.",
- .sections = (const struct shirudo_help_section[]) {
+ .sections = (const struct help_section[]) {
{ "subcommands:", bpm_subcmds, ARRAY_SIZE(bpm_subcmds) },
},
.n_sections = 1,
@@ -2451,16 +2451,16 @@ static int bpm_finish(int lock, int ret, const char *action)
return ret ? bpm_fail(action, ret) : 0;
}
-static const struct shirudo_help_item bpm_key_subcmds[] = {
+static const struct help_item bpm_key_subcmds[] = {
{ "add", "install a trusted package certificate and print its fingerprint" },
{ "fingerprint", "print the SHA-256 fingerprint of a certificate's SPKI" },
{ "list", "list installed certificate fingerprints" },
};
-static const struct shirudo_help bpm_key_help = {
+static const struct help bpm_key_help = {
.usage = "shirudo bpm key <add|fingerprint|list>",
.summary = "Manage package signing certificates.",
- .sections = (const struct shirudo_help_section[]) {
+ .sections = (const struct help_section[]) {
{ "subcommands:", bpm_key_subcmds, ARRAY_SIZE(bpm_key_subcmds) },
},
.n_sections = 1,
@@ -2530,9 +2530,9 @@ static int cmd_bpm_key(int argc, const char **argv)
int cmd_bpm(int argc, const char **argv)
{
- const struct shirudo_help *help = build_available() ?
+ const struct help *help = build_available() ?
&bpm_operator_help : &bpm_target_help;
- const struct shirudo_help_item *subcmds = build_available() ?
+ const struct help_item *subcmds = build_available() ?
bpm_subcmds : bpm_target_subcmds;
size_t n_subcmds = build_available() ? ARRAY_SIZE(bpm_subcmds) :
ARRAY_SIZE(bpm_target_subcmds);
diff --git a/builtin-build.c b/builtin-build.c
index 1f1ed237..33c65321 100644
--- a/builtin-build.c
+++ b/builtin-build.c
@@ -23,7 +23,7 @@
#define LIBEXEC_DIR "/usr/local/libexec/shirudo"
#endif
-static const struct shirudo_help build_help = {
+static const struct help build_help = {
.usage = "shirudo build <input.bpf.c|.bpf.o> [-o <output.upatch>] [options]\n"
" shirudo build --unload <upatch-name> [-o <output.upatch>] [options]",
.summary = "Build a signed BPF .upatch artifact ready\nfor target-side loading. "
diff --git a/builtin-config.c b/builtin-config.c
index f8733964..867438c3 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -20,7 +20,7 @@
#include "util/log.h"
#include "util/paths.h"
-static const struct shirudo_help config_help = {
+static const struct help config_help = {
.usage = "shirudo config",
.summary = "Print the effective shirudo configuration in shirudo.conf "
"syntax.\nWhen " CONF_PATH " is absent, prints "
@@ -37,7 +37,7 @@ static void usage(void)
int cmd_config(int argc, const char **argv)
{
bool image_mode = image_config_active();
- struct shirudo_config cfg;
+ struct config cfg;
bool file_present;
int ret;
int i;
diff --git a/builtin-genkey.c b/builtin-genkey.c
index 8cab095a..f0d44700 100644
--- a/builtin-genkey.c
+++ b/builtin-genkey.c
@@ -356,18 +356,18 @@ static int replace_pair(const char *pkey_new, const char *pkey_path,
return 0;
}
-static const struct shirudo_help_item genkey_options[] = {
+static const struct help_item genkey_options[] = {
{ "--force, -f", "overwrite an existing key/cert (refused otherwise)" },
{ "--keys-dir <dir>", "write signing_key.pem + cert.der under <dir> "
"instead of the default" },
};
-static const struct shirudo_help_section genkey_help_sections[] = {
+static const struct help_section genkey_help_sections[] = {
{ "options:", genkey_options,
ARRAY_SIZE(genkey_options) },
};
-static const struct shirudo_help genkey_help = {
+static const struct help genkey_help = {
.usage = "shirudo genkey [--force] [--keys-dir <dir>]",
.summary = "Generate a self-signed X.509 cert + ML-DSA-87 (FIPS 204) "
"private key\nfor signing .upatch loader bytes. "
diff --git a/builtin-init.c b/builtin-init.c
index cfb355e0..b7fd5337 100644
--- a/builtin-init.c
+++ b/builtin-init.c
@@ -57,13 +57,13 @@
#include "util/upatch.h"
#include "util/upatch_resolve.h"
-static void print_preflight(const struct shirudo_preflight_result *r)
+static void print_preflight(const struct preflight_result *r)
{
int i;
printf("pre-flight checks:\n");
for (i = 0; i < r->n; i++) {
- const struct shirudo_preflight_check *c = &r->checks[i];
+ const struct preflight_check *c = &r->checks[i];
printf(" %-22s %s%s%s\n",
c->name,
@@ -75,12 +75,12 @@ static void print_preflight(const struct shirudo_preflight_result *r)
r->n - r->n_failed, r->n, r->n_failed);
}
-static struct shirudo_trusted_set enrolled;
+static struct trusted_set enrolled;
static bool initrd_mode;
static int keyring_holds_set(key_serial_t ring,
- const struct shirudo_trusted_set *set)
+ const struct trusted_set *set)
{
struct keyring_cert certs[KEYS_MAX];
size_t i;
@@ -106,7 +106,7 @@ static int keyring_holds_set(key_serial_t ring,
* not install, is refused.
*/
static int init_bpf_keyring(key_serial_t ring,
- const struct shirudo_trusted_set *set)
+ const struct trusted_set *set)
{
bool sealed = false;
size_t i;
@@ -188,8 +188,8 @@ static int init_bpf_keyring(key_serial_t ring,
static int init_keyring(void)
{
- struct shirudo_trusted_set set;
- struct shirudo_identity id;
+ struct trusted_set set;
+ struct identity id;
key_serial_t ring;
int ret;
@@ -334,15 +334,15 @@ static int attach_pin(struct bpf_program *p, const char *pin,
}
static struct bpf_program *guard_program(struct bpf_object *object,
- enum shirudo_gate_guard guard)
+ enum gate_guard guard)
{
- const struct shirudo_image_guard *entry = &shirudo_gate_guards[guard];
+ const struct image_guard *entry = &shirudo_gate_guards[guard];
return bpf_object__find_program_by_name(object, entry->prog);
}
static int attach_guard(struct bpf_program *program,
- enum shirudo_gate_guard guard, struct bpf_link **link)
+ enum gate_guard guard, struct bpf_link **link)
{
return attach_pin(program, shirudo_gate_guards[guard].pin, link);
}
@@ -371,7 +371,7 @@ static int share_policy_maps(struct bpf_object *source,
/* Attach in order. The caller owns each pinned link, including on failure. */
static int attach_guard_group(struct bpf_object *obj,
- const struct shirudo_image_guard *guards,
+ const struct image_guard *guards,
size_t count, struct bpf_link **links)
{
struct bpf_program *program;
@@ -400,7 +400,7 @@ static int attach_guard_group(struct bpf_object *obj,
*/
static int record_bpffs_mount(struct bpf_object *obj)
{
- struct shirudo_mount_record rec = {};
+ struct mount_record rec = {};
struct bpf_map *map;
__u32 zero = 0;
int fd;
@@ -423,7 +423,7 @@ static int record_bpffs_mount(struct bpf_object *obj)
static int attach_seal(struct bpf_object *policy, struct bpf_object **obj_out,
struct bpf_link **links, struct bpf_link **image_links)
{
- const struct shirudo_embedded_bpf *blob = seal_blob();
+ const struct embedded_bpf *blob = seal_blob();
struct bpf_object *obj;
int err;
@@ -491,7 +491,7 @@ static void collect_asymmetric(key_serial_t serial, const char *type,
}
/* Boot keys left the sealed keyring holding the config certificate alone. */
-static int dm_verity_anchor(struct shirudo_identity *id)
+static int dm_verity_anchor(struct identity *id)
{
struct anchor_keys keys = {};
key_serial_t ring;
@@ -523,7 +523,7 @@ static int dm_verity_anchor(struct shirudo_identity *id)
/* Seed bootstrap and freeze shared state except the expected config root. */
static int freeze_task_maps(struct bpf_object *obj)
{
- struct shirudo_task_authority authority = {
+ struct task_authority authority = {
.trusted = TASK_BOOTSTRAP,
};
struct bpf_map *map;
@@ -534,7 +534,7 @@ static int freeze_task_maps(struct bpf_object *obj)
if (pidfd < 0)
return -errno;
for (i = SHIRUDO_GUARD_TASKS; i < SHIRUDO_GUARD_MAP_COUNT; i++) {
- const struct shirudo_guard_map *expected =
+ const struct guard_map *expected =
&shirudo_guard_maps[i];
map = bpf_object__find_map_by_name(obj, expected->name);
@@ -565,10 +565,10 @@ static int freeze_task_maps(struct bpf_object *obj)
* attestation key, whose name no other TPM produces, and compares it with
* the one recorded here (util/chain.c).
*/
-static int record_attestation_key(struct shirudo_identity *id)
+static int record_attestation_key(struct identity *id)
{
- struct shirudo_tpm_key ak = {};
- struct shirudo_tpm *tpm;
+ struct tpm_key ak = {};
+ struct tpm *tpm;
int ret;
ret = tpm_open(&tpm);
@@ -592,13 +592,13 @@ static int init_lsm(void)
struct bpf_link *identity_links[ARRAY_SIZE(shirudo_observer_guards)] = {};
struct bpf_link *mount_links[ARRAY_SIZE(shirudo_mount_guards)] = {};
struct bpf_program *p_bpf, *p_bpf_map, *p_unlink, *p_setx, *p_rmx;
- const struct shirudo_embedded_bpf *blob = bpf2_blob();
+ const struct embedded_bpf *blob = bpf2_blob();
struct bpf_link *seal_links[SEAL_HOOK_COUNT] = {};
struct bpf_link *link_bpf = NULL, *link_bpf_map = NULL;
struct bpf_object *obj = NULL, *seal_obj = NULL;
struct bpf_link *link_keyperm = NULL, *link_tpm = NULL;
struct bpf_link *link_unlink = NULL;
- struct shirudo_identity id = {};
+ struct identity id = {};
struct anchor_keys keys = {};
struct bpf_program *p_pload;
struct bpf_program *p_key, *p_tpm;
@@ -915,9 +915,9 @@ out:
* for the operator to resolve.
*/
static int boot_restore(bool recorded,
- struct shirudo_measured_upatch **out_set, size_t *out_n)
+ struct measured_upatch **out_set, size_t *out_n)
{
- struct shirudo_measured_upatch *set = NULL;
+ struct measured_upatch *set = NULL;
struct dirent **names = NULL;
int n, i, ret = 0;
size_t cnt = 0;
@@ -953,7 +953,7 @@ static int boot_restore(bool recorded,
for (i = 0; i < n; i++) {
char pinned_hex[2 * UPATCH_PAYLOAD_HASH_LEN + 1];
char path[PATH_MAX];
- struct shirudo_upatch u;
+ struct upatch u;
int fd;
if (ret)
@@ -1031,17 +1031,17 @@ next:
}
/* The binding a verifier needs to recompute the register's public area. */
-static int append_init_event(const struct shirudo_measured_upatch *set,
+static int append_init_event(const struct measured_upatch *set,
size_t n,
const __u8 cert_sha[32],
const __u8 set_digest[32],
const __u8 tree_root[32],
const __u8 init_digest[32],
- const struct shirudo_chain_init_info *info)
+ const struct chain_init_info *info)
{
char writer_hex[HEXLEN(TPM_NV_RSA_BYTES)];
char buf[64 * 1024];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
char pcr_hex[HEXLEN(32)], anchor_hex[HEXLEN(32)], chain_hex[HEXLEN(32)];
char name_hex[HEXLEN(TPM_NAME_LEN)], tree_hex[HEXLEN(32)];
char cert_hex[HEXLEN(32)], set_hex[HEXLEN(32)];
@@ -1120,7 +1120,7 @@ static bool phase_unmeasured(const __u8 pcr[32])
static void tree_root_at_boot(__u8 out[32])
{
- struct shirudo_tree_state s = {};
+ struct tree_state s = {};
memset(out, 0, 32);
if (tree_state_read(&s) == 0 &&
@@ -1138,14 +1138,14 @@ static void tree_root_at_boot(__u8 out[32])
* (category tpm_error), never an unmeasured init, because an
* unmeasured target is indistinguishable from a tampered one.
*/
-static int chain_extend_init(struct shirudo_measured_upatch *set, size_t n)
+static int chain_extend_init(struct measured_upatch *set, size_t n)
{
__u8 cert_sha[32], set_digest[32], tree_root[32], init_digest[32];
- struct shirudo_chain_init_info info;
+ struct chain_init_info info;
int ret;
{
- struct shirudo_config cfg;
+ struct config cfg;
__u64 max_bytes;
bool full;
@@ -1245,16 +1245,16 @@ static int chain_extend_init(struct shirudo_measured_upatch *set, size_t n)
return 0;
}
-static const struct shirudo_help_item init_options[] = {
+static const struct help_item init_options[] = {
{ "--check-only", "run the pre-flight only; never touch kernel state" },
};
-static const struct shirudo_help_section init_help_sections[] = {
+static const struct help_section init_help_sections[] = {
{ "options:", init_options,
ARRAY_SIZE(init_options) },
};
-static const struct shirudo_help init_help = {
+static const struct help init_help = {
.usage = "shirudo init [--check-only]",
.summary = "Bootstrap enforcement on this target. Idempotent; safe "
"to re-run.\nThe pinned link survives the process exit.",
@@ -1349,8 +1349,8 @@ static int init_phase_error(int ret, const char *phase)
static int run_init(void)
{
- struct shirudo_measured_upatch *set = NULL;
- struct shirudo_eventlog_init rec;
+ struct measured_upatch *set = NULL;
+ struct eventlog_init rec;
bool recorded, bootstrap;
size_t n = 0;
int ret;
@@ -1435,7 +1435,7 @@ static int run_init(void)
int cmd_init(int argc, const char **argv)
{
- struct shirudo_preflight_result res;
+ struct preflight_result res;
bool check_only = false;
int i, ret;
diff --git a/builtin-keys.c b/builtin-keys.c
index 39735794..1c5b9f64 100644
--- a/builtin-keys.c
+++ b/builtin-keys.c
@@ -399,23 +399,23 @@ static void keyring_absent(const struct keys_anchor *a, key_serial_t ret,
"Present:", strerror(-id_rc));
}
-static const struct shirudo_help_item keys_subcmds[] = {
+static const struct help_item keys_subcmds[] = {
{ "add", "trust a certificate an enrolled key vouched for (target)" },
{ "revoke", "stop trusting a certificate now and for good (target)" },
{ "vouch", "sign a vouch for a certificate (operator)" },
};
-static const struct shirudo_help_item keys_options[] = {
+static const struct help_item keys_options[] = {
{ "--keys-dir <dir>", "read signing_key.pem + cert.der from <dir>" },
};
-static const struct shirudo_help_section keys_help_sections[] = {
+static const struct help_section keys_help_sections[] = {
{ "subcommands:", keys_subcmds, ARRAY_SIZE(keys_subcmds) },
{ "options:", keys_options,
ARRAY_SIZE(keys_options) },
};
-static const struct shirudo_help keys_help = {
+static const struct help keys_help = {
.usage = "shirudo keys [--keys-dir <dir>]\n"
" shirudo keys add <cert.der> --vouch <file>\n"
" shirudo keys revoke <fingerprint> [--promote <fp>]\n"
@@ -438,16 +438,16 @@ static void usage(void)
fprintf(stderr, "usage: %s\n", keys_help.usage);
}
-static const struct shirudo_help_item keys_add_options[] = {
+static const struct help_item keys_add_options[] = {
{ "--vouch <file>", "the vouch an enrolled key signed for the certificate" },
{ "--keys-dir <dir>", "the keys directory (default " KEYS_DIR ")" },
};
-static const struct shirudo_help_section keys_add_sections[] = {
+static const struct help_section keys_add_sections[] = {
{ "options:", keys_add_options, ARRAY_SIZE(keys_add_options) },
};
-static const struct shirudo_help keys_add_help = {
+static const struct help keys_add_help = {
.usage = "shirudo keys add <cert.der> --vouch <file> [--keys-dir <dir>]",
.summary = "Add a certificate to the trusted set this target enrols at "
"its next boot.\nThe vouch must verify under a certificate "
@@ -457,18 +457,18 @@ static const struct shirudo_help keys_add_help = {
.n_sections = ARRAY_SIZE(keys_add_sections),
};
-static const struct shirudo_help_item keys_vouch_options[] = {
+static const struct help_item keys_vouch_options[] = {
{ "-o <file>", "where to write the vouch (default <cert.der>.vouch)" },
{ "--keys-dir <dir>", "read signing_key.pem + cert.der from <dir>" },
{ "--key <pem>", "the signing key (overrides --keys-dir)" },
{ "--cert <der>", "the signing certificate (overrides --keys-dir)" },
};
-static const struct shirudo_help_section keys_vouch_sections[] = {
+static const struct help_section keys_vouch_sections[] = {
{ "options:", keys_vouch_options, ARRAY_SIZE(keys_vouch_options) },
};
-static const struct shirudo_help keys_vouch_help = {
+static const struct help keys_vouch_help = {
.usage = "shirudo keys vouch <cert.der> [-o <file>] [--keys-dir <dir>]",
.summary = "Sign a vouch for another operator's certificate with this "
"operator's key,\nfor `shirudo keys add --vouch` on the "
@@ -482,7 +482,7 @@ static const struct shirudo_help keys_vouch_help = {
static int check_cert_algorithm(const __u8 *der, size_t der_sz,
const char *what)
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
char name[64] = {};
int ret;
@@ -506,10 +506,10 @@ static int check_cert_algorithm(const __u8 *der, size_t der_sz,
* right now, not only one on disk, when the live target's set is the
* one being extended.
*/
-static int check_voucher_live(const struct shirudo_trusted_set *set,
+static int check_voucher_live(const struct trusted_set *set,
const __u8 voucher[32])
{
- struct shirudo_identity id;
+ struct identity id;
const __u8 *der = NULL;
key_serial_t ring;
size_t der_sz = 0;
@@ -542,7 +542,7 @@ static int keys_add(int argc, const char **argv)
const char *keys_dir_arg = NULL, *vouch_path = NULL, *cert = NULL;
__u8 *der = NULL, *sig = NULL;
__u8 sha256[32], fp[32], by[32];
- struct shirudo_trusted_set set;
+ struct trusted_set set;
char fp_hex[65], by_hex[65];
size_t der_sz = 0, sig_sz = 0;
char revoked[PATH_MAX];
@@ -671,7 +671,7 @@ out:
return ret ? 1 : 0;
}
-static const struct shirudo_help keys_revoke_help = {
+static const struct help keys_revoke_help = {
.usage = "shirudo keys revoke",
.summary = "Local revocation is disabled. Publish revocation records "
"in a signed config image and activate it with image update.",
@@ -681,7 +681,7 @@ static int append_key_event(const char *type, const char *fp_hex,
const char *sha_hex, const __u8 event[32])
{
char buf[1024];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
eventlog_record_open(&e, type, event);
json_obj_open_key(&e, "key");
@@ -703,7 +703,7 @@ static int append_key_event(const char *type, const char *fp_hex,
* fail-closed treatment as a upatch event: no TPM is an error, not an
* unmeasured success.
*/
-static int measure_revoke_locked(const struct shirudo_trusted_cert *c,
+static int measure_revoke_locked(const struct trusted_cert *c,
const char *fp_hex)
{
__u8 event[32], chain[32];
@@ -735,7 +735,7 @@ static int measure_revoke_locked(const struct shirudo_trusted_cert *c,
return 0;
}
-static int measure_revoke(const struct shirudo_trusted_cert *c,
+static int measure_revoke(const struct trusted_cert *c,
const char *fp_hex)
{
int lock, ret;
@@ -760,7 +760,7 @@ static int measure_revoke(const struct shirudo_trusted_cert *c,
static int purge_signed_by(const __u8 *der, size_t der_sz,
size_t *unloaded)
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
struct dirent **names = NULL;
int n, i, ret = 0, purged = 0;
@@ -775,7 +775,7 @@ static int purge_signed_by(const __u8 *der, size_t der_sz,
}
for (i = 0; i < n; i++) {
char name[UPATCH_NAME_MAX + 1];
- struct shirudo_upatch u;
+ struct upatch u;
char path[PATH_MAX];
int signed_by, prc;
@@ -812,7 +812,7 @@ static int purge_signed_by(const __u8 *der, size_t der_sz,
int keys_revoke_image(const __u8 *der, size_t size, bool boot)
{
- struct shirudo_trusted_cert cert = {};
+ struct trusted_cert cert = {};
key_serial_t ring, key;
char fingerprint[65];
size_t unloaded;
@@ -899,8 +899,8 @@ int cmd_keys(int argc, const char **argv)
static int keys_show(int argc, const char **argv)
{
const char *keys_dir_arg = NULL;
- struct shirudo_identity id = {};
- struct shirudo_trusted_set set;
+ struct identity id = {};
+ struct trusted_set set;
const char *keys_dir;
char pkey_path[PATH_MAX];
char cert_path[PATH_MAX];
diff --git a/builtin-status.c b/builtin-status.c
index dd004222..e17063fe 100644
--- a/builtin-status.c
+++ b/builtin-status.c
@@ -178,13 +178,13 @@ struct ev_proj {
static int parse_event_line(const char *line, size_t len, struct ev_proj *ev)
{
- struct shirudo_json_field up[] = {
+ struct json_field up[] = {
{ "name", SHIRUDO_JSON_T_STRING, ev->up_name,
sizeof(ev->up_name), 0, NULL, 0 },
{ "payload_sha256", SHIRUDO_JSON_T_STRING, ev->up_payload,
sizeof(ev->up_payload), 0, NULL, 0 },
};
- struct shirudo_json_field f[] = {
+ struct json_field f[] = {
{ "ts", SHIRUDO_JSON_T_STRING, ev->ts, sizeof(ev->ts),
0, NULL, 0 },
{ "type", SHIRUDO_JSON_T_STRING, ev->type, sizeof(ev->type),
@@ -200,7 +200,7 @@ static int parse_event_line(const char *line, size_t len, struct ev_proj *ev)
return json_parse(line, len, f, ARRAY_SIZE(f));
}
-static void emit_eventlog_events(struct shirudo_json_emit *e)
+static void emit_eventlog_events(struct json_emit *e)
{
char *save, *line, *buf;
size_t len;
@@ -279,7 +279,7 @@ static void print_eventlog_table(void)
xfree(buf, len + 1);
}
-static void print_system_human(const struct shirudo_sysinfo *si)
+static void print_system_human(const struct sysinfo *si)
{
printf("\nSystem Info:\n");
printf(" %-16s %s\n", "OS:", si->os_pretty);
@@ -336,7 +336,7 @@ static void print_kernel_config_entry(void *ctx, const char *key,
printf(" %s=%s\n", key, value);
}
-static void print_kernel_config_human(const struct shirudo_sysinfo *si)
+static void print_kernel_config_human(const struct sysinfo *si)
{
printf(" Kernel Config:\n");
if (sysinfo_kernel_config_foreach(si->kernel_release,
@@ -345,7 +345,7 @@ static void print_kernel_config_human(const struct shirudo_sysinfo *si)
printf(" (unavailable)\n");
}
-static const struct shirudo_help_item status_options[] = {
+static const struct help_item status_options[] = {
{ "--json", "machine-readable JSON output" },
{ "--otel", "export the status report as an OTLP log" },
{ "--include-system", "add a `system` block (hostname, kernel, arch, cpus, ...)" },
@@ -358,12 +358,12 @@ static const struct shirudo_help_item status_options[] = {
"expands the loaded-modules dependency tree" },
};
-static const struct shirudo_help_section status_help_sections[] = {
+static const struct help_section status_help_sections[] = {
{ "options:", status_options,
ARRAY_SIZE(status_options) },
};
-static const struct shirudo_help status_help = {
+static const struct help status_help = {
.usage = "shirudo status [--json] [--otel] "
"[--include-system] [--include-eventlog]\n"
" [--include-kernellog[=N]] "
@@ -381,9 +381,9 @@ static void usage(void)
}
static size_t build_upatches_table(struct dirent **ups, int n_ups,
- struct shirudo_upatch_table_row **out)
+ struct upatch_table_row **out)
{
- struct shirudo_upatch_table_row *rows;
+ struct upatch_table_row *rows;
struct btf *vbtf;
int i;
@@ -402,8 +402,8 @@ static size_t build_upatches_table(struct dirent **ups, int n_ups,
*/
vbtf = btf__load_vmlinux_btf();
for (i = 0; i < n_ups; i++) {
- struct shirudo_upatch_table_row *r = &rows[i];
- struct shirudo_map_summary *list = NULL;
+ struct upatch_table_row *r = &rows[i];
+ struct map_summary *list = NULL;
char raw_name[UPATCH_NAME_MAX + 1];
size_t nm = 0;
const char *name = ups[i]->d_name;
@@ -433,7 +433,7 @@ static size_t build_upatches_table(struct dirent **ups, int n_ups,
}
/* Status runs on the host, so reachable and parsed are trivially true. */
-static void local_cond_input(struct shirudo_conditions_input *in,
+static void local_cond_input(struct conditions_input *in,
int lsm_attached, int keyring_present,
const char *keyring_mode,
__s64 keyring_serial,
@@ -443,7 +443,7 @@ static void local_cond_input(struct shirudo_conditions_input *in,
int chain_seen, int chain_matches, int cm_seen,
const char *nv_index)
{
- *in = (struct shirudo_conditions_input){
+ *in = (struct conditions_input){
.reachable = true,
.parsed = true,
.lsm_attached = lsm_attached,
@@ -480,7 +480,7 @@ static const char *roles_str(int is_target, int is_operator)
* the exporter fallback unchanged for map commands, but make status export
* conditional on an explicitly configured endpoint.
*/
-static bool status_otel_endpoint_configured(const struct shirudo_config *cfg)
+static bool status_otel_endpoint_configured(const struct config *cfg)
{
const char *endpoint;
@@ -574,7 +574,7 @@ static void keyring_view_free(struct status_keyring *k)
static void keyring_view_cert(struct status_keyring *k, struct status_cert *c,
const __u8 *der, size_t len)
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
char desc[KEYRING_DESC_MAX];
size_t i;
@@ -605,8 +605,8 @@ static void keyring_view_cert(struct status_keyring *k, struct status_cert *c,
}
static void keyring_view_bpf(struct status_keyring *k,
- const struct shirudo_identity *ident,
- const struct shirudo_trusted_set *certs,
+ const struct identity *ident,
+ const struct trusted_set *certs,
int certs_rc)
{
size_t i, n_frozen = 0;
@@ -633,9 +633,9 @@ static void keyring_view_bpf(struct status_keyring *k,
/* The config certificate comes from the runtime image's bootstrap. */
static void keyring_view_dm_verity(struct status_keyring *k,
- const struct shirudo_identity *ident)
+ const struct identity *ident)
{
- struct shirudo_image_bootstrap boot = {};
+ struct image_bootstrap boot = {};
struct status_cert *c = &k->certs[0];
__u8 *der = NULL;
size_t len = 0;
@@ -667,7 +667,7 @@ static void keyring_view_dm_verity(struct status_keyring *k,
xfree(der, len);
}
-static void keyring_cond_input(struct shirudo_conditions_input *in,
+static void keyring_cond_input(struct conditions_input *in,
const struct status_keyring *bpf,
const struct status_keyring *dmv)
{
@@ -682,7 +682,7 @@ static void keyring_cond_input(struct shirudo_conditions_input *in,
in->dmv_key_missing = dmv->key_missing;
}
-static void keyring_emit_json(struct shirudo_json_emit *e, const char *key,
+static void keyring_emit_json(struct json_emit *e, const char *key,
const struct status_keyring *k,
const char *role)
{
@@ -865,17 +865,17 @@ int cmd_status(int argc, const char **argv)
bool lsm_attached, keyring_present, is_operator, cert_present, is_target;
key_serial_t keyring_serial, keyring_pinned;
const char *keyring_mode, *mode;
- struct shirudo_sysinfo sysi = {};
- struct shirudo_trusted_set certs = {};
+ struct sysinfo sysi = {};
+ struct trusted_set certs = {};
int certs_enrolled = -1;
struct status_keyring bpf = {}, dmv = {};
- struct shirudo_identity ident = {};
+ struct identity ident = {};
int certs_rc = -ENOENT;
- struct shirudo_config otel_cfg = {};
- struct shirudo_otel_opts otel_opts = {};
+ struct config otel_cfg = {};
+ struct otel_opts otel_opts = {};
struct asset_view assets;
- struct shirudo_tamper_counts tamper = {};
- struct shirudo_conditions_input cin;
+ struct tamper_counts tamper = {};
+ struct conditions_input cin;
int tamper_rc = -ENOENT;
struct dirent **ups = NULL;
char pcr_before_hex[2 * CHAIN_DIGEST_LEN + 1] = "";
@@ -1071,7 +1071,7 @@ int cmd_status(int argc, const char **argv)
keyring_cond_input(&cin, &bpf, &dmv);
if (json) {
- struct shirudo_json_emit e;
+ struct json_emit e;
/*
* Every loaded upatch adds a row, every certificate and link
@@ -1080,7 +1080,7 @@ int cmd_status(int argc, const char **argv)
* clamp below keeps it under JSON_MAX_BYTES.
*/
json_cap = 16384 + (size_t)n_ups *
- (6 * sizeof(struct shirudo_upatch_table_row) + 256);
+ (6 * sizeof(struct upatch_table_row) + 256);
json_cap += (bpf.n_certs + bpf.n_links + dmv.n_certs +
dmv.n_links) *
(6 * (KEYRING_DESC_MAX + STATUS_SUBJECT_MAX) + 512);
@@ -1100,7 +1100,7 @@ int cmd_status(int argc, const char **argv)
ret = 1;
goto out;
}
- e = (struct shirudo_json_emit){ .buf = json_buf, .cap = json_cap };
+ e = (struct json_emit){ .buf = json_buf, .cap = json_cap };
json_obj_open(&e);
json_kv_int(&e, "schema", 1);
@@ -1108,7 +1108,7 @@ int cmd_status(int argc, const char **argv)
json_kv_bool(&e, "is_target", is_target);
json_kv_bool(&e, "is_operator", is_operator);
{
- struct shirudo_condition conds[CONDITIONS_MAX];
+ struct condition conds[CONDITIONS_MAX];
size_t nc, ci;
otel_status = status_verdict(&cin);
@@ -1177,7 +1177,7 @@ int cmd_status(int argc, const char **argv)
keyring_emit_json(&e, "dm_verity_keyring", &dmv, "config");
json_kv_bool(&e, "signing_key_present", is_operator);
{
- struct shirudo_upatch_table_row *rows = NULL;
+ struct upatch_table_row *rows = NULL;
size_t n_rows = build_upatches_table(ups, n_ups, &rows);
upatch_table_emit_json(&e, rows, n_rows);
@@ -1287,8 +1287,8 @@ int cmd_status(int argc, const char **argv)
}
if (include_kernel_log) {
size_t bytes = (size_t)kernel_log_lines *
- sizeof(struct shirudo_kmsg_record);
- struct shirudo_kmsg_record *recs = xmalloc(bytes);
+ sizeof(struct kmsg_record);
+ struct kmsg_record *recs = xmalloc(bytes);
int nr = recs ? kmsg_tail(recs, kernel_log_lines)
: -ENOMEM;
int j;
@@ -1304,7 +1304,7 @@ int cmd_status(int argc, const char **argv)
xfree(recs, bytes);
}
if (include_modules) {
- struct shirudo_kmod_set ks = {};
+ struct kmod_set ks = {};
int mrc = kmodules_read(&ks);
struct timespec rt = {}, bt = {};
__s64 boot_sec = 0;
@@ -1322,7 +1322,7 @@ int cmd_status(int argc, const char **argv)
json_arr_open(&e, "modules");
if (mrc == 0) {
for (mi = 0; mi < ks.n; mi++) {
- const struct shirudo_kmod *m =
+ const struct kmod *m =
&ks.mods[mi];
time_t at = m->loaded_at_sec;
char iso[32] = "";
@@ -1403,8 +1403,8 @@ int cmd_status(int argc, const char **argv)
printf("%s\n", json_buf);
}
} else {
- struct shirudo_condition conds[CONDITIONS_MAX];
- struct shirudo_upatch_table_row *rows = NULL;
+ struct condition conds[CONDITIONS_MAX];
+ struct upatch_table_row *rows = NULL;
size_t n_rows = 0;
size_t nc;
char hostname[256] = "?";
@@ -1567,8 +1567,8 @@ int cmd_status(int argc, const char **argv)
if (include_kernel_log) {
size_t bytes = (size_t)kernel_log_lines *
- sizeof(struct shirudo_kmsg_record);
- struct shirudo_kmsg_record *recs = xmalloc(bytes);
+ sizeof(struct kmsg_record);
+ struct kmsg_record *recs = xmalloc(bytes);
int nr = recs ? kmsg_tail(recs, kernel_log_lines)
: -ENOMEM;
int j;
@@ -1585,7 +1585,7 @@ int cmd_status(int argc, const char **argv)
xfree(recs, bytes);
}
if (include_modules) {
- struct shirudo_kmod_set ks = {};
+ struct kmod_set ks = {};
int mrc = kmodules_read(&ks);
struct timespec rt = {}, bt = {};
__s64 boot_sec = 0;
diff --git a/builtin-upatch.c b/builtin-upatch.c
index 2dee6e42..58fa5d80 100644
--- a/builtin-upatch.c
+++ b/builtin-upatch.c
@@ -74,7 +74,7 @@ static bool safe_upatch_name(const char *name);
#define NF_IP6_PRI_RAW_BEFORE_DEFRAG (-450)
#endif
-static void rep_fail(struct shirudo_op_report *rep, const char *phase,
+static void rep_fail(struct op_report *rep, const char *phase,
const char *cat, int err, const char *msg)
{
if (!rep)
@@ -108,7 +108,7 @@ static const char *cat_from_load_errno(int e)
}
}
-static const char *flag_str(const struct shirudo_upatch *u)
+static const char *flag_str(const struct upatch *u)
{
return upatch_is_unload(u) ? "UNLOAD-directive" : "LOAD";
}
@@ -139,7 +139,7 @@ static int print_sha256_hex(const __u8 hash[32])
return fputs(hex, stdout) < 0 ? -1 : 0;
}
-static const struct shirudo_help upatch_info_help = {
+static const struct help upatch_info_help = {
.usage = "shirudo upatch info [--json] <file.upatch>",
.summary = "Describe a .upatch file: header, signature, payload "
"digest,\nattach metadata and signed decoders. Offline -- "
@@ -152,7 +152,7 @@ static const struct shirudo_help upatch_info_help = {
" shirudo upatch info --json /var/lib/shirudo/upatches/foo.upatch",
};
-static const struct shirudo_help upatch_list_help = {
+static const struct help upatch_list_help = {
.usage = "shirudo upatch list [--json]",
.summary = "List upatches on this host. Shows the persisted set\n"
"(under /var/lib/shirudo/upatches/, survives reboot) "
@@ -165,7 +165,7 @@ static const struct shirudo_help upatch_list_help = {
" shirudo upatch list --json | jq",
};
-static const struct shirudo_help upatch_load_help = {
+static const struct help upatch_load_help = {
.usage = "shirudo upatch load [--expect-chain=<hex>] "
"[--expect-version-id=<hex>]\n"
" [--no-precheck] [--no-version-check] "
@@ -182,7 +182,7 @@ static const struct shirudo_help upatch_load_help = {
" shirudo upatch load --report=- foo.upatch | jq",
};
-static const struct shirudo_help upatch_unload_help = {
+static const struct help upatch_unload_help = {
.usage = "shirudo upatch unload [--expect-chain=<hex>] "
"[--expect-version-id=<hex>]\n"
" [--no-precheck] [--no-version-check] "
@@ -198,7 +198,7 @@ static const struct shirudo_help upatch_unload_help = {
" shirudo upatch unload --report=- foo.unload.upatch | jq",
};
-static const struct shirudo_help_item upatch_map_options[] = {
+static const struct help_item upatch_map_options[] = {
{ "--all", "export every map from every loaded upatch" },
{ "--json[=<path>]", "print JSON or append it to path" },
{ "--show-full", "lift the per-map 256-entry truncation cap" },
@@ -211,11 +211,11 @@ static const struct shirudo_help_item upatch_map_options[] = {
{ "--s3-uri=<uri>", "S3 overflow destination for OTLP payloads" },
};
-static const struct shirudo_help_section upatch_map_sections[] = {
+static const struct help_section upatch_map_sections[] = {
{ "options:", upatch_map_options, ARRAY_SIZE(upatch_map_options) },
};
-static const struct shirudo_help upatch_map_help = {
+static const struct help upatch_map_help = {
.usage = "shirudo upatch map [--all] [<upatch>] [<map>] "
"[--json[=<path>]] [--show-full] [--peek]\n"
" [--otel] "
@@ -249,16 +249,16 @@ static const struct shirudo_help upatch_map_help = {
" shirudo upatch map cve-2026-31431-counter big_hash --show-full",
};
-static const struct shirudo_help_item upatch_get_options[] = {
+static const struct help_item upatch_get_options[] = {
{ "--json", "machine-readable JSON output" },
{ "--show-full", "lift the per-map 256-entry truncation cap" },
};
-static const struct shirudo_help_section upatch_get_sections[] = {
+static const struct help_section upatch_get_sections[] = {
{ "options:", upatch_get_options, ARRAY_SIZE(upatch_get_options) },
};
-static const struct shirudo_help upatch_get_help = {
+static const struct help upatch_get_help = {
.usage = "shirudo upatch get <name> [--json] [--show-full]",
.summary = "Describe a loaded upatch from the target kernel:\n"
" - the SEC()-style attach hook (e.g. fexit/tcp_v4_connect),\n"
@@ -279,7 +279,7 @@ static int cmd_upatch_info(int argc, const char **argv)
{
char name[UPATCH_NAME_MAX + 1]; /* not NUL-term on disk */
const __u8 *unload_payload;
- struct shirudo_upatch u;
+ struct upatch u;
const char *path = NULL;
bool json = false;
int i, err, ret = 1;
@@ -321,7 +321,7 @@ static int cmd_upatch_info(int argc, const char **argv)
if (json) {
size_t cap = 8192 + (size_t)u.nr_decoders * 768;
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char payload_hex[2 * 32 + 1];
char *buf = xmalloc(cap);
@@ -505,7 +505,7 @@ test_pin:
static int cmd_upatch_list(int argc, const char **argv)
{
struct dirent **persisted = NULL, **active = NULL;
- struct shirudo_json_emit e = { .buf = NULL };
+ struct json_emit e = { .buf = NULL };
int np, na, i, j, ret = 0;
bool json = false;
char *jbuf = NULL;
@@ -554,7 +554,7 @@ static int cmd_upatch_list(int argc, const char **argv)
for (i = 0; i < np; i++) {
char path[1024], name[UPATCH_NAME_MAX + 1];
char payload_hex[2 * 32 + 1];
- struct shirudo_upatch u;
+ struct upatch u;
const char *type, *payload_type;
bool loaded;
@@ -657,7 +657,7 @@ out:
* signature or keyring, so the attr is built by hand.
*/
-struct shirudo_loader_ctx {
+struct loader_ctx {
__u32 sz;
__u32 flags;
__u32 log_level;
@@ -665,13 +665,13 @@ struct shirudo_loader_ctx {
__u64 log_buf;
};
-struct shirudo_map_desc {
+struct map_desc {
int map_fd;
__u32 max_entries;
__u64 initial_value;
};
-struct shirudo_prog_desc {
+struct prog_desc {
int prog_fd;
};
@@ -1046,13 +1046,13 @@ static const char *attach_kind_name(__u32 kind)
}
}
-static int prepare_uprobe_targets(struct shirudo_prog_spec *specs,
+static int prepare_uprobe_targets(struct prog_spec *specs,
__u32 nr_progs)
{
__u32 i;
for (i = 0; i < nr_progs; i++) {
- struct shirudo_prog_spec *spec = &specs[i];
+ struct prog_spec *spec = &specs[i];
__u8 build_id[UPATCH_BUILD_ID_MAX];
__u32 build_id_len = 0;
char proc_path[64];
@@ -1114,7 +1114,7 @@ static int prepare_uprobe_targets(struct shirudo_prog_spec *specs,
}
static int prog_attach_uprobe_multi(int prog_fd,
- const struct shirudo_prog_spec *spec)
+ const struct prog_spec *spec)
{
union bpf_attr attr = {};
long fd;
@@ -1134,7 +1134,7 @@ static int prog_attach_uprobe_multi(int prog_fd,
}
static int prog_attach_for_spec(int prog_fd,
- const struct shirudo_prog_spec *spec)
+ const struct prog_spec *spec)
{
int perf_fd, link_fd;
@@ -1205,7 +1205,7 @@ static int netns_initial(void)
* link is pinned; -EXDEV when they differ.
*/
static int link_matches_spec(int link_fd,
- const struct shirudo_prog_spec *spec)
+ const struct prog_spec *spec)
{
char func[UPATCH_ATTACH_TARGET_MAX] = {};
struct bpf_link_info info = {};
@@ -1283,7 +1283,7 @@ static int mkdir_if_absent(const char *path, mode_t mode, bool *made)
return errno == EEXIST ? 0 : -errno;
}
-static void count_attach_progs(const struct shirudo_prog_spec *specs,
+static void count_attach_progs(const struct prog_spec *specs,
__u32 nr_progs, __u32 *out)
{
__u32 i, n = 0;
@@ -1297,7 +1297,7 @@ static void count_attach_progs(const struct shirudo_prog_spec *specs,
static int prog_pin_path(char *pin, size_t sz, const char *dir,
const char *serializers_dir,
- const struct shirudo_prog_spec *spec,
+ const struct prog_spec *spec,
__u32 attach_count, __u32 attach_idx)
{
int n;
@@ -1318,10 +1318,10 @@ static int prog_pin_path(char *pin, size_t sz, const char *dir,
* A failure unpins what this call pinned: the upatch is then neither
* archived nor measured, so none of its programs may stay attached.
*/
-static int attach_and_pin_progs(const struct shirudo_loader_ctx *cx,
+static int attach_and_pin_progs(const struct loader_ctx *cx,
size_t prog_desc_off, __u32 nr_progs,
const char *name,
- const struct shirudo_prog_spec *specs)
+ const struct prog_spec *specs)
{
char dir[PATH_MAX], serializers_dir[PATH_MAX + 16];
char bpffs_name[UPATCH_BPFFS_NAME_MAX + 1];
@@ -1362,11 +1362,11 @@ static int attach_and_pin_progs(const struct shirudo_loader_ctx *cx,
count_attach_progs(specs, nr_progs, &attach_count);
for (i = 0; i < nr_progs; i++) {
- const struct shirudo_prog_desc *pd =
+ const struct prog_desc *pd =
(const void *)((const char *)cx + prog_desc_off +
(size_t)i * sizeof(*pd));
int inner_fd = pd->prog_fd;
- const struct shirudo_prog_spec *spec = &specs[i];
+ const struct prog_spec *spec = &specs[i];
int link_fd;
if (inner_fd <= 0) {
@@ -1509,7 +1509,7 @@ out:
* logged and left unobservable until the next load. bpffs reserves dots
* in path components, so libbpf's .bss, .data and .rodata are skipped.
*/
-static int pin_upatch_maps(const struct shirudo_loader_ctx *cx,
+static int pin_upatch_maps(const struct loader_ctx *cx,
__u32 nr_maps, const char *name)
{
char dir[PATH_MAX], maps_dir[PATH_MAX + 8];
@@ -1534,9 +1534,9 @@ static int pin_upatch_maps(const struct shirudo_loader_ctx *cx,
return 0;
}
for (i = 0; i < nr_maps; i++) {
- const struct shirudo_map_desc *md =
+ const struct map_desc *md =
(const void *)((const char *)cx +
- sizeof(struct shirudo_loader_ctx) +
+ sizeof(struct loader_ctx) +
(size_t)i * sizeof(*md));
struct bpf_map_info info = {};
__u32 info_len = sizeof(info);
@@ -1616,9 +1616,9 @@ static int get_pin_payload(const char *name, __u8 out[32])
/* Resolve the kernel BPF keyring and compare it with the frozen record. */
static int trust_anchor_keyring(key_serial_t *keyring, key_serial_t *serial,
- struct shirudo_op_report *rep)
+ struct op_report *rep)
{
- struct shirudo_identity id;
+ struct identity id;
key_serial_t ring;
int ret;
@@ -1648,11 +1648,11 @@ static int trust_anchor_keyring(key_serial_t *keyring, key_serial_t *serial,
* whose pins keep them once attached; boot restore applies every archived
* upatch in one process.
*/
-static void close_loader_fds(const struct shirudo_loader_ctx *cx,
+static void close_loader_fds(const struct loader_ctx *cx,
__u32 nr_maps, __u32 nr_progs)
{
- const struct shirudo_map_desc *md = (const void *)(cx + 1);
- const struct shirudo_prog_desc *pd = (const void *)(md + nr_maps);
+ const struct map_desc *md = (const void *)(cx + 1);
+ const struct prog_desc *pd = (const void *)(md + nr_maps);
__u32 i;
for (i = 0; i < nr_maps; i++) {
@@ -1667,10 +1667,10 @@ static void close_loader_fds(const struct shirudo_loader_ctx *cx,
/* Shared by `upatch load` and boot restore: one signature-verified path. */
static int __upatch_apply(const char *path, bool verify_only,
- struct shirudo_op_report *rep)
+ struct op_report *rep)
{
- struct shirudo_upatch u;
- struct shirudo_prog_spec *prog_specs = NULL;
+ struct upatch u;
+ struct prog_spec *prog_specs = NULL;
const struct bpf_insn *insns;
const void *sig, *data;
key_serial_t keyring, serial;
@@ -1679,7 +1679,7 @@ static int __upatch_apply(const char *path, bool verify_only,
char *vlog; /* shared PROG_LOAD / TEST_RUN log_buf */
size_t insn_cnt, ctx_sz = 0, prog_desc_off;
int prog_fd = -1, map_fd = -1, ret;
- struct shirudo_loader_ctx *cx = NULL;
+ struct loader_ctx *cx = NULL;
__u32 retval = 0;
vlog = xmalloc(VERIFIER_LOG_MAX);
@@ -1942,14 +1942,14 @@ static int __upatch_apply(const char *path, bool verify_only,
* bpf_sys_bpf() cannot BPF_OBJ_PIN. Its descriptors trail the context,
* sized from the header's counts.
*/
- prog_desc_off = sizeof(struct shirudo_loader_ctx) +
- (size_t)u.hdr.nr_maps * sizeof(struct shirudo_map_desc);
+ prog_desc_off = sizeof(struct loader_ctx) +
+ (size_t)u.hdr.nr_maps * sizeof(struct map_desc);
/*
* The loader's max_ctx_offset can exceed the descriptor tail, and
* TEST_RUN rejects a smaller ctx_size_in, so pad generously.
*/
ctx_sz = prog_desc_off +
- (size_t)u.hdr.nr_progs * sizeof(struct shirudo_prog_desc) +
+ (size_t)u.hdr.nr_progs * sizeof(struct prog_desc) +
1024;
cx = xmalloc(ctx_sz);
if (!cx) {
@@ -2067,7 +2067,7 @@ int upatch_apply(const char *path)
* here, without touching kernel state.
*/
static int upatch_preflight(const char *expect_chain,
- struct shirudo_op_report *rep)
+ struct op_report *rep)
{
__u8 want[CHAIN_DIGEST_LEN], have[CHAIN_DIGEST_LEN];
char have_hex[2 * CHAIN_DIGEST_LEN + 1];
@@ -2130,9 +2130,9 @@ static int upatch_preflight(const char *expect_chain,
* The register and the log advance together, so an extend that could
* not be logged must not happen: refuse before any state changes.
*/
-static int eventlog_room(struct shirudo_op_report *rep, const char *op)
+static int eventlog_room(struct op_report *rep, const char *op)
{
- struct shirudo_config cfg;
+ struct config cfg;
config_load(&cfg);
if (eventlog_would_exceed(cfg.eventlog_max_bytes)) {
@@ -2151,7 +2151,7 @@ static int eventlog_room(struct shirudo_op_report *rep, const char *op)
* comparison meaningless, so the version check runs first.
*/
static int version_gate(const char *expect_version_id, bool no_version_check,
- struct shirudo_op_report *rep, const char *op)
+ struct op_report *rep, const char *op)
{
if (no_version_check || !expect_version_id)
return 0;
@@ -2173,7 +2173,7 @@ static int format_upatch_event(const char *type, const char *name,
const __u8 event[32], const char *reason,
char *buf, size_t size)
{
- struct shirudo_json_emit e = { .buf = buf, .cap = size };
+ struct json_emit e = { .buf = buf, .cap = size };
char payload_hex[65];
hex_encode(payload, 32, payload_hex);
@@ -2459,7 +2459,7 @@ static int persist_upatch(const char *src, const char *name)
}
static int parse_op_args(int argc, const char **argv, const char *verb,
- const struct shirudo_help *help,
+ const struct help *help,
const char **file, const char **expect_chain,
const char **expect_version_id, bool *no_precheck,
bool *no_version_check, const char **report)
@@ -2641,8 +2641,8 @@ static int cmd_upatch_load(int argc, const char **argv)
char name[UPATCH_NAME_MAX + 1] = {};
char staged[PATH_MAX] = {};
__u8 payload[UPATCH_PAYLOAD_HASH_LEN];
- struct shirudo_upatch u;
- struct shirudo_op_report rep = { .op = "upatch_load", .phase = "done" };
+ struct upatch u;
+ struct op_report rep = { .op = "upatch_load", .phase = "done" };
bool no_precheck, no_version_check, have_id = false, measured;
int err, ret = 1;
@@ -2767,8 +2767,8 @@ static int cmd_upatch_unload(int argc, const char **argv)
char staged[PATH_MAX] = {};
char persisted[PATH_MAX];
__u8 payload[UPATCH_PAYLOAD_HASH_LEN] = {};
- struct shirudo_upatch u;
- struct shirudo_op_report rep = { .op = "upatch_unload", .phase = "done" };
+ struct upatch u;
+ struct op_report rep = { .op = "upatch_unload", .phase = "done" };
bool no_precheck, no_version_check;
int err, ret = 1;
@@ -2968,7 +2968,7 @@ int upatch_purge(const char *name, const char *reason)
{
__u8 payload[UPATCH_PAYLOAD_HASH_LEN] = {};
char persisted[PATH_MAX];
- struct shirudo_upatch u;
+ struct upatch u;
bool loaded;
int fd, ret;
@@ -3114,7 +3114,7 @@ static void dump_line_info_text(struct li_entry *ents, __u32 k)
}
}
-static void emit_line_info_json(struct shirudo_json_emit *e,
+static void emit_line_info_json(struct json_emit *e,
struct li_entry *ents, __u32 k)
{
__u32 i = 0;
@@ -3141,7 +3141,7 @@ static void emit_line_info_json(struct shirudo_json_emit *e,
}
static int append_one_map_json(const char *path,
- const struct shirudo_map_view *v)
+ const struct map_view *v)
{
char *decoded = NULL;
size_t decoded_len = 0;
@@ -3161,10 +3161,10 @@ static int append_one_map_json(const char *path,
static int export_one_map(const char *upatch, const char *map,
bool json_output, const char *json_path, bool otel,
- const struct shirudo_otel_opts *otel_opts,
+ const struct otel_opts *otel_opts,
bool show_full, bool peek, bool print_detail)
{
- struct shirudo_map_view v = {};
+ struct map_view v = {};
__u32 cap = (show_full || json_output || otel) ? 0 :
MAP_ENTRIES_DEFAULT;
int err, ret = 0;
@@ -3216,9 +3216,9 @@ static int export_one_map(const char *upatch, const char *map,
static int cmd_upatch_map(int argc, const char **argv)
{
- struct shirudo_map_summary *list = NULL;
- struct shirudo_config export_cfg = {};
- struct shirudo_otel_opts otel_opts = {
+ struct map_summary *list = NULL;
+ struct config export_cfg = {};
+ struct otel_opts otel_opts = {
.retries = 3,
};
const char *upatch = NULL, *map = NULL, *json_path = NULL;
@@ -3418,7 +3418,7 @@ static int cmd_upatch_map(int argc, const char **argv)
}
if (json_output) {
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
size_t cap = 8192 + 256 * n;
char *buf;
size_t k;
@@ -3596,7 +3596,7 @@ static void age_from_ts(const char *ts, char *out, size_t cap)
static void render_one_map_text(const char *upatch, const char *map,
__u32 cap)
{
- struct shirudo_map_view v = {};
+ struct map_view v = {};
int ret = upatch_maps_read(upatch, map, cap, MAP_READ_PEEK,
&v);
@@ -3611,7 +3611,7 @@ static void render_one_map_text(const char *upatch, const char *map,
}
static void render_get_text(const struct upatch_get_ctx *c,
- const struct shirudo_map_summary *maps, size_t nm,
+ const struct map_summary *maps, size_t nm,
__u32 map_cap)
{
char age[16] = "";
@@ -3646,10 +3646,10 @@ static void render_get_text(const struct upatch_get_ctx *c,
}
static int render_get_json(const struct upatch_get_ctx *c,
- const struct shirudo_map_summary *maps, size_t nm,
+ const struct map_summary *maps, size_t nm,
__u32 map_cap)
{
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
size_t cap = 64 * 1024 + 1024 * nm;
char age[16] = "";
char *buf;
@@ -3683,7 +3683,7 @@ static int render_get_json(const struct upatch_get_ctx *c,
json_obj_close(&e);
json_arr_open(&e, "maps");
for (k = 0; k < nm; k++) {
- struct shirudo_map_view v = {};
+ struct map_view v = {};
int err;
err = upatch_maps_read(c->upatch, maps[k].name, map_cap,
@@ -3718,7 +3718,7 @@ static int render_get_json(const struct upatch_get_ctx *c,
static int cmd_upatch_get(int argc, const char **argv)
{
- struct shirudo_map_summary *maps = NULL;
+ struct map_summary *maps = NULL;
struct upatch_get_ctx ctx = {};
const char *want = NULL;
bool json = false, show_full = false;
@@ -3776,7 +3776,7 @@ static int cmd_upatch_get(int argc, const char **argv)
return ret;
}
-static const struct shirudo_help_item upatch_subcmds[] = {
+static const struct help_item upatch_subcmds[] = {
{ "load", "load a signed .upatch into the target kernel (target-only)" },
{ "unload", "apply a signed UNLOAD directive (forward chain extension)" },
{ "list", "list persisted + bpffs-pinned upatches on this host" },
@@ -3785,12 +3785,12 @@ static const struct shirudo_help_item upatch_subcmds[] = {
{ "map", "read pinned map contents (target-only; BTF type-aware)" },
};
-static const struct shirudo_help_section upatch_help_sections[] = {
+static const struct help_section upatch_help_sections[] = {
{ "subcommands:", upatch_subcmds,
ARRAY_SIZE(upatch_subcmds) },
};
-static const struct shirudo_help upatch_help = {
+static const struct help upatch_help = {
.usage = "shirudo upatch <subcommand> [<args>...]",
.summary = "Manage signed BPF programs (.upatch). load/unload are "
"target-only;\nlist/info/get are read-only and run on "
diff --git a/builtin-version.c b/builtin-version.c
index a46f7de3..8aedbab1 100644
--- a/builtin-version.c
+++ b/builtin-version.c
@@ -14,16 +14,16 @@
#include "util/help.h"
#include "util/version.h"
-static const struct shirudo_help_item version_options[] = {
+static const struct help_item version_options[] = {
{ "--version-id", "print only the raw SHIRUDO_VERSION_ID, one line" },
};
-static const struct shirudo_help_section version_help_sections[] = {
+static const struct help_section version_help_sections[] = {
{ "options:", version_options,
ARRAY_SIZE(version_options) },
};
-static const struct shirudo_help version_help = {
+static const struct help version_help = {
.usage = "shirudo version [--version-id]",
.summary = "Print the release tag plus the architecture-stripped "
"SHIRUDO_VERSION_ID\nthat targets compare against the "
diff --git a/include/shirudo/upatch.h b/include/shirudo/upatch.h
index 2d972edd..793aa9fd 100644
--- a/include/shirudo/upatch.h
+++ b/include/shirudo/upatch.h
@@ -25,7 +25,7 @@
#define DIRECTIVE_UNLOAD (1u << 0)
-enum shirudo_upatch_type {
+enum upatch_type {
SHIRUDO_UPATCH_TYPE_BPF = 1,
};
@@ -33,7 +33,7 @@ enum shirudo_upatch_type {
#define UPATCH_BPFFS_NAME_MAX (2 * UPATCH_NAME_MAX)
#define UPATCH_PAYLOAD_HASH_LEN 32 /* SHA-256 */
-struct shirudo_upatch_header {
+struct upatch_header {
__le64 magic; /* UPATCH_MAGIC */
__le32 version; /* UPATCH_VERSION */
__le32 flags; /* DIRECTIVE_* */
@@ -57,11 +57,11 @@ struct shirudo_upatch_header {
__le32 nr_maps; /* loader ctx bpf_map_desc count */
__le32 nr_progs; /* loader ctx bpf_prog_desc count */
__le32 rodata_data_off; /* offset in gen_loader_opts.data */
- __le32 type; /* enum shirudo_upatch_type */
+ __le32 type; /* enum upatch_type */
__le32 reserved1; /* zero; keeps the header 8-byte aligned */
};
-BUILD_BUG_ON(sizeof(struct shirudo_upatch_header) != UPATCH_HEADER_SIZE);
+BUILD_BUG_ON(sizeof(struct upatch_header) != UPATCH_HEADER_SIZE);
/*
* The signed sections: what the target needs beyond the loader and its
@@ -76,21 +76,21 @@ BUILD_BUG_ON(sizeof(struct shirudo_upatch_header) != UPATCH_HEADER_SIZE);
#define UPATCH_SIGNED_VERSION 1u
#define UPATCH_SIGNED_SECTIONS_MAX 8u
-enum shirudo_upatch_section_tag {
+enum upatch_section_tag {
SHIRUDO_UPATCH_SECTION_NAME = 0x454d414eu, /* "NAME" le */
SHIRUDO_UPATCH_SECTION_ATTACH = 0x4d475055u, /* "UPGM" le */
SHIRUDO_UPATCH_SECTION_UNLOAD = 0x444c4e55u, /* "UNLD" le */
SHIRUDO_UPATCH_SECTION_DECODERS = 0x42444344u, /* "DCDB" le */
};
-struct shirudo_upatch_signed_section {
- __le32 tag; /* enum shirudo_upatch_section_tag */
+struct upatch_signed_section {
+ __le32 tag; /* enum upatch_section_tag */
__le32 reserved; /* zero */
__le32 off; /* from the start of data */
__le32 len;
};
-struct shirudo_upatch_signed_trailer {
+struct upatch_signed_trailer {
__le32 magic; /* UPATCH_SIGNED_TRAILER_MAGIC */
__le32 version; /* UPATCH_SIGNED_VERSION */
__le32 dir_off; /* the section directory, from the start of data */
@@ -108,12 +108,12 @@ struct shirudo_upatch_signed_trailer {
#define UPATCH_DECODER_LANG_LUA 1u
#define UPATCH_DECODER_INPUT_MAP_V1 1u
-enum shirudo_upatch_decoder_export_signal {
+enum upatch_decoder_export_signal {
UPATCH_DECODER_EXPORT_LOG = 1,
UPATCH_DECODER_EXPORT_METRIC = 2,
};
-struct shirudo_decoder_manifest {
+struct decoder_manifest {
__le32 magic;
__le16 version;
__le16 language;
@@ -127,7 +127,7 @@ struct shirudo_decoder_manifest {
char entrypoint[32];
};
-struct shirudo_upatch_decoder_entry {
+struct upatch_decoder_entry {
__le32 language;
__le32 api_version;
__le32 input_format;
@@ -140,12 +140,12 @@ struct shirudo_upatch_decoder_entry {
__le32 source_len;
};
-struct shirudo_upatch_decoder_blob {
+struct upatch_decoder_blob {
__le32 magic;
__le32 version;
__le32 nr_decoders;
__le32 reserved;
- struct shirudo_upatch_decoder_entry decoders[];
+ struct upatch_decoder_entry decoders[];
};
/*
@@ -166,7 +166,7 @@ struct shirudo_upatch_decoder_blob {
#define UPATCH_BUILD_ID_MAX 64u
#define UPATCH_UPROBE_OFFSETS_MAX (1u << 20)
-enum shirudo_upatch_attach_kind {
+enum upatch_attach_kind {
SHIRUDO_UPATCH_ATTACH_RAW_TRACEPOINT = 0,
SHIRUDO_UPATCH_ATTACH_KPROBE = 1,
SHIRUDO_UPATCH_ATTACH_KRETPROBE = 2,
@@ -177,30 +177,30 @@ enum shirudo_upatch_attach_kind {
SHIRUDO_UPATCH_ATTACH_UPROBE_MULTI = 7,
};
-enum shirudo_upatch_prog_role {
+enum upatch_prog_role {
SHIRUDO_UPATCH_PROG_ROLE_ATTACH = 0,
SHIRUDO_UPATCH_PROG_ROLE_SERIALIZER = 1,
SHIRUDO_UPATCH_PROG_ROLE_TEST_RUN = 2,
};
-struct shirudo_upatch_prog_entry {
- __le32 role; /* enum shirudo_upatch_prog_role */
- __le32 kind; /* enum shirudo_upatch_attach_kind */
+struct upatch_prog_entry {
+ __le32 role; /* enum upatch_prog_role */
+ __le32 kind; /* enum upatch_attach_kind */
__le64 offset; /* kprobe offset; zero for kretprobe */
char target[UPATCH_ATTACH_TARGET_MAX]; /* kprobe symbol */
char map[UPATCH_PROG_MAP_MAX];
};
-struct shirudo_upatch_prog_metadata {
+struct upatch_prog_metadata {
__le32 magic; /* UPATCH_PROG_MAGIC */
__le32 version; /* UPATCH_PROG_VERSION */
__le32 nr_progs;
__le32 reserved;
/*
- * Then: nr_progs struct shirudo_upatch_prog_entry entries in
+ * Then: nr_progs struct upatch_prog_entry entries in
* libbpf/gen_loader program iteration order.
*/
- struct shirudo_upatch_prog_entry progs[];
+ struct upatch_prog_entry progs[];
};
/*
@@ -210,14 +210,14 @@ struct shirudo_upatch_prog_metadata {
* path_len path bytes (without NUL), build_id_len build-ID bytes, and
* nr_offsets little-endian __u64 file offsets. Records have no padding.
*/
-struct shirudo_upatch_uprobe_targets {
+struct upatch_uprobe_targets {
__le32 magic; /* UPATCH_UPROBE_TARGET_MAGIC */
__le32 version; /* UPATCH_UPROBE_TARGET_VERSION */
__le32 nr_targets;
__le32 reserved;
};
-struct shirudo_upatch_uprobe_target {
+struct upatch_uprobe_target {
__le32 prog_idx;
__le32 path_len;
__le32 build_id_len;
diff --git a/shirudo.c b/shirudo.c
index 04f57788..876e4908 100644
--- a/shirudo.c
+++ b/shirudo.c
@@ -142,7 +142,7 @@ int main(int argc, const char **argv)
return 1;
}
if (!c) {
- struct shirudo_suggestion sugg[4];
+ struct suggestion sugg[4];
size_t n;
int max_dist, len;
diff --git a/testing/fixtures/arena-tree-serializer.bpf.c b/testing/fixtures/arena-tree-serializer.bpf.c
index e5bc7f08..af444bc9 100644
--- a/testing/fixtures/arena-tree-serializer.bpf.c
+++ b/testing/fixtures/arena-tree-serializer.bpf.c
@@ -42,7 +42,7 @@ struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 4);
__type(key, __u32);
- __type(value, struct shirudo_serial_chunk);
+ __type(value, struct serial_chunk);
} shirudo_ser SEC(".maps");
struct {
@@ -90,10 +90,10 @@ void __arena *bpf_arena_alloc_pages(void *map, void __arena *addr,
static struct tree_node __arena *root;
-static __always_inline void set_error(struct shirudo_serialize_ctx *ctx,
+static __always_inline void set_error(struct serialize_ctx *ctx,
int status)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 key = 0;
__u32 page_index = ctx ? ctx->page_index : 0;
__u64 cursor = ctx ? ctx->cursor : 0;
@@ -131,7 +131,7 @@ static __always_inline int init_page_chunks(__u32 records, __u32 flags,
total_chunks = 1;
for (i = 0; i < total_chunks; i++) {
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 key = i;
__u32 used = page_bytes -
i * SERIAL_CHUNK_PAYLOAD;
@@ -188,7 +188,7 @@ static __always_inline int build_tree(void)
static __always_inline int emit_record(struct tree_node __arena *node,
__u32 absolute, __u32 page_slot)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
struct tree_record rec = {};
__u32 chunk_key = page_slot / TREE_RECORDS_PER_CHUNK;
__u32 slot = page_slot % TREE_RECORDS_PER_CHUNK;
@@ -211,7 +211,7 @@ static __always_inline int emit_record(struct tree_node __arena *node,
}
SEC("syscall")
-int shirudo_serialize__tree_arena(struct shirudo_serialize_ctx *ctx)
+int shirudo_serialize__tree_arena(struct serialize_ctx *ctx)
{
__u32 start, records, emitted, flags = 0;
__u64 next_cursor;
@@ -278,7 +278,7 @@ int shirudo_serialize__tree_arena(struct shirudo_serialize_ctx *ctx)
}
SEC("syscall")
-int shirudo_serialize__tree_error(struct shirudo_serialize_ctx *ctx)
+int shirudo_serialize__tree_error(struct serialize_ctx *ctx)
{
if (!ctx || !ctx->invocation_id)
return -EINVAL;
diff --git a/testing/fixtures/map-export.bpf.c b/testing/fixtures/map-export.bpf.c
index 866a1e91..b27f8ee3 100644
--- a/testing/fixtures/map-export.bpf.c
+++ b/testing/fixtures/map-export.bpf.c
@@ -20,7 +20,7 @@ struct {
__type(value, __u64);
} second SEC(".maps");
-const struct shirudo_decoder_manifest first_decoder SEC(".rodata") = {
+const struct decoder_manifest first_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
@@ -33,7 +33,7 @@ const struct shirudo_decoder_manifest first_decoder SEC(".rodata") = {
.entrypoint = "decode",
};
-const struct shirudo_decoder_manifest second_decoder SEC(".rodata") = {
+const struct decoder_manifest second_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
diff --git a/testing/fixtures/otel-backend.bpf.c b/testing/fixtures/otel-backend.bpf.c
index a7df7540..08a707d7 100644
--- a/testing/fixtures/otel-backend.bpf.c
+++ b/testing/fixtures/otel-backend.bpf.c
@@ -20,7 +20,7 @@ struct {
__type(value, __u64);
} backend_metric SEC(".maps");
-const struct shirudo_decoder_manifest log_decoder SEC(".rodata") = {
+const struct decoder_manifest log_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
@@ -33,7 +33,7 @@ const struct shirudo_decoder_manifest log_decoder SEC(".rodata") = {
.entrypoint = "decode",
};
-const struct shirudo_decoder_manifest metric_decoder SEC(".rodata") = {
+const struct decoder_manifest metric_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
diff --git a/testing/fixtures/serialized-metric.bpf.c b/testing/fixtures/serialized-metric.bpf.c
index cb2bf51a..cdccf5bc 100644
--- a/testing/fixtures/serialized-metric.bpf.c
+++ b/testing/fixtures/serialized-metric.bpf.c
@@ -27,7 +27,7 @@ struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, __u32);
- __type(value, struct shirudo_serial_chunk);
+ __type(value, struct serial_chunk);
} shirudo_ser SEC(".maps");
struct {
@@ -37,7 +37,7 @@ struct {
__type(value, __u32);
} counter_state SEC(".maps");
-const struct shirudo_decoder_manifest counters_decoder SEC(".rodata") = {
+const struct decoder_manifest counters_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
@@ -51,9 +51,9 @@ const struct shirudo_decoder_manifest counters_decoder SEC(".rodata") = {
};
SEC("syscall")
-int shirudo_serialize__counters(struct shirudo_serialize_ctx *ctx)
+int shirudo_serialize__counters(struct serialize_ctx *ctx)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
struct counter_record record = {};
struct counter_value *value;
__u32 *initialized;
diff --git a/testing/functional/upatch/t3002-upatch-decoders.sh b/testing/functional/upatch/t3002-upatch-decoders.sh
index bb28c8ba..9952c119 100755
--- a/testing/functional/upatch/t3002-upatch-decoders.sh
+++ b/testing/functional/upatch/t3002-upatch-decoders.sh
@@ -66,7 +66,7 @@ struct {
__type(value, __u64);
} t0005_map SEC(".maps");
-const struct shirudo_decoder_manifest t0005_decoder SEC(".rodata") = {
+const struct decoder_manifest t0005_decoder SEC(".rodata") = {
.magic = DECODER_MANIFEST_MAGIC,
.version = UPATCH_DECODER_VERSION,
.language = UPATCH_DECODER_LANG_LUA,
diff --git a/testing/functional/upatch/t3004-upatch-serializer-metadata.sh b/testing/functional/upatch/t3004-upatch-serializer-metadata.sh
index facc4f3f..49986a07 100644
--- a/testing/functional/upatch/t3004-upatch-serializer-metadata.sh
+++ b/testing/functional/upatch/t3004-upatch-serializer-metadata.sh
@@ -56,7 +56,7 @@ struct {
__type(value, __u32);
} target SEC(".maps");
SEC("syscall")
-int shirudo_serialize__target(struct shirudo_serialize_ctx *ctx)
+int shirudo_serialize__target(struct serialize_ctx *ctx)
{
return 0;
}
@@ -70,10 +70,10 @@ struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 4);
__type(key, __u32);
- __type(value, struct shirudo_serial_chunk);
+ __type(value, struct serial_chunk);
} shirudo_ser SEC(".maps");
SEC("syscall")
-int shirudo_serialize__absent(struct shirudo_serialize_ctx *ctx)
+int shirudo_serialize__absent(struct serialize_ctx *ctx)
{
return 0;
}
@@ -87,10 +87,10 @@ struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 4);
__type(key, __u32);
- __type(value, struct shirudo_serial_chunk);
+ __type(value, struct serial_chunk);
} shirudo_ser SEC(".maps");
SEC("syscall")
-int shirudo_serialize__shirudo_ser(struct shirudo_serialize_ctx *ctx)
+int shirudo_serialize__shirudo_ser(struct serialize_ctx *ctx)
{
return 0;
}
diff --git a/testing/fuzz/fuzz-attest.c b/testing/fuzz/fuzz-attest.c
index b87c4dcd..c78d8d92 100644
--- a/testing/fuzz/fuzz-attest.c
+++ b/testing/fuzz/fuzz-attest.c
@@ -17,15 +17,15 @@ static const __u8 nonce[16] = {
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_attest_challenge_policy pol = {
+ struct attest_challenge_policy pol = {
.trust_presented = true,
};
- struct shirudo_attest_expect expect = {
+ struct attest_expect expect = {
.nonce = nonce,
.nonce_len = sizeof(nonce),
.allow_runtime_events = true,
};
- struct shirudo_attest_challenge challenge;
+ struct attest_challenge challenge;
__u8 credential[TPM_CREDENTIAL_LEN];
size_t out_len, cap;
char report[4096];
diff --git a/testing/fuzz/fuzz-cms.c b/testing/fuzz/fuzz-cms.c
index a383f334..86f387cd 100644
--- a/testing/fuzz/fuzz-cms.c
+++ b/testing/fuzz/fuzz-cms.c
@@ -15,7 +15,7 @@
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
struct cert_pubkey pub;
- struct shirudo_cert cert = {};
+ struct cert cert = {};
size_t der_len, sig_len, n;
const __u8 *der, *sig;
__u8 sha[32], fp[32];
diff --git a/testing/fuzz/fuzz-config.c b/testing/fuzz/fuzz-config.c
index 937576a9..6ce17a9f 100644
--- a/testing/fuzz/fuzz-config.c
+++ b/testing/fuzz/fuzz-config.c
@@ -16,7 +16,7 @@ int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
char endpoint[BPM_MAX_ENDPOINT], reference[BPM_MAX_DIGEST];
char line[PATH_MAX], copy[PATH_MAX], key_file[BPM_MAX_KEY];
- struct shirudo_config cfg;
+ struct config cfg;
char path[64];
FILE *fp;
int fd;
diff --git a/testing/fuzz/fuzz-decoder.c b/testing/fuzz/fuzz-decoder.c
index a06f5006..e2908d47 100644
--- a/testing/fuzz/fuzz-decoder.c
+++ b/testing/fuzz/fuzz-decoder.c
@@ -57,10 +57,10 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_map_entry entries[32];
+ struct map_entry entries[32];
struct upatch_decoder_view *d;
- struct shirudo_serial_page page = {};
- struct shirudo_map_view v = {
+ struct serial_page page = {};
+ struct map_view v = {
.type_name = "array",
.key_size = 4,
.value_size = 8,
diff --git a/testing/fuzz/fuzz-eventlog.c b/testing/fuzz/fuzz-eventlog.c
index 5e6d59b5..e1e2cd2b 100644
--- a/testing/fuzz/fuzz-eventlog.c
+++ b/testing/fuzz/fuzz-eventlog.c
@@ -34,7 +34,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_eventlog_init init;
+ struct eventlog_init init;
size_t seen = 0;
char path[64];
__u8 root[32];
diff --git a/testing/fuzz/fuzz-json.c b/testing/fuzz/fuzz-json.c
index 0bc5727d..4142d72b 100644
--- a/testing/fuzz/fuzz-json.c
+++ b/testing/fuzz/fuzz-json.c
@@ -19,16 +19,16 @@ int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
char s[64], k[32], v[16];
__s64 i = 0, n = 0;
int b = 0, elems = 0;
- struct shirudo_json_array arr = { on_elem, &elems };
- struct shirudo_json_field obj[] = {
+ struct json_array arr = { on_elem, &elems };
+ struct json_field obj[] = {
{ "k", SHIRUDO_JSON_T_STRING, k, sizeof(k), 0, NULL, 0 },
{ "n", SHIRUDO_JSON_T_INT, &n, 0, 0, NULL, 0 },
};
- struct shirudo_json_field elem[] = {
+ struct json_field elem[] = {
{ "v", SHIRUDO_JSON_T_STRING, v, sizeof(v), 0, NULL, 0 },
{ "o", SHIRUDO_JSON_T_OBJECT, NULL, 0, 0, obj, ARRAY_SIZE(obj) },
};
- struct shirudo_json_field root[] = {
+ struct json_field root[] = {
{ "s", SHIRUDO_JSON_T_STRING, s, sizeof(s), 0, NULL, 0 },
{ "i", SHIRUDO_JSON_T_INT, &i, 0, 0, NULL, 0 },
{ "b", SHIRUDO_JSON_T_BOOL, &b, 0, 0, NULL, 0 },
diff --git a/testing/fuzz/fuzz-kconfig.c b/testing/fuzz/fuzz-kconfig.c
index 4aa3b8a3..72597947 100644
--- a/testing/fuzz/fuzz-kconfig.c
+++ b/testing/fuzz/fuzz-kconfig.c
@@ -9,7 +9,7 @@
#include "fuzz.h"
#include "bpm_tree_state.c"
-static struct shirudo_tree_selector sel;
+static struct tree_selector sel;
static int slots[TREE_SELECTOR_HASH_SIZE];
int LLVMFuzzerInitialize(int *argc, char ***argv)
@@ -29,7 +29,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv)
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
static char values[TREE_MAX_KCONFIG][TREE_STRING_MAX];
- static struct shirudo_tree_kv labels[TREE_MAX_LABELS];
+ static struct tree_kv labels[TREE_MAX_LABELS];
bool found[TREE_MAX_KCONFIG] = {};
char path[64];
int fd, n;
diff --git a/testing/fuzz/fuzz-kernel.c b/testing/fuzz/fuzz-kernel.c
index bd2e56dd..d8f859fc 100644
--- a/testing/fuzz/fuzz-kernel.c
+++ b/testing/fuzz/fuzz-kernel.c
@@ -17,7 +17,7 @@ int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
char build_id[KERNEL_BUILD_ID_STRING_MAX];
const struct timespec mt = { 86400, 1 };
char ts[KMSG_TS_LEN];
- struct shirudo_kmod_set set;
+ struct kmod_set set;
char msg[1024], *text;
const char *m;
__u64 us;
diff --git a/testing/fuzz/fuzz-otel.c b/testing/fuzz/fuzz-otel.c
index 6dae1e90..f4cb9fd7 100644
--- a/testing/fuzz/fuzz-otel.c
+++ b/testing/fuzz/fuzz-otel.c
@@ -21,34 +21,34 @@ bool upatch_map_is_percpu(__u32 type)
return false;
}
-int upatch_decode_map_json(const struct shirudo_map_view *v,
+int upatch_decode_map_json(const struct map_view *v,
char **out, size_t *out_len)
{
return -EOPNOTSUPP;
}
-int upatch_decode_map_json_limit(const struct shirudo_map_view *v,
+int upatch_decode_map_json_limit(const struct map_view *v,
size_t max_bytes,
char **out, size_t *out_len)
{
return -EOPNOTSUPP;
}
-int upatch_decode_map_otel(const struct shirudo_map_view *v,
+int upatch_decode_map_otel(const struct map_view *v,
char **out, size_t *out_len)
{
return -EOPNOTSUPP;
}
int upatch_decode_map_file_json(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
return -EOPNOTSUPP;
}
int upatch_decode_map_file_json_limit(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
size_t max_bytes, char **out,
size_t *out_len)
{
@@ -56,7 +56,7 @@ int upatch_decode_map_file_json_limit(const char *path,
}
int upatch_decode_map_file_otel(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
return -EOPNOTSUPP;
@@ -64,7 +64,7 @@ int upatch_decode_map_file_otel(const char *path,
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
struct otel_response r = {};
struct otel_state st = {};
size_t off, n, cap;
diff --git a/testing/fuzz/fuzz-prog-metadata.c b/testing/fuzz/fuzz-prog-metadata.c
index 2adb3c08..0a8aad9c 100644
--- a/testing/fuzz/fuzz-prog-metadata.c
+++ b/testing/fuzz/fuzz-prog-metadata.c
@@ -14,8 +14,8 @@
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_upatch_prog_metadata md;
- struct shirudo_prog_spec *specs;
+ struct upatch_prog_metadata md;
+ struct prog_spec *specs;
__u32 nr_progs = 0;
if (size > UINT32_MAX)
diff --git a/testing/fuzz/fuzz-serializer.c b/testing/fuzz/fuzz-serializer.c
index 8ec350e7..8ccf9772 100644
--- a/testing/fuzz/fuzz-serializer.c
+++ b/testing/fuzz/fuzz-serializer.c
@@ -20,7 +20,7 @@ static size_t chunks_len;
int fuzz_lookup(int fd, const void *key, void *value)
{
size_t off = (size_t)*(const __u32 *)key *
- sizeof(struct shirudo_serial_chunk);
+ sizeof(struct serial_chunk);
size_t n;
if (off >= chunks_len) {
@@ -28,9 +28,9 @@ int fuzz_lookup(int fd, const void *key, void *value)
return -1;
}
n = chunks_len - off;
- if (n > sizeof(struct shirudo_serial_chunk))
- n = sizeof(struct shirudo_serial_chunk);
- memset(value, 0, sizeof(struct shirudo_serial_chunk));
+ if (n > sizeof(struct serial_chunk))
+ n = sizeof(struct serial_chunk);
+ memset(value, 0, sizeof(struct serial_chunk));
memcpy(value, chunks + off, n);
return 0;
}
@@ -38,8 +38,8 @@ int fuzz_lookup(int fd, const void *key, void *value)
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
struct bpf_map_info info = { .max_entries = 64 };
- struct shirudo_serial_chunk first = {};
- struct shirudo_serial_page page;
+ struct serial_chunk first = {};
+ struct serial_page page;
chunks = data;
chunks_len = size;
diff --git a/testing/fuzz/fuzz-tpm-wire.c b/testing/fuzz/fuzz-tpm-wire.c
index 383c1e09..27e98e24 100644
--- a/testing/fuzz/fuzz-tpm-wire.c
+++ b/testing/fuzz/fuzz-tpm-wire.c
@@ -12,9 +12,9 @@
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
__u8 name[TPM_NAME_LEN], r[32], s[32];
- struct shirudo_tpm_ecc_public ecc;
- struct shirudo_tpm_public pub;
- struct shirudo_tpm_attest at;
+ struct tpm_ecc_public ecc;
+ struct tpm_public pub;
+ struct tpm_attest at;
tpm_public_parse(data, size, &pub);
tpm_ecc_public_parse(data, size, &ecc);
diff --git a/testing/fuzz/fuzz-tree-state.c b/testing/fuzz/fuzz-tree-state.c
index 0ebdaf31..99684144 100644
--- a/testing/fuzz/fuzz-tree-state.c
+++ b/testing/fuzz/fuzz-tree-state.c
@@ -20,7 +20,7 @@ static char fuzz_path[64];
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_tree_state state;
+ struct tree_state state;
__u8 root[32];
int fd;
diff --git a/testing/fuzz/fuzz-tree.c b/testing/fuzz/fuzz-tree.c
index 66cf1f80..e225c22f 100644
--- a/testing/fuzz/fuzz-tree.c
+++ b/testing/fuzz/fuzz-tree.c
@@ -12,7 +12,7 @@
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_tree_publication pub;
+ struct tree_publication pub;
char digest[72], *out;
size_t len;
diff --git a/testing/fuzz/fuzz-upatch.c b/testing/fuzz/fuzz-upatch.c
index a6de7f16..ae024b1e 100644
--- a/testing/fuzz/fuzz-upatch.c
+++ b/testing/fuzz/fuzz-upatch.c
@@ -10,8 +10,8 @@
int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)
{
- struct shirudo_prog_spec *specs;
- struct shirudo_upatch u;
+ struct prog_spec *specs;
+ struct upatch u;
const void *attach;
__u32 attach_len;
char path[64];
diff --git a/testing/helper/image-cleanup.h b/testing/helper/image-cleanup.h
index c030653c..0a149aa3 100644
--- a/testing/helper/image-cleanup.h
+++ b/testing/helper/image-cleanup.h
@@ -8,7 +8,7 @@
#include "util/dm_verity.h"
-int __wrap_dm_verity_remove(struct shirudo_dm_verity *device,
+int __wrap_dm_verity_remove(struct dm_verity *device,
bool deferred);
int __wrap_usleep(useconds_t usec);
diff --git a/testing/helper/image-fault.c b/testing/helper/image-fault.c
index ecef41d6..96acb8ed 100644
--- a/testing/helper/image-fault.c
+++ b/testing/helper/image-fault.c
@@ -34,7 +34,7 @@ static __u32 begin_calls, end_calls;
static int consumed_valid = -1;
int __wrap_config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard)
+ struct config_root_guard *guard)
{
__u8 wrong[32];
@@ -52,9 +52,9 @@ int __wrap_config_root_begin(const __u8 root[32],
return __real_config_root_begin(wrong, guard);
}
-int __wrap_config_root_end(struct shirudo_config_root_guard *guard)
+int __wrap_config_root_end(struct config_root_guard *guard)
{
- struct shirudo_expected_root expected = {};
+ struct expected_root expected = {};
int ret = 0, cleanup;
if (root_mode != ROOT_NORMAL) {
@@ -71,7 +71,7 @@ int __wrap_config_root_end(struct shirudo_config_root_guard *guard)
static int check_root_cleared(void)
{
- struct shirudo_expected_root expected = {}, empty = {};
+ struct expected_root expected = {}, empty = {};
int map, task, ret;
map = bpf_obj_get(BPFFS_DIR "/config_roots");
@@ -93,10 +93,10 @@ out:
return ret;
}
-static int check_classification(const struct shirudo_dm_verity *device)
+static int check_classification(const struct dm_verity *device)
{
__u32 dev = (major(device->device) << 20) | minor(device->device);
- struct shirudo_device_authority entry;
+ struct device_authority entry;
__u64 key, next, diskseq;
__u32 matches = 0;
int map, block, ret = 0;
@@ -151,7 +151,7 @@ out_block:
static int config_root_test(const char *mode, const char *prefix)
{
struct config_image_open opened;
- struct shirudo_dm_verity device;
+ struct dm_verity device;
bool created = false;
int ret, cleanup;
char name[128];
diff --git a/testing/helper/image-fault.h b/testing/helper/image-fault.h
index 7ac05d2a..98560f22 100644
--- a/testing/helper/image-fault.h
+++ b/testing/helper/image-fault.h
@@ -11,11 +11,11 @@
#include "util/image_guards.h"
int __real_config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard);
+ struct 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);
+ struct config_root_guard *guard);
+int __real_config_root_end(struct config_root_guard *guard);
+int __wrap_config_root_end(struct 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/policy-probe.c b/testing/helper/policy-probe.c
index b297a2b8..7876721e 100644
--- a/testing/helper/policy-probe.c
+++ b/testing/helper/policy-probe.c
@@ -24,7 +24,7 @@ static __u64 probe_word = 0x5348495255444fUL;
static int check_mark(const char *pin, int expected)
{
- struct shirudo_task_authority authority = {};
+ struct task_authority authority = {};
union bpf_attr attr = {};
int fd, pidfd, ret;
@@ -65,7 +65,7 @@ static void print_hex(const __u8 *bytes, size_t n)
static int print_identity(const char *pin, const char *field)
{
- struct shirudo_identity id = {};
+ struct identity id = {};
union bpf_attr attr = {};
__u32 zero = 0;
int fd, ret;
diff --git a/testing/helper/test-conditions.c b/testing/helper/test-conditions.c
index fad47633..77437a4a 100644
--- a/testing/helper/test-conditions.c
+++ b/testing/helper/test-conditions.c
@@ -45,8 +45,8 @@ static __s64 env_s64(const char *name, __s64 def)
int main(int argc, char **argv)
{
- struct shirudo_condition conds[CONDITIONS_MAX];
- struct shirudo_conditions_input in = {};
+ struct condition conds[CONDITIONS_MAX];
+ struct conditions_input in = {};
__s64 lsm, serial, pinned;
const char *mode, *config;
char reason[160];
diff --git a/testing/helper/test-config-attest.c b/testing/helper/test-config-attest.c
index 5dfe7416..3e0f56ed 100644
--- a/testing/helper/test-config-attest.c
+++ b/testing/helper/test-config-attest.c
@@ -22,7 +22,7 @@
static int boot_identity(void *ctx, __u32 *reset, __u32 *restart)
{
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
int ret;
(void)ctx;
@@ -35,7 +35,7 @@ static int boot_identity(void *ctx, __u32 *reset, __u32 *restart)
static int pcr_read(void *ctx, __u32 pcr, __u8 out[32])
{
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
int ret;
(void)ctx;
@@ -55,7 +55,7 @@ static int no_extend(void *ctx, __u32 pcr, const __u8 event[32])
}
static int no_activate(void *ctx,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
(void)ctx;
(void)target;
@@ -69,7 +69,7 @@ static int no_seal(void *ctx, int fd)
return 0;
}
-static const struct shirudo_config_update_ops ops = {
+static const struct config_update_ops ops = {
.boot_identity = boot_identity,
.pcr_read = pcr_read,
.pcr_extend = no_extend,
@@ -80,7 +80,7 @@ static const struct shirudo_config_update_ops ops = {
static int render(const char *directory, const char *nonce)
{
- struct shirudo_config_update update = { .dir_fd = -1, .lock_fd = -1 };
+ struct config_update update = { .dir_fd = -1, .lock_fd = -1 };
__u8 bytes[ATTEST_NONCE_MAX];
char *document = NULL;
size_t length = 0, capacity = 0, nonce_length;
@@ -136,7 +136,7 @@ static int read_document(const char *path, char **out, size_t *length)
int main(int argc, char **argv)
{
- struct shirudo_config_evidence config = {};
+ struct config_evidence config = {};
__u8 pcrs[24][32] = {}, root[32];
const char *reason = NULL;
const __u8 *expected;
diff --git a/testing/helper/test-config-image.c b/testing/helper/test-config-image.c
index f57b5c15..6d89057a 100644
--- a/testing/helper/test-config-image.c
+++ b/testing/helper/test-config-image.c
@@ -12,7 +12,7 @@
#include "config_image.h"
#include "hex.h"
-static int header_read(const char *path, struct shirudo_config_image *image)
+static int header_read(const char *path, struct config_image *image)
{
int fd, ret;
@@ -31,7 +31,7 @@ int main(int argc, char **argv)
.hash_fd = -1,
.signature_fd = -1,
};
- struct shirudo_config_image image;
+ struct config_image image;
__u8 root[32];
int ret = -EINVAL;
diff --git a/testing/helper/test-config-update.c b/testing/helper/test-config-update.c
index 4f38f251..18f4a477 100644
--- a/testing/helper/test-config-update.c
+++ b/testing/helper/test-config-update.c
@@ -33,9 +33,9 @@ struct simulated_tpm {
};
struct test_context {
- struct shirudo_config_update *update;
+ struct config_update *update;
struct simulated_tpm sim;
- struct shirudo_tpm *tpm;
+ struct tpm *tpm;
const char *directory;
};
@@ -142,7 +142,7 @@ static int test_pcr_extend(void *opaque, __u32 pcr,
}
static int test_prepare(void *opaque,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
struct test_context *ctx = opaque;
size_t i;
@@ -166,9 +166,9 @@ static int test_prepare(void *opaque,
}
static int test_activate(void *opaque,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
struct test_context *ctx = opaque;
__u8 live[32];
int ret;
@@ -201,7 +201,7 @@ static int test_seal(void *opaque, int fd)
}
static int test_checkpoint(void *opaque,
- enum shirudo_config_update_checkpoint checkpoint)
+ enum config_update_checkpoint checkpoint)
{
const char *crash = getenv("SHIRUDO_TEST_CONFIG_CRASH");
const char *fail = getenv("SHIRUDO_TEST_CONFIG_FAIL");
@@ -214,7 +214,7 @@ static int test_checkpoint(void *opaque,
return 0;
}
-static const struct shirudo_config_update_ops test_ops = {
+static const struct config_update_ops test_ops = {
.boot_identity = test_boot_identity,
.pcr_read = test_pcr_read,
.pcr_extend = test_pcr_extend,
@@ -224,7 +224,7 @@ static const struct shirudo_config_update_ops test_ops = {
.checkpoint = test_checkpoint,
};
-static int make_target(char id, struct shirudo_config_update_target *target)
+static int make_target(char id, struct config_update_target *target)
{
memset(target, 0, sizeof(*target));
snprintf(target->prefix, sizeof(target->prefix), "/verified/config-%c",
@@ -233,7 +233,7 @@ static int make_target(char id, struct shirudo_config_update_target *target)
return 0;
}
-static int show_event(const struct shirudo_config_update_record *record,
+static int show_event(const struct config_update_record *record,
void *opaque)
{
__u32 *count = opaque;
@@ -248,7 +248,7 @@ static int show_event(const struct shirudo_config_update_record *record,
static void inspect(struct test_context *ctx)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
__u8 value[32];
__u32 count = 0;
char hex[65];
@@ -280,11 +280,11 @@ static void inspect(struct test_context *ctx)
int main(int argc, char **argv)
{
- struct shirudo_config_update second = { .dir_fd = -1, .lock_fd = -1 };
- struct shirudo_config_update update = { .dir_fd = -1, .lock_fd = -1 };
+ struct config_update second = { .dir_fd = -1, .lock_fd = -1 };
+ struct config_update update = { .dir_fd = -1, .lock_fd = -1 };
struct test_context ctx = { .update = &update };
- struct shirudo_config_update_ops ops;
- struct shirudo_config_update_target target;
+ struct config_update_ops ops;
+ struct config_update_target target;
char hex[65];
__u32 pcr = 15;
__u8 event[32];
diff --git a/testing/helper/test-config.c b/testing/helper/test-config.c
index 35f91a78..d4fe98a5 100644
--- a/testing/helper/test-config.c
+++ b/testing/helper/test-config.c
@@ -33,7 +33,7 @@ static int write_config(const char *path, const char *contents)
static int check_defaults(const char *path)
{
- struct shirudo_config cfg;
+ struct config cfg;
unlink(path);
if (config_load_path(&cfg, path) != 0)
@@ -59,7 +59,7 @@ static int check_valid(const char *path)
"map_export.log_record_max_bytes = 1024\n"
"map_export.otlp_max_bytes = 2048\n"
"map_export.s3_uri = s3://bucket/prefix\n";
- struct shirudo_config cfg;
+ struct config cfg;
if (write_config(path, input) != 0 ||
config_load_path(&cfg, path) != 0)
@@ -79,7 +79,7 @@ static int check_valid(const char *path)
static int check_invalid(const char *path, const char *input)
{
- struct shirudo_config cfg;
+ struct config cfg;
return write_config(path, input) != 0 ||
config_load_path(&cfg, path) != 0 ||
@@ -90,7 +90,7 @@ static int check_invalid(const char *path, const char *input)
static int check_max_bytes(const char *path, const char *value,
__u64 expected)
{
- struct shirudo_config cfg;
+ struct config cfg;
char input[128];
snprintf(input, sizeof(input), "eventlog.max_bytes = %s\n", value);
diff --git a/testing/helper/test-eventlog.c b/testing/helper/test-eventlog.c
index d57e38ab..eab5e68e 100644
--- a/testing/helper/test-eventlog.c
+++ b/testing/helper/test-eventlog.c
@@ -29,7 +29,7 @@ static int append_init(const char *path, const char *bound_in,
char writer_hex[2 * TPM_NV_RSA_BYTES + 1];
__u8 modulus[TPM_NV_RSA_BYTES] = { [0] = 0x80, [383] = 1 };
char buf[4096], ts[32], boot_id[64], nv_index[16], hex[65];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
char name_hex[2 * TPM_NAME_LEN + 1];
__u8 zero[TPM_NAME_LEN] = {};
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
return ret ? 1 : 0;
}
if (strcmp(argv[1], "boot-init") == 0) {
- struct shirudo_eventlog_init rec;
+ struct eventlog_init rec;
int ret = eventlog_boot_init(&rec);
printf("rc=%d\n", ret);
diff --git a/testing/helper/test-image-cleanup.c b/testing/helper/test-image-cleanup.c
index d0381e41..27a4f075 100644
--- a/testing/helper/test-image-cleanup.c
+++ b/testing/helper/test-image-cleanup.c
@@ -6,12 +6,12 @@
#include "../../util/image_runtime.c"
#include "image-cleanup.h"
-static struct shirudo_dm_verity candidate;
+static struct dm_verity candidate;
static __u32 busy_calls, remove_calls, sleep_calls;
static int remove_result;
static bool invalid_call;
-int __wrap_dm_verity_remove(struct shirudo_dm_verity *device,
+int __wrap_dm_verity_remove(struct dm_verity *device,
bool deferred)
{
if (device != &candidate || deferred || remove_calls != sleep_calls)
diff --git a/testing/helper/test-image-cli.c b/testing/helper/test-image-cli.c
index 20b06029..3496e2df 100644
--- a/testing/helper/test-image-cli.c
+++ b/testing/helper/test-image-cli.c
@@ -8,14 +8,14 @@ int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client,
const char *repository,
const char *reference,
const char *certificate,
- struct shirudo_tree_publication *pub,
+ struct tree_publication *pub,
char *digest, size_t capacity);
int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client,
const char *repository,
const char *reference,
const char *certificate,
- struct shirudo_tree_publication *pub,
+ struct tree_publication *pub,
char *digest, size_t capacity)
{
(void)client;
@@ -30,7 +30,7 @@ int __wrap_bpm_tree_fetch_publication(struct bpm_oci_client *client,
int main(int argc, const char **argv)
{
- struct shirudo_config bootstrap;
+ struct config bootstrap;
int fd, ret;
if (argc < 3)
@@ -77,7 +77,7 @@ int main(int argc, const char **argv)
}
}
} else if (!strcmp(argv[2], "tree")) {
- struct shirudo_tree_publication publication = {};
+ struct tree_publication publication = {};
struct bpm_tree_config config = {};
char digest[BPM_MAX_DIGEST];
diff --git a/testing/helper/test-image-config.c b/testing/helper/test-image-config.c
index e89171f6..9f8f8480 100644
--- a/testing/helper/test-image-config.c
+++ b/testing/helper/test-image-config.c
@@ -14,7 +14,7 @@
static int read_bootstrap(int argc, char **argv)
{
- struct shirudo_image_bootstrap boot = {};
+ struct image_bootstrap boot = {};
char root[65];
int ret;
@@ -33,7 +33,7 @@ static int read_bootstrap(int argc, char **argv)
int main(int argc, char **argv)
{
- struct shirudo_config bootstrap, effective;
+ struct config bootstrap, effective;
int fd, ret;
if (argc < 3 || argc > 4)
diff --git a/testing/helper/test-image-keys.c b/testing/helper/test-image-keys.c
index 21fda11c..05eff580 100644
--- a/testing/helper/test-image-keys.c
+++ b/testing/helper/test-image-keys.c
@@ -22,7 +22,7 @@ static char **held;
static int held_count;
struct test_context {
- struct shirudo_trusted_set *set;
+ struct trusted_set *set;
__u8 pcr[32];
__u32 extends;
__u32 activations;
@@ -93,7 +93,7 @@ static int pcr_extend(void *opaque, __u32 pcr, const __u8 event[32])
}
static int prepare(void *opaque,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
struct test_context *ctx = opaque;
@@ -102,7 +102,7 @@ static int prepare(void *opaque,
}
static int activate(void *opaque,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
struct test_context *ctx = opaque;
@@ -122,7 +122,7 @@ static int seal(void *opaque, int fd)
return 0;
}
-static const struct shirudo_config_update_ops ops = {
+static const struct config_update_ops ops = {
.boot_identity = boot_count,
.pcr_read = pcr_read,
.pcr_extend = pcr_extend,
@@ -131,10 +131,10 @@ static const struct shirudo_config_update_ops ops = {
.seal = seal,
};
-static int live_update(const char *directory, struct shirudo_trusted_set *set)
+static int live_update(const char *directory, struct trusted_set *set)
{
- struct shirudo_config_update_target target = {};
- struct shirudo_config_update update;
+ struct config_update_target target = {};
+ struct config_update update;
struct test_context ctx = { .set = set };
int ret;
@@ -162,7 +162,7 @@ static int live_update(const char *directory, struct shirudo_trusted_set *set)
int main(int argc, char **argv)
{
- struct shirudo_trusted_set set = {};
+ struct trusted_set set = {};
int fd, ret;
if (argc != 3 && argc < 5)
diff --git a/testing/helper/test-keyring-seal.c b/testing/helper/test-keyring-seal.c
index 675ca654..6a335cf2 100644
--- a/testing/helper/test-keyring-seal.c
+++ b/testing/helper/test-keyring-seal.c
@@ -108,7 +108,7 @@ static int exact_case(const struct keyring_cert *a,
/* <set> is the trusted set init enrols; <other> a certificate outside it. */
static int seal_case(const char *mode,
- const struct shirudo_trusted_set *set,
+ const struct trusted_set *set,
const struct keyring_cert *own,
const struct keyring_cert *other)
{
@@ -160,7 +160,7 @@ static int seal_case(const char *mode,
int main(int argc, char **argv)
{
struct keyring_cert own = {}, other = {};
- struct shirudo_trusted_set set = {};
+ struct trusted_set set = {};
char keys[PATH_MAX];
int ret;
diff --git a/testing/helper/test-keys.c b/testing/helper/test-keys.c
index ca5062c7..27a3e8f5 100644
--- a/testing/helper/test-keys.c
+++ b/testing/helper/test-keys.c
@@ -31,7 +31,7 @@ static void puthex(const __u8 *b, size_t n)
int main(int argc, char **argv)
{
- struct shirudo_trusted_set set;
+ struct trusted_set set;
__u8 digest[32];
size_t i;
int ret;
@@ -43,8 +43,8 @@ int main(int argc, char **argv)
return 2;
}
if (strcmp(argv[1], "signer") == 0) {
- struct shirudo_cert cert = {};
- struct shirudo_upatch u;
+ struct cert cert = {};
+ struct upatch u;
if (argc < 4 || upatch_open(argv[2], &u)) {
fprintf(stderr, "usage: signer <upatch> <cert.der>\n");
diff --git a/testing/helper/test-mode-objects.c b/testing/helper/test-mode-objects.c
index 8752edb4..39100825 100644
--- a/testing/helper/test-mode-objects.c
+++ b/testing/helper/test-mode-objects.c
@@ -10,7 +10,7 @@
#include "util/loader.h"
static int symbols(const char *selection,
- const struct shirudo_embedded_bpf *blob)
+ const struct embedded_bpf *blob)
{
Elf_Scn *section = NULL;
Elf *elf;
@@ -60,7 +60,7 @@ static int symbols(const char *selection,
}
static int inspect(const char *selection,
- const struct shirudo_embedded_bpf *blob)
+ const struct embedded_bpf *blob)
{
struct bpf_program *program;
struct bpf_object *obj;
diff --git a/testing/helper/test-nv-cphash.c b/testing/helper/test-nv-cphash.c
index 3e519c6f..06d52d80 100644
--- a/testing/helper/test-nv-cphash.c
+++ b/testing/helper/test-nv-cphash.c
@@ -89,7 +89,7 @@ out:
return ret;
}
-static int authorize(struct shirudo_tpm *t, ESYS_TR writer, ESYS_TR nv,
+static int authorize(struct tpm *t, ESYS_TR writer, ESYS_TR nv,
const __u8 event[32], const __u8 policy[32],
ESYS_TR *session, __u8 saved[TPM_NV_RSA_BYTES],
enum signature_fault fault)
@@ -150,7 +150,7 @@ int main(void)
TPM2B_MAX_NV_BUFFER seed = { .size = 32 };
ESYS_TR session = ESYS_TR_NONE;
ESYS_TR writer = ESYS_TR_NONE;
- struct shirudo_tpm *t = NULL;
+ struct tpm *t = NULL;
ESYS_CONTEXT *esys = NULL;
ESYS_TR nv = ESYS_TR_NONE;
__u8 writer_seed[32];
diff --git a/testing/helper/test-nv-writer.c b/testing/helper/test-nv-writer.c
index 23968919..4695f53c 100644
--- a/testing/helper/test-nv-writer.c
+++ b/testing/helper/test-nv-writer.c
@@ -17,7 +17,7 @@
static int public_matches_init(const char *hex)
{
__u8 expected[TPM_NV_RSA_BYTES];
- struct shirudo_eventlog_init rec;
+ struct eventlog_init rec;
if (strlen(hex) != 2 * sizeof(expected) ||
hex_decode(hex, expected, sizeof(expected))) {
diff --git a/testing/helper/test-otel-map.c b/testing/helper/test-otel-map.c
index 7b8b4a91..f6e6c387 100644
--- a/testing/helper/test-otel-map.c
+++ b/testing/helper/test-otel-map.c
@@ -29,8 +29,8 @@
const char shirudo_version[] = "test-1";
struct fixture {
- struct shirudo_map_view view;
- struct shirudo_map_entry entry;
+ struct map_view view;
+ struct map_entry entry;
struct btf *btf;
__u32 key;
__u8 values[16];
@@ -68,22 +68,22 @@ static int make_decoder(bool metric, bool counter, bool snapshot,
const char *source = snapshot ? snapshot_source : metric ?
(counter ? counter_source : gauge_source) : log_source;
size_t source_len = strlen(source);
- size_t entries_end = sizeof(struct shirudo_upatch_decoder_blob) +
- sizeof(struct shirudo_upatch_decoder_entry);
+ size_t entries_end = sizeof(struct upatch_decoder_blob) +
+ sizeof(struct upatch_decoder_entry);
size_t decoder_len = entries_end + source_len;
size_t dir_off = (decoder_len + 7) & ~(size_t)7;
size_t data_len = dir_off +
- sizeof(struct shirudo_upatch_signed_section) +
- sizeof(struct shirudo_upatch_signed_trailer);
- size_t loader_off = sizeof(struct shirudo_upatch_header);
+ sizeof(struct upatch_signed_section) +
+ sizeof(struct upatch_signed_trailer);
+ size_t loader_off = sizeof(struct upatch_header);
size_t sig_off = loader_off + sizeof(struct bpf_insn);
size_t data_off = sig_off + 1;
size_t file_len = data_off + data_len;
- struct shirudo_upatch_signed_section section = {};
- struct shirudo_upatch_signed_trailer trailer = {};
- struct shirudo_upatch_decoder_entry entry = {};
- struct shirudo_upatch_decoder_blob blob = {};
- struct shirudo_upatch_header header = {};
+ struct upatch_signed_section section = {};
+ struct upatch_signed_trailer trailer = {};
+ struct upatch_decoder_entry entry = {};
+ struct upatch_decoder_blob blob = {};
+ struct upatch_header header = {};
__u8 *file;
char template[] = "/tmp/test-otel-map-decoder-XXXXXX";
int fd, ret;
@@ -215,7 +215,7 @@ static int print_classification(__u32 type, bool is_signed, bool with_btf,
bool serialized)
{
struct fixture f;
- enum shirudo_otel_signal signal;
+ enum otel_signal signal;
char reason[160];
int ret = fixture_init(&f, type, is_signed, with_btf);
@@ -266,7 +266,7 @@ static int print_payload(bool metric, bool counter, bool with_location)
static int print_local_json(void)
{
struct fixture f;
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char buf[4096];
if (fixture_init(&f, BPF_MAP_TYPE_PERCPU_ARRAY, false, true))
@@ -285,7 +285,7 @@ static int print_local_json(void)
static int send_log_limits(const char *url, __u32 retries, __u32 record_max,
__u32 request_max, bool use_environment)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.endpoint = use_environment ? NULL : url,
.retries = retries,
.log_record_max_bytes = record_max,
@@ -311,7 +311,7 @@ static int send_log_limits(const char *url, __u32 retries, __u32 record_max,
static int send_log(const char *url, __u32 retries, bool insecure)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.endpoint = url,
.allow_insecure = insecure,
.retries = retries,
@@ -362,7 +362,7 @@ static int print_record_size(void)
static int send_auto(const char *base, bool is_signed)
{
- struct shirudo_otel_opts opts = { .endpoint = base, .retries = 0 };
+ struct otel_opts opts = { .endpoint = base, .retries = 0 };
struct fixture f;
char decoder_path[128] = {};
int ret;
@@ -382,7 +382,7 @@ static int send_auto(const char *base, bool is_signed)
static int send_metric(const char *url)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.endpoint = url,
.retries = 0,
};
@@ -405,7 +405,7 @@ static int send_metric(const char *url)
static int send_status(const char *url, const char *status)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.endpoint = url,
.retries = 0,
};
@@ -427,7 +427,7 @@ static int send_status(const char *url, const char *status)
static int send_metric_env(void)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.retries = 0,
};
struct fixture f;
@@ -461,7 +461,7 @@ static bool large_serialized_fixture(struct fixture *f)
if (!f->view.serial_pages)
return false;
for (__u32 i = 0; i < pages; i++) {
- struct shirudo_serial_page *page = &f->view.serial_pages[i];
+ struct serial_page *page = &f->view.serial_pages[i];
page->page_index = i;
page->cursor = i;
@@ -492,7 +492,7 @@ static void large_serialized_destroy(struct fixture *f)
static int send_s3(const char *endpoint, __u32 retries, bool large)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.s3_uri = getenv("SHIRUDO_TEST_S3_URI") ?
getenv("SHIRUDO_TEST_S3_URI") : "s3://test-bucket/prefix",
.tenant_id = large ? NULL : "tenant-uuid-1234",
@@ -529,7 +529,7 @@ static int send_s3(const char *endpoint, __u32 retries, bool large)
static int tenant_validation(void)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.endpoint = "http://127.0.0.1:1",
.retries = 0,
};
@@ -566,7 +566,7 @@ static int tenant_validation(void)
static int s3_validation(void)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.s3_uri = "s3://test-bucket/prefix",
.retries = 0,
};
@@ -637,7 +637,7 @@ fail:
static int security_check(void)
{
- struct shirudo_otel_opts opts = {
+ struct otel_opts opts = {
.endpoint = "http://collector.example",
.retries = 0,
};
diff --git a/testing/helper/test-register.c b/testing/helper/test-register.c
index f1e2c041..1881ce86 100644
--- a/testing/helper/test-register.c
+++ b/testing/helper/test-register.c
@@ -34,7 +34,7 @@
static int writer_create(void)
{
struct bpf_map_create_opts opts = { .sz = sizeof(opts) };
- struct shirudo_identity id = {};
+ struct identity id = {};
int fd, ret;
__u32 zero = 0;
@@ -79,11 +79,11 @@ static void puthex(const __u8 *b, size_t n)
/* Record an init the way shirudo init does, minus the set details. */
static int append_init(const __u8 event[32],
- const struct shirudo_chain_init_info *info)
+ const struct chain_init_info *info)
{
char buf[4096], ts[32], boot_id[64], nv_index[16];
char hex[2 * TPM_NV_RSA_BYTES + 1];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
eventlog_timestamp(ts, sizeof(ts));
eventlog_boot_id(boot_id, sizeof(boot_id));
@@ -125,7 +125,7 @@ static int append_event(const char *type, const char *name,
const __u8 chain[32])
{
char buf[4096], ts[32], boot_id[64], nv_index[16], hex[65];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
eventlog_timestamp(ts, sizeof(ts));
eventlog_boot_id(boot_id, sizeof(boot_id));
@@ -157,7 +157,7 @@ static int append_tree(__s64 seq, const char *op, const char *id,
const __u8 chain[32])
{
char buf[4096], ts[32], boot_id[64], nv_index[16], hex[65];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
eventlog_timestamp(ts, sizeof(ts));
eventlog_boot_id(boot_id, sizeof(boot_id));
@@ -208,7 +208,7 @@ int main(int argc, char **argv)
}
if (strcmp(argv[1], "init") == 0 && argc == 3) {
- struct shirudo_chain_init_info info;
+ struct chain_init_info info;
if (hex_decode(argv[2], event, 32))
return 2;
@@ -302,7 +302,7 @@ int main(int argc, char **argv)
}
/* A measurement into a PCR, as systemd's boot phases make them. */
if (strcmp(argv[1], "pcr-extend") == 0 && argc == 4) {
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
__u8 d[32];
if (hex_decode(argv[3], d, 32) || tpm_open(&tpm))
@@ -313,7 +313,7 @@ int main(int argc, char **argv)
return ret ? 1 : 0;
}
if (strcmp(argv[1], "pcr") == 0 && argc == 3) {
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
__u8 v[32];
if (tpm_open(&tpm))
@@ -330,8 +330,8 @@ int main(int argc, char **argv)
* presents it.
*/
if (strcmp(argv[1], "ek-public") == 0 && argc == 3) {
- struct shirudo_tpm_key ek = { .handle = 0 };
- struct shirudo_tpm *tpm = NULL;
+ struct tpm_key ek = { .handle = 0 };
+ struct tpm *tpm = NULL;
if (tpm_open(&tpm))
return 1;
@@ -351,7 +351,7 @@ int main(int argc, char **argv)
/* The attack: recreate the index with the same public area. */
if (strcmp(argv[1], "recreate") == 0) {
struct tpm_nv_info nv;
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
if (tpm_open(&tpm))
return 1;
@@ -375,8 +375,8 @@ int main(int argc, char **argv)
/* The attack: try the init branch again after the anchor. */
if (strcmp(argv[1], "first-write") == 0 && argc == 3) {
__u8 branch_written[32], branch_init[32], policy[32];
- struct shirudo_eventlog_init rec;
- struct shirudo_tpm *tpm = NULL;
+ struct eventlog_init rec;
+ struct tpm *tpm = NULL;
__u8 writer_public[TPM_NV_RSA_BYTES];
__u8 writer_seed[32], values[64];
@@ -413,20 +413,20 @@ int main(int argc, char **argv)
* real register's place.
*/
if (strcmp(argv[1], "forge") == 0 && argc == 7) {
- struct shirudo_tpm_key ak = { .handle = 0 }, ek = { .handle = 0 };
+ struct tpm_key ak = { .handle = 0 }, ek = { .handle = 0 };
char hex[2 * TPM_ATTEST_MAX + 1], buf[32 * 1024];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
- struct shirudo_tpm_attestation quote = {}, certify = {};
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct tpm_attestation quote = {}, certify = {};
__u8 values[24][32] = {}, before[64], anchor_digest[32];
__u8 branch_written[32], branch_init[32], policy[32];
__u32 index, pcr, phase, mask, quoted, reset = 0, i;
- struct shirudo_tpm_key ak_copy = {}, ek_copy = {};
+ struct tpm_key ak_copy = {}, ek_copy = {};
__u8 writer_public[TPM_NV_RSA_BYTES];
char ts[32], boot_id[64], nv_index[16];
__u8 writer_seed[TPM_DIGEST_LEN];
size_t nonce_len = strlen(argv[6]) / 2;
char anchor[CHAIN_ANCHOR_MAX];
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
__u8 value[32], nonce[64];
struct tpm_nv_info nv;
@@ -593,7 +593,7 @@ int main(int argc, char **argv)
return 0;
}
if (strcmp(argv[1], "evidence") == 0 && (argc == 3 || argc == 4)) {
- struct shirudo_attest_challenge challenge = {};
+ struct attest_challenge challenge = {};
__u8 nonce[64];
size_t nonce_len = strlen(argv[2]) / 2, len, cap;
char *doc;
diff --git a/testing/helper/test-signed-load.c b/testing/helper/test-signed-load.c
index 4df505d4..5384051e 100644
--- a/testing/helper/test-signed-load.c
+++ b/testing/helper/test-signed-load.c
@@ -39,7 +39,7 @@ static long sys_bpf(int cmd, union bpf_attr *a)
int main(int argc, char **argv)
{
- const struct shirudo_upatch_header *h;
+ const struct upatch_header *h;
__u8 *m, cert[16384]; /* an ML-DSA-87 cert is ~7.5 KiB */
const void *insns, *sig;
int ufd, cfd, cn, prog_fd;
@@ -62,7 +62,7 @@ int main(int argc, char **argv)
fprintf(stderr, "mmap: %s\n", strerror(errno));
return 2;
}
- h = (const struct shirudo_upatch_header *)m;
+ h = (const struct upatch_header *)m;
insns = m + get_le32(&h->loader_insns_off);
sig = m + get_le32(&h->signature_off);
diff --git a/testing/helper/test-tpm-preopened.c b/testing/helper/test-tpm-preopened.c
index 30ebfbed..8f18be94 100644
--- a/testing/helper/test-tpm-preopened.c
+++ b/testing/helper/test-tpm-preopened.c
@@ -13,7 +13,7 @@
static int read_register(__u8 out[TPM_DIGEST_LEN])
{
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
int ret;
if (tpm_open(&tpm))
diff --git a/testing/helper/test-tpm-wire.c b/testing/helper/test-tpm-wire.c
index a639036b..0c30fdd1 100644
--- a/testing/helper/test-tpm-wire.c
+++ b/testing/helper/test-tpm-wire.c
@@ -157,7 +157,7 @@ int main(int argc, char **argv)
return 0;
}
if (strcmp(argv[1], "ecc-public") == 0 && argc == 3) {
- struct shirudo_tpm_ecc_public pub;
+ struct tpm_ecc_public pub;
int ret;
if (gethex(argv[2], buf, sizeof(buf), &len))
@@ -173,7 +173,7 @@ int main(int argc, char **argv)
return 0;
}
if (strcmp(argv[1], "public") == 0 && argc == 3) {
- struct shirudo_tpm_public pub;
+ struct tpm_public pub;
__u8 again[512];
size_t again_len = 0;
int ret;
@@ -256,7 +256,7 @@ int main(int argc, char **argv)
return 0;
}
if (strcmp(argv[1], "attest") == 0 && argc == 3) {
- struct shirudo_tpm_attest at;
+ struct tpm_attest at;
int ret;
if (gethex(argv[2], buf, sizeof(buf), &len))
diff --git a/testing/helper/test-upatch-decode.c b/testing/helper/test-upatch-decode.c
index f33b5c38..1cb77dbb 100644
--- a/testing/helper/test-upatch-decode.c
+++ b/testing/helper/test-upatch-decode.c
@@ -33,7 +33,7 @@ static int dump(const char *source)
int main(int argc, char **argv)
{
- struct shirudo_map_view view = {
+ struct map_view view = {
.serialized = true,
.max_entries = 1,
.type_name = "array",
diff --git a/testing/helper/test-upatch-prog-metadata.c b/testing/helper/test-upatch-prog-metadata.c
index 0a595688..6c70d4c0 100644
--- a/testing/helper/test-upatch-prog-metadata.c
+++ b/testing/helper/test-upatch-prog-metadata.c
@@ -20,11 +20,11 @@ static int fail(const char *msg)
return 1;
}
-static int expect_attach(const struct shirudo_upatch *u, __u32 kind,
+static int expect_attach(const struct upatch *u, __u32 kind,
const char *target, __u64 offset)
{
- struct shirudo_upatch_prog_metadata md;
- struct shirudo_upatch_prog_entry prog;
+ struct upatch_prog_metadata md;
+ struct upatch_prog_entry prog;
const __u8 *raw;
__u32 len;
@@ -61,10 +61,10 @@ static int expect_attach(const struct shirudo_upatch *u, __u32 kind,
return 0;
}
-static int expect_serializer(const struct shirudo_upatch *u)
+static int expect_serializer(const struct upatch *u)
{
- struct shirudo_upatch_prog_entry progs[2];
- struct shirudo_upatch_prog_metadata md;
+ struct upatch_prog_entry progs[2];
+ struct upatch_prog_metadata md;
bool arena = false, error = false;
const __u8 *raw;
size_t i;
@@ -97,14 +97,14 @@ static int expect_serializer(const struct shirudo_upatch *u)
return arena && error ? 0 : fail("serializer map mismatch");
}
-static int expect_uprobe_multi(const struct shirudo_upatch *u,
+static int expect_uprobe_multi(const struct upatch *u,
const char *path, const char *pattern,
__u32 expected_offsets)
{
- struct shirudo_upatch_uprobe_targets targets;
- struct shirudo_upatch_uprobe_target record;
- struct shirudo_upatch_prog_metadata md;
- struct shirudo_upatch_prog_entry prog;
+ struct upatch_uprobe_targets targets;
+ struct upatch_uprobe_target record;
+ struct upatch_prog_metadata md;
+ struct upatch_prog_entry prog;
const __u8 *raw, *cursor, *end;
__u32 path_len, build_id_len, nr_offsets, len, i;
__u64 previous = 0;
@@ -162,7 +162,7 @@ static int expect_uprobe_multi(const struct shirudo_upatch *u,
int main(int argc, char **argv)
{
- struct shirudo_upatch u;
+ struct upatch u;
const char *mode = "serializer";
int ret;
diff --git a/testing/helper/test-upatch-serializer-pages.c b/testing/helper/test-upatch-serializer-pages.c
index 75757d27..26cd728f 100644
--- a/testing/helper/test-upatch-serializer-pages.c
+++ b/testing/helper/test-upatch-serializer-pages.c
@@ -32,7 +32,7 @@ static int has(const char *haystack, const char *needle)
static int check_abi_and_nonce(void)
{
__u64 generated = 0;
- struct shirudo_serial_chunk chunk = {
+ struct serial_chunk chunk = {
.magic = SERIAL_MAGIC,
.version = SERIAL_VERSION,
.chunk_index = 1,
@@ -46,8 +46,8 @@ static int check_abi_and_nonce(void)
};
if (SERIAL_VERSION != 1 ||
- sizeof(struct shirudo_serialize_ctx) != 40 ||
- sizeof(struct shirudo_serial_chunk) != 4096 ||
+ sizeof(struct serialize_ctx) != 40 ||
+ sizeof(struct serial_chunk) != 4096 ||
SERIAL_CHUNK_PAYLOAD != 4032)
return fail("serializer v1 ABI layout mismatch");
if (serial_chunk_validate(&chunk, 1, 2, 3, 10, 11, 0x12345678) != 0)
@@ -111,7 +111,7 @@ int main(void)
{
__u8 page0_data[] = { 0xaa, 0xbb };
__u8 page1_data[] = { 0xcc };
- struct shirudo_serial_page pages[2] = {
+ struct serial_page pages[2] = {
{
.page_index = 0,
.cursor = 0,
@@ -133,7 +133,7 @@ int main(void)
.data = page1_data,
},
};
- struct shirudo_map_view v = {
+ struct map_view v = {
.name = "tree_arena",
.type_name = "arena",
.max_entries = 32,
@@ -142,7 +142,7 @@ int main(void)
.serial_bytes_total = sizeof(page0_data) + sizeof(page1_data),
.serial_pages = pages,
};
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char buf[2048];
char doc[4096];
@@ -179,7 +179,7 @@ int main(void)
if (has(buf, "\"serialized_chunks\""))
return fail("old chunk field still emitted");
- e = (struct shirudo_json_emit){ .buf = doc, .cap = sizeof(doc) };
+ e = (struct json_emit){ .buf = doc, .cap = sizeof(doc) };
json_obj_open(&e);
json_kv_int(&e, "schema", 1);
json_kv_string(&e, "upatch", "exec-uid-arena");
diff --git a/testing/unit/json.c b/testing/unit/json.c
index a9982d47..e8f2e801 100644
--- a/testing/unit/json.c
+++ b/testing/unit/json.c
@@ -43,19 +43,19 @@ static int event_on_elem(void *ctx)
static int parse_len(const char *text, size_t len, struct doc *d)
{
- struct shirudo_json_array event_sink = { event_on_elem, d };
- struct shirudo_json_array name_sink = { name_on_elem, d };
- struct shirudo_json_field name_sub[] = {
+ struct json_array event_sink = { event_on_elem, d };
+ struct json_array name_sink = { name_on_elem, d };
+ struct json_field name_sub[] = {
{ "", SHIRUDO_JSON_T_STRING, d->name, sizeof(d->name),
0, NULL, 0 },
};
- struct shirudo_json_field event_sub[] = {
+ struct json_field event_sub[] = {
{ "type", SHIRUDO_JSON_T_STRING, d->ev_type,
sizeof(d->ev_type), 0, NULL, 0 },
{ "digest", SHIRUDO_JSON_T_STRING, d->ev_digest,
sizeof(d->ev_digest), 0, NULL, 0 },
};
- struct shirudo_json_field f[] = {
+ struct json_field f[] = {
{ "schema", SHIRUDO_JSON_T_INT, &d->schema, 0, 0, NULL, 0 },
{ "type", SHIRUDO_JSON_T_STRING, d->type, sizeof(d->type),
0, NULL, 0 },
diff --git a/tools/shirudo-build/bpm-build.c b/tools/shirudo-build/bpm-build.c
index 8ddea057..8003cc44 100644
--- a/tools/shirudo-build/bpm-build.c
+++ b/tools/shirudo-build/bpm-build.c
@@ -266,10 +266,10 @@ static int build_parse_string_array(const char *value,
}
static int build_parse_selector_kv(const char *key, const char *value,
- struct shirudo_tree_selector_kv *kvs,
+ struct tree_selector_kv *kvs,
int max, int *n)
{
- struct shirudo_tree_selector_kv *kv;
+ struct tree_selector_kv *kv;
size_t key_len = strlen(key);
if (key_len >= 2 && (key[0] == '"' || key[0] == '\'') &&
@@ -361,7 +361,7 @@ static int build_parse_spec(struct bpm_build_spec *spec, char *body)
{
struct bpm_build_upatch *upatch = NULL, *tree_owner = NULL;
struct bpm_build_rodata *rodata = NULL;
- struct shirudo_tree_selector *sel = NULL;
+ struct tree_selector *sel = NULL;
struct bpm_build_file *file = NULL;
bool tree_section = false;
char *save = NULL, *line;
@@ -1166,7 +1166,7 @@ static int build_upatches(struct bpm_build_spec *spec, const char *pkey,
struct bpm_build_upatch *u = &spec->upatches[i];
const char *bpf_o = source, *src_path = NULL;
__u8 payload[CRYPTO_SHA256_LEN];
- struct shirudo_upatch parsed = {};
+ struct upatch parsed = {};
int ret;
if (build_resolve_source(spec, u->source, source, sizeof(source),
@@ -1241,7 +1241,7 @@ static int build_environment(const struct bpm_build_spec *spec,
__u8 **out, size_t *out_len)
{
char *body = xmalloc(BPM_BUILD_MAX_JSON);
- struct shirudo_json_emit e = { .buf = body, .cap = BPM_BUILD_MAX_JSON };
+ struct json_emit e = { .buf = body, .cap = BPM_BUILD_MAX_JSON };
struct utsname un = {};
char self[PATH_MAX] = "shirudo";
char timestamp[32] = {};
@@ -1514,7 +1514,7 @@ static int build_bpm_build(int argc, char **argv)
char keys_abs[PATH_MAX], pkey[PATH_MAX], cert_path[PATH_MAX];
char fingerprint[CRYPTO_SHA256_LEN * 2 + 1];
__u8 digest[CRYPTO_SHA256_LEN];
- struct shirudo_cert cert = {};
+ struct cert cert = {};
struct bpm_build_spec *spec;
int positional = 0, ret;
char out_dir[PATH_MAX];
@@ -1810,7 +1810,7 @@ static int build_bpm_config_update(int argc, char **argv)
char out_dir[PATH_MAX], pkey[PATH_MAX], cert_path[PATH_MAX];
char fingerprint[CRYPTO_SHA256_LEN * 2 + 1];
__u8 digest[CRYPTO_SHA256_LEN], *body = NULL;
- struct shirudo_cert cert = {};
+ struct cert cert = {};
struct bpm_package_info base_info = {};
struct bpm_build_spec *spec;
size_t body_len = 0;
@@ -2022,7 +2022,7 @@ static int build_bpm_config_update(int argc, char **argv)
struct bpm_build_upatch *upatch = &spec->upatches[i];
char load[PATH_MAX], unload[PATH_MAX];
char expected_name[UPATCH_NAME_MAX];
- struct shirudo_upatch parsed = {};
+ struct upatch parsed = {};
__u8 payload[CRYPTO_SHA256_LEN];
if (strsprintf(load, sizeof(load), "%s/update-%zu.upatch",
diff --git a/tools/shirudo-build/bpm-publish.c b/tools/shirudo-build/bpm-publish.c
index 42801bac..3df7e969 100644
--- a/tools/shirudo-build/bpm-publish.c
+++ b/tools/shirudo-build/bpm-publish.c
@@ -68,7 +68,7 @@ static int sign_detached(const void *payload, size_t len,
const char *key, const char *cert,
__u8 **sig, size_t *sig_len)
{
- struct shirudo_sign_io io = {
+ struct sign_io io = {
.insns = payload, .insns_sz = len, .signature_sz = BPM_SIGN_MAX,
};
int ret;
@@ -164,7 +164,7 @@ static int push_index(struct bpm_oci_client *c, const char *repository,
struct bpm_descriptor config, payload_layer, sig_layer;
struct bpm_index_entry *entries, *entry = NULL;
char *body = NULL, *manifest = NULL;
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char timestamp[32], digest[72];
char empty_config[] = "{}";
size_t cap, sig_len = 0;
@@ -219,7 +219,7 @@ static int push_index(struct bpm_oci_client *c, const char *repository,
ret = -ENOMEM;
goto out;
}
- e = (struct shirudo_json_emit){ .buf = body, .cap = cap };
+ e = (struct json_emit){ .buf = body, .cap = cap };
json_obj_open(&e);
json_kv_int(&e, "schema", 1);
json_kv_string(&e, "generated_at", timestamp);
@@ -262,7 +262,7 @@ static int push_index(struct bpm_oci_client *c, const char *repository,
ret = -ENOMEM;
goto out;
}
- e = (struct shirudo_json_emit){ .buf = manifest, .cap = BPM_MANIFEST_CAP };
+ e = (struct json_emit){ .buf = manifest, .cap = BPM_MANIFEST_CAP };
json_obj_open(&e);
json_kv_int(&e, "schemaVersion", 2);
json_kv_string(&e, "mediaType", BPM_MANIFEST_MEDIA);
@@ -297,7 +297,7 @@ static int push_package(const char *package_path, const char *raw_repository,
struct bpm_oci_client c = {};
struct bpm_package_info info = {};
struct bpm_descriptor config, layer, key_config, key_layer, subject;
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
__u8 *archive = NULL, *manifest = NULL;
const char *base;
char repository[BPM_MAX_ENDPOINT], package_digest[72], key_digest[72];
@@ -411,7 +411,7 @@ static int push_package(const char *package_path, const char *raw_repository,
ret = -ENOMEM;
goto out;
}
- e = (struct shirudo_json_emit){ .buf = key_manifest_body, .cap = BPM_MANIFEST_CAP };
+ e = (struct json_emit){ .buf = key_manifest_body, .cap = BPM_MANIFEST_CAP };
json_obj_open(&e);
json_kv_int(&e, "schemaVersion", 2);
json_kv_string(&e, "mediaType", "application/vnd.oci.image.manifest.v1+json");
@@ -478,7 +478,7 @@ static int tree_string_compare(const void *left, const void *right)
}
/* Selector lists are sets: sort them so equal Beefiles digest equally. */
-static void tree_selector_canonicalize(struct shirudo_tree_selector *s)
+static void tree_selector_canonicalize(struct tree_selector *s)
{
qsort(s->kernel_release_prefix, (size_t)s->n_kernel_release_prefix,
TREE_STRING_MAX, tree_string_compare);
@@ -504,14 +504,14 @@ static int tree_push_artifact(struct bpm_oci_client *c, const char *repository,
const char *raw_repository,
const __u8 *body, size_t len,
const char *id, bool unload,
- struct shirudo_tree_artifact *out)
+ struct tree_artifact *out)
{
char name[UPATCH_NAME_MAX + 1], title[UPATCH_NAME_MAX + 16];
char temporary[] = "/tmp/shirudo-bpm-tree-XXXXXX";
struct bpm_descriptor layer, config;
char empty_config[] = "{}";
- struct shirudo_json_emit e;
- struct shirudo_upatch u;
+ struct json_emit e;
+ struct upatch u;
char hex[65], tag[160];
char *manifest;
int fd, ret;
@@ -556,7 +556,7 @@ static int tree_push_artifact(struct bpm_oci_client *c, const char *repository,
manifest = xmalloc(BPM_MANIFEST_CAP);
if (!manifest)
return -ENOMEM;
- e = (struct shirudo_json_emit){ .buf = manifest, .cap = BPM_MANIFEST_CAP };
+ e = (struct json_emit){ .buf = manifest, .cap = BPM_MANIFEST_CAP };
json_obj_open(&e);
json_kv_int(&e, "schemaVersion", 2);
json_kv_string(&e, "mediaType", BPM_MANIFEST_MEDIA);
@@ -595,15 +595,15 @@ static int cmd_bpm_tree_append(int argc, char **argv)
const char *reference = "stable", *operation = "add";
char key_path[PATH_MAX], cert_path[PATH_MAX];
char parent[BPM_MAX_DIGEST] = {}, digest[72];
- struct shirudo_tree_publication pub = {};
- struct shirudo_tree_operation *op = NULL;
+ struct tree_publication pub = {};
+ struct tree_operation *op = NULL;
size_t len, payload_len = 0, sig_len = 0;
char *payload = NULL, *manifest = NULL;
struct bpm_build_spec *spec = NULL;
__u8 *beefile = NULL, *sig = NULL;
struct bpm_package_info info = {};
struct bpm_oci_client c = {};
- struct shirudo_json_emit e;
+ struct json_emit e;
char empty_config[] = "{}";
char package_dir[101];
int appended = 0, ret;
@@ -710,7 +710,7 @@ static int cmd_bpm_tree_append(int argc, char **argv)
ret = bpm_tree_fetch_publication(&c, repository, reference, cert, &pub,
parent, sizeof(parent));
if (ret == -ENOENT) {
- pub = (struct shirudo_tree_publication){ .schema = 1,
+ pub = (struct tree_publication){ .schema = 1,
.generation = 1 };
parent[0] = '\0';
if (tree_id)
@@ -754,7 +754,7 @@ static int cmd_bpm_tree_append(int argc, char **argv)
pr_err("bpm tree append: package entry %s not found", member);
goto out;
}
- *op = (struct shirudo_tree_operation){ .seq = pub.head_seq + 1 };
+ *op = (struct tree_operation){ .seq = pub.head_seq + 1 };
bpm_copy_string(op->op, sizeof(op->op), operation);
bpm_copy_string(op->id, sizeof(op->id), u->tree.id);
if (u->tree.selector)
@@ -802,7 +802,7 @@ static int cmd_bpm_tree_append(int argc, char **argv)
ret = -ENOMEM;
goto out;
}
- e = (struct shirudo_json_emit){ .buf = manifest, .cap = BPM_MANIFEST_CAP };
+ e = (struct json_emit){ .buf = manifest, .cap = BPM_MANIFEST_CAP };
json_obj_open(&e);
json_kv_int(&e, "schemaVersion", 2);
json_kv_string(&e, "mediaType", BPM_MANIFEST_MEDIA);
diff --git a/tools/shirudo-build/bpm.h b/tools/shirudo-build/bpm.h
index 1ec292cd..7ca03f10 100644
--- a/tools/shirudo-build/bpm.h
+++ b/tools/shirudo-build/bpm.h
@@ -52,7 +52,7 @@ struct bpm_build_tree {
char id[UPATCH_NAME_MAX];
char load_artifact[PATH_MAX];
char unload_artifact[PATH_MAX];
- struct shirudo_tree_selector *selector;
+ struct tree_selector *selector;
};
struct bpm_build_upatch {
diff --git a/tools/shirudo-build/image.c b/tools/shirudo-build/image.c
index 4b1b6482..614677e2 100644
--- a/tools/shirudo-build/image.c
+++ b/tools/shirudo-build/image.c
@@ -115,7 +115,7 @@ static int verify_verity(int data_fd, int hash_fd, const char *root)
static int verify_root_signature(const char root[65], const __u8 *signature,
size_t size, const char *path)
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
char algorithm[32];
int ret;
@@ -181,7 +181,7 @@ static int sign_root(const char *input, const char *output, const char *pkey,
const char *cert)
{
__u8 signature[CONFIG_IMAGE_SIG_MAX];
- struct shirudo_sign_io sign = {};
+ struct sign_io sign = {};
char root[65] = {};
size_t done = 0;
struct stat st;
diff --git a/tools/shirudo-build/package.c b/tools/shirudo-build/package.c
index b530079d..2062dff8 100644
--- a/tools/shirudo-build/package.c
+++ b/tools/shirudo-build/package.c
@@ -49,12 +49,12 @@
static struct bpf_map *find_rodata(struct bpf_object *obj);
-struct shirudo_data_range {
+struct data_range {
__u32 offset;
__u32 length;
};
-struct shirudo_unload_params {
+struct unload_params {
char name[UPATCH_NAME_MAX];
__u8 expected_sha256[UPATCH_PAYLOAD_HASH_LEN];
};
@@ -82,7 +82,7 @@ struct decoder_set {
__u32 nr_items;
};
-static void pack_header(struct shirudo_upatch_header *h,
+static void pack_header(struct upatch_header *h,
const char *name, __u32 type, __u32 flags,
const __u8 *payload_sha256,
__u32 loader_off, __u32 loader_len,
@@ -138,7 +138,7 @@ static bool output_is_input(int fd, const char *original,
* The CMS covers the loader and the data but not the header, whose
* payload digest the target measures, so the digest is compared as well.
*/
-static int verify_payload(const struct shirudo_upatch *u,
+static int verify_payload(const struct upatch *u,
const char *cert_path)
{
__u8 digest[SHA256_LEN], *payload;
@@ -169,15 +169,15 @@ static int verify_payload(const struct shirudo_upatch *u,
static int package_resign_symbols(const char *original,
const char *modified, const char *output,
- const struct shirudo_data_range *ranges,
+ const struct data_range *ranges,
size_t nr_ranges, const char *const *symbols,
size_t nr_symbols, const char *pkey_path,
const char *cert_path)
{
- struct shirudo_upatch_header hdr;
- struct shirudo_sign_io sio = {};
- struct shirudo_upatch src = {}, mod = {};
- struct shirudo_rodata_range expected[16] = {};
+ struct upatch_header hdr;
+ struct sign_io sio = {};
+ struct upatch src = {}, mod = {};
+ struct rodata_range expected[16] = {};
const __u8 *src_data, *mod_data;
bool range_found[16] = {};
char name[UPATCH_NAME_MAX + 1];
@@ -347,7 +347,7 @@ out:
static int build_package_resign(const char *original,
const char *modified,
const char *output,
- const struct shirudo_data_range *ranges,
+ const struct data_range *ranges,
size_t nr_ranges, const char *pkey_path,
const char *cert_path)
{
@@ -365,9 +365,9 @@ int build_package_patch_rodata(const char *input, const char *output,
size_t value_len, const char *pkey_path,
const char *cert_path)
{
- struct shirudo_upatch src = {};
- struct shirudo_rodata_range range = {};
- struct shirudo_data_range allowed = {};
+ struct upatch src = {};
+ struct rodata_range range = {};
+ struct data_range allowed = {};
const char *symbols[1] = { symbol };
char modified[] = "/tmp/shirudo-rodata-XXXXXX";
__u8 *candidate = NULL;
@@ -435,7 +435,7 @@ out:
int build_package_verify(const char *input, const char *cert_path)
{
- struct shirudo_upatch upatch = {};
+ struct upatch upatch = {};
int ret;
ret = upatch_open(input, &upatch);
@@ -453,7 +453,7 @@ int build_upatch_cli(int argc, char **argv)
const char *output = NULL;
const char *pkey = SIGNING_KEY_PATH;
const char *cert = CERT_PATH;
- struct shirudo_data_range ranges[16] = {};
+ struct data_range ranges[16] = {};
char pkey_buf[PATH_MAX], cert_buf[PATH_MAX];
int pkey_explicit = 0, cert_explicit = 0;
size_t nr_ranges = 0;
@@ -836,7 +836,7 @@ static int make_decoder_path(const char *src_path, const char *rel,
static bool parse_decoder_manifest(const __u8 *p, size_t n,
struct decoder_manifest_view *out)
{
- const struct shirudo_decoder_manifest *m = (const void *)p;
+ const struct decoder_manifest *m = (const void *)p;
if (n < sizeof(*m))
return false;
@@ -936,10 +936,10 @@ static int collect_decoder_manifests(struct bpf_object *obj,
if (!rodata)
return 0;
data = bpf_map__initial_value(rodata, &data_sz);
- if (!data || data_sz < sizeof(struct shirudo_decoder_manifest))
+ if (!data || data_sz < sizeof(struct decoder_manifest))
return 0;
- for (off = 0; off + sizeof(struct shirudo_decoder_manifest) <= data_sz;
+ for (off = 0; off + sizeof(struct decoder_manifest) <= data_sz;
off += 4) {
struct decoder_manifest_view manifest;
@@ -993,7 +993,7 @@ err_free:
static int build_decoder_blob(const struct decoder_set *set,
void **out, __u32 *out_len)
{
- struct shirudo_upatch_decoder_blob *blob;
+ struct upatch_decoder_blob *blob;
__u64 entries_end, total;
__u32 off;
size_t i;
@@ -1004,7 +1004,7 @@ static int build_decoder_blob(const struct decoder_set *set,
return 0;
entries_end = sizeof(*blob) +
(__u64)set->nr_items *
- sizeof(struct shirudo_upatch_decoder_entry);
+ sizeof(struct upatch_decoder_entry);
total = entries_end;
for (i = 0; i < set->nr_items; i++)
total += set->items[i].source_len;
@@ -1022,7 +1022,7 @@ static int build_decoder_blob(const struct decoder_set *set,
off = (__u32)entries_end;
for (i = 0; i < set->nr_items; i++) {
const struct decoder_file *file = &set->items[i];
- struct shirudo_upatch_decoder_entry *d = &blob->decoders[i];
+ struct upatch_decoder_entry *d = &blob->decoders[i];
d->language = cpu_to_le32(file->manifest.language);
d->api_version = cpu_to_le32(file->manifest.api_version);
@@ -1060,7 +1060,7 @@ static int compose_signed_data(const void *data, __u32 data_len,
const struct signed_section *sections,
__u32 nr_sections, void **out, __u32 *out_len)
{
- struct shirudo_upatch_signed_trailer trailer = {};
+ struct upatch_signed_trailer trailer = {};
__u64 total = data_len, dir_off;
__u8 *buf;
__u32 i;
@@ -1077,7 +1077,7 @@ static int compose_signed_data(const void *data, __u32 data_len,
dir_off = (total + 7) & ~7ULL;
total = dir_off +
(__u64)nr_sections *
- sizeof(struct shirudo_upatch_signed_section) +
+ sizeof(struct upatch_signed_section) +
sizeof(trailer);
if (total > UINT32_MAX)
return -EOVERFLOW;
@@ -1088,7 +1088,7 @@ static int compose_signed_data(const void *data, __u32 data_len,
memcpy(buf, data, data_len);
total = data_len;
for (i = 0; i < nr_sections; i++) {
- struct shirudo_upatch_signed_section s = {};
+ struct upatch_signed_section s = {};
total = (total + 7) & ~7ULL;
memcpy(buf + total, sections[i].data, sections[i].len);
@@ -1103,7 +1103,7 @@ static int compose_signed_data(const void *data, __u32 data_len,
trailer.dir_off = cpu_to_le32((__u32)dir_off);
trailer.nr_sections = cpu_to_le32(nr_sections);
total = dir_off +
- (__u64)nr_sections * sizeof(struct shirudo_upatch_signed_section);
+ (__u64)nr_sections * sizeof(struct upatch_signed_section);
memcpy(buf + total, &trailer, sizeof(trailer));
*out = buf;
@@ -1131,8 +1131,8 @@ static int validate_serializer_output_map(struct bpf_object *obj)
return -EINVAL;
}
if (bpf_map__value_size(m) !=
- sizeof(struct shirudo_serial_chunk)) {
- pr_err("%s value must be struct shirudo_serial_chunk",
+ sizeof(struct serial_chunk)) {
+ pr_err("%s value must be struct serial_chunk",
SERIAL_MAP_NAME);
return -EINVAL;
}
@@ -1157,9 +1157,9 @@ static int build_prog_metadata(struct bpf_object *obj, __u32 nr_progs,
__u32 prog_idx;
char *path;
__u32 path_len;
- struct shirudo_elf_target elf;
+ struct elf_target elf;
};
- struct shirudo_upatch_prog_metadata *md;
+ struct upatch_prog_metadata *md;
struct build_uprobe_target *uprobe_targets = NULL;
char (*seen_maps)[UPATCH_PROG_MAP_MAX] = NULL;
struct bpf_program *p;
@@ -1379,7 +1379,7 @@ static int build_prog_metadata(struct bpf_object *obj, __u32 nr_progs,
}
if (nr_uprobe_targets) {
- struct shirudo_upatch_uprobe_targets targets = {};
+ struct upatch_uprobe_targets targets = {};
__u8 *cursor;
__u32 j;
@@ -1390,7 +1390,7 @@ static int build_prog_metadata(struct bpf_object *obj, __u32 nr_progs,
len += sizeof(targets);
for (j = 0; j < nr_uprobe_targets; j++) {
const struct build_uprobe_target *ut = &uprobe_targets[j];
- size_t record_len = sizeof(struct shirudo_upatch_uprobe_target) +
+ size_t record_len = sizeof(struct upatch_uprobe_target) +
ut->path_len + ut->elf.build_id_len +
(size_t)ut->elf.nr_offsets * sizeof(__u64);
@@ -1418,7 +1418,7 @@ static int build_prog_metadata(struct bpf_object *obj, __u32 nr_progs,
cursor += sizeof(targets);
for (j = 0; j < nr_uprobe_targets; j++) {
const struct build_uprobe_target *ut = &uprobe_targets[j];
- struct shirudo_upatch_uprobe_target record = {};
+ struct upatch_uprobe_target record = {};
__u32 k;
record.prog_idx = cpu_to_le32(ut->prog_idx);
@@ -1538,10 +1538,10 @@ static int finalize_object(struct bpf_object *obj, const char *out_path,
char signed_name[UPATCH_NAME_MAX] = {};
__u32 nr_maps = 0, nr_progs = 0;
__u32 rodata_data_off = 0;
- struct shirudo_upatch_header hdr;
- struct shirudo_upatch rodata_upatch = {};
+ struct upatch_header hdr;
+ struct upatch rodata_upatch = {};
struct decoder_set decoders = {};
- struct shirudo_sign_io sio = {};
+ struct sign_io sio = {};
void *signed_data = NULL;
size_t loader_data_len;
void *loader_data_buf = NULL;
@@ -1802,8 +1802,8 @@ int build_package_unload(const char *upatch_name,
const char *pkey_path,
const char *cert_path)
{
- const struct shirudo_embedded_bpf *blob = unload_blob();
- struct shirudo_unload_params params = {};
+ const struct embedded_bpf *blob = unload_blob();
+ struct unload_params params = {};
struct bpf_object *obj;
struct bpf_map *rodata;
int err;
diff --git a/tools/shirudo-build/shirudo-build.c b/tools/shirudo-build/shirudo-build.c
index 2c83bc8a..4e9c3f29 100644
--- a/tools/shirudo-build/shirudo-build.c
+++ b/tools/shirudo-build/shirudo-build.c
@@ -313,7 +313,7 @@ int main(int argc, char **argv)
* safe escape hatch).
*/
char archive[PATH_MAX];
- struct shirudo_upatch u;
+ struct upatch u;
if (strsprintf(archive, sizeof(archive), "%s/%s.upatch",
UPATCHES_DIR, unload_name) < 0) {
diff --git a/tools/shirudo-build/vouch.c b/tools/shirudo-build/vouch.c
index 60e69cdb..e12fd8ef 100644
--- a/tools/shirudo-build/vouch.c
+++ b/tools/shirudo-build/vouch.c
@@ -43,7 +43,7 @@ static void usage(FILE *fp)
static int cert_algorithm_ok(const __u8 *der, size_t der_sz,
const char *what)
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
char name[64] = {};
int ret;
@@ -83,7 +83,7 @@ int build_keys_vouch(int argc, char **argv)
const char *keys_dir_arg = NULL, *input = NULL, *output = NULL;
__u8 *der = NULL, *own = NULL, *payload = NULL;
size_t der_sz = 0, own_sz = 0, payload_sz = 0;
- struct shirudo_sign_io io = {};
+ struct sign_io io = {};
__u8 sha[32], fp[32], own_fp[32];
int pkey_explicit = 0, cert_explicit = 0;
char fp_hex[65], own_hex[65];
diff --git a/upatches/kernel-obs/kernel-obs.bpf.c b/upatches/kernel-obs/kernel-obs.bpf.c
index 65ae01e8..59cb6393 100644
--- a/upatches/kernel-obs/kernel-obs.bpf.c
+++ b/upatches/kernel-obs/kernel-obs.bpf.c
@@ -41,7 +41,7 @@ OBS_VIEW(priv);
OBS_VIEW(file);
#define OBS_DECODER(sym, map_name, src, signal) \
- const struct shirudo_decoder_manifest sym SEC(".rodata") = { \
+ const struct decoder_manifest sym SEC(".rodata") = { \
.magic = DECODER_MANIFEST_MAGIC, \
.version = UPATCH_DECODER_VERSION, \
.language = UPATCH_DECODER_LANG_LUA, \
diff --git a/upatches/kernel-obs/obs_common.h b/upatches/kernel-obs/obs_common.h
index 522ded2d..3c67e75b 100644
--- a/upatches/kernel-obs/obs_common.h
+++ b/upatches/kernel-obs/obs_common.h
@@ -155,7 +155,7 @@ struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 4);
__type(key, __u32);
- __type(value, struct shirudo_serial_chunk);
+ __type(value, struct serial_chunk);
} shirudo_ser SEC(".maps");
void __arena *bpf_arena_alloc_pages(void *map, void __arena *addr,
@@ -360,10 +360,10 @@ BUILD_BUG_ON(sizeof(struct obs_serial_header) != 64);
#define OBS_SERIAL_VERSION 1
#define OBS_SERIAL_PAGE_CHUNKS 4
-static __always_inline void obs_serial_error(struct shirudo_serialize_ctx *ctx,
+static __always_inline void obs_serial_error(struct serialize_ctx *ctx,
int status)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 key = 0;
chunk = bpf_map_lookup_elem(&shirudo_ser, &key);
@@ -385,7 +385,7 @@ static __always_inline void obs_serial_error(struct shirudo_serialize_ctx *ctx,
}
/* Copy arena words into a serializer chunk at a verifier-known offset. */
-static __always_inline void obs_emit_bytes(struct shirudo_serial_chunk *chunk,
+static __always_inline void obs_emit_bytes(struct serial_chunk *chunk,
__u32 off, const void __arena *src,
__u32 words)
{
@@ -398,7 +398,7 @@ static __always_inline void obs_emit_bytes(struct shirudo_serial_chunk *chunk,
}
static __always_inline bool
-obs_serial_ctx_valid(const struct shirudo_serialize_ctx *ctx)
+obs_serial_ctx_valid(const struct serialize_ctx *ctx)
{
return ctx && ctx->magic == SERIAL_MAGIC &&
ctx->version == SERIAL_VERSION &&
diff --git a/upatches/kernel-obs/obs_dns.bpf.c b/upatches/kernel-obs/obs_dns.bpf.c
index 87038b3a..c0c00b8d 100644
--- a/upatches/kernel-obs/obs_dns.bpf.c
+++ b/upatches/kernel-obs/obs_dns.bpf.c
@@ -181,7 +181,7 @@ static __always_inline void dns_debug_inc(__u32 key)
}
__attribute__((noinline)) void
-obs_dns_emit_name(struct shirudo_serial_chunk *chunk, __u32 base,
+obs_dns_emit_name(struct serial_chunk *chunk, __u32 base,
const struct dns_name __arena *stat)
{
int i;
@@ -197,7 +197,7 @@ obs_dns_emit_name(struct shirudo_serial_chunk *chunk, __u32 base,
chunk->data[base + 16 + i] = stat->name[i];
}
-static int dns_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int dns_emit_record(struct serial_chunk *chunk, __u32 off,
const struct dns_entry __arena *e)
{
int i;
diff --git a/upatches/kernel-obs/obs_exec.bpf.c b/upatches/kernel-obs/obs_exec.bpf.c
index feeb60c0..bbde77eb 100644
--- a/upatches/kernel-obs/obs_exec.bpf.c
+++ b/upatches/kernel-obs/obs_exec.bpf.c
@@ -45,7 +45,7 @@ struct exec_val {
#define OBS_T_EMIT exec_emit_record
#include "obs_table.h"
-static int exec_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int exec_emit_record(struct serial_chunk *chunk, __u32 off,
const struct exec_entry __arena *e)
{
*(__u32 *)&chunk->data[off + 8] = e->key.ident.exe.dev;
diff --git a/upatches/kernel-obs/obs_file.bpf.c b/upatches/kernel-obs/obs_file.bpf.c
index cc38ce46..e5750bc8 100644
--- a/upatches/kernel-obs/obs_file.bpf.c
+++ b/upatches/kernel-obs/obs_file.bpf.c
@@ -54,7 +54,7 @@ struct file_val {
#define OBS_T_EMIT file_emit_record
#include "obs_table.h"
-static int file_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int file_emit_record(struct serial_chunk *chunk, __u32 off,
const struct file_entry __arena *e)
{
*(__u32 *)&chunk->data[off + 8] = e->key.ident.exe.dev;
diff --git a/upatches/kernel-obs/obs_net.bpf.c b/upatches/kernel-obs/obs_net.bpf.c
index 449ac388..3e877a43 100644
--- a/upatches/kernel-obs/obs_net.bpf.c
+++ b/upatches/kernel-obs/obs_net.bpf.c
@@ -124,7 +124,7 @@ struct {
__type(value, struct obs_watch_counter);
} watch_stat SEC(".maps");
-static __always_inline void net_emit_key(struct shirudo_serial_chunk *chunk,
+static __always_inline void net_emit_key(struct serial_chunk *chunk,
__u32 off,
const struct net_key __arena *key)
{
@@ -156,7 +156,7 @@ static __always_inline void net_emit_key(struct shirudo_serial_chunk *chunk,
#define OBS_T_EMIT net_emit_record
#include "obs_table.h"
-static int net_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int net_emit_record(struct serial_chunk *chunk, __u32 off,
const struct net_entry __arena *e)
{
net_emit_key(chunk, off, &e->key);
@@ -184,7 +184,7 @@ static int net_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
#define OBS_T_EMIT listen_emit_record
#include "obs_table.h"
-static int listen_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int listen_emit_record(struct serial_chunk *chunk, __u32 off,
const struct listen_entry __arena *e)
{
net_emit_key(chunk, off, &e->key);
@@ -208,7 +208,7 @@ static int listen_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
#define OBS_T_EMIT watch_emit_record
#include "obs_table.h"
-static int watch_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int watch_emit_record(struct serial_chunk *chunk, __u32 off,
const struct watch_entry __arena *e)
{
net_emit_key(chunk, off, &e->key);
@@ -234,7 +234,7 @@ static int watch_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
#define OBS_T_EMIT socket_emit_record
#include "obs_table.h"
-static int socket_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int socket_emit_record(struct serial_chunk *chunk, __u32 off,
const struct socket_entry __arena *e)
{
const struct socket_key __arena *key = &e->key;
diff --git a/upatches/kernel-obs/obs_priv.bpf.c b/upatches/kernel-obs/obs_priv.bpf.c
index b9d6163b..8f0b4457 100644
--- a/upatches/kernel-obs/obs_priv.bpf.c
+++ b/upatches/kernel-obs/obs_priv.bpf.c
@@ -58,7 +58,7 @@ struct priv_val {
#define OBS_T_EMIT priv_emit_record
#include "obs_table.h"
-static int priv_emit_record(struct shirudo_serial_chunk *chunk, __u32 off,
+static int priv_emit_record(struct serial_chunk *chunk, __u32 off,
const struct priv_entry __arena *e)
{
*(__u32 *)&chunk->data[off + 8] = e->key.ident.exe.dev;
diff --git a/upatches/kernel-obs/obs_table.h b/upatches/kernel-obs/obs_table.h
index 1f82b59e..a57e6324 100644
--- a/upatches/kernel-obs/obs_table.h
+++ b/upatches/kernel-obs/obs_table.h
@@ -56,7 +56,7 @@ static struct OBS_FN(table_state) __arena *OBS_FN(active);
static struct OBS_FN(table_state) __arena *OBS_FN(drain);
static __u32 OBS_FN(lost);
-static int OBS_T_EMIT(struct shirudo_serial_chunk *chunk, __u32 off,
+static int OBS_T_EMIT(struct serial_chunk *chunk, __u32 off,
const struct OBS_FN(entry) __arena *e);
/*
@@ -172,10 +172,10 @@ static __always_inline void OBS_FN(flip)(__u64 now)
OBS_FN(drain) = cur;
}
-static __always_inline struct shirudo_serial_chunk *
+static __always_inline struct serial_chunk *
OBS_FN(slot)(__u32 page_slot, __u32 *off_out)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 key, slot, off;
barrier_var(page_slot);
@@ -201,10 +201,10 @@ OBS_FN(slot)(__u32 page_slot, __u32 *off_out)
static __always_inline int OBS_FN(chunk_meta)(__u32 key, __u32 flags,
__u32 total_chunks,
__u32 page_bytes,
- const struct shirudo_serialize_ctx *ctx,
+ const struct serialize_ctx *ctx,
__u64 next_cursor)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 used;
if (key >= total_chunks)
@@ -235,7 +235,7 @@ static __always_inline int
OBS_FN(emit_header)(const struct OBS_FN(table_state) __arena *state,
__u32 hdr_flags, __u64 now)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 off, used;
chunk = OBS_FN(slot)(0, &off);
@@ -276,7 +276,7 @@ static int OBS_FN(emit_cb)(__u32 scanned, void *data)
{
struct OBS_FN(emit_ctx) *emit = data;
struct OBS_FN(entry) __arena *e;
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 idx, off;
int ret;
@@ -312,7 +312,7 @@ static int OBS_FN(emit_cb)(__u32 scanned, void *data)
}
SEC("syscall")
-int OBS_CAT(shirudo_serialize__, OBS_T_MAP)(struct shirudo_serialize_ctx *ctx)
+int OBS_CAT(shirudo_serialize__, OBS_T_MAP)(struct serialize_ctx *ctx)
{
struct OBS_FN(emit_ctx) emit = {};
struct OBS_FN(table_state) __arena *state;
diff --git a/util/attest.c b/util/attest.c
index c1a9cf14..a547c297 100644
--- a/util/attest.c
+++ b/util/attest.c
@@ -102,7 +102,7 @@ static int emit_line(const char *line, size_t len, void *ctx)
return 0;
}
-static void emit_hex(struct shirudo_json_emit *e, const char *key,
+static void emit_hex(struct json_emit *e, const char *key,
const __u8 *data, size_t len)
{
char hex[2 * TPM_ATTEST_MAX + 1];
@@ -116,11 +116,11 @@ static void emit_hex(struct shirudo_json_emit *e, const char *key,
}
/* A quote is accepted only when it covers the PCR values read beside it. */
-static bool quote_covers(const struct shirudo_tpm_attestation *quote,
+static bool quote_covers(const struct tpm_attestation *quote,
__u32 mask, __u8 values[24][32])
{
- struct shirudo_tpm_attest a;
- struct shirudo_sha256_ctx ctx;
+ struct tpm_attest a;
+ struct sha256_ctx ctx;
__u8 digest[32];
__u32 i;
@@ -143,19 +143,19 @@ static bool quote_covers(const struct shirudo_tpm_attestation *quote,
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,
+ const struct attest_challenge *c,
+ struct 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 };
- struct shirudo_tpm_key ak_copy = {}, ek_copy = {};
- struct shirudo_tpm_attestation quote = {}, certify = {};
- struct shirudo_config_evidence config = {};
- struct shirudo_tpm_attest quoted;
+ const struct attest_challenge *challenge = c;
+ struct tpm_key ak = { .handle = 0 }, ek = { .handle = 0 };
+ struct tpm_key ak_copy = {}, ek_copy = {};
+ struct tpm_attestation quote = {}, certify = {};
+ struct config_evidence config = {};
+ struct tpm_attest quoted;
struct tpm_nv_info nv;
- struct shirudo_tpm *tpm = NULL;
- struct shirudo_json_emit e;
+ struct tpm *tpm = NULL;
+ struct json_emit e;
__u8 values[24][32] = {};
__u8 reg[32], cred[TPM_CREDENTIAL_LEN], *ek_cert = NULL;
size_t ek_cert_len = 0, ek_b64_cap = 0, fw_cap = 0, sd_cap = 0, need;
@@ -310,7 +310,7 @@ int attest_evidence_config(const __u8 *nonce, size_t nonce_len,
}
hex_encode(nonce, nonce_len, nonce_hex);
- e = (struct shirudo_json_emit){ .buf = *out, .cap = need };
+ e = (struct json_emit){ .buf = *out, .cap = need };
json_obj_open(&e);
json_kv_int(&e, "schema", 1);
json_kv_string(&e, "kind", "shirudo-attestation");
@@ -676,11 +676,11 @@ static int hex_bytes(const char *hex, __u8 *out, size_t cap, size_t *len)
static int check_signed(struct reporter *rep, const char *what,
const char *attest_hex, const char *sig_hex,
- const struct shirudo_tpm_ecc_public *ak,
+ const struct tpm_ecc_public *ak,
const __u8 ak_name[TPM_NAME_LEN],
const __u8 *nonce, size_t nonce_len,
__u8 *attest, size_t attest_cap, size_t *attest_len,
- struct shirudo_tpm_attest *parsed)
+ struct tpm_attest *parsed)
{
__u8 sig[TPM_SIGNATURE_MAX], r[32], s[32], digest[32];
__u8 qn[TPM_NAME_LEN];
@@ -712,13 +712,13 @@ static int check_signed(struct reporter *rep, const char *what,
}
int attest_verify(const char *evidence, size_t len,
- const struct shirudo_attest_expect *expect,
+ const struct attest_expect *expect,
char *report, size_t report_cap)
{
struct reporter rep = { .buf = report, .cap = report_cap };
- struct shirudo_config_evidence config = {};
- struct shirudo_tpm_attest quote = {}, certify = {};
- struct shirudo_tpm_ecc_public ak_pub;
+ struct config_evidence config = {};
+ struct tpm_attest quote = {}, certify = {};
+ struct tpm_ecc_public ak_pub;
__u8 ak_public[TPM_PUBLIC_MAX];
__u8 ak_name[TPM_NAME_LEN];
__u8 reg_name[TPM_NAME_LEN], reg_value[32];
@@ -750,27 +750,27 @@ int attest_verify(const char *evidence, size_t len,
p->rec_reset = -1;
{
- struct shirudo_json_array pcr_sink = { on_pcr, p };
- struct shirudo_json_array rec_sink = { on_record, p };
- struct shirudo_json_field pcr_sub[] = {
+ struct json_array pcr_sink = { on_pcr, p };
+ struct json_array rec_sink = { on_record, p };
+ struct json_field pcr_sub[] = {
{ "index", SHIRUDO_JSON_T_INT, &p->pcr_index, 0, 0,
NULL, 0 },
{ "value", SHIRUDO_JSON_T_STRING, p->pcr_value_hex,
sizeof(p->pcr_value_hex), 0, NULL, 0 },
};
- struct shirudo_json_field ak_sub[] = {
+ struct json_field ak_sub[] = {
{ "public", SHIRUDO_JSON_T_STRING, p->ak_public_hex,
sizeof(p->ak_public_hex), 0, NULL, 0 },
{ "name", SHIRUDO_JSON_T_STRING, p->ak_name_hex,
sizeof(p->ak_name_hex), 0, NULL, 0 },
};
- struct shirudo_json_field quote_sub[] = {
+ struct json_field quote_sub[] = {
{ "attest", SHIRUDO_JSON_T_STRING, p->quote_attest_hex,
sizeof(p->quote_attest_hex), 0, NULL, 0 },
{ "signature", SHIRUDO_JSON_T_STRING, p->quote_sig_hex,
sizeof(p->quote_sig_hex), 0, NULL, 0 },
};
- struct shirudo_json_field ek_sub[] = {
+ struct json_field ek_sub[] = {
{ "type", SHIRUDO_JSON_T_STRING, p->ek_type,
sizeof(p->ek_type), 0, NULL, 0 },
{ "public", SHIRUDO_JSON_T_STRING, p->ek_public_hex,
@@ -778,11 +778,11 @@ int attest_verify(const char *evidence, size_t len,
{ "name", SHIRUDO_JSON_T_STRING, p->ek_name_hex,
sizeof(p->ek_name_hex), 0, NULL, 0 },
};
- struct shirudo_json_field cred_sub[] = {
+ struct json_field cred_sub[] = {
{ "value", SHIRUDO_JSON_T_STRING, p->cred_hex,
sizeof(p->cred_hex), 0, NULL, 0 },
};
- struct shirudo_json_field reg_sub[] = {
+ struct json_field reg_sub[] = {
{ "nv_index", SHIRUDO_JSON_T_STRING, p->reg_index,
sizeof(p->reg_index), 0, NULL, 0 },
{ "pcr", SHIRUDO_JSON_T_INT, &p->reg_pcr, 0, 0, NULL,
@@ -796,21 +796,21 @@ int attest_verify(const char *evidence, size_t len,
{ "signature", SHIRUDO_JSON_T_STRING, p->reg_sig_hex,
sizeof(p->reg_sig_hex), 0, NULL, 0 },
};
- struct shirudo_json_field upatch_sub[] = {
+ struct json_field upatch_sub[] = {
{ "name", SHIRUDO_JSON_T_STRING, p->upatch_name,
sizeof(p->upatch_name), 0, NULL, 0 },
{ "payload_sha256", SHIRUDO_JSON_T_STRING,
p->upatch_payload_hex, sizeof(p->upatch_payload_hex),
0, NULL, 0 },
};
- struct shirudo_json_field key_sub[] = {
+ struct json_field key_sub[] = {
{ "fingerprint", SHIRUDO_JSON_T_STRING,
p->key_fingerprint, sizeof(p->key_fingerprint), 0,
NULL, 0 },
{ "cert_sha256", SHIRUDO_JSON_T_STRING, p->key_sha_hex,
sizeof(p->key_sha_hex), 0, NULL, 0 },
};
- struct shirudo_json_field tree_sub[] = {
+ struct json_field tree_sub[] = {
{ "seq", SHIRUDO_JSON_T_INT, &p->tree_seq, 0, 0, NULL,
0 },
{ "op", SHIRUDO_JSON_T_STRING, p->tree_op,
@@ -821,7 +821,7 @@ int attest_verify(const char *evidence, size_t len,
p->tree_digest_hex, sizeof(p->tree_digest_hex), 0,
NULL, 0 },
};
- struct shirudo_json_field rec_sub[] = {
+ struct json_field rec_sub[] = {
{ "type", SHIRUDO_JSON_T_STRING, p->type,
sizeof(p->type), 0, NULL, 0 },
{ "digest", SHIRUDO_JSON_T_STRING, p->digest_hex,
@@ -859,7 +859,7 @@ int attest_verify(const char *evidence, size_t len,
{ "key", SHIRUDO_JSON_T_OBJECT, NULL, 0, 0, key_sub,
ARRAY_SIZE(key_sub) },
};
- struct shirudo_json_field top[] = {
+ struct json_field top[] = {
{ "nonce", SHIRUDO_JSON_T_STRING, p->nonce_hex,
sizeof(p->nonce_hex), 0, NULL, 0 },
{ "pcr_mask", SHIRUDO_JSON_T_INT, &p->pcr_mask, 0, 0,
@@ -940,7 +940,7 @@ int attest_verify(const char *evidence, size_t len,
if (have_ek) {
__u8 ek_public[TPM_PUBLIC_MAX];
__u8 ek_name[TPM_NAME_LEN], computed[TPM_NAME_LEN];
- struct shirudo_tpm_public ek_pub;
+ struct tpm_public ek_pub;
size_t ek_public_len, ek_name_len;
bool parsed;
@@ -996,7 +996,7 @@ int attest_verify(const char *evidence, size_t len,
goto out;
qrc = ret;
if (ret == 0) {
- struct shirudo_sha256_ctx ctx;
+ struct sha256_ctx ctx;
__u8 digest[32] = {};
bool complete =
quote.type == TPM_ST_ATTEST_QUOTE &&
@@ -1243,15 +1243,15 @@ out:
}
int attest_challenge_read(const char *path,
- struct shirudo_attest_challenge *out)
+ struct attest_challenge *out)
{
char blob_hex[2 * TPM_ID_OBJECT_LEN + 1], secret_hex[2 * 256 + 1];
char ak_hex[2 * TPM_NAME_LEN + 1], kind[32], type[8];
- struct shirudo_json_field ek_sub[] = {
+ struct json_field ek_sub[] = {
{ "type", SHIRUDO_JSON_T_STRING, type, sizeof(type), 0, NULL,
0 },
};
- struct shirudo_json_field top[] = {
+ struct json_field top[] = {
{ "kind", SHIRUDO_JSON_T_STRING, kind, sizeof(kind), 0, NULL,
0 },
{ "ek", SHIRUDO_JSON_T_OBJECT, NULL, 0, 0, ek_sub,
@@ -1297,7 +1297,7 @@ int attest_challenge_read(const char *path,
/* The certificate's key must be the endorsement key of the evidence. */
static bool cert_describes(const struct cert_pubkey *key,
- const struct shirudo_tpm_public *pub)
+ const struct tpm_public *pub)
{
bool rsa = pub->type == TPM_ALG_RSA;
@@ -1312,7 +1312,7 @@ static bool cert_describes(const struct cert_pubkey *key,
}
int attest_challenge_make(const char *evidence, size_t len,
- const struct shirudo_attest_challenge_policy *pol,
+ const struct attest_challenge_policy *pol,
__u8 credential[TPM_CREDENTIAL_LEN],
char **out, size_t *out_len, size_t *cap,
char *report, size_t report_cap)
@@ -1328,14 +1328,14 @@ int attest_challenge_make(const char *evidence, size_t len,
__u8 seed[32], z[32], eph_x[32], eph_y[32], secret[256];
__u8 blob[TPM_ID_OBJECT_LEN], *der = NULL;
struct cert_pubkey cert_key;
- struct shirudo_tpm_public pub;
- struct shirudo_cert cert = {};
- struct shirudo_json_emit e;
- struct shirudo_json_field ak_sub[] = {
+ struct tpm_public pub;
+ struct cert cert = {};
+ struct json_emit e;
+ struct json_field ak_sub[] = {
{ "name", SHIRUDO_JSON_T_STRING, ak_hex, sizeof(ak_hex), 0,
NULL, 0 },
};
- struct shirudo_json_field ek_sub[] = {
+ struct json_field ek_sub[] = {
{ "type", SHIRUDO_JSON_T_STRING, ek_type, sizeof(ek_type), 0,
NULL, 0 },
{ "public", SHIRUDO_JSON_T_STRING, ek_public_hex,
@@ -1344,7 +1344,7 @@ int attest_challenge_make(const char *evidence, size_t len,
sizeof(ek_name_hex), 0, NULL, 0 },
};
char *cert_b64 = xmalloc(EK_CERT_B64_MAX);
- struct shirudo_json_field top[] = {
+ struct json_field top[] = {
{ "ak", SHIRUDO_JSON_T_OBJECT, NULL, 0, 0, ak_sub,
ARRAY_SIZE(ak_sub) },
{ "ek", SHIRUDO_JSON_T_OBJECT, NULL, 0, 0, ek_sub,
@@ -1495,7 +1495,7 @@ int attest_challenge_make(const char *evidence, size_t len,
ret = -ENOMEM;
goto out;
}
- e = (struct shirudo_json_emit){ .buf = *out, .cap = *cap };
+ e = (struct json_emit){ .buf = *out, .cap = *cap };
json_obj_open(&e);
json_kv_int(&e, "schema", 1);
json_kv_string(&e, "kind", "shirudo-credential");
diff --git a/util/attest.h b/util/attest.h
index fb947dcf..ba48c796 100644
--- a/util/attest.h
+++ b/util/attest.h
@@ -29,7 +29,7 @@
* attestation key of the given name under the endorsement key of the
* given type.
*/
-struct shirudo_attest_challenge {
+struct attest_challenge {
bool ek_rsa;
__u8 ak_name[TPM_NAME_LEN];
__u8 blob[TPM_ID_OBJECT_LEN];
@@ -41,9 +41,9 @@ struct shirudo_attest_challenge {
#define ATTEST_CHALLENGE_MAX (16 * 1024)
int attest_challenge_read(const char *path,
- struct shirudo_attest_challenge *out);
+ struct attest_challenge *out);
-struct shirudo_config_update;
+struct config_update;
/*
* Target side. The buffer is xmalloc'd to *cap and NUL-terminated;
@@ -52,8 +52,8 @@ struct shirudo_config_update;
*/
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,
+ const struct attest_challenge *c,
+ struct config_update *update,
char **out, size_t *len, size_t *cap);
/*
@@ -61,7 +61,7 @@ int attest_evidence_config(const __u8 *nonce, size_t nonce_len,
* to the caller and kept nowhere else; ek_ca is a PEM bundle or NULL.
* -EKEYREJECTED when a check failed and no challenge was made.
*/
-struct shirudo_attest_challenge_policy {
+struct attest_challenge_policy {
const char *ek_ca; /* issuer bundle, or NULL */
const __u8 *ak_name; /* pinned attestation key, or NULL */
const __u8 *ek_name; /* pinned endorsement key, or NULL */
@@ -69,12 +69,12 @@ struct shirudo_attest_challenge_policy {
};
int attest_challenge_make(const char *evidence, size_t len,
- const struct shirudo_attest_challenge_policy *pol,
+ const struct attest_challenge_policy *pol,
__u8 credential[TPM_CREDENTIAL_LEN],
char **out, size_t *out_len, size_t *cap,
char *report, size_t report_cap);
-struct shirudo_attest_expect {
+struct attest_expect {
const __u8 *nonce;
size_t nonce_len;
bool have_ak_name;
@@ -105,7 +105,7 @@ struct shirudo_attest_expect {
* failed, -EINVAL when the document is malformed.
*/
int attest_verify(const char *evidence, size_t len,
- const struct shirudo_attest_expect *expect,
+ const struct attest_expect *expect,
char *report, size_t report_cap);
#endif /* SHIRUDO_ATTEST_H */
diff --git a/util/bpm_oci.c b/util/bpm_oci.c
index 66d2e24f..3fd9c4eb 100644
--- a/util/bpm_oci.c
+++ b/util/bpm_oci.c
@@ -369,7 +369,7 @@ int bpm_oci_parse_endpoint(const char *endpoint, struct bpm_oci_client *c)
return -ENAMETOOLONG;
if (getenv("BPM_OCI_CA_FILE")) {
const char *ca_file = getenv("BPM_OCI_CA_FILE");
- struct shirudo_cert ca = {};
+ struct cert ca = {};
if (strlen(ca_file) >= sizeof(c->ca_file))
return -ENAMETOOLONG;
@@ -949,32 +949,32 @@ int bpm_oci_parse_manifest(const __u8 *body, size_t len,
size_t package_name_sz)
{
struct desc_sink sink = { .items = layers, .max = max_layers };
- struct shirudo_json_array arr = { on_descriptor, &sink };
- struct shirudo_json_field layer_annotations[1], manifest_annotations[1];
- struct shirudo_json_field sub[4], root[3];
+ struct json_array arr = { on_descriptor, &sink };
+ struct json_field layer_annotations[1], manifest_annotations[1];
+ struct json_field sub[4], root[3];
__s64 schema = 0;
memset(sub, 0, sizeof(sub));
- sub[0] = (struct shirudo_json_field){ .key = "mediaType", .type = SHIRUDO_JSON_T_STRING,
+ sub[0] = (struct json_field){ .key = "mediaType", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.media, .dst_cap = sizeof(sink.scratch.media) };
- sub[1] = (struct shirudo_json_field){ .key = "digest", .type = SHIRUDO_JSON_T_STRING,
+ sub[1] = (struct json_field){ .key = "digest", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.digest, .dst_cap = sizeof(sink.scratch.digest) };
- sub[2] = (struct shirudo_json_field){ .key = "size", .type = SHIRUDO_JSON_T_INT,
+ sub[2] = (struct json_field){ .key = "size", .type = SHIRUDO_JSON_T_INT,
.dst = &sink.scratch.size };
- layer_annotations[0] = (struct shirudo_json_field){
+ layer_annotations[0] = (struct json_field){
.key = "org.opencontainers.image.title", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.title, .dst_cap = sizeof(sink.scratch.title) };
- sub[3] = (struct shirudo_json_field){ .key = "annotations", .type = SHIRUDO_JSON_T_OBJECT,
+ sub[3] = (struct json_field){ .key = "annotations", .type = SHIRUDO_JSON_T_OBJECT,
.sub = layer_annotations, .n_sub = ARRAY_SIZE(layer_annotations) };
- manifest_annotations[0] = (struct shirudo_json_field){
+ manifest_annotations[0] = (struct json_field){
.key = "dev.shirudo.bpm.package.name", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.package_name, .dst_cap = sizeof(sink.package_name) };
memset(root, 0, sizeof(root));
- root[0] = (struct shirudo_json_field){ .key = "schemaVersion", .type = SHIRUDO_JSON_T_INT,
+ root[0] = (struct json_field){ .key = "schemaVersion", .type = SHIRUDO_JSON_T_INT,
.dst = &schema };
- root[1] = (struct shirudo_json_field){ .key = "layers", .type = SHIRUDO_JSON_T_ARRAY,
+ root[1] = (struct json_field){ .key = "layers", .type = SHIRUDO_JSON_T_ARRAY,
.dst = &arr, .sub = sub, .n_sub = ARRAY_SIZE(sub) };
- root[2] = (struct shirudo_json_field){ .key = "annotations", .type = SHIRUDO_JSON_T_OBJECT,
+ root[2] = (struct json_field){ .key = "annotations", .type = SHIRUDO_JSON_T_OBJECT,
.sub = manifest_annotations, .n_sub = ARRAY_SIZE(manifest_annotations) };
if (json_parse((const char *)body, len, root, ARRAY_SIZE(root)) ||
!root[0].seen || schema != 2 || !root[1].seen)
@@ -1249,7 +1249,7 @@ out:
return ret;
}
-void bpm_oci_emit_descriptor(struct shirudo_json_emit *e, const char *key,
+void bpm_oci_emit_descriptor(struct json_emit *e, const char *key,
const struct bpm_descriptor *d, const char *title)
{
if (key)
diff --git a/util/bpm_oci.h b/util/bpm_oci.h
index a247d9d6..1a3227fd 100644
--- a/util/bpm_oci.h
+++ b/util/bpm_oci.h
@@ -17,7 +17,7 @@
#include "crypto.h"
-struct shirudo_json_emit;
+struct json_emit;
#define BPM_MAX_NAME 128
#define BPM_MAX_ENDPOINT 512
@@ -76,7 +76,7 @@ struct bpm_oci_client {
char password[BPM_OCI_PASSWORD_SIZE];
char token[BPM_OCI_TOKEN_SIZE];
char ca_file[PATH_MAX];
- struct shirudo_tls_ca tls_ca;
+ struct tls_ca tls_ca;
};
struct bpm_descriptor {
@@ -148,7 +148,7 @@ int bpm_oci_get_signed(struct bpm_oci_client *c, const char *repository,
const struct bpm_descriptor *layers, int n_layers,
const char *payload_media, const char *sig_media,
struct bpm_buffer *payload, struct bpm_buffer *sig);
-void bpm_oci_emit_descriptor(struct shirudo_json_emit *e, const char *key,
+void bpm_oci_emit_descriptor(struct json_emit *e, const char *key,
const struct bpm_descriptor *d, const char *title);
#endif /* SHIRUDO_BPM_OCI_H */
diff --git a/util/bpm_package.c b/util/bpm_package.c
index 0c7f58d8..7fe37eed 100644
--- a/util/bpm_package.c
+++ b/util/bpm_package.c
@@ -62,48 +62,48 @@ int bpm_index_parse(const __u8 *body, size_t len,
struct bpm_index_entry *entries, int *n_entries)
{
struct index_sink sink = { .items = entries };
- struct shirudo_json_array arr = { on_index_entry, &sink };
- struct shirudo_json_field sub[7], root[2];
+ struct json_array arr = { on_index_entry, &sink };
+ struct json_field sub[7], root[2];
__s64 schema = 0;
memset(sub, 0, sizeof(sub));
- sub[0] = (struct shirudo_json_field){
+ sub[0] = (struct json_field){
.key = "name", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.name, .dst_cap = sizeof(sink.scratch.name),
};
- sub[1] = (struct shirudo_json_field){
+ sub[1] = (struct json_field){
.key = "version", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.version,
.dst_cap = sizeof(sink.scratch.version),
};
- sub[2] = (struct shirudo_json_field){
+ sub[2] = (struct json_field){
.key = "repository", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.repository,
.dst_cap = sizeof(sink.scratch.repository),
};
- sub[3] = (struct shirudo_json_field){
+ sub[3] = (struct json_field){
.key = "manifest_digest", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.manifest_digest,
.dst_cap = sizeof(sink.scratch.manifest_digest),
};
- sub[4] = (struct shirudo_json_field){
+ sub[4] = (struct json_field){
.key = "package_digest", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.package_digest,
.dst_cap = sizeof(sink.scratch.package_digest),
};
- sub[5] = (struct shirudo_json_field){
+ sub[5] = (struct json_field){
.key = "signer_fingerprint", .type = SHIRUDO_JSON_T_STRING,
.dst = sink.scratch.signer,
.dst_cap = sizeof(sink.scratch.signer),
};
- sub[6] = (struct shirudo_json_field){
+ sub[6] = (struct json_field){
.key = "package_size", .type = SHIRUDO_JSON_T_INT,
.dst = &sink.scratch.package_size,
};
- root[0] = (struct shirudo_json_field){
+ root[0] = (struct json_field){
.key = "schema", .type = SHIRUDO_JSON_T_INT, .dst = &schema,
};
- root[1] = (struct shirudo_json_field){
+ root[1] = (struct json_field){
.key = "packages", .type = SHIRUDO_JSON_T_ARRAY,
.dst = &arr, .sub = sub, .n_sub = ARRAY_SIZE(sub),
};
@@ -187,7 +187,7 @@ int bpm_semver_compare(const char *a, const char *b)
int bpm_verify_cms(const __u8 *payload, size_t payload_len,
const __u8 *sig, size_t sig_len, const char *cert_path)
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
int ret = -EINVAL;
if (!cert_read_file(cert_path, &cert))
@@ -199,7 +199,7 @@ int bpm_verify_cms(const __u8 *payload, size_t payload_len,
int bpm_verify_cms_fd(const __u8 *payload, size_t payload_len,
const __u8 *sig, size_t sig_len, int cert_fd)
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
int ret = -EINVAL;
if (!cert_read_fd(cert_fd, &cert))
@@ -710,8 +710,8 @@ int bpm_pkg_load_info(const char *archive, struct bpm_package_info *info)
char version[BPM_MAX_NAME];
char signer[BPM_MAX_DIGEST];
} parsed = {};
- struct shirudo_json_field package_fields[2], shirudo_fields[1], root[2];
- struct shirudo_cert signer = {};
+ struct json_field package_fields[2], shirudo_fields[1], root[2];
+ struct cert signer = {};
__u8 digest[32];
X509 *cert = NULL;
char hex[EVP_MAX_MD_SIZE * 2 + 1];
@@ -719,23 +719,23 @@ int bpm_pkg_load_info(const char *archive, struct bpm_package_info *info)
int ret;
memset(package_fields, 0, sizeof(package_fields));
- package_fields[0] = (struct shirudo_json_field){
+ package_fields[0] = (struct json_field){
.key = "name", .type = SHIRUDO_JSON_T_STRING,
.dst = parsed.name, .dst_cap = sizeof(parsed.name),
};
- package_fields[1] = (struct shirudo_json_field){
+ package_fields[1] = (struct json_field){
.key = "version", .type = SHIRUDO_JSON_T_STRING,
.dst = parsed.version, .dst_cap = sizeof(parsed.version),
};
- shirudo_fields[0] = (struct shirudo_json_field){
+ shirudo_fields[0] = (struct json_field){
.key = "spki_sha256_fingerprint", .type = SHIRUDO_JSON_T_STRING,
.dst = parsed.signer, .dst_cap = sizeof(parsed.signer),
};
- root[0] = (struct shirudo_json_field){
+ root[0] = (struct json_field){
.key = "package", .type = SHIRUDO_JSON_T_OBJECT,
.sub = package_fields, .n_sub = ARRAY_SIZE(package_fields),
};
- root[1] = (struct shirudo_json_field){
+ root[1] = (struct json_field){
.key = "shirudo", .type = SHIRUDO_JSON_T_OBJECT,
.sub = shirudo_fields, .n_sub = ARRAY_SIZE(shirudo_fields),
};
@@ -789,7 +789,7 @@ int bpm_tree_fetch_publication(struct bpm_oci_client *c,
const char *repository,
const char *reference,
const char *cert_path,
- struct shirudo_tree_publication *pub,
+ struct tree_publication *pub,
char *manifest_digest, size_t digest_sz)
{
struct bpm_buffer manifest = {}, payload = {}, sig = {};
diff --git a/util/bpm_package.h b/util/bpm_package.h
index 1e2108ad..32aee94c 100644
--- a/util/bpm_package.h
+++ b/util/bpm_package.h
@@ -79,7 +79,7 @@ int bpm_pkg_load_info(const char *archive, struct bpm_package_info *info);
int bpm_tree_fetch_publication(struct bpm_oci_client *c,
const char *repository, const char *reference,
const char *cert_path,
- struct shirudo_tree_publication *pub,
+ struct tree_publication *pub,
char *manifest_digest, size_t digest_sz);
#endif /* SHIRUDO_BPM_PACKAGE_H */
diff --git a/util/bpm_tree.c b/util/bpm_tree.c
index 1ac1d034..55c1dfe0 100644
--- a/util/bpm_tree.c
+++ b/util/bpm_tree.c
@@ -223,7 +223,7 @@ static int tp_string_array(struct tree_parser *p,
}
static int tp_selector_string_map(struct tree_parser *p,
- struct shirudo_tree_selector_kv *dst,
+ struct tree_selector_kv *dst,
int *n, int max)
{
char key[TREE_STRING_MAX];
@@ -249,7 +249,7 @@ static int tp_selector_string_map(struct tree_parser *p,
}
}
-static int tp_selector(struct tree_parser *p, struct shirudo_tree_selector *s)
+static int tp_selector(struct tree_parser *p, struct tree_selector *s)
{
char key[TREE_STRING_MAX];
bool first = true;
@@ -294,7 +294,7 @@ static int tp_selector(struct tree_parser *p, struct shirudo_tree_selector *s)
}
}
-static int tp_artifact(struct tree_parser *p, struct shirudo_tree_artifact *a)
+static int tp_artifact(struct tree_parser *p, struct tree_artifact *a)
{
char key[TREE_STRING_MAX];
bool first = true;
@@ -329,7 +329,7 @@ static int tp_artifact(struct tree_parser *p, struct shirudo_tree_artifact *a)
}
}
-static int tp_operation(struct tree_parser *p, struct shirudo_tree_operation *o)
+static int tp_operation(struct tree_parser *p, struct tree_operation *o)
{
char key[TREE_STRING_MAX];
bool first = true;
@@ -379,19 +379,19 @@ static int tp_operation(struct tree_parser *p, struct shirudo_tree_operation *o)
}
}
-void tree_publication_free(struct shirudo_tree_publication *pub)
+void tree_publication_free(struct tree_publication *pub)
{
if (!pub)
return;
if (pub->operations)
xfree(pub->operations,
(size_t)pub->operations_capacity * sizeof(*pub->operations));
- *pub = (struct shirudo_tree_publication){};
+ *pub = (struct tree_publication){};
}
-static int tree_operations_reserve(struct shirudo_tree_publication *pub)
+static int tree_operations_reserve(struct tree_publication *pub)
{
- struct shirudo_tree_operation *operations;
+ struct tree_operation *operations;
int old_capacity = pub->operations_capacity;
int new_capacity = old_capacity ? old_capacity * 2 : 16;
@@ -410,8 +410,8 @@ static int tree_operations_reserve(struct shirudo_tree_publication *pub)
return 0;
}
-int tree_publication_append(struct shirudo_tree_publication *pub,
- const struct shirudo_tree_operation *op)
+int tree_publication_append(struct tree_publication *pub,
+ const struct tree_operation *op)
{
int ret;
@@ -451,7 +451,7 @@ static int tp_seq_object(struct tree_parser *p, char *key, size_t cap,
}
int tree_parse(const char *body, size_t len,
- struct shirudo_tree_publication *out)
+ struct tree_publication *out)
{
struct tree_parser p;
char key[TREE_STRING_MAX];
@@ -465,7 +465,7 @@ int tree_parse(const char *body, size_t len,
if (!body || !out || len > JSON_MAX_BYTES)
return -EINVAL;
p = (struct tree_parser){ .p = body, .end = body + len };
- *out = (struct shirudo_tree_publication){};
+ *out = (struct tree_publication){};
if (tp_char(&p, '{')) {
ret = -EINVAL;
goto fail;
@@ -589,10 +589,10 @@ fail:
static int tree_selector_kv_compare(const void *left, const void *right)
{
- const struct shirudo_tree_selector_kv *a =
- *(const struct shirudo_tree_selector_kv * const *)left;
- const struct shirudo_tree_selector_kv *b =
- *(const struct shirudo_tree_selector_kv * const *)right;
+ const struct tree_selector_kv *a =
+ *(const struct tree_selector_kv * const *)left;
+ const struct tree_selector_kv *b =
+ *(const struct tree_selector_kv * const *)right;
return strcmp(a->key, b->key);
}
@@ -601,11 +601,11 @@ static int tree_selector_kv_compare(const void *left, const void *right)
* the publisher's order. Targets recompute operation digests from this
* form, so publisher and consumer share one emitter.
*/
-static int tree_emit_selector(struct shirudo_json_emit *e,
- const struct shirudo_tree_selector *s)
+static int tree_emit_selector(struct json_emit *e,
+ const struct tree_selector *s)
{
- const struct shirudo_tree_selector_kv *kconfig[TREE_MAX_KCONFIG];
- const struct shirudo_tree_selector_kv *labels[TREE_MAX_LABELS];
+ const struct tree_selector_kv *kconfig[TREE_MAX_KCONFIG];
+ const struct tree_selector_kv *labels[TREE_MAX_LABELS];
if (s->n_kconfig > (int)ARRAY_SIZE(kconfig) ||
s->n_labels > (int)ARRAY_SIZE(labels))
@@ -662,8 +662,8 @@ static int tree_emit_selector(struct shirudo_json_emit *e,
return 0;
}
-static void tree_emit_artifact(struct shirudo_json_emit *e,
- const struct shirudo_tree_artifact *a)
+static void tree_emit_artifact(struct json_emit *e,
+ const struct tree_artifact *a)
{
json_obj_open_key(e, "artifact");
json_kv_string(e, "repository", a->repository);
@@ -673,8 +673,8 @@ static void tree_emit_artifact(struct shirudo_json_emit *e,
json_obj_close(e);
}
-static int tree_emit_operation(struct shirudo_json_emit *e,
- const struct shirudo_tree_operation *op,
+static int tree_emit_operation(struct json_emit *e,
+ const struct tree_operation *op,
bool with_digest)
{
int ret;
@@ -697,11 +697,11 @@ static int tree_emit_operation(struct shirudo_json_emit *e,
* The operation digest covers the canonical operation without the digest
* field itself: seq, op, id, selector and artifact.
*/
-int tree_operation_digest(const struct shirudo_tree_operation *op,
+int tree_operation_digest(const struct tree_operation *op,
char out[72])
{
size_t body_cap = 1024u * 1024u;
- struct shirudo_json_emit e;
+ struct json_emit e;
char *body, hex[65];
__u8 digest[32];
int ret;
@@ -709,7 +709,7 @@ int tree_operation_digest(const struct shirudo_tree_operation *op,
body = xmalloc(body_cap);
if (!body)
return -ENOMEM;
- e = (struct shirudo_json_emit){ .buf = body, .cap = body_cap };
+ e = (struct json_emit){ .buf = body, .cap = body_cap };
ret = tree_emit_operation(&e, op, false);
if (!ret && sha256_buffer(body, e.len, digest))
ret = -EIO;
@@ -727,7 +727,7 @@ static size_t tree_json_bound(const char *s)
return 2 * strlen(s) + 4;
}
-static size_t tree_selector_kv_bound(const struct shirudo_tree_selector_kv *kv)
+static size_t tree_selector_kv_bound(const struct tree_selector_kv *kv)
{
size_t n = 8 + tree_json_bound(kv->key);
@@ -736,9 +736,9 @@ static size_t tree_selector_kv_bound(const struct shirudo_tree_selector_kv *kv)
return n;
}
-static size_t tree_operation_bound(const struct shirudo_tree_operation *op)
+static size_t tree_operation_bound(const struct tree_operation *op)
{
- const struct shirudo_tree_selector *s = &op->selector;
+ const struct tree_selector *s = &op->selector;
size_t n = 512;
n += tree_json_bound(op->op) + tree_json_bound(op->id) +
@@ -765,10 +765,10 @@ static size_t tree_operation_bound(const struct shirudo_tree_operation *op)
* schema, tree_id, generation, parent_manifest_digest (when any), base,
* operations, head.
*/
-int tree_emit_publication(const struct shirudo_tree_publication *pub,
+int tree_emit_publication(const struct tree_publication *pub,
char **out, size_t *out_len)
{
- struct shirudo_json_emit e;
+ struct json_emit e;
size_t cap = 4096;
char *body;
int ret = 0;
@@ -778,7 +778,7 @@ int tree_emit_publication(const struct shirudo_tree_publication *pub,
body = xmalloc(cap);
if (!body)
return -ENOMEM;
- e = (struct shirudo_json_emit){ .buf = body, .cap = cap };
+ e = (struct json_emit){ .buf = body, .cap = cap };
json_obj_open(&e);
json_kv_int(&e, "schema", pub->schema);
json_kv_string(&e, "tree_id", pub->tree_id);
diff --git a/util/bpm_tree.h b/util/bpm_tree.h
index 15ae9cb4..4ebb3281 100644
--- a/util/bpm_tree.h
+++ b/util/bpm_tree.h
@@ -16,62 +16,62 @@
#define TREE_MAX_SELECTOR_VALUES 16
#define TREE_STRING_MAX 256
-struct shirudo_json_emit;
+struct json_emit;
-struct shirudo_tree_kv {
+struct tree_kv {
char key[TREE_STRING_MAX];
char value[TREE_STRING_MAX];
};
-struct shirudo_tree_selector_kv {
+struct tree_selector_kv {
char key[TREE_STRING_MAX];
char values[TREE_MAX_SELECTOR_VALUES][TREE_STRING_MAX];
int n_values;
};
-struct shirudo_tree_selector {
+struct tree_selector {
char kernel_release_prefix[TREE_MAX_SELECTOR_VALUES][TREE_STRING_MAX];
int n_kernel_release_prefix;
char kernel_build_id[TREE_MAX_SELECTOR_VALUES][TREE_STRING_MAX];
int n_kernel_build_id;
char architecture[TREE_MAX_SELECTOR_VALUES][TREE_STRING_MAX];
int n_architecture;
- struct shirudo_tree_selector_kv kconfig[TREE_MAX_KCONFIG];
+ struct tree_selector_kv kconfig[TREE_MAX_KCONFIG];
int n_kconfig;
- struct shirudo_tree_selector_kv labels[TREE_MAX_LABELS];
+ struct tree_selector_kv labels[TREE_MAX_LABELS];
int n_labels;
};
-struct shirudo_tree_artifact {
+struct tree_artifact {
char repository[512];
char manifest_digest[128];
char layer_digest[128];
char payload_sha256[128];
};
-struct shirudo_tree_operation {
+struct tree_operation {
__s64 seq;
char op[16];
char id[TREE_STRING_MAX];
- struct shirudo_tree_selector selector;
- struct shirudo_tree_artifact artifact;
+ struct tree_selector selector;
+ struct tree_artifact artifact;
char expected_payload_sha256[128];
char operation_digest[128];
};
-struct shirudo_tree_publication {
+struct tree_publication {
int schema;
char tree_id[TREE_STRING_MAX];
__s64 generation;
char parent_manifest_digest[128];
__s64 base_seq;
- struct shirudo_tree_operation *operations;
+ struct tree_operation *operations;
int operations_capacity;
int n_operations;
__s64 head_seq;
};
-struct shirudo_tree_state {
+struct tree_state {
int schema;
char tree_id[TREE_STRING_MAX];
__s64 generation;
@@ -83,10 +83,10 @@ struct shirudo_tree_state {
};
int tree_parse(const char *body, size_t len,
- struct shirudo_tree_publication *out);
-int tree_publication_append(struct shirudo_tree_publication *pub,
- const struct shirudo_tree_operation *op);
-void tree_publication_free(struct shirudo_tree_publication *pub);
+ struct tree_publication *out);
+int tree_publication_append(struct tree_publication *pub,
+ const struct tree_operation *op);
+void tree_publication_free(struct tree_publication *pub);
/*
* Canonical forms shared by publisher and target: the operation digest
@@ -94,9 +94,9 @@ void tree_publication_free(struct shirudo_tree_publication *pub);
* the publication document. The emitted document is xmalloc'd; release
* it with xfree(out, out_len).
*/
-int tree_operation_digest(const struct shirudo_tree_operation *op,
+int tree_operation_digest(const struct tree_operation *op,
char out[72]);
-int tree_emit_publication(const struct shirudo_tree_publication *pub,
+int tree_emit_publication(const struct tree_publication *pub,
char **out, size_t *out_len);
/*
@@ -104,15 +104,15 @@ int tree_emit_publication(const struct shirudo_tree_publication *pub,
* selector is an unconstrained wildcard and matches every node. 1 on a
* match, 0 without one, -errno when the node's labels cannot be read.
*/
-int tree_selector_matches(const struct shirudo_tree_selector *selector);
+int tree_selector_matches(const struct tree_selector *selector);
-int tree_state_read(struct shirudo_tree_state *out);
-int tree_state_write(const struct shirudo_tree_state *state);
+int tree_state_read(struct tree_state *out);
+int tree_state_write(const struct tree_state *state);
int tree_event_append(__s64 seq, const char *operation_digest,
const __u8 projection_root[32]);
int tree_event_replay(__u8 out[32]);
-void tree_emit_status(struct shirudo_json_emit *e);
+void tree_emit_status(struct json_emit *e);
/* Whether a tree is configured, in the config image when one is active. */
bool tree_configured(void);
diff --git a/util/bpm_tree_state.c b/util/bpm_tree_state.c
index eaace7a6..ec056ecd 100644
--- a/util/bpm_tree_state.c
+++ b/util/bpm_tree_state.c
@@ -35,7 +35,7 @@
#include "paths.h"
#include "seal.h"
-static int kv_add(struct shirudo_tree_kv *dst, int *n, int max,
+static int kv_add(struct tree_kv *dst, int *n, int max,
const char *key, const char *value)
{
if (*n >= max)
@@ -47,7 +47,7 @@ static int kv_add(struct shirudo_tree_kv *dst, int *n, int max,
return 0;
}
-static const char *kv_value(const struct shirudo_tree_kv *v, int n,
+static const char *kv_value(const struct tree_kv *v, int n,
const char *key)
{
for (int i = 0; i < n; i++) {
@@ -57,7 +57,7 @@ static const char *kv_value(const struct shirudo_tree_kv *v, int n,
return NULL;
}
-static int selector_values_match(const struct shirudo_tree_selector_kv *v,
+static int selector_values_match(const struct tree_selector_kv *v,
const char *want)
{
if (!v || !want)
@@ -82,10 +82,10 @@ bool tree_configured(void)
return true;
}
-static int read_config_stream(FILE *f, struct shirudo_tree_kv *out, int *n,
+static int read_config_stream(FILE *f, struct tree_kv *out, int *n,
int max);
-static int read_config_file(const char *path, struct shirudo_tree_kv *out,
+static int read_config_file(const char *path, struct tree_kv *out,
int *n, int max, bool gz)
{
char line[512];
@@ -139,7 +139,7 @@ static int read_config_file(const char *path, struct shirudo_tree_kv *out,
}
/* The stream is consumed and closed. */
-static int read_config_stream(FILE *f, struct shirudo_tree_kv *out, int *n,
+static int read_config_stream(FILE *f, struct tree_kv *out, int *n,
int max)
{
size_t capacity = 0;
@@ -180,7 +180,7 @@ static int read_config_stream(FILE *f, struct shirudo_tree_kv *out, int *n,
return ret;
}
-static int read_config_fd(int fd, struct shirudo_tree_kv *out, int *n,
+static int read_config_fd(int fd, struct tree_kv *out, int *n,
int max)
{
FILE *f = fdopen(fd, "r");
@@ -211,7 +211,7 @@ static __u32 selector_hash(const char *key)
return hash;
}
-static void selector_hash_build(const struct shirudo_tree_selector *s,
+static void selector_hash_build(const struct tree_selector *s,
int slots[TREE_SELECTOR_HASH_SIZE])
{
memset(slots, 0xff, sizeof(int) * TREE_SELECTOR_HASH_SIZE);
@@ -227,7 +227,7 @@ static void selector_hash_build(const struct shirudo_tree_selector *s,
}
}
-static int selector_hash_find(const struct shirudo_tree_selector *s,
+static int selector_hash_find(const struct tree_selector *s,
const int slots[TREE_SELECTOR_HASH_SIZE],
const char *key)
{
@@ -246,7 +246,7 @@ static int selector_hash_find(const struct shirudo_tree_selector *s,
}
static int selector_config_line(const char *line,
- const struct shirudo_tree_selector *s,
+ const struct tree_selector *s,
const int slots[TREE_SELECTOR_HASH_SIZE],
char values[][TREE_STRING_MAX],
bool found[])
@@ -305,7 +305,7 @@ static int selector_config_line(const char *line,
}
static int read_selector_config_file(const char *path,
- const struct shirudo_tree_selector *s,
+ const struct tree_selector *s,
const int slots[TREE_SELECTOR_HASH_SIZE],
char values[][TREE_STRING_MAX],
bool found[], bool gz)
@@ -347,10 +347,10 @@ static int read_selector_config_file(const char *path,
return ret;
}
-int tree_selector_matches(const struct shirudo_tree_selector *s)
+int tree_selector_matches(const struct tree_selector *s)
{
struct utsname u;
- struct shirudo_tree_kv labels[TREE_MAX_LABELS];
+ struct tree_kv labels[TREE_MAX_LABELS];
char cfg_values[TREE_MAX_KCONFIG][TREE_STRING_MAX];
int cfg_slots[TREE_SELECTOR_HASH_SIZE];
bool cfg_found[TREE_MAX_KCONFIG] = {};
@@ -486,12 +486,12 @@ static bool hex32_valid(const char *hex)
return !hex_decode(hex, raw, sizeof(raw));
}
-int tree_state_read(struct shirudo_tree_state *out)
+int tree_state_read(struct tree_state *out)
{
__u8 *body;
size_t len;
__s64 schema = 0;
- struct shirudo_json_field f[] = {
+ struct json_field f[] = {
{ "schema", SHIRUDO_JSON_T_INT, &schema, 0, 0, NULL, 0 },
{ "tree_id", SHIRUDO_JSON_T_STRING, out->tree_id,
sizeof(out->tree_id), 0, NULL, 0 },
@@ -506,7 +506,7 @@ int tree_state_read(struct shirudo_tree_state *out)
};
int ret;
- *out = (struct shirudo_tree_state){};
+ *out = (struct tree_state){};
ret = tree_read_file(BPM_TREE_STATE_PATH, &body, &len);
if (ret)
return ret;
@@ -552,10 +552,10 @@ static int tree_atomic_write(const char *path, const void *data, size_t len)
return seal_write_file(path, data, len, 0600);
}
-int tree_state_write(const struct shirudo_tree_state *s)
+int tree_state_write(const struct tree_state *s)
{
char buf[4096];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
json_obj_open(&e);
json_kv_int(&e, "schema", 1);
@@ -575,7 +575,7 @@ int tree_event_append(__s64 seq, const char *operation_digest,
const __u8 projection_root[32])
{
char buf[1024], root[65];
- struct shirudo_json_emit e = { .buf = buf, .cap = sizeof(buf) };
+ struct json_emit e = { .buf = buf, .cap = sizeof(buf) };
struct stat st;
int fd, ret;
@@ -644,7 +644,7 @@ int tree_event_replay(__u8 out[32])
char digest[128] = {};
char projection[65] = {};
__s64 seq = 0;
- struct shirudo_json_field f[] = {
+ struct json_field f[] = {
{ "seq", SHIRUDO_JSON_T_INT, &seq, 0, 0, NULL, 0 },
{ "digest", SHIRUDO_JSON_T_STRING, digest, sizeof(digest),
0, NULL, 0 },
@@ -682,9 +682,9 @@ int tree_event_replay(__u8 out[32])
return ret;
}
-void tree_emit_status(struct shirudo_json_emit *e)
+void tree_emit_status(struct json_emit *e)
{
- struct shirudo_tree_state s = {};
+ struct tree_state s = {};
__u8 live[32], replay[32];
char hex[65];
bool configured = tree_configured();
diff --git a/util/chain.c b/util/chain.c
index 37200c37..4d6f4862 100644
--- a/util/chain.c
+++ b/util/chain.c
@@ -41,7 +41,7 @@ int sha256_calc(const void *data, size_t len, __u8 out[32])
void sha256_2(const void *a, size_t a_len,
const void *b, size_t b_len, __u8 out[32])
{
- struct shirudo_sha256_ctx ctx;
+ struct sha256_ctx ctx;
if (sha256_init(&ctx) != 0) {
memset(out, 0, 32);
@@ -68,12 +68,12 @@ int ct_eq(const void *a, const void *b, size_t n)
static int member_cmp(const void *a, const void *b)
{
- return strcmp(((const struct shirudo_measured_upatch *)a)->name,
- ((const struct shirudo_measured_upatch *)b)->name);
+ return strcmp(((const struct measured_upatch *)a)->name,
+ ((const struct measured_upatch *)b)->name);
}
int chain_init_event(const __u8 cert_sha[32],
- struct shirudo_measured_upatch *set, size_t n,
+ struct measured_upatch *set, size_t n,
const __u8 tree_root[32],
__u8 set_digest[32], __u8 event[32])
{
@@ -226,10 +226,10 @@ static bool name_equals(const struct tpm_nv_info *info,
ct_eq(info->name, name, TPM_NAME_LEN);
}
-static int register_define(struct shirudo_tpm *tpm, bool defined,
+static int register_define(struct tpm *tpm, bool defined,
const __u8 policy[32])
{
- struct shirudo_config cfg = {};
+ struct config cfg = {};
int ret;
config_load(&cfg);
@@ -247,7 +247,7 @@ out:
return ret;
}
-static int register_writer(struct shirudo_tpm *tpm,
+static int register_writer(struct tpm *tpm,
__u8 public[TPM_NV_RSA_BYTES])
{
__u8 seed[32];
@@ -262,10 +262,10 @@ static int register_writer(struct shirudo_tpm *tpm,
* public and a substitute transport can replay it. Remote evidence
* still needs a valid signature from the pinned key.
*/
-int chain_tpm_bound(struct shirudo_tpm *tpm)
+int chain_tpm_bound(struct tpm *tpm)
{
- struct shirudo_identity id = {};
- struct shirudo_tpm_key ak = {};
+ struct identity id = {};
+ struct tpm_key ak = {};
int ret;
ret = enforcement_active();
@@ -294,13 +294,13 @@ int chain_tpm_bound(struct shirudo_tpm *tpm)
}
int chain_init(const __u8 event[32],
- struct shirudo_chain_init_info *info)
+ struct chain_init_info *info)
{
__u8 unwritten[TPM_NAME_LEN], written[TPM_NAME_LEN];
__u8 branch_written[32], branch_init[32], policy[32];
- struct shirudo_eventlog_init rec;
+ struct eventlog_init rec;
struct tpm_nv_info nv;
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
bool recorded;
int ret;
@@ -450,9 +450,9 @@ int chain_extend(const __u8 event[32], __u8 out_chain[32])
{
__u8 writer_public[TPM_NV_RSA_BYTES];
__u8 branch_written[32], branch_init[32], policy[32], values[64];
- struct shirudo_eventlog_init rec;
+ struct eventlog_init rec;
struct tpm_nv_info nv;
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
__u32 reset;
int ret;
@@ -523,7 +523,7 @@ out:
int chain_read(__u8 out[32])
{
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
int ret;
ret = tpm_open(&tpm);
@@ -536,7 +536,7 @@ int chain_read(__u8 out[32])
bool chain_bound(void)
{
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
struct tpm_nv_info nv;
bool bound;
@@ -552,7 +552,7 @@ int chain_status(struct chain_status *st)
{
__u8 branch_written[32], branch_init[32], policy[32], values[64];
__u8 expected[TPM_NAME_LEN];
- struct shirudo_tpm *tpm = NULL;
+ struct tpm *tpm = NULL;
struct tpm_nv_info nv;
__u32 reset_count = 0;
int ret;
diff --git a/util/chain.h b/util/chain.h
index 3e62abda..6e811bff 100644
--- a/util/chain.h
+++ b/util/chain.h
@@ -44,7 +44,7 @@ void sha256_2(const void *a, size_t a_len,
/* Constant time; 1 when equal. */
int ct_eq(const void *a, const void *b, size_t n);
-struct shirudo_measured_upatch {
+struct measured_upatch {
char name[UPATCH_NAME_MAX + 1];
char payload_hex[2 * UPATCH_PAYLOAD_HASH_LEN + 1];
};
@@ -54,7 +54,7 @@ struct shirudo_measured_upatch {
* The set is sorted by name before hashing.
*/
int chain_init_event(const __u8 cert_sha[32],
- struct shirudo_measured_upatch *set, size_t n,
+ struct measured_upatch *set, size_t n,
const __u8 tree_root[32],
__u8 set_digest[32], __u8 event[32]);
/* SHA256(tag || NUL || cert_sha256), tag "shirudo-key-revoke". */
@@ -71,7 +71,7 @@ void chain_fold(__u8 chain[32], const __u8 event[32]);
int chain_anchor(const __u8 name[TPM_NAME_LEN],
char *out, size_t cap);
-struct shirudo_chain_init_info {
+struct chain_init_info {
__u8 writer_public[TPM_NV_RSA_BYTES];
bool reused; /* written and on record */
bool initrd; /* bound while the initrd ran */
@@ -94,7 +94,7 @@ struct shirudo_chain_init_info {
* the computed one.
*/
int chain_init(const __u8 event[CHAIN_DIGEST_LEN],
- struct shirudo_chain_init_info *info);
+ struct chain_init_info *info);
/*
* Extend this boot's register by one event through the written
@@ -108,14 +108,14 @@ int chain_extend(const __u8 event[CHAIN_DIGEST_LEN],
/* The live value; -ENODEV when no register is written this boot. */
int chain_read(__u8 out[CHAIN_DIGEST_LEN]);
-struct shirudo_tpm;
+struct tpm;
/*
* Whether the TPM behind an open handle is the one init recorded, by
* the name of its attestation key: 0 when it is or enforcement is not
* live, -EACCES for another TPM, -EPROTO without a record.
*/
-int chain_tpm_bound(struct shirudo_tpm *tpm);
+int chain_tpm_bound(struct tpm *tpm);
/* For a probe: a TPM that does not answer is not logged. */
bool chain_bound(void);
@@ -130,7 +130,7 @@ struct chain_status {
__u8 value[CHAIN_DIGEST_LEN];
__u8 name[TPM_NAME_LEN];
size_t name_len;
- struct shirudo_eventlog_init init;
+ struct eventlog_init init;
};
int chain_status(struct chain_status *st);
diff --git a/util/conditions.c b/util/conditions.c
index ae0529b2..eeee33b3 100644
--- a/util/conditions.c
+++ b/util/conditions.c
@@ -15,7 +15,7 @@
#include "conditions.h"
-static bool config_untrusted(const struct shirudo_conditions_input *in)
+static bool config_untrusted(const struct conditions_input *in)
{
return in->config_seen && in->config_state &&
in->config_state != -EINPROGRESS;
@@ -30,7 +30,7 @@ static const char *config_untrusted_detail(int state)
return "the config PCR, activation records and mounted config disagree (tamper?)";
}
-static bool keyring_tampered(const struct shirudo_conditions_input *in)
+static bool keyring_tampered(const struct conditions_input *in)
{
return (in->ksp_seen && !in->keyring_present) ||
(in->ksm_seen && !in->keyring_serial_matches) ||
@@ -40,7 +40,7 @@ static bool keyring_tampered(const struct shirudo_conditions_input *in)
}
static void __printf(3, 4)
-set_detail(struct shirudo_condition *c, const char *status,
+set_detail(struct condition *c, const char *status,
const char *fmt, ...)
{
va_list ap;
@@ -52,8 +52,8 @@ set_detail(struct shirudo_condition *c, const char *status,
va_end(ap);
}
-static void keyring_condition(const struct shirudo_conditions_input *in,
- struct shirudo_condition *c)
+static void keyring_condition(const struct conditions_input *in,
+ struct condition *c)
{
c->type = "KeyringSealed";
if (!in->keyring_present && in->ksp_seen)
@@ -97,8 +97,8 @@ static void keyring_condition(const struct shirudo_conditions_input *in,
in->ksp_seen ? "pin matches" : "no pin recorded");
}
-size_t conditions(const struct shirudo_conditions_input *in,
- struct shirudo_condition *c, size_t cap)
+size_t conditions(const struct conditions_input *in,
+ struct condition *c, size_t cap)
{
size_t n = 0;
@@ -185,7 +185,7 @@ size_t conditions(const struct shirudo_conditions_input *in,
return n;
}
-void conditions_print(const struct shirudo_condition *c, size_t n)
+void conditions_print(const struct condition *c, size_t n)
{
size_t i;
@@ -196,7 +196,7 @@ void conditions_print(const struct shirudo_condition *c, size_t n)
c[i].detail);
}
-const char *status_verdict(const struct shirudo_conditions_input *in)
+const char *status_verdict(const struct conditions_input *in)
{
if (!in->reachable)
return "unreachable";
@@ -216,7 +216,7 @@ const char *status_verdict(const struct shirudo_conditions_input *in)
return "ok";
}
-void status_reason(const struct shirudo_conditions_input *in,
+void status_reason(const struct conditions_input *in,
char *buf, size_t cap)
{
const char *v = status_verdict(in);
diff --git a/util/conditions.h b/util/conditions.h
index 2343a2d7..c3f91cb7 100644
--- a/util/conditions.h
+++ b/util/conditions.h
@@ -18,7 +18,7 @@
* The *_seen flags say whether the JSON carried a non-null value,
* since the parser leaves a null untouched.
*/
-struct shirudo_conditions_input {
+struct conditions_input {
bool reachable;
bool parsed;
const char *unreach; /* optional reason on !reachable */
@@ -48,7 +48,7 @@ struct shirudo_conditions_input {
const char *config_root; /* hex, when config_seen */
};
-struct shirudo_condition {
+struct condition {
const char *type; /* "LsmAttached" / "KeyringSealed" / ... */
const char *status; /* "OK" / "WARN" / "ALERT" */
char detail[192];
@@ -61,10 +61,10 @@ struct shirudo_condition {
*/
#define CONDITIONS_MAX 5
-size_t conditions(const struct shirudo_conditions_input *in,
- struct shirudo_condition *out, size_t cap);
+size_t conditions(const struct conditions_input *in,
+ struct condition *out, size_t cap);
-void conditions_print(const struct shirudo_condition *c, size_t n);
+void conditions_print(const struct condition *c, size_t n);
/*
* Single-word aggregate verdict (severity worst -> best):
@@ -72,9 +72,9 @@ void conditions_print(const struct shirudo_condition *c, size_t n);
* init-pending -> reboot-pending -> degraded -> ok
* Used by the `Status:` line in `shirudo status` and its JSON output.
*/
-const char *status_verdict(const struct shirudo_conditions_input *in);
+const char *status_verdict(const struct conditions_input *in);
-void status_reason(const struct shirudo_conditions_input *in,
+void status_reason(const struct conditions_input *in,
char *buf, size_t cap);
#endif /* SHIRUDO_CONDITIONS_H */
diff --git a/util/config.c b/util/config.c
index b4bea087..71e8ca41 100644
--- a/util/config.c
+++ b/util/config.c
@@ -40,7 +40,7 @@ static char *trim(char *s)
return s;
}
-static void map_export_bad(struct shirudo_config *cfg, const char *key,
+static void map_export_bad(struct config *cfg, const char *key,
const char *val, const char *reason)
{
cfg->map_export_valid = false;
@@ -91,9 +91,9 @@ static bool tls_classical_hosts_valid(const char *value)
return true;
}
-static void config_defaults(struct shirudo_config *cfg)
+static void config_defaults(struct config *cfg)
{
- *cfg = (struct shirudo_config){};
+ *cfg = (struct config){};
cfg->map_export_valid = true;
cfg->tls_classical_hosts_valid = true;
cfg->map_export_otel_retries = 3;
@@ -105,7 +105,7 @@ static void config_defaults(struct shirudo_config *cfg)
* Owner auth is a literal passphrase, or "hex:<even hex>" for a binary
* auth value (what provisioning tools that randomise owner auth emit).
*/
-static void set_owner_auth(struct shirudo_config *cfg, const char *val)
+static void set_owner_auth(struct config *cfg, const char *val)
{
size_t l;
@@ -148,7 +148,7 @@ static void set_owner_auth(struct shirudo_config *cfg, const char *val)
}
/* The stream is consumed and closed; the file is named for the log. */
-static int config_parse(struct shirudo_config *cfg, FILE *f,
+static int config_parse(struct config *cfg, FILE *f,
const char *path)
{
const size_t max = MAP_EXPORT_PATH_MAX + 127;
@@ -292,7 +292,7 @@ static int config_parse(struct shirudo_config *cfg, FILE *f,
return ret;
}
-static int config_finish(struct shirudo_config *cfg, int ret)
+static int config_finish(struct config *cfg, int ret)
{
if (cfg->map_export_s3_uri[0] && !cfg->map_export_otel_endpoint[0])
map_export_bad(cfg, "map_export.s3_uri", "",
@@ -303,7 +303,7 @@ static int config_finish(struct shirudo_config *cfg, int ret)
return ret;
}
-int config_load_path(struct shirudo_config *cfg, const char *path)
+int config_load_path(struct config *cfg, const char *path)
{
int ret = 0;
FILE *f;
@@ -322,7 +322,7 @@ int config_load_path(struct shirudo_config *cfg, const char *path)
}
/* A copy of the descriptor is read from its start; the caller keeps its own. */
-int config_load_fd(struct shirudo_config *cfg, int fd, const char *label)
+int config_load_fd(struct config *cfg, int fd, const char *label)
{
int copy, ret;
FILE *f;
@@ -347,7 +347,7 @@ int config_load_fd(struct shirudo_config *cfg, int fd, const char *label)
return config_finish(cfg, config_parse(cfg, f, label));
}
-int config_load(struct shirudo_config *cfg)
+int config_load(struct config *cfg)
{
const char *env;
int ret;
diff --git a/util/config.h b/util/config.h
index 9cb89923..9fa36dfe 100644
--- a/util/config.h
+++ b/util/config.h
@@ -24,7 +24,7 @@
#define MAP_EXPORT_LOG_RECORD_MAX_DEFAULT (1u * 1024u * 1024u)
#define MAP_EXPORT_OTLP_MAX_DEFAULT (4u * 1024u * 1024u)
-struct shirudo_config {
+struct config {
__u64 eventlog_max_bytes; /* 0 = unlimited */
/*
* Owner-hierarchy auth used to define the NV index on TPMs whose
@@ -53,11 +53,11 @@ struct shirudo_config {
};
/* A missing file is not an error. */
-int config_load(struct shirudo_config *cfg);
+int config_load(struct config *cfg);
/* Testable path-specific loader; unlike config_load(), no env. */
-int config_load_path(struct shirudo_config *cfg, const char *path);
+int config_load_path(struct config *cfg, const char *path);
/* The same from an open descriptor, read from its start. */
-int config_load_fd(struct shirudo_config *cfg, int fd, const char *label);
+int config_load_fd(struct config *cfg, int fd, const char *label);
#endif /* SHIRUDO_CONFIG_H */
diff --git a/util/config_attest.c b/util/config_attest.c
index d5cac488..b8ddcd97 100644
--- a/util/config_attest.c
+++ b/util/config_attest.c
@@ -15,10 +15,10 @@
#include "json.h"
#include "malloc.h"
-static int append_event(struct shirudo_config_evidence *view,
- const struct shirudo_config_evidence_event *event)
+static int append_event(struct config_evidence *view,
+ const struct config_evidence_event *event)
{
- struct shirudo_config_evidence_event *events;
+ struct config_evidence_event *events;
size_t capacity;
if (view->n_events >= CONFIG_EVIDENCE_EVENTS_MAX)
@@ -36,7 +36,7 @@ static int append_event(struct shirudo_config_evidence *view,
return 0;
}
-static int replay(const struct shirudo_config_evidence *view, __u8 out[32])
+static int replay(const struct config_evidence *view, __u8 out[32])
{
__u8 digest[32];
__u64 sequence = 0;
@@ -48,7 +48,7 @@ static int replay(const struct shirudo_config_evidence *view, __u8 out[32])
return -EINVAL;
memcpy(out, view->initial_pcr, 32);
for (i = 0; i < view->n_events; i++) {
- const struct shirudo_config_evidence_event *event =
+ const struct config_evidence_event *event =
&view->events[i];
if (!event->sequence || event->sequence > INT64_MAX ||
@@ -67,11 +67,11 @@ static int replay(const struct shirudo_config_evidence *view, __u8 out[32])
return 0;
}
-static int collect_event(const struct shirudo_config_update_record *record,
+static int collect_event(const struct config_update_record *record,
void *opaque)
{
- struct shirudo_config_evidence_event event = {};
- struct shirudo_config_evidence *view = opaque;
+ struct config_evidence_event event = {};
+ struct config_evidence *view = opaque;
if (record->reset_count != view->reset_count ||
record->restart_count != view->restart_count)
@@ -85,11 +85,11 @@ static int collect_event(const struct shirudo_config_update_record *record,
return append_event(view, &event);
}
-int config_evidence_collect(struct shirudo_config_update *update,
- struct shirudo_config_evidence *out)
+int config_evidence_collect(struct config_update *update,
+ struct config_evidence *out)
{
- struct shirudo_config_update_record active;
- const struct shirudo_config_evidence_event *last;
+ struct config_update_record active;
+ const struct config_evidence_event *last;
int ret;
memset(out, 0, sizeof(*out));
@@ -119,7 +119,7 @@ int config_evidence_collect(struct shirudo_config_update *update,
return 0;
}
-void config_evidence_clear(struct shirudo_config_evidence *view)
+void config_evidence_clear(struct config_evidence *view)
{
if (!view)
return;
@@ -127,7 +127,7 @@ void config_evidence_clear(struct shirudo_config_evidence *view)
memset(view, 0, sizeof(*view));
}
-static void emit_hash(struct shirudo_json_emit *emit, const char *key,
+static void emit_hash(struct json_emit *emit, const char *key,
const __u8 bytes[32])
{
char hex[65];
@@ -136,8 +136,8 @@ static void emit_hash(struct shirudo_json_emit *emit, const char *key,
json_kv_string(emit, key, hex);
}
-int config_evidence_emit(struct shirudo_json_emit *emit,
- const struct shirudo_config_evidence *view)
+int config_evidence_emit(struct json_emit *emit,
+ const struct config_evidence *view)
{
size_t i;
@@ -151,7 +151,7 @@ int config_evidence_emit(struct shirudo_json_emit *emit,
emit_hash(emit, "initial_pcr", view->initial_pcr);
json_arr_open(emit, "events");
for (i = 0; i < view->n_events; i++) {
- const struct shirudo_config_evidence_event *event =
+ const struct config_evidence_event *event =
&view->events[i];
if (event->sequence > INT64_MAX)
@@ -168,8 +168,8 @@ int config_evidence_emit(struct shirudo_json_emit *emit,
}
struct config_parser {
- struct shirudo_config_evidence *view;
- struct shirudo_json_field *event_fields;
+ struct config_evidence *view;
+ struct json_field *event_fields;
size_t n_fields;
__s64 sequence, kind;
char root_hash[65];
@@ -177,7 +177,7 @@ struct config_parser {
static int on_event(void *opaque)
{
- struct shirudo_config_evidence_event event = {};
+ struct config_evidence_event event = {};
struct config_parser *parser = opaque;
size_t i;
@@ -196,22 +196,22 @@ static int on_event(void *opaque)
}
int config_evidence_parse(const char *evidence, size_t length,
- struct shirudo_config_evidence *out)
+ struct config_evidence *out)
{
struct config_parser parser = { .view = out };
- struct shirudo_json_array sink = { on_event, &parser };
+ struct json_array sink = { on_event, &parser };
__s64 schema = 0, reset = 0, restart = 0, pcr = 0;
char initial[65] = {};
size_t i;
int ret;
- struct shirudo_json_field event_fields[] = {
+ struct json_field event_fields[] = {
{ "sequence", SHIRUDO_JSON_T_INT, &parser.sequence, 0, 0, NULL,
0 },
{ "kind", SHIRUDO_JSON_T_INT, &parser.kind, 0, 0, NULL, 0 },
{ "root_hash", SHIRUDO_JSON_T_STRING, parser.root_hash,
sizeof(parser.root_hash), 0, NULL, 0 },
};
- struct shirudo_json_field config_fields[] = {
+ struct json_field config_fields[] = {
{ "schema", SHIRUDO_JSON_T_INT, &schema, 0, 0, NULL, 0 },
{ "pcr", SHIRUDO_JSON_T_INT, &pcr, 0, 0, NULL, 0 },
{ "reset_count", SHIRUDO_JSON_T_INT, &reset, 0, 0, NULL, 0 },
@@ -222,7 +222,7 @@ int config_evidence_parse(const char *evidence, size_t length,
{ "events", SHIRUDO_JSON_T_ARRAY, &sink, 0, 0, event_fields,
ARRAY_SIZE(event_fields) },
};
- struct shirudo_json_field top[] = {
+ struct json_field top[] = {
{ "config", SHIRUDO_JSON_T_OBJECT, NULL, 0, 0, config_fields,
ARRAY_SIZE(config_fields) },
};
@@ -260,7 +260,7 @@ fail:
return ret;
}
-int config_evidence_verify(const struct shirudo_config_evidence *view,
+int config_evidence_verify(const struct config_evidence *view,
__u32 quote_mask, __u32 reset,
__u32 restart, const __u8 pcrs[24][32],
const __u8 *expected_root,
diff --git a/util/config_attest.h b/util/config_attest.h
index 1a33623a..ef424986 100644
--- a/util/config_attest.h
+++ b/util/config_attest.h
@@ -14,16 +14,16 @@
#define CONFIG_EVIDENCE_EVENTS_MAX 4096u
-struct shirudo_json_emit;
+struct json_emit;
-struct shirudo_config_evidence_event {
+struct config_evidence_event {
__u8 root_hash[32];
__u64 sequence;
- enum shirudo_config_event_kind kind;
+ enum config_event_kind kind;
};
-struct shirudo_config_evidence {
- struct shirudo_config_evidence_event *events;
+struct config_evidence {
+ struct config_evidence_event *events;
__u8 initial_pcr[32];
__u8 value[32];
size_t n_events;
@@ -34,14 +34,14 @@ struct shirudo_config_evidence {
bool present;
};
-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_collect(struct config_update *update,
+ struct config_evidence *out);
+void config_evidence_clear(struct config_evidence *view);
+int config_evidence_emit(struct json_emit *emit,
+ const struct 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,
+ struct config_evidence *out);
+int config_evidence_verify(const struct config_evidence *view,
__u32 quote_mask, __u32 reset,
__u32 restart, const __u8 pcrs[24][32],
const __u8 *expected_root,
diff --git a/util/config_image.c b/util/config_image.c
index 2808d558..eb5469e0 100644
--- a/util/config_image.c
+++ b/util/config_image.c
@@ -104,9 +104,9 @@ static int validate_superblock(const struct verity_superblock *header)
}
int config_image_read_header(int hash_fd,
- struct shirudo_config_image *out)
+ struct config_image *out)
{
- struct shirudo_config_image image = {};
+ struct config_image image = {};
struct verity_superblock header;
int ret;
@@ -127,7 +127,7 @@ int config_image_read_header(int hash_fd,
}
int config_image_check_files(int data_fd, int hash_fd,
- const struct shirudo_config_image *image)
+ const struct config_image *image)
{
__u64 data_size, hash_size, blocks;
int ret;
diff --git a/util/config_image.h b/util/config_image.h
index cc0ef726..3e47cf5a 100644
--- a/util/config_image.h
+++ b/util/config_image.h
@@ -15,7 +15,7 @@
#define CONFIG_IMAGE_SIG_MAX 16384u
#define CONFIG_IMAGE_MAX_BYTES (1ull << 40)
-struct shirudo_config_image {
+struct config_image {
__u64 data_blocks;
__u64 hash_blocks;
bool signed_root;
@@ -24,7 +24,7 @@ struct shirudo_config_image {
};
struct config_image_open {
- struct shirudo_config_image image;
+ struct config_image image;
int data_fd;
int hash_fd;
int signature_fd;
@@ -32,9 +32,9 @@ struct config_image_open {
/* Read the standard veritysetup superblock; no trust decision is made. */
int config_image_read_header(int hash_fd,
- struct shirudo_config_image *out);
+ struct config_image *out);
int config_image_check_files(int data_fd, int hash_fd,
- const struct shirudo_config_image *image);
+ const struct config_image *image);
/* Hold config inputs for kernel root-signature and mapped-data verification. */
int config_image_open(const char *prefix,
struct config_image_open *out);
diff --git a/util/config_measure.c b/util/config_measure.c
index bce1224e..d054d40f 100644
--- a/util/config_measure.c
+++ b/util/config_measure.c
@@ -14,7 +14,7 @@ int config_measure_pcr_valid(__u32 pcr)
return pcr < 16 && pcr != 9 && pcr != 11 ? 0 : -EINVAL;
}
-int config_measure_event(enum shirudo_config_event_kind kind,
+int config_measure_event(enum config_event_kind kind,
const __u8 root_hash[32], __u8 out[32])
{
static const char domain[] = "shirudo-config-root-v1";
diff --git a/util/config_measure.h b/util/config_measure.h
index b9d75df4..330bc43f 100644
--- a/util/config_measure.h
+++ b/util/config_measure.h
@@ -11,7 +11,7 @@
#include "config_update.h"
int config_measure_pcr_valid(__u32 pcr);
-int config_measure_event(enum shirudo_config_event_kind kind,
+int config_measure_event(enum 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 89b39821..09c704ff 100644
--- a/util/config_update.c
+++ b/util/config_update.c
@@ -25,7 +25,7 @@
#define RECORD_MAX (2 * CONFIG_UPDATE_PREFIX_MAX + 1024)
-static int target_valid(const struct shirudo_config_update_target *target)
+static int target_valid(const struct config_update_target *target)
{
size_t len, i;
@@ -41,10 +41,10 @@ static int target_valid(const struct shirudo_config_update_target *target)
return 0;
}
-static int record_encode(const struct shirudo_config_update_record *record,
+static int record_encode(const struct config_update_record *record,
bool state, char *out, size_t cap, size_t *length)
{
- struct shirudo_json_emit emit = { .buf = out, .cap = cap - 1 };
+ struct json_emit emit = { .buf = out, .cap = cap - 1 };
char root[65], initial[65];
hex_encode(record->target.root_hash, 32, root);
@@ -71,7 +71,7 @@ static int record_encode(const struct shirudo_config_update_record *record,
}
static int record_decode(const char *data, size_t length, bool state,
- struct shirudo_config_update_record *record)
+ struct config_update_record *record)
{
__s64 schema = 0, sequence = 0, reset = 0, restart = 0;
char root[65] = {}, initial[65] = {};
@@ -79,7 +79,7 @@ static int record_decode(const char *data, size_t length, bool state,
int pending = 0;
size_t i;
int ret;
- struct shirudo_json_field fields[] = {
+ struct json_field fields[] = {
{ "schema", SHIRUDO_JSON_T_INT, &schema, 0, 0, NULL, 0 },
{ "sequence", SHIRUDO_JSON_T_INT, &sequence, 0, 0, NULL, 0 },
{ "reset_count", SHIRUDO_JSON_T_INT, &reset, 0, 0, NULL, 0 },
@@ -133,8 +133,8 @@ static int regular_file(int fd)
return 0;
}
-static int checkpoint(struct shirudo_config_update *update,
- enum shirudo_config_update_checkpoint point)
+static int checkpoint(struct config_update *update,
+ enum config_update_checkpoint point)
{
return update->ops->checkpoint ?
update->ops->checkpoint(update->ctx, point) :
@@ -169,8 +169,8 @@ static int lock_wait(int fd, __u32 wait_ms)
}
int config_update_open(const char *directory,
- const struct shirudo_config_update_ops *ops,
- void *ctx, struct shirudo_config_update *out)
+ const struct config_update_ops *ops,
+ void *ctx, struct config_update *out)
{
struct stat st;
int ret;
@@ -232,7 +232,7 @@ fail:
return ret;
}
-void config_update_close(struct shirudo_config_update *update)
+void config_update_close(struct config_update *update)
{
if (!update)
return;
@@ -244,8 +244,8 @@ void config_update_close(struct shirudo_config_update *update)
update->lock_fd = -1;
}
-int config_update_read(struct shirudo_config_update *update,
- struct shirudo_config_update_record *out)
+int config_update_read(struct config_update *update,
+ struct config_update_record *out)
{
char wire[RECORD_MAX];
struct stat st;
@@ -282,8 +282,8 @@ int config_update_read(struct shirudo_config_update *update,
return ret;
}
-static int state_save(struct shirudo_config_update *update,
- const struct shirudo_config_update_record *record,
+static int state_save(struct config_update *update,
+ const struct config_update_record *record,
bool inject)
{
char wire[RECORD_MAX];
@@ -320,15 +320,15 @@ static int state_save(struct shirudo_config_update *update,
return ret;
}
-static bool same_boot(const struct shirudo_config_update_record *a,
- const struct shirudo_config_update_record *b)
+static bool same_boot(const struct config_update_record *a,
+ const struct config_update_record *b)
{
return a->reset_count == b->reset_count &&
a->restart_count == b->restart_count;
}
-static bool same_event(const struct shirudo_config_update_record *a,
- const struct shirudo_config_update_record *b)
+static bool same_event(const struct config_update_record *a,
+ const struct config_update_record *b)
{
return same_boot(a, b) && a->sequence == b->sequence &&
a->pcr == b->pcr && a->kind == b->kind &&
@@ -336,8 +336,8 @@ static bool same_event(const struct shirudo_config_update_record *a,
!memcmp(a->target.root_hash, b->target.root_hash, 32);
}
-static int event_follows(const struct shirudo_config_update_record *previous,
- const struct shirudo_config_update_record *record)
+static int event_follows(const struct config_update_record *previous,
+ const struct config_update_record *record)
{
if (record->sequence != previous->sequence + 1)
return -EUCLEAN;
@@ -369,12 +369,12 @@ static int read_line(FILE *file, char *line, size_t cap, size_t *length)
return *length ? -ENODATA : 0;
}
-static int events_scan(struct shirudo_config_update *update,
- struct shirudo_config_update_record *last,
+static int events_scan(struct config_update *update,
+ struct config_update_record *last,
__u8 value[32], off_t *end, bool partial,
shirudo_config_cb consume, void *ctx)
{
- struct shirudo_config_update_record previous = {}, record;
+ struct config_update_record previous = {}, record;
const __u8 *root = record.target.root_hash;
__u8 running[32] = {}, digest[32];
char wire[RECORD_MAX];
@@ -435,20 +435,20 @@ static int events_scan(struct shirudo_config_update *update,
return ret;
}
-int config_update_events(struct shirudo_config_update *update,
+int config_update_events(struct config_update *update,
shirudo_config_cb consume, void *ctx)
{
- struct shirudo_config_update_record last;
+ struct config_update_record last;
if (!update || update->dir_fd < 0 || !consume)
return -EINVAL;
return events_scan(update, &last, NULL, NULL, false, consume, ctx);
}
-static int event_append(struct shirudo_config_update *update,
- const struct shirudo_config_update_record *record)
+static int event_append(struct config_update *update,
+ const struct config_update_record *record)
{
- struct shirudo_config_update_record last;
+ struct config_update_record last;
char wire[RECORD_MAX];
size_t length;
int fd, ret;
@@ -485,7 +485,7 @@ static int event_append(struct shirudo_config_update *update,
return ret;
}
-static int live_read(struct shirudo_config_update *update, __u32 pcr,
+static int live_read(struct config_update *update, __u32 pcr,
__u32 *reset, __u32 *restart, __u8 value[32])
{
__u32 reset_after, restart_after;
@@ -502,10 +502,10 @@ static int live_read(struct shirudo_config_update *update, __u32 pcr,
return ret;
}
-static int check_record(struct shirudo_config_update *update,
- const struct shirudo_config_update_record *record)
+static int check_record(struct config_update *update,
+ const struct config_update_record *record)
{
- struct shirudo_config_update_record last;
+ struct config_update_record last;
__u8 expected[32], value[32];
__u32 reset, restart;
int ret;
@@ -523,10 +523,10 @@ static int check_record(struct shirudo_config_update *update,
return ret;
}
-int config_update_check(struct shirudo_config_update *update,
- struct shirudo_config_update_record *out)
+int config_update_check(struct config_update *update,
+ struct config_update_record *out)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
int ret;
ret = config_update_read(update, &record);
@@ -539,9 +539,9 @@ int config_update_check(struct shirudo_config_update *update,
return ret;
}
-static int complete(struct shirudo_config_update *update)
+static int complete(struct config_update *update)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
int ret, restore;
ret = config_update_read(update, &record);
@@ -563,12 +563,12 @@ static int complete(struct shirudo_config_update *update)
return ret;
}
-static int begin_event(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *target,
- const struct shirudo_config_update_record *previous,
- __u32 pcr, enum shirudo_config_event_kind kind)
+static int begin_event(struct config_update *update,
+ const struct config_update_target *target,
+ const struct config_update_record *previous,
+ __u32 pcr, enum config_event_kind kind)
{
- struct shirudo_config_update_record record = {};
+ struct config_update_record record = {};
__u8 before[32], expected[32], value[32], event[32];
__u32 reset, restart;
int ret;
@@ -628,11 +628,11 @@ static int begin_event(struct shirudo_config_update *update,
return complete(update);
}
-int config_update_begin(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *t,
+int config_update_begin(struct config_update *update,
+ const struct config_update_target *t,
__u32 pcr)
{
- struct shirudo_config_update_record previous;
+ struct config_update_record previous;
int ret;
if (!update || update->dir_fd < 0 || target_valid(t) ||
@@ -649,11 +649,11 @@ int config_update_begin(struct shirudo_config_update *update,
SHIRUDO_CONFIG_EVENT_UPDATE);
}
-int config_update_boot(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *t,
+int config_update_boot(struct config_update *update,
+ const struct config_update_target *t,
__u32 pcr)
{
- struct shirudo_config_update_record previous = {}, last;
+ struct config_update_record previous = {}, last;
__u32 reset, restart;
int ret;
@@ -694,7 +694,7 @@ int config_update_boot(struct shirudo_config_update *update,
SHIRUDO_CONFIG_EVENT_BOOT);
}
-int config_update_complete_boot(struct shirudo_config_update *update)
+int config_update_complete_boot(struct config_update *update)
{
int ret;
diff --git a/util/config_update.h b/util/config_update.h
index 0cbe5905..5ee975de 100644
--- a/util/config_update.h
+++ b/util/config_update.h
@@ -11,12 +11,12 @@
#define CONFIG_UPDATE_PREFIX_MAX 4096u
-enum shirudo_config_event_kind {
+enum config_event_kind {
SHIRUDO_CONFIG_EVENT_BOOT = 1,
SHIRUDO_CONFIG_EVENT_UPDATE = 2,
};
-enum shirudo_config_update_checkpoint {
+enum config_update_checkpoint {
SHIRUDO_CONFIG_CHECK_PENDING_SYNC = 1,
SHIRUDO_CONFIG_CHECK_EXTEND,
SHIRUDO_CONFIG_CHECK_EVENT_SYNC,
@@ -27,43 +27,43 @@ enum shirudo_config_update_checkpoint {
SHIRUDO_CONFIG_CHECK_EVENT_WRITE,
};
-struct shirudo_config_update_target {
+struct config_update_target {
char prefix[CONFIG_UPDATE_PREFIX_MAX];
__u8 root_hash[32];
};
-struct shirudo_config_update_record {
- struct shirudo_config_update_target target;
+struct config_update_record {
+ struct config_update_target target;
__u8 initial_pcr[32];
__u64 sequence;
__u32 reset_count;
__u32 restart_count;
__u32 pcr;
- enum shirudo_config_event_kind kind;
+ enum config_event_kind kind;
bool pending;
};
/* prepare verifies the signed mapping and contents before saving intent. */
-struct shirudo_config_update_ops {
+struct config_update_ops {
int (*boot_identity)(void *ctx, __u32 *reset, __u32 *restart);
int (*pcr_read)(void *ctx, __u32 pcr, __u8 out[32]);
int (*pcr_extend)(void *ctx, __u32 pcr, const __u8 event[32]);
int (*prepare)(void *ctx,
- const struct shirudo_config_update_target *target);
+ const struct config_update_target *target);
int (*activate)(void *ctx,
- const struct shirudo_config_update_target *target);
+ const struct config_update_target *target);
int (*seal)(void *ctx, int fd);
int (*checkpoint)(void *ctx,
- enum shirudo_config_update_checkpoint checkpoint);
+ enum config_update_checkpoint checkpoint);
/* How long to wait for another command's operation lock; 0 fails at once. */
__u32 lock_wait_ms;
};
-typedef int (*shirudo_config_cb)(const struct shirudo_config_update_record *r,
+typedef int (*shirudo_config_cb)(const struct config_update_record *r,
void *ctx);
-struct shirudo_config_update {
- const struct shirudo_config_update_ops *ops;
+struct config_update {
+ const struct config_update_ops *ops;
void *ctx;
int dir_fd;
int lock_fd;
@@ -72,24 +72,24 @@ struct shirudo_config_update {
/* Holds the update lock until close. The directory must already exist. */
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,
+ const struct config_update_ops *ops,
+ void *ctx, struct config_update *out);
+void config_update_close(struct config_update *update);
+int config_update_read(struct config_update *update,
+ struct config_update_record *out);
+int config_update_begin(struct config_update *update,
+ const struct config_update_target *t,
__u32 pcr);
/* Boot leaves intent pending until upatch restoration and NV init succeed. */
-int config_update_boot(struct shirudo_config_update *update,
- const struct shirudo_config_update_target *t,
+int config_update_boot(struct config_update *update,
+ const struct config_update_target *t,
__u32 pcr);
-int config_update_complete_boot(struct shirudo_config_update *update);
+int config_update_complete_boot(struct config_update *update);
/* Refuses pending updates and PCR drift; callers also validate live mounts. */
-int config_update_check(struct shirudo_config_update *update,
- struct shirudo_config_update_record *out);
+int config_update_check(struct config_update *update,
+ struct config_update_record *out);
/* Events describe selections, not a proof that activation completed. */
-int config_update_events(struct shirudo_config_update *update,
+int config_update_events(struct config_update *update,
shirudo_config_cb consume, void *ctx);
#endif /* SHIRUDO_CONFIG_UPDATE_H */
diff --git a/util/crypto.h b/util/crypto.h
index b1a0727b..c0a7507b 100644
--- a/util/crypto.h
+++ b/util/crypto.h
@@ -19,16 +19,16 @@
#define CRYPTO_SHA256_LEN 32
-struct shirudo_sha256_ctx {
+struct sha256_ctx {
void *impl;
};
-int sha256_init(struct shirudo_sha256_ctx *ctx);
-int sha256_update(struct shirudo_sha256_ctx *ctx,
+int sha256_init(struct sha256_ctx *ctx);
+int sha256_update(struct sha256_ctx *ctx,
const void *data, size_t len);
-int sha256_final(struct shirudo_sha256_ctx *ctx,
+int sha256_final(struct sha256_ctx *ctx,
__u8 out[CRYPTO_SHA256_LEN]);
-void sha256_free(struct shirudo_sha256_ctx *ctx);
+void sha256_free(struct sha256_ctx *ctx);
int sha256_buffer(const void *data, size_t len,
__u8 out[CRYPTO_SHA256_LEN]);
int base64_encode(const __u8 *data, size_t len,
@@ -39,40 +39,40 @@ int ecdsa_p256_verify(const __u8 x[32], const __u8 y[32],
const __u8 digest[CRYPTO_SHA256_LEN],
const __u8 r[32], const __u8 s[32]);
-struct shirudo_cert {
+struct cert {
void *impl;
};
-int cert_read_file(const char *path, struct shirudo_cert *cert);
-int cert_read_fd(int fd, struct shirudo_cert *cert);
-void cert_free(struct shirudo_cert *cert);
-int cert_pubkey_digest(const struct shirudo_cert *cert,
+int cert_read_file(const char *path, struct cert *cert);
+int cert_read_fd(int fd, struct cert *cert);
+void cert_free(struct cert *cert);
+int cert_pubkey_digest(const struct cert *cert,
__u8 out[CRYPTO_SHA256_LEN]);
/* The provider's name for the cert's public key, e.g. "ML-DSA-87". */
-int cert_key_algorithm(const struct shirudo_cert *cert,
+int cert_key_algorithm(const struct cert *cert,
char *out, size_t out_sz);
/* The subject on one line, "O=Example, CN=fleet", control bytes escaped. */
-int cert_subject(const struct shirudo_cert *cert, char *out, size_t out_sz);
+int cert_subject(const struct cert *cert, char *out, size_t out_sz);
/* The validity window as UTC dates, YYYY-MM-DD. */
-int cert_validity(const struct shirudo_cert *cert, char not_before[11],
+int cert_validity(const struct cert *cert, char not_before[11],
char not_after[11]);
int verify_detached(const __u8 *payload, size_t payload_len,
const __u8 *signature, size_t signature_len,
- const struct shirudo_cert *cert);
+ const struct cert *cert);
/*
* Whether a signer of the CMS blob names this certificate, by key id
* or by issuer and serial: 1 when one does, 0 when none, -EINVAL when
* the blob does not parse. Says nothing about the signature's validity.
*/
int cms_signed_by(const __u8 *signature, size_t signature_len,
- const struct shirudo_cert *cert);
+ const struct cert *cert);
-struct shirudo_tls_ca {
+struct tls_ca {
const char *path;
void *impl;
};
-void tls_ca_cleanup(struct shirudo_tls_ca *ca);
+void tls_ca_cleanup(struct tls_ca *ca);
/*
* shirudo's TLS policy for every libcurl handle it opens: TLS 1.3 only
@@ -84,7 +84,7 @@ void tls_ca_cleanup(struct shirudo_tls_ca *ca);
* is the extra trust anchor fed to the SSL_CTX callback. Returns 0 or a
* negative errno; callers must not connect when it fails.
*/
-int tls_curl_policy(CURL *curl, struct shirudo_tls_ca *ca);
+int tls_curl_policy(CURL *curl, struct tls_ca *ca);
int hmac_sha256(const __u8 *key, size_t key_len,
const void *data, size_t len,
@@ -115,7 +115,7 @@ int base64_decode(const char *in, size_t in_len, __u8 *out,
size_t cap, size_t *out_len);
int cert_read_der(const __u8 *der, size_t len,
- struct shirudo_cert *cert);
+ struct cert *cert);
struct cert_pubkey {
bool rsa;
@@ -126,7 +126,7 @@ struct cert_pubkey {
__u8 y[32];
};
-int cert_pubkey(const struct shirudo_cert *cert,
+int cert_pubkey(const struct cert *cert,
struct cert_pubkey *out);
/*
@@ -134,7 +134,7 @@ int cert_pubkey(const struct shirudo_cert *cert,
* -EKEYREJECTED when it does not chain, with *reason set to libcrypto's
* static explanation; -EINVAL when the bundle cannot be loaded.
*/
-int cert_verify_chain(const struct shirudo_cert *cert,
+int cert_verify_chain(const struct cert *cert,
const char *bundle_path, const char **reason);
/* Log libcrypto's last error under where. */
diff --git a/util/crypto_openssl.c b/util/crypto_openssl.c
index 30c9a0ad..a7080a75 100644
--- a/util/crypto_openssl.c
+++ b/util/crypto_openssl.c
@@ -72,7 +72,7 @@ static int read_x509(const char *path, X509 **out)
return 0;
}
-int sha256_init(struct shirudo_sha256_ctx *ctx)
+int sha256_init(struct sha256_ctx *ctx)
{
EVP_MD_CTX *md;
@@ -88,7 +88,7 @@ int sha256_init(struct shirudo_sha256_ctx *ctx)
return 0;
}
-int sha256_update(struct shirudo_sha256_ctx *ctx,
+int sha256_update(struct sha256_ctx *ctx,
const void *data, size_t len)
{
if (!ctx || !ctx->impl || (len && !data))
@@ -96,7 +96,7 @@ int sha256_update(struct shirudo_sha256_ctx *ctx,
return EVP_DigestUpdate(ctx->impl, data, len) == 1 ? 0 : -EIO;
}
-int sha256_final(struct shirudo_sha256_ctx *ctx,
+int sha256_final(struct sha256_ctx *ctx,
__u8 out[CRYPTO_SHA256_LEN])
{
__u32 len = 0;
@@ -110,7 +110,7 @@ int sha256_final(struct shirudo_sha256_ctx *ctx,
return ret;
}
-void sha256_free(struct shirudo_sha256_ctx *ctx)
+void sha256_free(struct sha256_ctx *ctx)
{
if (!ctx)
return;
@@ -121,7 +121,7 @@ void sha256_free(struct shirudo_sha256_ctx *ctx)
int sha256_buffer(const void *data, size_t len,
__u8 out[CRYPTO_SHA256_LEN])
{
- struct shirudo_sha256_ctx ctx;
+ struct sha256_ctx ctx;
int ret;
ret = sha256_init(&ctx);
@@ -215,7 +215,7 @@ out:
return ret;
}
-int cert_read_file(const char *path, struct shirudo_cert *cert)
+int cert_read_file(const char *path, struct cert *cert)
{
X509 *x509;
int ret;
@@ -227,7 +227,7 @@ int cert_read_file(const char *path, struct shirudo_cert *cert)
return ret;
}
-int cert_read_fd(int fd, struct shirudo_cert *cert)
+int cert_read_fd(int fd, struct cert *cert)
{
size_t len = 0;
__u8 *der;
@@ -243,7 +243,7 @@ int cert_read_fd(int fd, struct shirudo_cert *cert)
return ret;
}
-void cert_free(struct shirudo_cert *cert)
+void cert_free(struct cert *cert)
{
if (!cert)
return;
@@ -259,7 +259,7 @@ void cert_free(struct shirudo_cert *cert)
* X.509 parser accepts, including ML-DSA keys libcrypto cannot otherwise
* marshal as a bare EVP_PKEY on older releases.
*/
-int cert_pubkey_digest(const struct shirudo_cert *cert,
+int cert_pubkey_digest(const struct cert *cert,
__u8 out[CRYPTO_SHA256_LEN])
{
__u8 *der = NULL, *p;
@@ -291,7 +291,7 @@ out:
return ret;
}
-int cert_key_algorithm(const struct shirudo_cert *cert,
+int cert_key_algorithm(const struct cert *cert,
char *out, size_t out_sz)
{
const char *name;
@@ -308,7 +308,7 @@ int cert_key_algorithm(const struct shirudo_cert *cert,
return 0;
}
-int cert_subject(const struct shirudo_cert *cert, char *out, size_t out_sz)
+int cert_subject(const struct cert *cert, char *out, size_t out_sz)
{
char *text;
long len;
@@ -345,7 +345,7 @@ static int asn1_date(const ASN1_TIME *t, char out[11])
return strftime(out, 11, "%Y-%m-%d", &tm) == 10 ? 0 : -EINVAL;
}
-int cert_validity(const struct shirudo_cert *cert, char not_before[11],
+int cert_validity(const struct cert *cert, char not_before[11],
char not_after[11])
{
int ret;
@@ -380,7 +380,7 @@ static CMS_ContentInfo *read_cms(const __u8 *signature, size_t len)
*/
int verify_detached(const __u8 *payload, size_t payload_len,
const __u8 *signature, size_t signature_len,
- const struct shirudo_cert *cert)
+ const struct cert *cert)
{
STACK_OF(X509) *signers = NULL;
BIO *data = NULL, *out = NULL;
@@ -417,7 +417,7 @@ done:
}
int cms_signed_by(const __u8 *signature, size_t signature_len,
- const struct shirudo_cert *cert)
+ const struct cert *cert)
{
STACK_OF(CMS_SignerInfo) *sis;
CMS_ContentInfo *cms = NULL;
@@ -603,7 +603,7 @@ out:
}
int cert_read_der(const __u8 *der, size_t len,
- struct shirudo_cert *cert)
+ struct cert *cert)
{
const __u8 *p = der;
@@ -613,7 +613,7 @@ int cert_read_der(const __u8 *der, size_t len,
return cert->impl ? 0 : -EINVAL;
}
-int cert_pubkey(const struct shirudo_cert *cert,
+int cert_pubkey(const struct cert *cert,
struct cert_pubkey *out)
{
BIGNUM *a = NULL, *b = NULL;
@@ -654,7 +654,7 @@ out:
return ret;
}
-int cert_verify_chain(const struct shirudo_cert *cert,
+int cert_verify_chain(const struct cert *cert,
const char *bundle_path, const char **reason)
{
X509_STORE_CTX *ctx = NULL;
diff --git a/util/dm_verity.c b/util/dm_verity.c
index 9d1496c6..13018ad5 100644
--- a/util/dm_verity.c
+++ b/util/dm_verity.c
@@ -192,7 +192,7 @@ static int loop_attach(int file_fd, __u64 bytes, int *out)
return 0;
}
-static int device_path(struct shirudo_dm_verity *device, __u64 dev)
+static int device_path(struct dm_verity *device, __u64 dev)
{
struct stat st;
@@ -238,8 +238,8 @@ static int dm_device(char *token, dev_t *out)
}
static int check_table(union dm_buffer *buf,
- const struct shirudo_config_image *image,
- struct shirudo_dm_verity *device)
+ const struct config_image *image,
+ struct dm_verity *device)
{
char root[65], salt[65], *tokens[13], *save = NULL, *token;
struct dm_target_spec *target;
@@ -305,10 +305,10 @@ static int check_table(union dm_buffer *buf,
}
int dm_verity_inspect(const char *name,
- const struct shirudo_config_image *image,
- struct shirudo_dm_verity *out)
+ const struct config_image *image,
+ struct dm_verity *out)
{
- struct shirudo_dm_verity device = {.data_loop_fd = -1,
+ struct dm_verity device = {.data_loop_fd = -1,
.hash_loop_fd = -1};
union dm_buffer buf;
int control, ret;
@@ -335,7 +335,7 @@ int dm_verity_inspect(const char *name,
return ret;
}
-void dm_verity_close(struct shirudo_dm_verity *device)
+void dm_verity_close(struct dm_verity *device)
{
if (!device)
return;
@@ -347,7 +347,7 @@ void dm_verity_close(struct shirudo_dm_verity *device)
device->hash_loop_fd = -1;
}
-int dm_verity_remove(struct shirudo_dm_verity *device, bool deferred)
+int dm_verity_remove(struct dm_verity *device, bool deferred)
{
union dm_buffer buf;
int control, ret;
@@ -423,12 +423,12 @@ static key_serial_t signature_key(int fd, char description[64])
}
int dm_verity_create(const struct config_image_open *image,
- const char *name, struct shirudo_dm_verity *out)
+ const char *name, struct dm_verity *out)
{
- struct shirudo_dm_verity device = {.data_loop_fd = -1,
+ struct dm_verity device = {.data_loop_fd = -1,
.hash_loop_fd = -1};
char root[65], salt[65], params[512], signature[64];
- struct shirudo_config_root_guard guard = {
+ struct config_root_guard guard = {
.map_fd = -1,
.task_fd = -1,
};
@@ -593,12 +593,12 @@ static int loop_check(int loop_fd, int file_fd, __u64 bytes)
}
/* Direct reads verify all logical data, including blocks outside live files. */
-int dm_verity_verify(const struct shirudo_dm_verity *device,
+int dm_verity_verify(const struct dm_verity *device,
const struct config_image_open *image)
{
_Alignas(4096) __u8 buffer[65536];
int data = -1, hashes = -1, fd = -1;
- struct shirudo_dm_verity checked;
+ struct dm_verity checked;
__u64 bytes, size, offset = 0;
int ret, readonly;
struct stat st;
@@ -687,11 +687,11 @@ out:
return ret;
}
-int dm_verity_mount(const struct shirudo_dm_verity *device,
+int dm_verity_mount(const struct dm_verity *device,
const char *mountpoint, bool executable)
{
__u64 flags = MS_RDONLY | MS_NODEV | MS_NOSUID;
- struct shirudo_dm_verity checked;
+ struct dm_verity checked;
struct stat st;
int ret;
diff --git a/util/dm_verity.h b/util/dm_verity.h
index b7ea433b..2b137e90 100644
--- a/util/dm_verity.h
+++ b/util/dm_verity.h
@@ -10,8 +10,8 @@
#include "config_image.h"
-struct shirudo_dm_verity {
- struct shirudo_config_image image;
+struct dm_verity {
+ struct config_image image;
char name[128];
char path[PATH_MAX];
dev_t device;
@@ -25,17 +25,17 @@ typedef int (*shirudo_dm_verity_cb)(const char *name, dev_t device, void *ctx);
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);
+ const char *name, struct dm_verity *out);
/* Require the active readonly table to match the image parameters exactly. */
int dm_verity_inspect(const char *name,
- const struct shirudo_config_image *image,
- struct shirudo_dm_verity *out);
+ const struct config_image *image,
+ struct dm_verity *out);
/* Read every data block through the mapping bound to these retained files. */
-int dm_verity_verify(const struct shirudo_dm_verity *device,
+int dm_verity_verify(const struct dm_verity *device,
const struct config_image_open *image);
-int dm_verity_mount(const struct shirudo_dm_verity *device,
+int dm_verity_mount(const struct 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);
+int dm_verity_remove(struct dm_verity *device, bool deferred);
+void dm_verity_close(struct dm_verity *device);
#endif /* SHIRUDO_DM_VERITY_H */
diff --git a/util/elf_target.c b/util/elf_target.c
index 42f6165b..a8a1b03c 100644
--- a/util/elf_target.c
+++ b/util/elf_target.c
@@ -144,7 +144,7 @@ int elf_build_id_fd(int fd,
}
int elf_target_resolve(const char *path, const char *pattern,
- struct shirudo_elf_target *out)
+ struct elf_target *out)
{
Elf *elf = NULL;
unsigned long *resolved_offsets = NULL;
@@ -216,7 +216,7 @@ out:
return err;
}
-void elf_target_free(struct shirudo_elf_target *target)
+void elf_target_free(struct elf_target *target)
{
if (!target)
return;
diff --git a/util/elf_target.h b/util/elf_target.h
index 07153f8d..0e5f5380 100644
--- a/util/elf_target.h
+++ b/util/elf_target.h
@@ -9,7 +9,7 @@
#include <shirudo/misc.h>
#include <shirudo/upatch.h>
-struct shirudo_elf_target {
+struct elf_target {
__u8 build_id[UPATCH_BUILD_ID_MAX];
__u32 build_id_len;
__u64 *offsets;
@@ -17,12 +17,12 @@ struct shirudo_elf_target {
};
int elf_target_resolve(const char *path, const char *pattern,
- struct shirudo_elf_target *out);
+ struct elf_target *out);
int elf_build_id_fd(int fd,
__u8 build_id[UPATCH_BUILD_ID_MAX],
__u32 *build_id_len);
-void elf_target_free(struct shirudo_elf_target *target);
+void elf_target_free(struct elf_target *target);
#endif /* SHIRUDO_ELF_TARGET_H */
diff --git a/util/eventlog.c b/util/eventlog.c
index 2d1431df..1632f41c 100644
--- a/util/eventlog.c
+++ b/util/eventlog.c
@@ -189,7 +189,7 @@ static int walk_lines(char *buf, int (*cb)(const char *line, size_t len,
eventlog_boot_id(boot_id, sizeof(boot_id));
for (line = strtok_r(buf, "\n", &save); line && !ret;
line = strtok_r(NULL, "\n", &save)) {
- struct shirudo_json_field f[] = {
+ struct json_field f[] = {
{ "boot_id", SHIRUDO_JSON_T_STRING, line_boot,
sizeof(line_boot), 0, NULL, 0 },
{ "type", SHIRUDO_JSON_T_STRING, type, sizeof(type),
@@ -357,7 +357,7 @@ int eventlog_adopt_pending(void)
static int replay_line(const char *line, size_t len, bool is_init, void *ctx)
{
char digest_hex[2 * 32 + 1];
- struct shirudo_json_field f[] = {
+ struct json_field f[] = {
{ "digest", SHIRUDO_JSON_T_STRING, digest_hex,
sizeof(digest_hex), 0, NULL, 0 },
};
@@ -391,9 +391,9 @@ static int init_line(const char *line, size_t len, bool is_init, void *ctx)
char writer_public[2 * TPM_NV_RSA_BYTES + 1];
char pcr_before[2 * 32 + 1], name[2 * TPM_NAME_LEN + 1];
char phase_before[2 * 32 + 1], anchor[2 * 32 + 1], bound_in[8];
- struct shirudo_eventlog_init *out = ctx;
+ struct eventlog_init *out = ctx;
__s64 pcr = -1, reset_count = -1;
- struct shirudo_json_field f[] = {
+ struct json_field f[] = {
{ "pcr_before", SHIRUDO_JSON_T_STRING, pcr_before,
sizeof(pcr_before), 0, NULL, 0 },
{ "nv_name", SHIRUDO_JSON_T_STRING, name, sizeof(name), 0,
@@ -447,7 +447,7 @@ static int init_line(const char *line, size_t len, bool is_init, void *ctx)
return 0;
}
-int eventlog_boot_init(struct shirudo_eventlog_init *out)
+int eventlog_boot_init(struct eventlog_init *out)
{
memset(out, 0, sizeof(*out));
return walk_boot(init_line, out);
@@ -498,7 +498,7 @@ void eventlog_boot_id(char *out, size_t cap)
out[--n] = '\0';
}
-void eventlog_record_open(struct shirudo_json_emit *e, const char *type,
+void eventlog_record_open(struct json_emit *e, const char *type,
const __u8 digest[32])
{
char ts[32], boot_id[64], nv_index[16], digest_hex[65];
diff --git a/util/eventlog.h b/util/eventlog.h
index c42a4089..30c1c7a9 100644
--- a/util/eventlog.h
+++ b/util/eventlog.h
@@ -54,7 +54,7 @@ int eventlog_replay(__u8 out[TPM_DIGEST_LEN]);
* how many init records the boot holds: more than one for the TPM reset
* the last one names means the register was bound again.
*/
-struct shirudo_eventlog_init {
+struct eventlog_init {
__u8 writer_public[TPM_NV_RSA_BYTES];
__u32 pcr;
bool initrd; /* bound while the initrd ran */
@@ -69,7 +69,7 @@ struct shirudo_eventlog_init {
__u32 records_epoch; /* for this reset count */
};
-int eventlog_boot_init(struct shirudo_eventlog_init *out);
+int eventlog_boot_init(struct eventlog_init *out);
int eventlog_boot_lines(int (*cb)(const char *line, size_t len,
void *ctx), void *ctx);
@@ -85,14 +85,14 @@ int eventlog_would_exceed(__u64 max_bytes);
void eventlog_timestamp(char *out, size_t cap); /* ISO-8601 UTC */
void eventlog_boot_id(char *out, size_t cap); /* /proc boot_id */
-struct shirudo_json_emit;
+struct json_emit;
/*
* Open a record and write the fields every record starts with, through
* boot_id; the caller adds its own and closes the object. A failure
* lands in e->err like any other.
*/
-void eventlog_record_open(struct shirudo_json_emit *e, const char *type,
+void eventlog_record_open(struct json_emit *e, const char *type,
const __u8 digest[32]);
#endif /* SHIRUDO_EVENTLOG_H */
diff --git a/util/help.c b/util/help.c
index a2eea4ef..9a27eb71 100644
--- a/util/help.c
+++ b/util/help.c
@@ -70,7 +70,7 @@ int is_list_cmds(const char *arg)
return arg && strcmp(arg, "--list-cmds") == 0;
}
-void print_subcmd_list(const struct shirudo_help_item *items,
+void print_subcmd_list(const struct help_item *items,
size_t n_items)
{
size_t i;
@@ -79,7 +79,7 @@ void print_subcmd_list(const struct shirudo_help_item *items,
printf("%s\n", items[i].name);
}
-void print_help(const struct shirudo_help *h)
+void print_help(const struct help *h)
{
size_t i, j;
@@ -89,7 +89,7 @@ void print_help(const struct shirudo_help *h)
fprintf(stderr, "\n%s\n", h->summary);
for (i = 0; i < h->n_sections; i++) {
- const struct shirudo_help_section *s = &h->sections[i];
+ const struct help_section *s = &h->sections[i];
size_t w = 0;
if (s->n_items == 0)
@@ -121,10 +121,10 @@ void print_help(const struct shirudo_help *h)
static void
help_unknown_subcommand(const char *cmd_label, const char *bad,
- const struct shirudo_help_item *subcmds,
+ const struct help_item *subcmds,
size_t n_subcmds)
{
- struct shirudo_suggestion sugg[4];
+ struct suggestion sugg[4];
const char *names[SUBCMD_MAX];
size_t i, n_names = 0, n;
int max_dist, len;
@@ -154,7 +154,7 @@ help_unknown_subcommand(const char *cmd_label, const char *bad,
const char *resolve_subcommand(const char *cmd_label,
const char *input,
- const struct shirudo_help_item *subcmds,
+ const struct help_item *subcmds,
size_t n_subcmds)
{
const char *names[SUBCMD_MAX];
diff --git a/util/help.h b/util/help.h
index 2bc7f5af..56d2922a 100644
--- a/util/help.h
+++ b/util/help.h
@@ -10,21 +10,21 @@
#include <stddef.h>
-struct shirudo_help_item {
+struct help_item {
const char *name;
const char *summary;
};
-struct shirudo_help_section {
+struct help_section {
const char *header;
- const struct shirudo_help_item *items;
+ const struct help_item *items;
size_t n_items;
};
-struct shirudo_help {
+struct help {
const char *usage;
const char *summary;
- const struct shirudo_help_section *sections;
+ const struct help_section *sections;
size_t n_sections;
const char *footer;
};
@@ -33,10 +33,10 @@ int is_help(const char *arg);
int is_list_cmds(const char *arg);
-void print_help(const struct shirudo_help *h);
+void print_help(const struct help *h);
/* What bash completion reads through --list-cmds. */
-void print_subcmd_list(const struct shirudo_help_item *items,
+void print_subcmd_list(const struct help_item *items,
size_t n_items);
/*
@@ -45,7 +45,7 @@ void print_subcmd_list(const struct shirudo_help_item *items,
*/
const char *resolve_subcommand(const char *cmd_label,
const char *input,
- const struct shirudo_help_item *subcmds,
+ const struct help_item *subcmds,
size_t n_subcmds);
#endif /* SHIRUDO_HELP_H */
diff --git a/util/identity.c b/util/identity.c
index e58a754e..36f79c3a 100644
--- a/util/identity.c
+++ b/util/identity.c
@@ -31,7 +31,7 @@ int enforcement_active(void)
return errno == EINVAL || errno == ENOSYS ? 0 : -errno;
}
-int identity_read(struct shirudo_identity *out)
+int identity_read(struct identity *out)
{
struct bpf_map_info info = {};
__u32 len = sizeof(info);
diff --git a/util/identity.h b/util/identity.h
index 82d980cb..5fbb8851 100644
--- a/util/identity.h
+++ b/util/identity.h
@@ -18,7 +18,7 @@
#define IDENTITY_KEYS_MAX 16
/* The frozen ABI shared with bpf/lib/identity.h. */
-struct shirudo_identity {
+struct identity {
__u32 sb_dev;
__u32 run_dev;
__s32 keyring_serial;
@@ -41,7 +41,7 @@ struct shirudo_identity {
#define DEVICE_RUNTIME 1
#define DEVICE_CONFIG 2
-struct shirudo_device_authority {
+struct device_authority {
__u32 dev;
__u32 kind;
__u8 root[32];
@@ -49,14 +49,14 @@ struct shirudo_device_authority {
};
/* Task storage for one config mapping preparation. */
-struct shirudo_expected_root {
+struct expected_root {
__u8 root[32];
__u32 valid;
};
-BUILD_BUG_ON(sizeof(struct shirudo_expected_root) != 36);
+BUILD_BUG_ON(sizeof(struct expected_root) != 36);
-struct shirudo_task_authority {
+struct task_authority {
__u8 trusted;
__u8 candidate_valid;
__u8 candidate_trusted;
@@ -64,16 +64,16 @@ struct shirudo_task_authority {
__u32 pad2;
};
-BUILD_BUG_ON(sizeof(struct shirudo_device_authority) != 48);
-BUILD_BUG_ON(sizeof(struct shirudo_task_authority) != 8);
-BUILD_BUG_ON(sizeof(struct shirudo_identity) != 584);
+BUILD_BUG_ON(sizeof(struct device_authority) != 48);
+BUILD_BUG_ON(sizeof(struct task_authority) != 8);
+BUILD_BUG_ON(sizeof(struct identity) != 584);
/* The bpffs mount init made, which the unmount guard keeps mounted. */
-struct shirudo_mount_record {
+struct mount_record {
__u64 mount;
};
-BUILD_BUG_ON(sizeof(struct shirudo_mount_record) != 8);
+BUILD_BUG_ON(sizeof(struct mount_record) != 8);
/*
* The identity map init populated, froze and pinned this boot. -ENOENT
@@ -81,6 +81,6 @@ BUILD_BUG_ON(sizeof(struct shirudo_mount_record) != 8);
*/
/* 1 when enforcement is active, 0 before init, otherwise -errno. */
int enforcement_active(void);
-int identity_read(struct shirudo_identity *out);
+int identity_read(struct identity *out);
#endif /* SHIRUDO_UTIL_IDENTITY_H */
diff --git a/util/image_bootstrap.c b/util/image_bootstrap.c
index 45ca3bdd..5f4443a5 100644
--- a/util/image_bootstrap.c
+++ b/util/image_bootstrap.c
@@ -40,7 +40,7 @@ static char *trim(char *text)
}
/* The stream is consumed and closed. */
-static int bootstrap_parse(FILE *file, struct shirudo_image_bootstrap *boot,
+static int bootstrap_parse(FILE *file, struct image_bootstrap *boot,
bool initial)
{
size_t capacity = 0;
@@ -119,7 +119,7 @@ static int bootstrap_parse(FILE *file, struct shirudo_image_bootstrap *boot,
}
int image_bootstrap_read(const char *path,
- struct shirudo_image_bootstrap *boot,
+ struct image_bootstrap *boot,
bool initial)
{
FILE *file = fopen(path, "re");
@@ -131,7 +131,7 @@ int image_bootstrap_read(const char *path,
/* A copy of the descriptor is read from its start; the caller keeps its own. */
int image_bootstrap_read_fd(int fd,
- struct shirudo_image_bootstrap *boot,
+ struct image_bootstrap *boot,
bool initial)
{
int copy, ret;
diff --git a/util/image_bootstrap.h b/util/image_bootstrap.h
index 935192a2..77e9db30 100644
--- a/util/image_bootstrap.h
+++ b/util/image_bootstrap.h
@@ -10,7 +10,7 @@
#include <stdbool.h>
#include <stdint.h>
-struct shirudo_image_bootstrap {
+struct image_bootstrap {
char runtime[PATH_MAX];
char config[PATH_MAX];
char certificate[PATH_MAX];
@@ -23,10 +23,10 @@ struct shirudo_image_bootstrap {
bool image_path_valid(const char *path);
/* Only the authenticated initrd may supply runtime.image and root_hash. */
int image_bootstrap_read(const char *path,
- struct shirudo_image_bootstrap *boot,
+ struct image_bootstrap *boot,
bool initial);
int image_bootstrap_read_fd(int fd,
- struct shirudo_image_bootstrap *boot,
+ struct image_bootstrap *boot,
bool initial);
#endif /* SHIRUDO_IMAGE_BOOTSTRAP_H */
diff --git a/util/image_cache.c b/util/image_cache.c
index e09f0ec0..044d2065 100644
--- a/util/image_cache.c
+++ b/util/image_cache.c
@@ -149,7 +149,7 @@ static int fetch_file(const char *source, const char *destination, __u64 max)
static int verify_incoming(const struct config_image_open *opened,
const char *staging)
{
- struct shirudo_dm_verity device = {
+ struct dm_verity device = {
.data_loop_fd = -1,
.hash_loop_fd = -1,
};
@@ -171,7 +171,7 @@ static int verify_incoming(const struct config_image_open *opened,
}
int image_cache_fetch(const char *source,
- struct shirudo_config_update_target *target)
+ struct config_update_target *target)
{
static const struct {
const char *suffix;
diff --git a/util/image_cache.h b/util/image_cache.h
index ec8205e9..39e77325 100644
--- a/util/image_cache.h
+++ b/util/image_cache.h
@@ -4,10 +4,10 @@
#ifndef SHIRUDO_IMAGE_CACHE_H
#define SHIRUDO_IMAGE_CACHE_H
-struct shirudo_config_update_target;
+struct config_update_target;
/* The caller holds the update lock and owns the sealed cache directory. */
int image_cache_fetch(const char *source,
- struct shirudo_config_update_target *target);
+ struct config_update_target *target);
#endif /* SHIRUDO_IMAGE_CACHE_H */
diff --git a/util/image_config.c b/util/image_config.c
index 19f3b613..10d3707d 100644
--- a/util/image_config.c
+++ b/util/image_config.c
@@ -29,7 +29,7 @@ static const char *const relative[SHIRUDO_IMAGE_PATH_COUNT] = {
[SHIRUDO_IMAGE_REVOKED_KEYS] = "keys/revoked",
};
-static struct shirudo_config effective;
+static struct config effective;
static bool active;
static int config_fd = -1;
@@ -38,7 +38,7 @@ bool image_config_active(void)
return active;
}
-int image_config_get(struct shirudo_config *out)
+int image_config_get(struct config *out)
{
if (!active)
return 0;
@@ -56,7 +56,7 @@ int 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 image_open(enum shirudo_image_path which, int flags)
+int image_open(enum image_path which, int flags)
{
if (which >= SHIRUDO_IMAGE_PATH_COUNT || config_fd < 0)
return -ENOENT;
@@ -71,7 +71,7 @@ int image_open_relative(const char *path, int flags)
}
/* The image's shirudo.conf, read through its root. */
-static int config_load_root(struct shirudo_config *cfg, int root_fd)
+static int config_load_root(struct config *cfg, int root_fd)
{
int fd, ret;
@@ -208,7 +208,7 @@ static int validate_settings(int root_fd)
int image_config_validate(int root_fd)
{
- struct shirudo_config candidate;
+ struct config candidate;
__u32 entries = 0;
struct stat st;
int ret;
@@ -230,10 +230,10 @@ int image_config_validate(int root_fd)
return ret;
}
-int image_config_set(const struct shirudo_config *bootstrap,
+int image_config_set(const struct config *bootstrap,
int root_fd)
{
- struct shirudo_config candidate;
+ struct config candidate;
int fd = -1, ret;
candidate = *bootstrap;
diff --git a/util/image_config.h b/util/image_config.h
index 5716d5b6..58a221b5 100644
--- a/util/image_config.h
+++ b/util/image_config.h
@@ -8,9 +8,9 @@
#include <stdbool.h>
-struct shirudo_config;
+struct config;
-enum shirudo_image_path {
+enum image_path {
SHIRUDO_IMAGE_ETC,
SHIRUDO_IMAGE_REGISTRIES,
SHIRUDO_IMAGE_REPOSITORY_KEYS,
@@ -22,13 +22,13 @@ enum shirudo_image_path {
};
bool image_config_active(void);
-int image_config_get(struct shirudo_config *out);
-int image_config_set(const struct shirudo_config *bootstrap,
+int image_config_get(struct config *out);
+int image_config_set(const struct 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 image_open(enum shirudo_image_path which, int flags);
+int image_open(enum image_path which, int flags);
int image_open_relative(const char *path, int flags);
int image_config_root_fd(void);
diff --git a/util/image_guards.c b/util/image_guards.c
index e078d31d..fe7c764b 100644
--- a/util/image_guards.c
+++ b/util/image_guards.c
@@ -25,7 +25,7 @@
#include "paths.h"
#include "tamper.h"
-const struct shirudo_image_guard
+const struct image_guard
shirudo_seal_guards[SEAL_HOOK_COUNT] = {
{ "shirudo_seal_bprm_check_security",
SEAL_BPRM_CHECK_PIN },
@@ -56,7 +56,7 @@ shirudo_seal_guards[SEAL_HOOK_COUNT] = {
SEAL_PERF_PIN },
};
-const struct shirudo_image_guard
+const struct image_guard
shirudo_image_seal_guards[IMAGE_SEAL_HOOK_COUNT] = {
{ "shirudo_seal_mmap_file",
BPFFS_DIR "/seal_mmap_link" },
@@ -64,7 +64,7 @@ shirudo_image_seal_guards[IMAGE_SEAL_HOOK_COUNT] = {
BPFFS_DIR "/seal_mprotect_link" },
};
-const struct shirudo_image_guard
+const struct image_guard
shirudo_mount_guards[MOUNT_HOOK_COUNT] = {
{ "shirudo_lsm_sb_umount", SB_UMOUNT_LINK_PIN },
{ "shirudo_lsm_move_mount", MOVE_MOUNT_LINK_PIN },
@@ -73,7 +73,7 @@ shirudo_mount_guards[MOUNT_HOOK_COUNT] = {
{ "shirudo_lsm_file_open", BPFFS_DIR "/bpf2_file_open_link" },
};
-const struct shirudo_image_guard
+const struct image_guard
shirudo_observer_guards[OBSERVER_HOOK_COUNT] = {
{ "shirudo_lsm_task_prctl", TASK_PRCTL_LINK_PIN },
{ "shirudo_lsm_bprm_check_security", BPRM_CHECK_LINK_PIN },
@@ -93,7 +93,7 @@ shirudo_observer_guards[OBSERVER_HOOK_COUNT] = {
BPFFS_DIR "/kernel_read_file_link" },
};
-const struct shirudo_image_guard
+const struct image_guard
shirudo_image_observer_guards[IMAGE_OBSERVER_HOOK_COUNT] = {
{ "shirudo_lsm_file_ioctl", BPFFS_DIR "/file_ioctl_link" },
{ "shirudo_lsm_file_ioctl_compat",
@@ -104,7 +104,7 @@ shirudo_image_observer_guards[IMAGE_OBSERVER_HOOK_COUNT] = {
BPFFS_DIR "/bdev_free_link" },
};
-const struct shirudo_image_guard
+const struct image_guard
shirudo_gate_guards[SHIRUDO_GATE_HOOK_COUNT] = {
[SHIRUDO_GUARD_UNLINK] = {
"shirudo_lsm_inode_unlink", INODE_UNLINK_LINK_PIN,
@@ -132,26 +132,26 @@ shirudo_gate_guards[SHIRUDO_GATE_HOOK_COUNT] = {
},
};
-const struct shirudo_guard_map shirudo_guard_maps[SHIRUDO_GUARD_MAP_COUNT] = {
+const struct guard_map shirudo_guard_maps[SHIRUDO_GUARD_MAP_COUNT] = {
[SHIRUDO_GUARD_IDENTITY] = {
"shirudo_bpffs_sb", IDENTITY_PIN,
BPF_MAP_TYPE_ARRAY, sizeof(__u32),
- sizeof(struct shirudo_identity), 1, 0,
+ sizeof(struct identity), 1, 0,
},
[SHIRUDO_GUARD_TASKS] = {
"shirudo_tasks", BPFFS_DIR "/task_authority",
BPF_MAP_TYPE_TASK_STORAGE, sizeof(__u32),
- sizeof(struct shirudo_task_authority), 0, BPF_F_NO_PREALLOC,
+ sizeof(struct task_authority), 0, BPF_F_NO_PREALLOC,
},
[SHIRUDO_GUARD_DEVICES] = {
"shirudo_devices", BPFFS_DIR "/devices",
BPF_MAP_TYPE_HASH, sizeof(__u64),
- sizeof(struct shirudo_device_authority), 128, 0,
+ sizeof(struct device_authority), 128, 0,
},
[SHIRUDO_GUARD_ROOTS] = {
"shirudo_roots", BPFFS_DIR "/config_roots",
BPF_MAP_TYPE_TASK_STORAGE, sizeof(__u32),
- sizeof(struct shirudo_expected_root), 0, BPF_F_NO_PREALLOC,
+ sizeof(struct expected_root), 0, BPF_F_NO_PREALLOC,
},
[SHIRUDO_GUARD_TAMPER] = {
"shirudo_tamper", TAMPER_PIN,
@@ -162,14 +162,14 @@ const struct shirudo_guard_map shirudo_guard_maps[SHIRUDO_GUARD_MAP_COUNT] = {
/* Initial authenticated boot creates mappings before these guards exist. */
int config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard)
+ struct config_root_guard *guard)
{
- struct shirudo_expected_root previous = {}, expected = { .valid = 1 };
- const struct shirudo_guard_map *map =
+ struct expected_root previous = {}, expected = { .valid = 1 };
+ const struct guard_map *map =
&shirudo_guard_maps[SHIRUDO_GUARD_ROOTS];
int mode, ret;
- *guard = (struct shirudo_config_root_guard) {
+ *guard = (struct config_root_guard) {
.map_fd = -1,
.task_fd = -1,
};
@@ -212,9 +212,9 @@ fail:
}
/* Clear through retained FDs on every exit; report failure to clear. */
-int config_root_end(struct shirudo_config_root_guard *guard)
+int config_root_end(struct config_root_guard *guard)
{
- struct shirudo_expected_root empty = {};
+ struct expected_root empty = {};
int ret = 0;
if (guard->map_fd < 0)
@@ -237,7 +237,7 @@ static int guard_map_ids(__u32 ids[SHIRUDO_GUARD_MAP_COUNT])
int fd, ret;
for (i = 0; i < SHIRUDO_GUARD_MAP_COUNT; i++) {
- const struct shirudo_guard_map *expected =
+ const struct guard_map *expected =
&shirudo_guard_maps[i];
fd = bpf_obj_get(expected->pin);
@@ -331,7 +331,7 @@ static int guard_kernel_btf(__u32 id, struct btf **result)
return 0;
}
-static int guard_link(const struct shirudo_image_guard *guard,
+static int guard_link(const struct image_guard *guard,
const __u32 maps[SHIRUDO_GUARD_MAP_COUNT],
struct btf **kernel, __u32 *kernel_id)
{
@@ -398,7 +398,7 @@ static int guard_link(const struct shirudo_image_guard *guard,
int image_guards_ready(void)
{
const struct {
- const struct shirudo_image_guard *guards;
+ const struct image_guard *guards;
size_t count;
} groups[] = {
{
@@ -437,7 +437,7 @@ int image_guards_ready(void)
return ret;
for (i = 0; i < ARRAY_SIZE(groups); i++) {
for (j = 0; j < groups[i].count; j++) {
- const struct shirudo_image_guard *guard =
+ const struct image_guard *guard =
&groups[i].guards[j];
ret = guard_link(guard, map_ids, &kernel, &kernel_id);
diff --git a/util/image_guards.h b/util/image_guards.h
index afee050b..0cfa742c 100644
--- a/util/image_guards.h
+++ b/util/image_guards.h
@@ -14,12 +14,12 @@
#define OBSERVER_HOOK_COUNT 9
#define IMAGE_OBSERVER_HOOK_COUNT 4
-struct shirudo_image_guard {
+struct image_guard {
const char *prog;
const char *pin;
};
-enum shirudo_gate_guard {
+enum gate_guard {
SHIRUDO_GUARD_UNLINK,
SHIRUDO_GUARD_SETXATTR,
SHIRUDO_GUARD_REMOVEXATTR,
@@ -31,7 +31,7 @@ enum shirudo_gate_guard {
SHIRUDO_GATE_HOOK_COUNT,
};
-enum shirudo_guard_map_index {
+enum guard_map_index {
SHIRUDO_GUARD_IDENTITY,
SHIRUDO_GUARD_TASKS,
SHIRUDO_GUARD_DEVICES,
@@ -40,7 +40,7 @@ enum shirudo_guard_map_index {
SHIRUDO_GUARD_MAP_COUNT,
};
-struct shirudo_guard_map {
+struct guard_map {
const char *name;
const char *pin;
__u32 type;
@@ -50,29 +50,29 @@ struct shirudo_guard_map {
__u32 flags;
};
-extern const struct shirudo_image_guard
+extern const struct image_guard
shirudo_seal_guards[SEAL_HOOK_COUNT];
-extern const struct shirudo_image_guard
+extern const struct image_guard
shirudo_image_seal_guards[IMAGE_SEAL_HOOK_COUNT];
-extern const struct shirudo_image_guard
+extern const struct image_guard
shirudo_image_observer_guards[IMAGE_OBSERVER_HOOK_COUNT];
-extern const struct shirudo_image_guard
+extern const struct image_guard
shirudo_mount_guards[MOUNT_HOOK_COUNT];
-extern const struct shirudo_image_guard
+extern const struct image_guard
shirudo_observer_guards[OBSERVER_HOOK_COUNT];
-extern const struct shirudo_image_guard
+extern const struct image_guard
shirudo_gate_guards[SHIRUDO_GATE_HOOK_COUNT];
-extern const struct shirudo_guard_map
+extern const struct guard_map
shirudo_guard_maps[SHIRUDO_GUARD_MAP_COUNT];
-struct shirudo_config_root_guard {
+struct config_root_guard {
int map_fd;
int task_fd;
};
int config_root_begin(const __u8 root[32],
- struct shirudo_config_root_guard *guard);
-int config_root_end(struct shirudo_config_root_guard *guard);
+ struct config_root_guard *guard);
+int config_root_end(struct 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 9d7c49a7..59b4da4e 100644
--- a/util/image_keys.c
+++ b/util/image_keys.c
@@ -105,7 +105,7 @@ static int revocations(int root_fd, bool apply, bool boot)
}
int keys_validate_image_set(const char *primary, int root_fd,
- struct shirudo_trusted_set *set)
+ struct trusted_set *set)
{
int ret;
@@ -135,7 +135,7 @@ int keys_validate_image_set(const char *primary, int root_fd,
return 0;
}
-int keys_check_image_set(const struct shirudo_trusted_set *set)
+int keys_check_image_set(const struct trusted_set *set)
{
key_serial_t keyring;
size_t i;
@@ -160,7 +160,7 @@ int keys_check_image_set(const struct shirudo_trusted_set *set)
int keys_validate_image(int root_fd)
{
- struct shirudo_trusted_set set;
+ struct trusted_set set;
int ret;
ret = keys_validate_image_set(RUNTIME_CERT_PATH,
diff --git a/util/image_keys.h b/util/image_keys.h
index 38bbd2d0..47cba67a 100644
--- a/util/image_keys.h
+++ b/util/image_keys.h
@@ -9,11 +9,11 @@
#include <stdbool.h>
#include <stddef.h>
-struct shirudo_trusted_set;
+struct trusted_set;
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);
+ struct trusted_set *set);
+int keys_check_image_set(const struct trusted_set *set);
int keys_validate_image(int root_fd);
int keys_apply_image(int root_fd, bool boot);
diff --git a/util/image_runtime.c b/util/image_runtime.c
index a5c46fd9..5c1e23b4 100644
--- a/util/image_runtime.c
+++ b/util/image_runtime.c
@@ -48,14 +48,14 @@
#include "tpm.h"
struct image_context {
- struct shirudo_config_update_target boot_target;
- struct shirudo_dm_verity boot_runtime;
- struct shirudo_config_update update;
+ struct config_update_target boot_target;
+ struct dm_verity boot_runtime;
+ struct config_update update;
struct config_image_open candidate;
- struct shirudo_dm_verity candidate_device;
- struct shirudo_config bootstrap_config;
- struct shirudo_image_bootstrap bootstrap;
- struct shirudo_tpm *tpm;
+ struct dm_verity candidate_device;
+ struct config bootstrap_config;
+ struct image_bootstrap bootstrap;
+ struct tpm *tpm;
int candidate_fd;
int certificate_fd;
int config_state; /* what current_config() refused status with */
@@ -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 *image_update_context(void)
+struct config_update *image_update_context(void)
{
return image.update.lock_fd >= 0 ? &image.update : NULL;
}
@@ -105,7 +105,7 @@ static int reject_overrides(void)
int image_bootstrap_load(void)
{
- struct shirudo_identity identity;
+ struct identity identity;
int mode, ret;
if (image.loaded)
@@ -173,7 +173,7 @@ static int mapping_name(const __u8 root[32], char out[128])
static int device_observed(dev_t device, const __u8 root[32], __u32 kind)
{
- struct shirudo_device_authority entry;
+ struct device_authority entry;
__u32 dev = (major(device) << 20) | minor(device);
__u64 key, next, diskseq;
struct stat st;
@@ -316,7 +316,7 @@ static int mount_runtime(bool trusted_boot)
.hash_fd = -1,
.signature_fd = -1,
};
- struct shirudo_dm_verity device = {
+ struct dm_verity device = {
.data_loop_fd = -1,
.hash_loop_fd = -1,
};
@@ -415,7 +415,7 @@ static int pcr_extend(void *ctx, __u32 pcr, const __u8 event[32])
static int collect_mapping(const char *name, dev_t device, void *ctx)
{
- struct shirudo_dm_verity retired = {
+ struct dm_verity retired = {
.data_loop_fd = -1,
.hash_loop_fd = -1,
};
@@ -466,7 +466,7 @@ static void close_candidate(void)
config_image_close(&image.candidate);
}
-static int remove_candidate(struct shirudo_dm_verity *device)
+static int remove_candidate(struct dm_verity *device)
{
__u32 attempt;
int ret;
@@ -494,7 +494,7 @@ static int candidate_keys(int fd)
static int mount_candidate(struct image_context *current)
{
- struct shirudo_dm_verity *device = &current->candidate_device;
+ struct dm_verity *device = &current->candidate_device;
const char *mountpoint = CONFIG_CANDIDATE_DIR;
struct stat st;
int ret;
@@ -519,10 +519,10 @@ static int mount_candidate(struct image_context *current)
}
static int prepare_config(struct image_context *current,
- const struct shirudo_config_update_target *target,
+ const struct config_update_target *target,
bool trusted_boot)
{
- struct shirudo_dm_verity *device = &current->candidate_device;
+ struct dm_verity *device = &current->candidate_device;
bool created = false;
int ret, cleanup;
char name[128];
@@ -614,26 +614,26 @@ static int activate_config(struct image_context *current, bool boot)
}
static int prepare_update(void *ctx,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
return prepare_config(ctx, target, false);
}
static int activate_update(void *ctx,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
(void)target;
return activate_config(ctx, false);
}
static int activate_boot(void *ctx,
- const struct shirudo_config_update_target *target)
+ const struct config_update_target *target)
{
(void)target;
return activate_config(ctx, true);
}
-static const struct shirudo_config_update_ops update_ops = {
+static const struct config_update_ops update_ops = {
.boot_identity = boot_identity,
.pcr_read = pcr_read,
.pcr_extend = pcr_extend,
@@ -643,7 +643,7 @@ static const struct shirudo_config_update_ops update_ops = {
.lock_wait_ms = 30 * 1000,
};
-static const struct shirudo_config_update_ops boot_ops = {
+static const struct config_update_ops boot_ops = {
.boot_identity = boot_identity,
.pcr_read = pcr_read,
.pcr_extend = pcr_extend,
@@ -670,9 +670,9 @@ static int open_update(void)
return ret;
}
-static int boot_target(struct shirudo_config_update_target *target)
+static int boot_target(struct config_update_target *target)
{
- struct shirudo_config_update_record previous;
+ struct config_update_record previous;
struct config_image_open opened;
const char *prefix;
bool selected;
@@ -762,9 +762,9 @@ static int enroll_config_key(void)
}
/* The authenticated initrd validates the boot set before installing guards. */
-int image_boot_keys(struct shirudo_trusted_set *set)
+int image_boot_keys(struct trusted_set *set)
{
- struct shirudo_trusted_cert primary = { .primary = true };
+ struct trusted_cert primary = { .primary = true };
size_t i;
int ret;
@@ -844,7 +844,7 @@ int image_boot_keys_close(void)
int image_boot(void)
{
- struct shirudo_config_update_target target = {};
+ struct config_update_target target = {};
int ret;
ret = open_update();
@@ -867,10 +867,10 @@ int image_boot(void)
return ret;
}
-static int config_mount_check(const struct shirudo_config_update_record *record)
+static int config_mount_check(const struct config_update_record *record)
{
struct config_image_open opened;
- struct shirudo_dm_verity device;
+ struct dm_verity device;
struct stat st;
char name[128];
int fd, ret;
@@ -911,7 +911,7 @@ out:
int image_boot_complete(void)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
int ret;
ret = config_update_read(&image.update, &record);
@@ -924,7 +924,7 @@ int image_boot_complete(void)
static int current_config(void)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
int ret;
ret = open_update();
@@ -941,7 +941,7 @@ static int current_config(void)
*/
static int status_config(int state)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
image.config_state = state;
if (state == -EINPROGRESS &&
@@ -952,7 +952,7 @@ static int status_config(int state)
int image_enter(const char *command, int argc, const char **argv)
{
- struct shirudo_identity identity;
+ struct identity identity;
int mode, ret;
if (!strcmp(command, "image") && argc > 1 &&
@@ -998,7 +998,7 @@ int image_enter(const char *command, int argc, const char **argv)
int image_config_state(__u8 root[32])
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
if (image.update.lock_fd < 0)
return -ENODEV;
@@ -1011,9 +1011,9 @@ int image_config_state(__u8 root[32])
int image_status(void)
{
- struct shirudo_config_update_record record;
+ struct config_update_record record;
char buffer[512], root[65];
- struct shirudo_json_emit emit = {
+ struct json_emit emit = {
.buf = buffer,
.cap = sizeof(buffer),
};
@@ -1059,7 +1059,7 @@ void image_leave(void)
int image_update(const char *prefix)
{
- struct shirudo_config_update_target target = {};
+ struct config_update_target target = {};
int ret;
if (image.update.lock_fd < 0)
diff --git a/util/image_runtime.h b/util/image_runtime.h
index 37ba4a1c..25c0e513 100644
--- a/util/image_runtime.h
+++ b/util/image_runtime.h
@@ -8,14 +8,14 @@
#include <stdint.h>
-struct shirudo_config_update;
-struct shirudo_trusted_set;
+struct config_update;
+struct trusted_set;
-struct shirudo_config_update *image_update_context(void);
+struct 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(struct trusted_set *set);
int image_boot_keys_close(void);
int image_boot(void);
int image_boot_complete(void);
diff --git a/util/json.c b/util/json.c
index fca0eedd..c157c9db 100644
--- a/util/json.c
+++ b/util/json.c
@@ -17,7 +17,7 @@
#include "hex.h"
#include "json.h"
-static void put(struct shirudo_json_emit *e, char c)
+static void put(struct json_emit *e, char c)
{
if (e->err)
return;
@@ -29,7 +29,7 @@ static void put(struct shirudo_json_emit *e, char c)
e->buf[e->len] = '\0';
}
-static void put_raw(struct shirudo_json_emit *e, const char *s)
+static void put_raw(struct json_emit *e, const char *s)
{
while (*s && !e->err)
put(e, *s++);
@@ -39,7 +39,7 @@ static void put_raw(struct shirudo_json_emit *e, const char *s)
* Malformed UTF-8 is -EILSEQ, so a stray byte can never produce
* invalid JSON.
*/
-static void put_string(struct shirudo_json_emit *e, const char *s)
+static void put_string(struct json_emit *e, const char *s)
{
const __u8 *p = (const __u8 *)s;
@@ -99,7 +99,7 @@ static void put_string(struct shirudo_json_emit *e, const char *s)
put(e, '"');
}
-static void sep(struct shirudo_json_emit *e)
+static void sep(struct json_emit *e)
{
if (e->err)
return;
@@ -109,7 +109,7 @@ static void sep(struct shirudo_json_emit *e)
e->nonempty |= (1u << e->depth);
}
-static void enter(struct shirudo_json_emit *e)
+static void enter(struct json_emit *e)
{
if (e->err)
return;
@@ -121,13 +121,13 @@ static void enter(struct shirudo_json_emit *e)
e->nonempty &= ~(1u << e->depth);
}
-static void leave(struct shirudo_json_emit *e)
+static void leave(struct json_emit *e)
{
if (e->depth)
e->depth--;
}
-static void json_value_begin(struct shirudo_json_emit *e)
+static void json_value_begin(struct json_emit *e)
{
if (e->value_pending)
e->value_pending = false;
@@ -135,14 +135,14 @@ static void json_value_begin(struct shirudo_json_emit *e)
sep(e);
}
-void json_obj_open(struct shirudo_json_emit *e)
+void json_obj_open(struct json_emit *e)
{
sep(e);
put(e, '{');
enter(e);
}
-void json_obj_open_key(struct shirudo_json_emit *e, const char *key)
+void json_obj_open_key(struct json_emit *e, const char *key)
{
sep(e);
put_string(e, key);
@@ -151,20 +151,20 @@ void json_obj_open_key(struct shirudo_json_emit *e, const char *key)
enter(e);
}
-void json_obj_value_open(struct shirudo_json_emit *e)
+void json_obj_value_open(struct json_emit *e)
{
json_value_begin(e);
put(e, '{');
enter(e);
}
-void json_obj_close(struct shirudo_json_emit *e)
+void json_obj_close(struct json_emit *e)
{
put(e, '}');
leave(e);
}
-void json_arr_open(struct shirudo_json_emit *e, const char *key)
+void json_arr_open(struct json_emit *e, const char *key)
{
sep(e);
put_string(e, key);
@@ -173,14 +173,14 @@ void json_arr_open(struct shirudo_json_emit *e, const char *key)
enter(e);
}
-void json_arr_open_value(struct shirudo_json_emit *e)
+void json_arr_open_value(struct json_emit *e)
{
json_value_begin(e);
put(e, '[');
enter(e);
}
-void json_key(struct shirudo_json_emit *e, const char *key)
+void json_key(struct json_emit *e, const char *key)
{
sep(e);
put_string(e, key);
@@ -188,13 +188,13 @@ void json_key(struct shirudo_json_emit *e, const char *key)
e->value_pending = true;
}
-void json_arr_close(struct shirudo_json_emit *e)
+void json_arr_close(struct json_emit *e)
{
put(e, ']');
leave(e);
}
-void json_kv_string(struct shirudo_json_emit *e,
+void json_kv_string(struct json_emit *e,
const char *key, const char *val)
{
sep(e);
@@ -203,7 +203,7 @@ void json_kv_string(struct shirudo_json_emit *e,
put_string(e, val);
}
-void json_kv_int(struct shirudo_json_emit *e,
+void json_kv_int(struct json_emit *e,
const char *key, __s64 val)
{
char num[24];
@@ -218,7 +218,7 @@ void json_kv_int(struct shirudo_json_emit *e,
put_raw(e, num);
}
-void json_kv_bool(struct shirudo_json_emit *e, const char *key, int val)
+void json_kv_bool(struct json_emit *e, const char *key, int val)
{
sep(e);
put_string(e, key);
@@ -226,7 +226,7 @@ void json_kv_bool(struct shirudo_json_emit *e, const char *key, int val)
put_raw(e, val ? "true" : "false");
}
-void json_kv_null(struct shirudo_json_emit *e, const char *key)
+void json_kv_null(struct json_emit *e, const char *key)
{
sep(e);
put_string(e, key);
@@ -234,7 +234,7 @@ void json_kv_null(struct shirudo_json_emit *e, const char *key)
put_raw(e, "null");
}
-void json_kv_raw(struct shirudo_json_emit *e, const char *key,
+void json_kv_raw(struct json_emit *e, const char *key,
const char *value, size_t value_len)
{
size_t i;
@@ -246,19 +246,19 @@ void json_kv_raw(struct shirudo_json_emit *e, const char *key,
put(e, value[i]);
}
-void json_str(struct shirudo_json_emit *e, const char *val)
+void json_str(struct json_emit *e, const char *val)
{
sep(e);
put_string(e, val);
}
-void json_str_value(struct shirudo_json_emit *e, const char *val)
+void json_str_value(struct json_emit *e, const char *val)
{
json_value_begin(e);
put_string(e, val);
}
-void json_raw_value(struct shirudo_json_emit *e, const char *value,
+void json_raw_value(struct json_emit *e, const char *value,
size_t value_len)
{
size_t i;
@@ -268,7 +268,7 @@ void json_raw_value(struct shirudo_json_emit *e, const char *value,
put(e, value[i]);
}
-void json_raw(struct shirudo_json_emit *e, const char *value,
+void json_raw(struct json_emit *e, const char *value,
size_t value_len)
{
size_t i;
@@ -282,7 +282,7 @@ struct pctx {
const char *p;
const char *end;
__u32 depth;
- struct shirudo_json_field *fields;
+ struct json_field *fields;
size_t n_fields;
};
@@ -454,7 +454,7 @@ static int parse_string(struct pctx *c, char *dst, size_t cap)
return 0;
}
-static int parse_value(struct pctx *c, struct shirudo_json_field *f);
+static int parse_value(struct pctx *c, struct json_field *f);
static int parse_object(struct pctx *c)
{
@@ -471,7 +471,7 @@ static int parse_object(struct pctx *c)
return 0;
}
for (;;) {
- struct shirudo_json_field *f = NULL;
+ struct json_field *f = NULL;
size_t i;
skip_ws(c);
@@ -542,9 +542,9 @@ static int parse_array(struct pctx *c)
return 0;
}
-static int parse_array_into(struct pctx *c, struct shirudo_json_field *f)
+static int parse_array_into(struct pctx *c, struct json_field *f)
{
- struct shirudo_json_array *sink = f->dst;
+ struct json_array *sink = f->dst;
int ret;
if (++c->depth > JSON_MAX_DEPTH)
@@ -566,7 +566,7 @@ static int parse_array_into(struct pctx *c, struct shirudo_json_field *f)
if (c->p >= c->end)
return -EINVAL;
if (*c->p == '{') {
- struct shirudo_json_field *save_f = c->fields;
+ struct json_field *save_f = c->fields;
size_t save_n = c->n_fields;
c->fields = f->sub;
@@ -624,7 +624,7 @@ static int skip_digits(struct pctx *c)
* A number as JSON spells one: -?(0|[1-9][0-9]*)(.[0-9]+)?([eE][+-]?[0-9]+)?
* An integer field takes the integer part alone, and only within __s64.
*/
-static int parse_number(struct pctx *c, struct shirudo_json_field *f)
+static int parse_number(struct pctx *c, struct json_field *f)
{
const char *start = c->p;
const char *int_end;
@@ -659,14 +659,14 @@ static int parse_number(struct pctx *c, struct shirudo_json_field *f)
return 0;
}
-static int parse_value(struct pctx *c, struct shirudo_json_field *f)
+static int parse_value(struct pctx *c, struct json_field *f)
{
skip_ws(c);
if (c->p >= c->end)
return -EINVAL;
switch (*c->p) {
case '{': {
- struct shirudo_json_field *save_f = c->fields;
+ struct json_field *save_f = c->fields;
size_t save_n = c->n_fields;
int ret;
@@ -743,7 +743,7 @@ static int parse_value(struct pctx *c, struct shirudo_json_field *f)
}
int json_parse(const char *data, size_t len,
- struct shirudo_json_field *fields, size_t n_fields)
+ struct json_field *fields, size_t n_fields)
{
struct pctx c = {
.p = data, .end = data + len,
diff --git a/util/json.h b/util/json.h
index f2e8d78d..81624176 100644
--- a/util/json.h
+++ b/util/json.h
@@ -23,7 +23,7 @@
#define JSON_MAX_STRING_BYTES (16u * 1024u * 1024u)
#endif
-struct shirudo_json_emit {
+struct json_emit {
char *buf;
size_t cap;
size_t len;
@@ -38,30 +38,30 @@ struct shirudo_json_emit {
* latches and later calls are no-ops: check it once after the final
* close.
*/
-void json_obj_open(struct shirudo_json_emit *e);
-void json_obj_open_key(struct shirudo_json_emit *e, const char *key);
+void json_obj_open(struct json_emit *e);
+void json_obj_open_key(struct json_emit *e, const char *key);
/* Value containers and scalars consume a pending json_key or array slot. */
-void json_obj_value_open(struct shirudo_json_emit *e);
-void json_obj_close(struct shirudo_json_emit *e);
-void json_arr_open(struct shirudo_json_emit *e, const char *key);
-void json_arr_open_value(struct shirudo_json_emit *e);
-void json_arr_close(struct shirudo_json_emit *e);
-void json_key(struct shirudo_json_emit *e, const char *key);
-void json_kv_string(struct shirudo_json_emit *e,
+void json_obj_value_open(struct json_emit *e);
+void json_obj_close(struct json_emit *e);
+void json_arr_open(struct json_emit *e, const char *key);
+void json_arr_open_value(struct json_emit *e);
+void json_arr_close(struct json_emit *e);
+void json_key(struct json_emit *e, const char *key);
+void json_kv_string(struct json_emit *e,
const char *key, const char *val);
-void json_kv_int(struct shirudo_json_emit *e,
+void json_kv_int(struct json_emit *e,
const char *key, __s64 val);
-void json_kv_bool(struct shirudo_json_emit *e,
+void json_kv_bool(struct json_emit *e,
const char *key, int val);
-void json_kv_null(struct shirudo_json_emit *e, const char *key);
+void json_kv_null(struct json_emit *e, const char *key);
/* Insert an internally-generated, already-valid JSON value verbatim. */
-void json_kv_raw(struct shirudo_json_emit *e, const char *key,
+void json_kv_raw(struct json_emit *e, const char *key,
const char *value, size_t value_len);
-void json_str(struct shirudo_json_emit *e, const char *val);
-void json_str_value(struct shirudo_json_emit *e, const char *val);
-void json_raw_value(struct shirudo_json_emit *e, const char *value,
+void json_str(struct json_emit *e, const char *val);
+void json_str_value(struct json_emit *e, const char *val);
+void json_raw_value(struct json_emit *e, const char *value,
size_t value_len);
-void json_raw(struct shirudo_json_emit *e, const char *value,
+void json_raw(struct json_emit *e, const char *value,
size_t value_len);
/*
@@ -69,7 +69,7 @@ void json_raw(struct shirudo_json_emit *e, const char *value,
* else is parsed and discarded, within bounds so hostile input cannot
* exhaust the stack or a buffer.
*/
-enum shirudo_json_vtype {
+enum json_vtype {
SHIRUDO_JSON_T_STRING, /* dst: char[dst_cap] (NUL-terminated) */
SHIRUDO_JSON_T_INT, /* dst: __s64 * */
SHIRUDO_JSON_T_BOOL, /* dst: int * (0/1) */
@@ -82,18 +82,18 @@ enum shirudo_json_vtype {
* element out of the scratch dst buffers before the next one overwrites
* them, and returns a negative errno to abort.
*/
-struct shirudo_json_array {
+struct json_array {
int (*on_elem)(void *ctx);
void *ctx;
};
-struct shirudo_json_field {
+struct json_field {
const char *key;
- enum shirudo_json_vtype type;
+ enum json_vtype type;
void *dst;
size_t dst_cap; /* STRING only */
int seen; /* set by the parser */
- struct shirudo_json_field *sub; /* OBJECT/ARRAY schema */
+ struct json_field *sub; /* OBJECT/ARRAY schema */
size_t n_sub; /* OBJECT/ARRAY schema */
};
@@ -102,6 +102,6 @@ struct shirudo_json_field {
* violation, -ENOSPC when a string exceeds its dst_cap.
*/
int json_parse(const char *data, size_t len,
- struct shirudo_json_field *fields, size_t n_fields);
+ struct json_field *fields, size_t n_fields);
#endif /* SHIRUDO_JSON_H */
diff --git a/util/keys.c b/util/keys.c
index e6d81d12..d69cf514 100644
--- a/util/keys.c
+++ b/util/keys.c
@@ -110,7 +110,7 @@ int keys_read_der(const char *path, __u8 **out,
int keys_digest_der(const __u8 *der, size_t der_sz,
__u8 sha256[32], __u8 fingerprint[32])
{
- struct shirudo_cert cert = {};
+ struct cert cert = {};
int ret;
ret = sha256_buffer(der, der_sz, sha256);
@@ -161,7 +161,7 @@ static int der_keep(const __u8 sha256[32], const __u8 *der, size_t len)
return 0;
}
-int keys_cert_der(const struct shirudo_trusted_cert *c, const __u8 **der,
+int keys_cert_der(const struct trusted_cert *c, const __u8 **der,
size_t *len)
{
size_t i;
@@ -176,8 +176,8 @@ int keys_cert_der(const struct shirudo_trusted_cert *c, const __u8 **der,
return -ENOKEY;
}
-int keys_cert_read(const struct shirudo_trusted_cert *c,
- struct shirudo_cert *cert)
+int keys_cert_read(const struct trusted_cert *c,
+ struct cert *cert)
{
const __u8 *der;
size_t len;
@@ -271,7 +271,7 @@ int keys_vouch_payload(const __u8 *der, size_t der_sz,
return 0;
}
-int keys_verify_vouch(const struct shirudo_trusted_set *set,
+int keys_verify_vouch(const struct trusted_set *set,
const __u8 *der, size_t der_sz,
const __u8 *sig, size_t sig_sz,
__u8 voucher[32])
@@ -285,7 +285,7 @@ int keys_verify_vouch(const struct shirudo_trusted_set *set,
return ret;
ret = -EKEYREJECTED;
for (i = 0; i < set->n && ret; i++) {
- struct shirudo_cert cert = {};
+ struct cert cert = {};
if (keys_cert_read(&set->certs[i], &cert))
continue;
@@ -302,11 +302,11 @@ int keys_verify_vouch(const struct shirudo_trusted_set *set,
static int cert_cmp(const void *a, const void *b)
{
- return memcmp(((const struct shirudo_trusted_cert *)a)->sha256,
- ((const struct shirudo_trusted_cert *)b)->sha256, 32);
+ return memcmp(((const struct trusted_cert *)a)->sha256,
+ ((const struct trusted_cert *)b)->sha256, 32);
}
-static bool set_holds(const struct shirudo_trusted_set *set,
+static bool set_holds(const struct trusted_set *set,
const __u8 fingerprint[32])
{
size_t i;
@@ -318,11 +318,11 @@ static bool set_holds(const struct shirudo_trusted_set *set,
return false;
}
-static int set_add(struct shirudo_trusted_set *set, const char *path,
+static int set_add(struct trusted_set *set, const char *path,
const __u8 sha256[32], const __u8 fingerprint[32],
const __u8 voucher[32], const __u8 *der, size_t der_sz)
{
- struct shirudo_trusted_cert *c;
+ struct trusted_cert *c;
int ret;
if (set->n >= KEYS_MAX)
@@ -396,7 +396,7 @@ static int vouch_path_for(const char *der_path, char *out, size_t cap)
* Admit the candidates whose vouch verifies under a member, in rounds,
* so a certificate vouched for by one admitted later still joins.
*/
-static int admit_vouched(struct shirudo_trusted_set *set,
+static int admit_vouched(struct trusted_set *set,
struct keys_candidate *cand, size_t n_cand)
{
bool progress = true;
@@ -460,7 +460,7 @@ static void candidates_free(struct keys_candidate *cand, size_t n)
* candidates for admission, which needs the whole list first.
*/
static int scan_trusted(const char *keys_dir, const char *revoked_dir,
- struct shirudo_trusted_set *set,
+ struct trusted_set *set,
struct keys_candidate *cand, size_t *n_cand)
{
struct dirent **names = NULL;
@@ -563,7 +563,7 @@ static int scan_trusted_at(int keys_fd, const char *display,
static int load_set(const char *primary, const char *keys_dir,
const char *revoked_dir, bool with_trusted,
- struct shirudo_trusted_set *set)
+ struct trusted_set *set)
{
struct keys_candidate *cand = NULL;
__u8 sha256[32], fingerprint[32];
@@ -612,7 +612,7 @@ sort:
* revoked certificate's vouch for another still admits it.
*/
static int load_set_at(const char *primary, int keys_fd, const char *display,
- bool with_trusted, struct shirudo_trusted_set *set)
+ bool with_trusted, struct trusted_set *set)
{
struct keys_candidate *cand = NULL;
__u8 sha256[32], fingerprint[32];
@@ -661,14 +661,14 @@ out:
int keys_load_image_at(const char *primary, int keys_fd,
bool with_trusted,
- struct shirudo_trusted_set *set)
+ struct trusted_set *set)
{
return load_set_at(primary, keys_fd, "keys", with_trusted, set);
}
int keys_load_image_root(const char *primary, int root_fd,
bool with_trusted,
- struct shirudo_trusted_set *set)
+ struct trusted_set *set)
{
int keys_fd, ret;
@@ -685,7 +685,7 @@ int keys_load_image_root(const char *primary, int root_fd,
}
int keys_load(const char *keys_dir, const char *revoked_dir,
- bool with_trusted, struct shirudo_trusted_set *set)
+ bool with_trusted, struct trusted_set *set)
{
char primary[PATH_MAX];
@@ -728,7 +728,7 @@ int keys_anchor_digest(const __u8 sha256[][32], size_t n,
return ret;
}
-int keys_set_digest(const struct shirudo_trusted_set *set,
+int keys_set_digest(const struct trusted_set *set,
__u8 out[32])
{
__u8 sha[KEYS_MAX][32];
diff --git a/util/keys.h b/util/keys.h
index 0b26aefa..802d0f1d 100644
--- a/util/keys.h
+++ b/util/keys.h
@@ -24,7 +24,7 @@
#define KEYS_VOUCH_PREFIX "shirudo-key-vouch"
/* voucher is the admitting member's fingerprint, zero for the primary. */
-struct shirudo_trusted_cert {
+struct trusted_cert {
char path[PATH_MAX];
__u8 sha256[32]; /* of the DER file */
__u8 fingerprint[32]; /* of the public key */
@@ -40,8 +40,8 @@ struct shirudo_trusted_cert {
* one whose fingerprint the revoked directory names. n_revoked counts
* that directory's certificates.
*/
-struct shirudo_trusted_set {
- struct shirudo_trusted_cert certs[KEYS_MAX];
+struct trusted_set {
+ struct trusted_cert certs[KEYS_MAX];
size_t n;
size_t n_revoked;
size_t n_unvouched;
@@ -53,7 +53,7 @@ struct shirudo_trusted_set {
* means revoked/ beside them. -ENOENT when there is no cert.der.
*/
int keys_load(const char *keys_dir, const char *revoked_dir,
- bool with_trusted, struct shirudo_trusted_set *set);
+ bool with_trusted, struct trusted_set *set);
/*
* The set of a config image, read through its root descriptor; historical
@@ -61,23 +61,23 @@ int keys_load(const char *keys_dir, const char *revoked_dir,
*/
int keys_load_image_at(const char *primary, int keys_fd,
bool with_trusted,
- struct shirudo_trusted_set *set);
+ struct trusted_set *set);
/* The same from the image root, whose keys directory is opened beneath it. */
int keys_load_image_root(const char *primary, int root_fd,
bool with_trusted,
- struct shirudo_trusted_set *set);
+ struct trusted_set *set);
-struct shirudo_cert;
+struct cert;
/*
* A member's DER as the loader read it, owned by the store, or its
* parsed certificate; -ENOKEY for a member no loader of this process
* admitted.
*/
-int keys_cert_der(const struct shirudo_trusted_cert *c, const __u8 **der,
+int keys_cert_der(const struct trusted_cert *c, const __u8 **der,
size_t *len);
-int keys_cert_read(const struct shirudo_trusted_cert *c,
- struct shirudo_cert *cert);
+int keys_cert_read(const struct trusted_cert *c,
+ struct cert *cert);
/* A whole file of at most KEYS_DER_MAX bytes, xmalloc'd. */
int keys_read_der(const char *path, __u8 **out,
@@ -96,7 +96,7 @@ int keys_digest_file(const char *path, __u8 sha256[32],
*/
int keys_anchor_digest(const __u8 sha256[][32], size_t n,
__u8 out[32]);
-int keys_set_digest(const struct shirudo_trusted_set *set,
+int keys_set_digest(const struct trusted_set *set,
__u8 out[32]);
bool keys_is_revoked(const char *revoked_dir,
@@ -111,7 +111,7 @@ int keys_vouch_payload(const __u8 *der, size_t der_sz,
* 0 with the member's fingerprint in voucher, -EKEYREJECTED when none
* did.
*/
-int keys_verify_vouch(const struct shirudo_trusted_set *set,
+int keys_verify_vouch(const struct trusted_set *set,
const __u8 *der, size_t der_sz,
const __u8 *sig, size_t sig_sz,
__u8 voucher[32]);
diff --git a/util/kmodules.c b/util/kmodules.c
index 3e9ae096..3f0bf05b 100644
--- a/util/kmodules.c
+++ b/util/kmodules.c
@@ -73,11 +73,11 @@ static int slurp(char **buf_out, size_t *len_out)
static int kmod_cmp(const void *a, const void *b)
{
- return strcmp(((const struct shirudo_kmod *)a)->name,
- ((const struct shirudo_kmod *)b)->name);
+ return strcmp(((const struct kmod *)a)->name,
+ ((const struct kmod *)b)->name);
}
-static int kmod_find(const struct shirudo_kmod_set *set, const char *name)
+static int kmod_find(const struct kmod_set *set, const char *name)
{
size_t lo = 0, hi = set->n;
@@ -110,7 +110,7 @@ static __u64 next_column(char **p, __u64 max)
return parse_u64(s, n, max, &v) ? 0 : v;
}
-int kmodules_parse(char *buf, struct shirudo_kmod_set *set)
+int kmodules_parse(char *buf, struct kmod_set *set)
{
size_t mod_cap = 64, deps_cap = 256, edge_cap = 256, n_edges = 0;
struct edge { __u16 user, dep; } *edges = NULL;
@@ -138,7 +138,7 @@ int kmodules_parse(char *buf, struct shirudo_kmod_set *set)
* used-by column into indices.
*/
for (line = buf; line < end; line += strlen(line) + 1) {
- struct shirudo_kmod *m;
+ struct kmod *m;
char *p = line, *e;
size_t name_len;
@@ -275,7 +275,7 @@ out:
return ret;
}
-int kmodules_read(struct shirudo_kmod_set *set)
+int kmodules_read(struct kmod_set *set)
{
size_t buf_cap = 0, i;
char *buf = NULL;
@@ -298,7 +298,7 @@ int kmodules_read(struct shirudo_kmod_set *set)
* and this stat) is non-fatal; leave loaded_at zero.
*/
for (i = 0; i < set->n; i++) {
- struct shirudo_kmod *m = &set->mods[i];
+ struct kmod *m = &set->mods[i];
char path[64 + sizeof("/sys/module/")];
struct stat st;
@@ -311,17 +311,17 @@ int kmodules_read(struct shirudo_kmod_set *set)
return 0;
}
-void kmodules_free(struct shirudo_kmod_set *set)
+void kmodules_free(struct kmod_set *set)
{
xfree(set->mods, set->n * sizeof(*set->mods));
xfree(set->deps, set->n_deps * sizeof(*set->deps));
memset(set, 0, sizeof(*set));
}
-static void print_subtree(const struct shirudo_kmod_set *set, size_t i,
+static void print_subtree(const struct kmod_set *set, size_t i,
const char *prefix, int is_last, __u8 *seen)
{
- const struct shirudo_kmod *m = &set->mods[i];
+ const struct kmod *m = &set->mods[i];
const char *branch = is_last ? "└── " : "├── ";
int already = (seen[i >> 3] >> (i & 7)) & 1;
const char *child = prefix;
@@ -351,7 +351,7 @@ static void print_subtree(const struct shirudo_kmod_set *set, size_t i,
}
}
-void kmodules_print_tree(const struct shirudo_kmod_set *set)
+void kmodules_print_tree(const struct kmod_set *set)
{
__u8 *used_by;
__u8 *seen;
@@ -381,7 +381,7 @@ void kmodules_print_tree(const struct shirudo_kmod_set *set)
* The remainder are entry-point modules nothing else uses.
*/
for (size_t i = 0; i < set->n; i++) {
- const struct shirudo_kmod *m = &set->mods[i];
+ const struct kmod *m = &set->mods[i];
for (__u16 k = 0; k < m->n_deps; k++) {
size_t d = set->deps[m->deps_off + k];
@@ -411,15 +411,15 @@ void kmodules_print_tree(const struct shirudo_kmod_set *set)
* failure) sort to the bottom so they don't crowd out real entries.
*/
struct recent_idx {
- const struct shirudo_kmod_set *set;
+ const struct kmod_set *set;
size_t idx;
};
static int recent_cmp(const void *a, const void *b)
{
const struct recent_idx *x = a, *y = b;
- const struct shirudo_kmod *mx = &x->set->mods[x->idx];
- const struct shirudo_kmod *my = &y->set->mods[y->idx];
+ const struct kmod *mx = &x->set->mods[x->idx];
+ const struct kmod *my = &y->set->mods[y->idx];
if (mx->loaded_at_sec == 0 && my->loaded_at_sec != 0)
return 1;
@@ -432,7 +432,7 @@ static int recent_cmp(const void *a, const void *b)
return strcmp(mx->name, my->name);
}
-void kmodules_print_recent(const struct shirudo_kmod_set *set,
+void kmodules_print_recent(const struct kmod_set *set,
size_t last_n, __s64 boot_sec)
{
struct recent_idx *all;
@@ -455,7 +455,7 @@ void kmodules_print_recent(const struct shirudo_kmod_set *set,
qsort(all, set->n, sizeof(*all), recent_cmp);
take = min(set->n, last_n);
for (i = 0; i < take; i++) {
- const struct shirudo_kmod *m = &set->mods[all[i].idx];
+ const struct kmod *m = &set->mods[all[i].idx];
char ts[32], size_s[16], age[24];
if (m->loaded_at_sec <= 0 ||
diff --git a/util/kmodules.h b/util/kmodules.h
index cb76b2e4..c37f6157 100644
--- a/util/kmodules.h
+++ b/util/kmodules.h
@@ -14,7 +14,7 @@
#define KMOD_NAME_LEN 64
-struct shirudo_kmod {
+struct kmod {
char name[KMOD_NAME_LEN];
__u64 size; /* bytes */
__u32 refcount; /* /proc/modules column 3 */
@@ -30,25 +30,25 @@ struct shirudo_kmod {
__s32 loaded_at_nsec;
};
-struct shirudo_kmod_set {
- struct shirudo_kmod *mods; /* sorted by name, ascending */
+struct kmod_set {
+ struct kmod *mods; /* sorted by name, ascending */
size_t n;
__u16 *deps; /* flat: mods[i].deps_off..+n_deps */
size_t n_deps;
};
-int kmodules_read(struct shirudo_kmod_set *set);
+int kmodules_read(struct kmod_set *set);
/* The text of /proc/modules, modified in place, into set. */
-int kmodules_parse(char *buf, struct shirudo_kmod_set *set);
-void kmodules_free(struct shirudo_kmod_set *set);
+int kmodules_parse(char *buf, struct kmod_set *set);
+void kmodules_free(struct kmod_set *set);
-void kmodules_print_tree(const struct shirudo_kmod_set *set);
+void kmodules_print_tree(const struct kmod_set *set);
/*
* boot_sec is the wallclock instant of boot: the since-boot column is
* elapsed from boot, not time ago.
*/
-void kmodules_print_recent(const struct shirudo_kmod_set *set,
+void kmodules_print_recent(const struct kmod_set *set,
size_t last_n, __s64 boot_sec);
#endif /* SHIRUDO_UTIL_KMODULES_H */
diff --git a/util/kmsg.c b/util/kmsg.c
index f62fa1bf..81b5c3a2 100644
--- a/util/kmsg.c
+++ b/util/kmsg.c
@@ -128,7 +128,7 @@ static void monotonic_to_iso(__u64 mono_us,
strscpy(out, "?", out_cap);
}
-int kmsg_tail(struct shirudo_kmsg_record *out, size_t cap)
+int kmsg_tail(struct kmsg_record *out, size_t cap)
{
struct timespec rt_at_open, mt_at_open;
char buf[KMSG_READ_BUF];
@@ -189,7 +189,7 @@ int kmsg_tail(struct shirudo_kmsg_record *out, size_t cap)
size_t bytes = cap * sizeof(*out);
size_t start = head % cap;
size_t i;
- struct shirudo_kmsg_record *tmp = xmalloc(bytes);
+ struct kmsg_record *tmp = xmalloc(bytes);
if (!tmp)
return -ENOMEM;
diff --git a/util/kmsg.h b/util/kmsg.h
index f03ce5de..5603faaf 100644
--- a/util/kmsg.h
+++ b/util/kmsg.h
@@ -13,7 +13,7 @@
#define KMSG_TS_LEN 24 /* "2026-05-28T14:32:01Z" + slack */
#define KMSG_MSG_LEN 480 /* one printk record, joined */
-struct shirudo_kmsg_record {
+struct kmsg_record {
char ts[KMSG_TS_LEN]; /* ISO-8601 UTC, NUL-term */
char msg[KMSG_MSG_LEN]; /* control bytes stripped */
};
@@ -22,6 +22,6 @@ struct shirudo_kmsg_record {
* Records the ring buffer has dropped are skipped: EPIPE restarts the
* read.
*/
-int kmsg_tail(struct shirudo_kmsg_record *out, size_t cap);
+int kmsg_tail(struct kmsg_record *out, size_t cap);
#endif /* SHIRUDO_UTIL_KMSG_H */
diff --git a/util/loader.c b/util/loader.c
index 11792794..0ca5c447 100644
--- a/util/loader.c
+++ b/util/loader.c
@@ -28,7 +28,7 @@ asm(".section .rodata, \"a\"\n"
".previous\n");
-static const struct shirudo_embedded_bpf bpf2 = {
+static const struct embedded_bpf bpf2 = {
.name = "bpf2",
.data = shirudo_bpf2_o,
/*
@@ -37,37 +37,37 @@ static const struct shirudo_embedded_bpf bpf2 = {
*/
};
-static const struct shirudo_embedded_bpf seal = {
+static const struct embedded_bpf seal = {
.name = "seal",
.data = shirudo_seal_o,
};
-static const struct shirudo_embedded_bpf unload = {
+static const struct embedded_bpf unload = {
.name = "unload",
.data = shirudo_unload_bpf_o,
};
-const struct shirudo_embedded_bpf *bpf2_blob(void)
+const struct embedded_bpf *bpf2_blob(void)
{
- static struct shirudo_embedded_bpf b;
+ static struct embedded_bpf b;
b = bpf2;
b.size = (size_t)(shirudo_bpf2_o_end - shirudo_bpf2_o);
return &b;
}
-const struct shirudo_embedded_bpf *seal_blob(void)
+const struct embedded_bpf *seal_blob(void)
{
- static struct shirudo_embedded_bpf b;
+ static struct embedded_bpf b;
b = seal;
b.size = (size_t)(shirudo_seal_o_end - shirudo_seal_o);
return &b;
}
-const struct shirudo_embedded_bpf *unload_blob(void)
+const struct embedded_bpf *unload_blob(void)
{
- static struct shirudo_embedded_bpf b;
+ static struct embedded_bpf b;
b = unload;
b.size = (size_t)(shirudo_unload_bpf_o_end - shirudo_unload_bpf_o);
diff --git a/util/loader.h b/util/loader.h
index ad02256d..bab29f7e 100644
--- a/util/loader.h
+++ b/util/loader.h
@@ -15,14 +15,14 @@ extern const char shirudo_bpf2_o[], shirudo_bpf2_o_end[];
extern const char shirudo_seal_o[], shirudo_seal_o_end[];
extern const char shirudo_unload_bpf_o[], shirudo_unload_bpf_o_end[];
-struct shirudo_embedded_bpf {
+struct embedded_bpf {
const char *name;
const void *data;
size_t size;
};
-const struct shirudo_embedded_bpf *bpf2_blob(void);
-const struct shirudo_embedded_bpf *seal_blob(void);
-const struct shirudo_embedded_bpf *unload_blob(void);
+const struct embedded_bpf *bpf2_blob(void);
+const struct embedded_bpf *seal_blob(void);
+const struct embedded_bpf *unload_blob(void);
#endif /* SHIRUDO_LOADER_H */
diff --git a/util/nv_writer.c b/util/nv_writer.c
index cd321c43..c5c9d1ea 100644
--- a/util/nv_writer.c
+++ b/util/nv_writer.c
@@ -13,7 +13,7 @@
int nv_writer_create(__u8 seed[TPM_DIGEST_LEN],
__u8 public[TPM_NV_RSA_BYTES])
{
- struct shirudo_tpm *t = NULL;
+ struct tpm *t = NULL;
size_t off = 0;
ssize_t got;
int err;
@@ -44,7 +44,7 @@ fail:
int nv_writer_read(__u8 seed[TPM_DIGEST_LEN],
__u8 public[TPM_NV_RSA_BYTES])
{
- struct shirudo_identity id = {};
+ struct identity id = {};
int err;
err = identity_read(&id);
diff --git a/util/preflight.c b/util/preflight.c
index 64bce129..667a0689 100644
--- a/util/preflight.c
+++ b/util/preflight.c
@@ -41,11 +41,11 @@
#define PREFLIGHT_CERT_MAX (1u * 1024u * 1024u)
-static struct shirudo_preflight_check *
-next_slot(struct shirudo_preflight_result *r, enum shirudo_preflight_id id,
+static struct preflight_check *
+next_slot(struct preflight_result *r, enum preflight_id id,
const char *name)
{
- struct shirudo_preflight_check *c = &r->checks[r->n++];
+ struct preflight_check *c = &r->checks[r->n++];
c->id = id;
c->name = name;
@@ -53,14 +53,14 @@ next_slot(struct shirudo_preflight_result *r, enum shirudo_preflight_id id,
return c;
}
-static void pass(struct shirudo_preflight_check *c)
+static void pass(struct preflight_check *c)
{
c->ok = true;
}
__printf(3, 4)
-static void fail(struct shirudo_preflight_result *r,
- struct shirudo_preflight_check *c, const char *fmt, ...)
+static void fail(struct preflight_result *r,
+ struct preflight_check *c, const char *fmt, ...)
{
va_list ap;
@@ -72,9 +72,9 @@ static void fail(struct shirudo_preflight_result *r,
r->n_failed++;
}
-static void check_root(struct shirudo_preflight_result *r)
+static void check_root(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_ROOT, "root");
if (geteuid() == 0)
@@ -106,9 +106,9 @@ static bool lsm_lists_bpf(void)
return false;
}
-static void check_bpf_lsm(struct shirudo_preflight_result *r)
+static void check_bpf_lsm(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_BPF_LSM, "bpf_lsm_active");
if (lsm_lists_bpf())
@@ -146,9 +146,9 @@ static bool bpffs_in_proc_filesystems(void)
return found;
}
-static void check_bpffs(struct shirudo_preflight_result *r)
+static void check_bpffs(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_BPFFS, "bpffs_supported");
if (bpffs_in_proc_filesystems())
@@ -159,9 +159,9 @@ static void check_bpffs(struct shirudo_preflight_result *r)
"(needs CONFIG_BPF_FS=y)");
}
-static void check_signed_loader_abi(struct shirudo_preflight_result *r)
+static void check_signed_loader_abi(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_SIGNED_LOADER_ABI,
"signed_loader_kernel_abi");
@@ -173,9 +173,9 @@ static void check_signed_loader_abi(struct shirudo_preflight_result *r)
}
}
-static void check_cert(struct shirudo_preflight_result *r)
+static void check_cert(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_CERT_ON_DISK, "cert_on_disk");
struct stat st;
@@ -198,17 +198,17 @@ static void check_cert(struct shirudo_preflight_result *r)
* beside it. A set that cannot be read is reported by cert_on_disk;
* the checks below skip rather than fail twice.
*/
-static int preflight_keys(struct shirudo_trusted_set *set)
+static int preflight_keys(struct trusted_set *set)
{
return keys_load(get_keys_dir(), KEYS_REVOKED_DIR,
true, set);
}
-static void check_cert_algorithm(struct shirudo_preflight_result *r)
+static void check_cert_algorithm(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_CERT_ALGORITHM, "cert_algorithm");
- struct shirudo_trusted_set set;
+ struct trusted_set set;
size_t i;
if (preflight_keys(&set)) {
@@ -218,7 +218,7 @@ static void check_cert_algorithm(struct shirudo_preflight_result *r)
return;
}
for (i = 0; i < set.n; i++) {
- struct shirudo_cert cert = {};
+ struct cert cert = {};
char name[64];
int ret;
@@ -253,11 +253,11 @@ static void check_cert_algorithm(struct shirudo_preflight_result *r)
* private to this thread and discarded with it, so no durable kernel
* state is touched; it is cleared right away regardless.
*/
-static void check_cert_kernel_algo(struct shirudo_preflight_result *r)
+static void check_cert_kernel_algo(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_CERT_KERNEL_ALGO, "cert_kernel_support");
- struct shirudo_trusted_set set;
+ struct trusted_set set;
size_t i;
if (preflight_keys(&set)) {
@@ -297,9 +297,9 @@ static void check_cert_kernel_algo(struct shirudo_preflight_result *r)
pass(c);
}
-static void check_keyring(struct shirudo_preflight_result *r)
+static void check_keyring(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_KEYRING, "kernel_keyring");
long ret;
@@ -321,12 +321,12 @@ static void check_keyring(struct shirudo_preflight_result *r)
"no bpf keyring)", strerror(errno));
}
-static void check_embedded_loader(struct shirudo_preflight_result *r)
+static void check_embedded_loader(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_EMBEDDED_LOADER, "embedded_loader");
- const struct shirudo_embedded_bpf *bpf2 = bpf2_blob();
- const struct shirudo_embedded_bpf *seal = seal_blob();
+ const struct embedded_bpf *bpf2 = bpf2_blob();
+ const struct embedded_bpf *seal = seal_blob();
if (bpf2 && bpf2->size && seal && seal->size)
pass(c);
@@ -334,9 +334,9 @@ static void check_embedded_loader(struct shirudo_preflight_result *r)
fail(r, c, "embedded BPF objects missing");
}
-static void check_tpm(struct shirudo_preflight_result *r)
+static void check_tpm(struct preflight_result *r)
{
- struct shirudo_preflight_check *c =
+ struct preflight_check *c =
next_slot(r, SHIRUDO_PRE_TPM, "tpm2_reachable");
/*
@@ -346,7 +346,7 @@ static void check_tpm(struct shirudo_preflight_result *r)
* produces, so this is a convenience, not a relaxation.
*/
{
- struct shirudo_config cfg = {};
+ struct config cfg = {};
bool override = config_load(&cfg) == 0 && cfg.tpm_tcti[0];
if (override) {
@@ -370,7 +370,7 @@ static void check_tpm(struct shirudo_preflight_result *r)
strerror(errno));
}
-void preflight_run(struct shirudo_preflight_result *out)
+void preflight_run(struct preflight_result *out)
{
memset(out, 0, sizeof(*out));
check_root(out);
diff --git a/util/preflight.h b/util/preflight.h
index 9c8817bd..246e900d 100644
--- a/util/preflight.h
+++ b/util/preflight.h
@@ -12,7 +12,7 @@
#define PREFLIGHT_DETAIL_MAX 256
-enum shirudo_preflight_id {
+enum preflight_id {
SHIRUDO_PRE_ROOT,
SHIRUDO_PRE_BPF_LSM,
SHIRUDO_PRE_BPFFS,
@@ -26,15 +26,15 @@ enum shirudo_preflight_id {
SHIRUDO_PRE__MAX,
};
-struct shirudo_preflight_check {
- enum shirudo_preflight_id id;
+struct preflight_check {
+ enum preflight_id id;
const char *name;
bool ok;
char detail[PREFLIGHT_DETAIL_MAX];
};
-struct shirudo_preflight_result {
- struct shirudo_preflight_check checks[SHIRUDO_PRE__MAX];
+struct preflight_result {
+ struct preflight_check checks[SHIRUDO_PRE__MAX];
int n;
int n_failed;
};
@@ -44,6 +44,6 @@ struct shirudo_preflight_result {
* or a classical certificate. Nothing is printed; the caller presents
* the outcome.
*/
-void preflight_run(struct shirudo_preflight_result *out);
+void preflight_run(struct preflight_result *out);
#endif /* SHIRUDO_PREFLIGHT_H */
diff --git a/util/report.c b/util/report.c
index cd157105..1c3485fb 100644
--- a/util/report.c
+++ b/util/report.c
@@ -23,9 +23,9 @@
#include "report.h"
#include "seal.h"
-int report_emit(const char *path, const struct shirudo_op_report *r)
+int report_emit(const char *path, const struct op_report *r)
{
- struct shirudo_json_emit e;
+ struct json_emit e;
struct utsname uts;
char nv_index[16];
const char *errname;
@@ -41,7 +41,7 @@ int report_emit(const char *path, const struct shirudo_op_report *r)
buf = xmalloc(cap);
if (!buf)
return -ENOMEM;
- e = (struct shirudo_json_emit){ .buf = buf, .cap = cap };
+ e = (struct json_emit){ .buf = buf, .cap = cap };
errname = r->err ? strerrorname_np(r->err) : NULL;
@@ -115,7 +115,7 @@ int report_emit(const char *path, const struct shirudo_op_report *r)
return ret;
}
-void report_set_log(struct shirudo_op_report *r, const char *log)
+void report_set_log(struct op_report *r, const char *log)
{
if (!r)
return;
@@ -130,7 +130,7 @@ void report_set_log(struct shirudo_op_report *r, const char *log)
r->verifier_log = xstrndup(log, VERIFIER_LOG_MAX);
}
-void report_free(struct shirudo_op_report *r)
+void report_free(struct op_report *r)
{
xstrfree(r->verifier_log);
r->verifier_log = NULL;
diff --git a/util/report.h b/util/report.h
index dd57282b..666df251 100644
--- a/util/report.h
+++ b/util/report.h
@@ -24,7 +24,7 @@
* payload_mismatch, already_unloaded, detach_failed, tpm_error,
* unknown.
*/
-struct shirudo_op_report {
+struct op_report {
bool ok;
const char *op; /* "upatch_load" / "upatch_unload" */
const char *phase;
@@ -40,9 +40,9 @@ struct shirudo_op_report {
char chain_after[65];
};
-int report_emit(const char *path, const struct shirudo_op_report *r);
+int report_emit(const char *path, const struct op_report *r);
-void report_set_log(struct shirudo_op_report *r, const char *log);
-void report_free(struct shirudo_op_report *r);
+void report_set_log(struct op_report *r, const char *log);
+void report_free(struct op_report *r);
#endif /* SHIRUDO_REPORT_H */
diff --git a/util/serializer.c b/util/serializer.c
index 2a489d55..5084f561 100644
--- a/util/serializer.c
+++ b/util/serializer.c
@@ -96,7 +96,7 @@ int serializer_new_invocation_id(__u64 *out)
return 0;
}
-int serial_chunk_validate(const struct shirudo_serial_chunk *c,
+int serial_chunk_validate(const struct serial_chunk *c,
__u32 want_index,
__u32 total_chunks,
__u32 page_index,
diff --git a/util/serializer.h b/util/serializer.h
index 2815481d..860a142b 100644
--- a/util/serializer.h
+++ b/util/serializer.h
@@ -12,7 +12,7 @@ int serializer_lock_acquire(__u32 map_id);
int serializer_lock_acquire_at(const char *dir, __u32 map_id);
int serializer_new_invocation_id(__u64 *out);
-int serial_chunk_validate(const struct shirudo_serial_chunk *chunk,
+int serial_chunk_validate(const struct serial_chunk *chunk,
__u32 want_index,
__u32 total_chunks,
__u32 page_index,
diff --git a/util/sign.c b/util/sign.c
index 01dcd3b3..bfc33b1f 100644
--- a/util/sign.c
+++ b/util/sign.c
@@ -160,7 +160,7 @@ static bool pkey_is_mldsa87(const EVP_PKEY *pkey)
return EVP_PKEY_is_a(pkey, "ML-DSA-87");
}
-int cms_sign(struct shirudo_sign_io *io,
+int cms_sign(struct sign_io *io,
const char *pkey_path, const char *cert_path)
{
unsigned int signer_flags = CMS_NOCERTS | CMS_BINARY | CMS_NOSMIMECAP |
diff --git a/util/sign.h b/util/sign.h
index b2c116d6..98433461 100644
--- a/util/sign.h
+++ b/util/sign.h
@@ -19,7 +19,7 @@
* the kernel reconstructs at BPF_PROG_LOAD; data may be empty.
* signature_sz comes back as the actual size.
*/
-struct shirudo_sign_io {
+struct sign_io {
const void *insns;
size_t insns_sz;
@@ -36,7 +36,7 @@ struct shirudo_sign_io {
* -ENOSPC when the signature buffer is too small, -EINVAL on a parse
* failure, -EIO on an OpenSSL failure.
*/
-int cms_sign(struct shirudo_sign_io *io,
+int cms_sign(struct sign_io *io,
const char *pkey_path, const char *cert_path);
/*
diff --git a/util/similar.c b/util/similar.c
index 1766e331..3616e9a0 100644
--- a/util/similar.c
+++ b/util/similar.c
@@ -69,7 +69,7 @@ static int edit_distance(const char *s, const char *t, int max)
size_t suggest(const char *name,
const char *const *commands, size_t n_commands,
int max_dist,
- struct shirudo_suggestion *out, size_t cap)
+ struct suggestion *out, size_t cap)
{
size_t n_out = 0;
size_t i;
diff --git a/util/similar.h b/util/similar.h
index a4b82163..8617e857 100644
--- a/util/similar.h
+++ b/util/similar.h
@@ -17,7 +17,7 @@
*/
#define SIMILAR_MAX_LEN 64
-struct shirudo_suggestion {
+struct suggestion {
const char *name;
int dist;
};
@@ -25,7 +25,7 @@ struct shirudo_suggestion {
size_t suggest(const char *name,
const char *const *commands, size_t n_commands,
int max_dist,
- struct shirudo_suggestion *out, size_t cap);
+ struct suggestion *out, size_t cap);
/*
* Three tiers, the first that hits wins: exact, input a prefix of a
diff --git a/util/sysinfo.c b/util/sysinfo.c
index 1e753f99..c731c39f 100644
--- a/util/sysinfo.c
+++ b/util/sysinfo.c
@@ -267,7 +267,7 @@ static void emit_kernel_config_entry(void *ctx, const char *key,
json_kv_string(ctx, key, value);
}
-static void emit_kernel_config(struct shirudo_json_emit *e,
+static void emit_kernel_config(struct json_emit *e,
const char *kernel_release)
{
json_obj_open_key(e, "kernel_config");
@@ -277,11 +277,11 @@ static void emit_kernel_config(struct shirudo_json_emit *e,
json_obj_close(e);
}
-void sysinfo_gather(struct shirudo_sysinfo *si)
+void sysinfo_gather(struct sysinfo *si)
{
struct utsname u;
- *si = (struct shirudo_sysinfo){};
+ *si = (struct sysinfo){};
si->nproc = -1;
si->mem_total_kb = -1;
si->mem_avail_kb = -1;
@@ -317,8 +317,8 @@ void sysinfo_gather(struct shirudo_sysinfo *si)
si->uptime_sec = read_uptime_sec();
}
-void sysinfo_emit_json(struct shirudo_json_emit *e,
- const struct shirudo_sysinfo *si)
+void sysinfo_emit_json(struct json_emit *e,
+ const struct sysinfo *si)
{
json_obj_open_key(e, "system");
json_kv_string(e, "hostname", si->hostname);
diff --git a/util/sysinfo.h b/util/sysinfo.h
index aa90d45f..6793bce5 100644
--- a/util/sysinfo.h
+++ b/util/sysinfo.h
@@ -10,7 +10,7 @@
#include "kernel_build_id.h"
-struct shirudo_sysinfo {
+struct sysinfo {
char hostname[256];
char os_pretty[256]; /* /etc/os-release PRETTY_NAME */
char kernel_release[96]; /* uname -r */
@@ -29,9 +29,9 @@ struct shirudo_sysinfo {
};
/* Fill *si; missing values become "" (strings) or -1 (numbers). */
-void sysinfo_gather(struct shirudo_sysinfo *si);
+void sysinfo_gather(struct sysinfo *si);
-struct shirudo_json_emit;
+struct json_emit;
typedef void (*shirudo_kernel_config_cb)(void *ctx, const char *key,
const char *value);
@@ -40,7 +40,7 @@ int sysinfo_kernel_config_foreach(const char *kernel_release,
shirudo_kernel_config_cb cb,
void *ctx);
-void sysinfo_emit_json(struct shirudo_json_emit *e,
- const struct shirudo_sysinfo *si);
+void sysinfo_emit_json(struct json_emit *e,
+ const struct sysinfo *si);
#endif /* SHIRUDO_SYSINFO_H */
diff --git a/util/tamper.c b/util/tamper.c
index fea68cb3..441df5c7 100644
--- a/util/tamper.c
+++ b/util/tamper.c
@@ -94,21 +94,21 @@ static const struct {
"pin, map or link opened by another executable" },
};
-const char *tamper_name(enum shirudo_tamper_point point)
+const char *tamper_name(enum tamper_point point)
{
if (point >= SHIRUDO_TAMPER_MAX || !tamper_points[point].name)
return "?";
return tamper_points[point].name;
}
-const char *tamper_meaning(enum shirudo_tamper_point point)
+const char *tamper_meaning(enum tamper_point point)
{
if (point >= SHIRUDO_TAMPER_MAX || !tamper_points[point].meaning)
return "?";
return tamper_points[point].meaning;
}
-int tamper_read(struct shirudo_tamper_counts *out)
+int tamper_read(struct tamper_counts *out)
{
struct bpf_map_info info = {};
__u32 len = sizeof(info);
diff --git a/util/tamper.h b/util/tamper.h
index 0ce7311e..351b0ae2 100644
--- a/util/tamper.h
+++ b/util/tamper.h
@@ -11,19 +11,19 @@
#include "bpf/lib/tamper.h"
-struct shirudo_tamper_counts {
+struct tamper_counts {
__u64 count[SHIRUDO_TAMPER_MAX];
__u64 total;
};
-const char *tamper_name(enum shirudo_tamper_point point);
-const char *tamper_meaning(enum shirudo_tamper_point point);
+const char *tamper_name(enum tamper_point point);
+const char *tamper_meaning(enum tamper_point point);
/*
* The counters the LSM has kept this boot. -ENOENT when init has not
* run, -EPROTO when the pinned map is not the shape this binary knows,
* another -errno when the pin cannot be read.
*/
-int tamper_read(struct shirudo_tamper_counts *out);
+int tamper_read(struct tamper_counts *out);
#endif /* SHIRUDO_UTIL_TAMPER_H */
diff --git a/util/tls_openssl.c b/util/tls_openssl.c
index 146fecf9..de068629 100644
--- a/util/tls_openssl.c
+++ b/util/tls_openssl.c
@@ -40,7 +40,7 @@
*/
static bool tls_classical_host_allowed(CURL *curl)
{
- struct shirudo_config cfg = {};
+ struct config cfg = {};
const char *allowlist, *effective_url;
CURLU *url = NULL;
char *scheme = NULL, *host = NULL;
@@ -117,7 +117,7 @@ static void tls_info_callback(const SSL *ssl, int where, int ret)
host ? host : "unknown host", group ? group : "unknown group");
}
-void tls_ca_cleanup(struct shirudo_tls_ca *ca)
+void tls_ca_cleanup(struct tls_ca *ca)
{
if (ca)
ca->impl = NULL;
@@ -125,7 +125,7 @@ void tls_ca_cleanup(struct shirudo_tls_ca *ca)
static CURLcode sslctx_callback(CURL *curl, void *sslctx, void *userptr)
{
- const struct shirudo_tls_ca *ca = userptr;
+ const struct tls_ca *ca = userptr;
const char *path = ca ? ca->path : NULL;
SSL_CTX *ctx = sslctx;
X509 *cert;
@@ -171,7 +171,7 @@ static CURLcode sslctx_callback(CURL *curl, void *sslctx, void *userptr)
return CURLE_OK;
}
-int tls_curl_policy(CURL *curl, struct shirudo_tls_ca *ca)
+int tls_curl_policy(CURL *curl, struct tls_ca *ca)
{
if (!curl)
return -EINVAL;
diff --git a/util/tpm.c b/util/tpm.c
index d00761a0..7a1ec4e3 100644
--- a/util/tpm.c
+++ b/util/tpm.c
@@ -33,7 +33,7 @@
*/
int tpm_tcti(char *buf, size_t size)
{
- struct shirudo_config cfg = {};
+ struct config cfg = {};
const char *tcti;
ssize_t n;
@@ -53,10 +53,10 @@ int tpm_tcti(char *buf, size_t size)
return n < 0 ? (int)n : 0;
}
-static int open_tpm(struct shirudo_tpm **out, bool quiet)
+static int open_tpm(struct tpm **out, bool quiet)
{
char tcti[TPM_TCTI_MAX];
- struct shirudo_tpm *t;
+ struct tpm *t;
TSS2_RC ret;
int err;
@@ -101,17 +101,17 @@ static int open_tpm(struct shirudo_tpm **out, bool quiet)
return 0;
}
-int tpm_open(struct shirudo_tpm **out)
+int tpm_open(struct tpm **out)
{
return open_tpm(out, false);
}
-int tpm_open_quiet(struct shirudo_tpm **out)
+int tpm_open_quiet(struct tpm **out)
{
return open_tpm(out, true);
}
-void tpm_close(struct shirudo_tpm *t)
+void tpm_close(struct tpm *t)
{
if (!t)
return;
@@ -122,7 +122,7 @@ void tpm_close(struct shirudo_tpm *t)
xfree(t, sizeof(*t));
}
-int tpm_nv_set_writer(struct shirudo_tpm *t,
+int tpm_nv_set_writer(struct tpm *t,
const __u8 seed[TPM_DIGEST_LEN],
const __u8 public[TPM_NV_RSA_BYTES])
{
@@ -163,7 +163,7 @@ static void pcr_selection(__u32 mask, TPML_PCR_SELECTION *sel)
sel->pcrSelections[0].pcrSelect[2] = (__u8)(mask >> 16);
}
-int tpm_pcr_read(struct shirudo_tpm *t, __u32 pcr,
+int tpm_pcr_read(struct tpm *t, __u32 pcr,
__u8 out[32])
{
TPML_PCR_SELECTION sel;
@@ -190,7 +190,7 @@ int tpm_pcr_read(struct shirudo_tpm *t, __u32 pcr,
return 0;
}
-int tpm_pcr_extend(struct shirudo_tpm *t, __u32 pcr,
+int tpm_pcr_extend(struct tpm *t, __u32 pcr,
const __u8 digest[32])
{
TPML_DIGEST_VALUES dv = { .count = 1 };
@@ -209,7 +209,7 @@ int tpm_pcr_extend(struct shirudo_tpm *t, __u32 pcr,
return 0;
}
-int tpm_boot_identity(struct shirudo_tpm *t, __u32 *reset,
+int tpm_boot_identity(struct tpm *t, __u32 *reset,
__u32 *restart)
{
TPMS_TIME_INFO *info = NULL;
@@ -229,7 +229,7 @@ int tpm_boot_identity(struct shirudo_tpm *t, __u32 *reset,
return 0;
}
-int tpm_reset_count(struct shirudo_tpm *t, __u32 *out)
+int tpm_reset_count(struct tpm *t, __u32 *out)
{
TPMS_TIME_INFO *info = NULL;
TSS2_RC ret;
@@ -245,7 +245,7 @@ int tpm_reset_count(struct shirudo_tpm *t, __u32 *out)
return 0;
}
-static int nv_handle(struct shirudo_tpm *t, __u32 index, ESYS_TR *out)
+static int nv_handle(struct tpm *t, __u32 index, ESYS_TR *out)
{
TSS2_RC ret;
@@ -261,7 +261,7 @@ static int nv_handle(struct shirudo_tpm *t, __u32 index, ESYS_TR *out)
return 0;
}
-int tpm_nv_info(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_info(struct tpm *t, __u32 index,
struct tpm_nv_info *info)
{
TPM2B_NV_PUBLIC *pub = NULL;
@@ -299,7 +299,7 @@ int tpm_nv_info(struct shirudo_tpm *t, __u32 index,
return 0;
}
-static int owner_auth_set(struct shirudo_tpm *t, const void *auth, size_t len)
+static int owner_auth_set(struct tpm *t, const void *auth, size_t len)
{
TPM2B_AUTH owner = {};
TSS2_RC ret;
@@ -319,7 +319,7 @@ static int owner_auth_set(struct shirudo_tpm *t, const void *auth, size_t len)
return 0;
}
-static void owner_auth_clear(struct shirudo_tpm *t)
+static void owner_auth_clear(struct tpm *t)
{
TPM2B_AUTH empty = {};
@@ -340,7 +340,7 @@ static int owner_auth_error(const char *op, __u32 index, TSS2_RC ret)
return -EIO;
}
-int tpm_nv_define(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_define(struct tpm *t, __u32 index,
const __u8 policy[32],
const void *owner_auth, size_t owner_auth_len)
{
@@ -369,7 +369,7 @@ int tpm_nv_define(struct shirudo_tpm *t, __u32 index,
return 0;
}
-int tpm_nv_undefine(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_undefine(struct tpm *t, __u32 index,
const void *owner_auth, size_t owner_auth_len)
{
ESYS_TR nv;
@@ -395,7 +395,7 @@ int tpm_nv_undefine(struct shirudo_tpm *t, __u32 index,
return 0;
}
-int tpm_nv_read(struct shirudo_tpm *t, __u32 index, __u8 out[32])
+int tpm_nv_read(struct tpm *t, __u32 index, __u8 out[32])
{
TPM2B_MAX_NV_BUFFER *data = NULL;
ESYS_TR nv;
@@ -425,7 +425,7 @@ int tpm_nv_read(struct shirudo_tpm *t, __u32 index, __u8 out[32])
return 0;
}
-int tpm_policy_session_start(struct shirudo_tpm *t, ESYS_TR *session)
+int tpm_policy_session_start(struct tpm *t, ESYS_TR *session)
{
TPMT_SYM_DEF sym = { .algorithm = TPM2_ALG_NULL };
TSS2_RC ret;
@@ -441,13 +441,13 @@ int tpm_policy_session_start(struct shirudo_tpm *t, ESYS_TR *session)
return 0;
}
-static void session_flush(struct shirudo_tpm *t, ESYS_TR session)
+static void session_flush(struct tpm *t, ESYS_TR session)
{
if (session != ESYS_TR_NONE)
Esys_FlushContext(t->esys, session);
}
-int tpm_writer_prepare(struct shirudo_tpm *t, ESYS_TR session,
+int tpm_writer_prepare(struct tpm *t, ESYS_TR session,
const __u8 name[TPM_NAME_LEN],
const __u8 event[TPM_DIGEST_LEN],
struct tpm_writer_authorization *authorization)
@@ -482,7 +482,7 @@ int tpm_writer_prepare(struct shirudo_tpm *t, ESYS_TR session,
* reproduces that key after a reset, while the frozen modulus refuses
* a replacement made under a different owner seed.
*/
-static int tpm_writer_primary(struct shirudo_tpm *t,
+static int tpm_writer_primary(struct tpm *t,
const __u8 seed[TPM_DIGEST_LEN],
const __u8 expected[TPM_NV_RSA_BYTES],
__u8 public[TPM_NV_RSA_BYTES],
@@ -493,7 +493,7 @@ static int tpm_writer_primary(struct shirudo_tpm *t,
TPML_PCR_SELECTION creation_pcr = {};
TPM2B_SENSITIVE_CREATE sensitive = {};
TPM2B_PUBLIC *out_pub = NULL;
- struct shirudo_config cfg = {};
+ struct config cfg = {};
TPM2B_PUBLIC in_pub = {};
TPM2B_NAME *name = NULL;
TPM2B_DATA outside = {};
@@ -574,7 +574,7 @@ cleanup:
return err;
}
-int tpm_writer_load(struct shirudo_tpm *t,
+int tpm_writer_load(struct tpm *t,
const __u8 seed[TPM_DIGEST_LEN],
const __u8 expected_public[TPM_NV_RSA_BYTES],
ESYS_TR *key)
@@ -584,7 +584,7 @@ int tpm_writer_load(struct shirudo_tpm *t,
return tpm_writer_primary(t, seed, expected_public, public, key);
}
-int tpm_writer_create(struct shirudo_tpm *t,
+int tpm_writer_create(struct tpm *t,
const __u8 seed[TPM_DIGEST_LEN],
__u8 public[TPM_NV_RSA_BYTES])
{
@@ -596,7 +596,7 @@ int tpm_writer_create(struct shirudo_tpm *t,
return err;
}
-static int tpm_writer_sign(struct shirudo_tpm *t, ESYS_TR key,
+static int tpm_writer_sign(struct tpm *t, ESYS_TR key,
const __u8 hash[TPM_DIGEST_LEN],
__u8 out[TPM_NV_RSA_BYTES])
{
@@ -631,7 +631,7 @@ static int tpm_writer_sign(struct shirudo_tpm *t, ESYS_TR key,
return err;
}
-TSS2_RC tpm_writer_authorize(struct shirudo_tpm *t, ESYS_TR key, ESYS_TR session,
+TSS2_RC tpm_writer_authorize(struct tpm *t, ESYS_TR key, ESYS_TR session,
const struct tpm_writer_authorization *authorization,
const __u8 signature[TPM_NV_RSA_BYTES])
{
@@ -653,7 +653,7 @@ TSS2_RC tpm_writer_authorize(struct shirudo_tpm *t, ESYS_TR key, ESYS_TR session
return ret;
}
-static int policy_writer_signed(struct shirudo_tpm *t, ESYS_TR session,
+static int policy_writer_signed(struct tpm *t, ESYS_TR session,
__u32 index, const __u8 event[32])
{
struct tpm_writer_authorization authorization = {};
@@ -693,7 +693,7 @@ out:
return err;
}
-int tpm_policy_session_finish(struct shirudo_tpm *t, ESYS_TR session,
+int tpm_policy_session_finish(struct tpm *t, ESYS_TR session,
const __u8 expected[TPM_DIGEST_LEN])
{
TPM2B_DIGEST *digest = NULL;
@@ -723,7 +723,7 @@ int tpm_policy_session_finish(struct shirudo_tpm *t, ESYS_TR session,
* authorize the exact NV_Extend with the TPM-held writer after PolicyOR.
* Compare the session digest with the software policy to detect drift.
*/
-static int policy_session_register(struct shirudo_tpm *t, bool init,
+static int policy_session_register(struct tpm *t, bool init,
__u32 index, const __u8 event[32],
__u32 pcr_mask,
const __u8 branch_written[32],
@@ -791,7 +791,7 @@ static int policy_session_register(struct shirudo_tpm *t, bool init,
return err;
}
-static int nv_extend_session(struct shirudo_tpm *t, __u32 index,
+static int nv_extend_session(struct tpm *t, __u32 index,
ESYS_TR session, const __u8 event[32])
{
TPM2B_MAX_NV_BUFFER data = { .size = TPM_NV_DIGEST_LEN };
@@ -814,7 +814,7 @@ static int nv_extend_session(struct shirudo_tpm *t, __u32 index,
return 0;
}
-int tpm_nv_extend_first(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_extend_first(struct tpm *t, __u32 index,
__u32 pcr_mask,
const __u8 branch_written[32],
const __u8 branch_init[32],
@@ -832,7 +832,7 @@ int tpm_nv_extend_first(struct shirudo_tpm *t, __u32 index,
return err;
}
-int tpm_nv_extend(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_extend(struct tpm *t, __u32 index,
const __u8 branch_written[32],
const __u8 branch_init[32],
const __u8 event[32])
@@ -852,7 +852,7 @@ int tpm_nv_extend(struct shirudo_tpm *t, __u32 index,
static int public_from_tss(const TPMT_PUBLIC *p, __u8 *out, size_t cap,
size_t *len)
{
- struct shirudo_tpm_public pub = {};
+ struct tpm_public pub = {};
if (p->nameAlg != TPM2_ALG_SHA256 || p->authPolicy.size > 32)
return -EINVAL;
@@ -924,9 +924,9 @@ static int marshal_signature(const TPMT_SIGNATURE *sig, __u8 *out,
* marshalled public area and its name, the latter checked against the
* area so that what the evidence carries is what the TPM named.
*/
-static int endorsement_primary(struct shirudo_tpm *t,
+static int endorsement_primary(struct tpm *t,
const TPM2B_PUBLIC *in_pub, const char *what,
- struct shirudo_tpm_key *key)
+ struct tpm_key *key)
{
TPM2B_SENSITIVE_CREATE sensitive = {};
TPML_PCR_SELECTION creation_pcr = {};
@@ -978,7 +978,7 @@ static int endorsement_primary(struct shirudo_tpm *t,
return err;
}
-int tpm_ak_create(struct shirudo_tpm *t, struct shirudo_tpm_key *ak)
+int tpm_ak_create(struct tpm *t, struct tpm_key *ak)
{
TPM2B_PUBLIC in_pub = {};
@@ -998,8 +998,8 @@ int tpm_ak_create(struct shirudo_tpm *t, struct shirudo_tpm_key *ak)
return endorsement_primary(t, &in_pub, "attestation key", ak);
}
-int tpm_ek_create(struct shirudo_tpm *t, bool rsa,
- struct shirudo_tpm_key *ek)
+int tpm_ek_create(struct tpm *t, bool rsa,
+ struct tpm_key *ek)
{
TPM2B_PUBLIC in_pub = {};
TPMT_PUBLIC *pub = &in_pub.publicArea;
@@ -1034,7 +1034,7 @@ int tpm_ek_create(struct shirudo_tpm *t, bool rsa,
return endorsement_primary(t, &in_pub, "endorsement key", ek);
}
-void tpm_key_flush(struct shirudo_tpm *t, struct shirudo_tpm_key *key)
+void tpm_key_flush(struct tpm *t, struct tpm_key *key)
{
if (key->handle != ESYS_TR_NONE && key->handle != 0)
Esys_FlushContext(t->esys, key->handle);
@@ -1044,7 +1044,7 @@ void tpm_key_flush(struct shirudo_tpm *t, struct shirudo_tpm_key *key)
static int attestation_copy(const TPM2B_ATTEST *attest,
const TPMT_SIGNATURE *sig,
- struct shirudo_tpm_attestation *out)
+ struct tpm_attestation *out)
{
if (attest->size > sizeof(out->attest))
return -E2BIG;
@@ -1054,9 +1054,9 @@ static int attestation_copy(const TPM2B_ATTEST *attest,
&out->signature_len);
}
-int tpm_quote(struct shirudo_tpm *t, const struct shirudo_tpm_key *ak,
+int tpm_quote(struct tpm *t, const struct tpm_key *ak,
const __u8 *nonce, size_t nonce_len, __u32 pcr_mask,
- struct shirudo_tpm_attestation *out)
+ struct tpm_attestation *out)
{
TPMT_SIG_SCHEME scheme = { .scheme = TPM2_ALG_NULL };
TPMT_SIGNATURE *sig = NULL;
@@ -1083,10 +1083,10 @@ int tpm_quote(struct shirudo_tpm *t, const struct shirudo_tpm_key *ak,
return err;
}
-int tpm_nv_certify(struct shirudo_tpm *t,
- const struct shirudo_tpm_key *ak, __u32 index,
+int tpm_nv_certify(struct tpm *t,
+ const struct tpm_key *ak, __u32 index,
const __u8 *nonce, size_t nonce_len,
- struct shirudo_tpm_attestation *out)
+ struct tpm_attestation *out)
{
TPMT_SIG_SCHEME scheme = { .scheme = TPM2_ALG_NULL };
TPMT_SIGNATURE *sig = NULL;
@@ -1118,9 +1118,9 @@ int tpm_nv_certify(struct shirudo_tpm *t,
return err;
}
-int tpm_activate_credential(struct shirudo_tpm *t,
- const struct shirudo_tpm_key *ak,
- const struct shirudo_tpm_key *ek,
+int tpm_activate_credential(struct tpm *t,
+ const struct tpm_key *ak,
+ const struct tpm_key *ek,
const __u8 *blob, size_t blob_len,
const __u8 *secret, size_t secret_len,
__u8 *out, size_t cap, size_t *out_len)
@@ -1169,7 +1169,7 @@ int tpm_activate_credential(struct shirudo_tpm *t,
return 0;
}
-static int nv_read_all(struct shirudo_tpm *t, __u32 index, __u8 *out,
+static int nv_read_all(struct tpm *t, __u32 index, __u8 *out,
size_t cap, size_t *len)
{
TPM2B_NV_PUBLIC *pub = NULL;
@@ -1220,7 +1220,7 @@ static int nv_read_all(struct shirudo_tpm *t, __u32 index, __u8 *out,
return 0;
}
-int tpm_ek_certificate(struct shirudo_tpm *t, __u8 *out,
+int tpm_ek_certificate(struct tpm *t, __u8 *out,
size_t cap, size_t *len, bool *rsa)
{
int err;
diff --git a/util/tpm.h b/util/tpm.h
index 34cb7887..5f410bad 100644
--- a/util/tpm.h
+++ b/util/tpm.h
@@ -20,31 +20,31 @@
#define TPM_ATTEST_MAX 1024
#define TPM_SIGNATURE_MAX 160
-struct shirudo_tpm;
+struct tpm;
int tpm_tcti(char *buf, size_t size);
-int tpm_open(struct shirudo_tpm **out);
-int tpm_open_quiet(struct shirudo_tpm **out);
-void tpm_close(struct shirudo_tpm *t);
+int tpm_open(struct tpm **out);
+int tpm_open_quiet(struct tpm **out);
+void tpm_close(struct tpm *t);
-int tpm_writer_create(struct shirudo_tpm *t,
+int tpm_writer_create(struct tpm *t,
const __u8 seed[TPM_DIGEST_LEN],
__u8 public[TPM_NV_RSA_BYTES]);
-int tpm_nv_set_writer(struct shirudo_tpm *t,
+int tpm_nv_set_writer(struct tpm *t,
const __u8 seed[TPM_DIGEST_LEN],
const __u8 public[TPM_NV_RSA_BYTES]);
-int tpm_pcr_read(struct shirudo_tpm *t, __u32 pcr,
+int tpm_pcr_read(struct tpm *t, __u32 pcr,
__u8 out[TPM_DIGEST_LEN]);
-int tpm_pcr_extend(struct shirudo_tpm *t, __u32 pcr,
+int tpm_pcr_extend(struct tpm *t, __u32 pcr,
const __u8 digest[TPM_DIGEST_LEN]);
/*
* The TPM's reset count, a new value at every TPM reset: the identity
* of the period a clear-on-reset index lives through.
*/
-int tpm_reset_count(struct shirudo_tpm *t, __u32 *out);
-int tpm_boot_identity(struct shirudo_tpm *t, __u32 *reset,
+int tpm_reset_count(struct tpm *t, __u32 *out);
+int tpm_boot_identity(struct tpm *t, __u32 *reset,
__u32 *restart);
struct tpm_nv_info {
@@ -69,22 +69,22 @@ struct tpm_nv_info {
* Both branches require the TPM writer's command-bound signature;
* extending requires nv_set_writer first.
*/
-int tpm_nv_info(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_info(struct tpm *t, __u32 index,
struct tpm_nv_info *info);
-int tpm_nv_define(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_define(struct tpm *t, __u32 index,
const __u8 policy[TPM_DIGEST_LEN],
const void *owner_auth, size_t owner_auth_len);
-int tpm_nv_undefine(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_undefine(struct tpm *t, __u32 index,
const void *owner_auth, size_t owner_auth_len);
/* -ENOENT: not defined; -ENODATA: defined but not written this boot. */
-int tpm_nv_read(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_read(struct tpm *t, __u32 index,
__u8 out[TPM_DIGEST_LEN]);
-int tpm_nv_extend_first(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_extend_first(struct tpm *t, __u32 index,
__u32 pcr_mask,
const __u8 branch_written[32],
const __u8 branch_init[32],
const __u8 event[32]);
-int tpm_nv_extend(struct shirudo_tpm *t, __u32 index,
+int tpm_nv_extend(struct tpm *t, __u32 index,
const __u8 branch_written[32],
const __u8 branch_init[32],
const __u8 event[32]);
@@ -94,7 +94,7 @@ int tpm_nv_extend(struct shirudo_tpm *t, __u32 index,
* endorsement hierarchy with a fixed template, so the same TPM always
* yields the same key and an operator can pin it by name.
*/
-struct shirudo_tpm_key {
+struct tpm_key {
__u32 handle;
__u8 public[TPM_PUBLIC_MAX];
size_t public_len;
@@ -102,21 +102,21 @@ struct shirudo_tpm_key {
size_t name_len;
};
-struct shirudo_tpm_attestation {
+struct tpm_attestation {
__u8 attest[TPM_ATTEST_MAX];
size_t attest_len;
__u8 signature[TPM_SIGNATURE_MAX];
size_t signature_len;
};
-int tpm_ak_create(struct shirudo_tpm *t, struct shirudo_tpm_key *ak);
+int tpm_ak_create(struct tpm *t, struct tpm_key *ak);
/*
* The endorsement key from the TCG default template of the given
* type, the key the TPM's endorsement certificate describes.
*/
-int tpm_ek_create(struct shirudo_tpm *t, bool rsa,
- struct shirudo_tpm_key *ek);
+int tpm_ek_create(struct tpm *t, bool rsa,
+ struct tpm_key *ek);
/*
* TPM2_ActivateCredential: recover the credential an operator
@@ -124,26 +124,26 @@ int tpm_ek_create(struct shirudo_tpm *t, bool rsa,
* -EKEYREJECTED when the TPM refuses it, as it does for a blob made
* for another key or another TPM.
*/
-int tpm_activate_credential(struct shirudo_tpm *t,
- const struct shirudo_tpm_key *ak,
- const struct shirudo_tpm_key *ek,
+int tpm_activate_credential(struct tpm *t,
+ const struct tpm_key *ak,
+ const struct tpm_key *ek,
const __u8 *blob, size_t blob_len,
const __u8 *secret, size_t secret_len,
__u8 *out, size_t cap, size_t *out_len);
-void tpm_key_flush(struct shirudo_tpm *t, struct shirudo_tpm_key *key);
-int tpm_quote(struct shirudo_tpm *t, const struct shirudo_tpm_key *ak,
+void tpm_key_flush(struct tpm *t, struct tpm_key *key);
+int tpm_quote(struct tpm *t, const struct tpm_key *ak,
const __u8 *nonce, size_t nonce_len, __u32 pcr_mask,
- struct shirudo_tpm_attestation *out);
-int tpm_nv_certify(struct shirudo_tpm *t,
- const struct shirudo_tpm_key *ak, __u32 index,
+ struct tpm_attestation *out);
+int tpm_nv_certify(struct tpm *t,
+ const struct tpm_key *ak, __u32 index,
const __u8 *nonce, size_t nonce_len,
- struct shirudo_tpm_attestation *out);
+ struct tpm_attestation *out);
/*
* The endorsement key certificate from its TCG NV index, the ECC one
* first; *rsa tells which key it describes. -ENOENT if none.
*/
-int tpm_ek_certificate(struct shirudo_tpm *t, __u8 *out,
+int tpm_ek_certificate(struct tpm *t, __u8 *out,
size_t cap, size_t *len, bool *rsa);
#endif /* SHIRUDO_TPM_H */
diff --git a/util/tpm_internal.h b/util/tpm_internal.h
index f6a0ff55..5d67b323 100644
--- a/util/tpm_internal.h
+++ b/util/tpm_internal.h
@@ -8,7 +8,7 @@
#include "tpm.h"
-struct shirudo_tpm {
+struct tpm {
TSS2_TCTI_CONTEXT *tcti;
ESYS_CONTEXT *esys;
__u8 writer_seed[TPM_DIGEST_LEN];
@@ -22,18 +22,18 @@ struct tpm_writer_authorization {
__u8 digest[TPM_DIGEST_LEN];
};
-int tpm_policy_session_start(struct shirudo_tpm *t, ESYS_TR *session);
-int tpm_policy_session_finish(struct shirudo_tpm *t, ESYS_TR session,
+int tpm_policy_session_start(struct tpm *t, ESYS_TR *session);
+int tpm_policy_session_finish(struct tpm *t, ESYS_TR session,
const __u8 expected[TPM_DIGEST_LEN]);
-int tpm_writer_load(struct shirudo_tpm *t,
+int tpm_writer_load(struct tpm *t,
const __u8 seed[TPM_DIGEST_LEN],
const __u8 expected_public[TPM_NV_RSA_BYTES],
ESYS_TR *key);
-int tpm_writer_prepare(struct shirudo_tpm *t, ESYS_TR session,
+int tpm_writer_prepare(struct tpm *t, ESYS_TR session,
const __u8 name[TPM_NAME_LEN],
const __u8 event[TPM_DIGEST_LEN],
struct tpm_writer_authorization *authorization);
-TSS2_RC tpm_writer_authorize(struct shirudo_tpm *t, ESYS_TR key, ESYS_TR session,
+TSS2_RC tpm_writer_authorize(struct tpm *t, ESYS_TR key, ESYS_TR session,
const struct tpm_writer_authorization *authorization,
const __u8 signature[TPM_NV_RSA_BYTES]);
diff --git a/util/tpm_wire.c b/util/tpm_wire.c
index 421f7150..35769c59 100644
--- a/util/tpm_wire.c
+++ b/util/tpm_wire.c
@@ -93,7 +93,7 @@ static int policy_hash(const __u8 prev[32], __u32 cc,
const __u8 *a, size_t a_len,
const __u8 *b, size_t b_len, __u8 out[32])
{
- struct shirudo_sha256_ctx ctx;
+ struct sha256_ctx ctx;
__u8 cc_be[4];
/* prev and out may be one buffer; out changes only once done. */
@@ -323,7 +323,7 @@ const __u8 shirudo_tpm_ek_policy[32] = {
};
int tpm_public_parse(const __u8 *buf, size_t len,
- struct shirudo_tpm_public *out)
+ struct tpm_public *out)
{
struct reader r = { buf, len };
const __u8 *policy, *n;
@@ -374,7 +374,7 @@ int tpm_public_parse(const __u8 *buf, size_t len,
return 0;
}
-int tpm_public_marshal(const struct shirudo_tpm_public *pub,
+int tpm_public_marshal(const struct tpm_public *pub,
__u8 *out, size_t cap, size_t *len)
{
size_t need = 2 + 2 + 4 + 2 + pub->policy_len + 2 + 2, off = 0;
@@ -430,9 +430,9 @@ int tpm_public_marshal(const struct shirudo_tpm_public *pub,
}
int tpm_ecc_public_parse(const __u8 *buf, size_t len,
- struct shirudo_tpm_ecc_public *out)
+ struct tpm_ecc_public *out)
{
- struct shirudo_tpm_public pub;
+ struct tpm_public pub;
int ret;
memset(out, 0, sizeof(*out));
@@ -577,7 +577,7 @@ static int get_name(struct reader *r, __u8 *name, size_t *name_len)
}
int tpm_attest_parse(const __u8 *buf, size_t len,
- struct shirudo_tpm_attest *out)
+ struct tpm_attest *out)
{
struct reader r = { buf, len };
__u32 magic;
diff --git a/util/tpm_wire.h b/util/tpm_wire.h
index a4b60ea2..0fa03eaf 100644
--- a/util/tpm_wire.h
+++ b/util/tpm_wire.h
@@ -129,7 +129,7 @@ extern const __u8 shirudo_tpm_ek_policy[TPM_DIGEST_LEN];
* P-256 or RSA-2048 key, its symmetric protector absent or
* AES-128-CFB, its scheme absent or ECDSA with SHA-256.
*/
-struct shirudo_tpm_public {
+struct tpm_public {
__u16 type;
__u32 attrs;
size_t policy_len; /* 0 or 32 */
@@ -149,11 +149,11 @@ struct shirudo_tpm_public {
};
int tpm_public_parse(const __u8 *buf, size_t len,
- struct shirudo_tpm_public *out);
-int tpm_public_marshal(const struct shirudo_tpm_public *pub,
+ struct tpm_public *out);
+int tpm_public_marshal(const struct tpm_public *pub,
__u8 *out, size_t cap, size_t *len);
-struct shirudo_tpm_ecc_public {
+struct tpm_ecc_public {
__u32 attrs;
__u16 scheme;
__u16 hash;
@@ -163,7 +163,7 @@ struct shirudo_tpm_ecc_public {
};
int tpm_ecc_public_parse(const __u8 *buf, size_t len,
- struct shirudo_tpm_ecc_public *out);
+ struct tpm_ecc_public *out);
/*
* The key derivations of TPM 2.0 Part 1 with SHA-256: KDFa (SP800-108
@@ -195,7 +195,7 @@ int tpm_credential_protect(const __u8 seed[32],
int tpm_ecdsa_signature_parse(const __u8 *buf, size_t len,
__u8 r[32], __u8 s[32]);
-struct shirudo_tpm_attest {
+struct tpm_attest {
__u16 type;
__u8 signer[TPM_NAME_LEN];
size_t signer_len;
@@ -223,6 +223,6 @@ struct shirudo_tpm_attest {
* input stay valid as long as buf does.
*/
int tpm_attest_parse(const __u8 *buf, size_t len,
- struct shirudo_tpm_attest *out);
+ struct tpm_attest *out);
#endif /* SHIRUDO_TPM_WIRE_H */
diff --git a/util/upatch.c b/util/upatch.c
index a34e5e02..398f6aa9 100644
--- a/util/upatch.c
+++ b/util/upatch.c
@@ -20,7 +20,7 @@
#include "upatch.h"
static int parse_header(const __u8 *m, size_t n,
- struct shirudo_upatch_host_header *out)
+ struct upatch_host_header *out)
{
const __u8 *p = m;
@@ -92,7 +92,7 @@ static int section_inside(__u32 off, __u32 len, size_t n)
return 1;
}
-static int validate_bounds(const struct shirudo_upatch_host_header *h,
+static int validate_bounds(const struct upatch_host_header *h,
size_t n)
{
if (h->type != SHIRUDO_UPATCH_TYPE_BPF)
@@ -120,14 +120,14 @@ static bool has_nul(const char *s, size_t n)
}
/* The DECODERS section: entries and sources within the blob. */
-static bool parse_decoders(struct shirudo_upatch *u, const __u8 *bp,
+static bool parse_decoders(struct upatch *u, const __u8 *bp,
__u32 decoder_len)
{
__u32 nr_decoders;
__u64 entries_end;
size_t i;
- if (decoder_len < sizeof(struct shirudo_upatch_decoder_blob))
+ if (decoder_len < sizeof(struct upatch_decoder_blob))
return false;
if (get_le32(bp) != UPATCH_DECODER_MAGIC ||
get_le32(bp + 4) != UPATCH_DECODER_VERSION)
@@ -136,18 +136,18 @@ static bool parse_decoders(struct shirudo_upatch *u, const __u8 *bp,
nr_decoders = get_le32(bp + 8);
if (nr_decoders == 0)
return false;
- entries_end = sizeof(struct shirudo_upatch_decoder_blob) +
+ entries_end = sizeof(struct upatch_decoder_blob) +
(__u64)nr_decoders *
- sizeof(struct shirudo_upatch_decoder_entry);
+ sizeof(struct upatch_decoder_entry);
if (entries_end > decoder_len)
return false;
/* The blob sits behind the signature, so entries are unaligned. */
for (i = 0; i < nr_decoders; i++) {
- struct shirudo_upatch_decoder_entry d;
+ struct upatch_decoder_entry d;
__u32 source_off, source_len;
- memcpy(&d, bp + sizeof(struct shirudo_upatch_decoder_blob) +
+ memcpy(&d, bp + sizeof(struct upatch_decoder_blob) +
i * sizeof(d), sizeof(d));
if (!has_nul(d.upatch, sizeof(d.upatch)) ||
!has_nul(d.map, sizeof(d.map)) ||
@@ -174,7 +174,7 @@ static bool parse_decoders(struct shirudo_upatch *u, const __u8 *bp,
return true;
}
-static void forget_signed_sections(struct shirudo_upatch *u)
+static void forget_signed_sections(struct upatch *u)
{
u->decoder_blob = NULL;
u->decoder_blob_len = 0;
@@ -191,9 +191,9 @@ static void forget_signed_sections(struct shirudo_upatch *u)
* once; a directory that breaks any of that is taken for none, so a
* load or unload refuses for what it then lacks.
*/
-static void parse_signed_sections(struct shirudo_upatch *u)
+static void parse_signed_sections(struct upatch *u)
{
- struct shirudo_upatch_signed_trailer tr;
+ struct upatch_signed_trailer tr;
__u32 i, nr, dir_off, seen = 0;
const __u8 *data, *dir;
__u64 end;
@@ -210,12 +210,12 @@ static void parse_signed_sections(struct shirudo_upatch *u)
end = u->hdr.data_len - sizeof(tr);
if (nr == 0 || nr > UPATCH_SIGNED_SECTIONS_MAX ||
dir_off > end ||
- (__u64)nr * sizeof(struct shirudo_upatch_signed_section) >
+ (__u64)nr * sizeof(struct upatch_signed_section) >
end - dir_off)
return;
dir = data + dir_off;
for (i = 0; i < nr; i++) {
- struct shirudo_upatch_signed_section s;
+ struct upatch_signed_section s;
__u32 tag, off, len, bit;
memcpy(&s, dir + i * sizeof(s), sizeof(s));
@@ -264,7 +264,7 @@ reject:
}
static int upatch_parse(const void *data, size_t size,
- struct shirudo_upatch *out)
+ struct upatch *out)
{
int ret;
@@ -288,12 +288,12 @@ err:
}
int upatch_open_memory(const void *data, size_t size,
- struct shirudo_upatch *out)
+ struct upatch *out)
{
return upatch_parse(data, size, out);
}
-int upatch_open_fd(int fd, struct shirudo_upatch *out)
+int upatch_open_fd(int fd, struct upatch *out)
{
struct stat st;
void *m;
@@ -321,7 +321,7 @@ int upatch_open_fd(int fd, struct shirudo_upatch *out)
return 0;
}
-int upatch_open(const char *path, struct shirudo_upatch *out)
+int upatch_open(const char *path, struct upatch *out)
{
int fd, ret;
@@ -334,7 +334,7 @@ int upatch_open(const char *path, struct shirudo_upatch *out)
return ret;
}
-void upatch_close(struct shirudo_upatch *u)
+void upatch_close(struct upatch *u)
{
if (u->map && u->mapped)
munmap((void *)u->map, u->map_size);
@@ -346,69 +346,69 @@ void upatch_close(struct shirudo_upatch *u)
}
}
-const char *upatch_signed_name(const struct shirudo_upatch *u)
+const char *upatch_signed_name(const struct upatch *u)
{
return u->map ? u->signed_name : NULL;
}
-const void *upatch_signed_attach(const struct shirudo_upatch *u, __u32 *len)
+const void *upatch_signed_attach(const struct upatch *u, __u32 *len)
{
*len = u->map ? u->signed_attach_len : 0;
return u->map ? u->signed_attach : NULL;
}
-const __u8 *upatch_signed_unload_payload(const struct shirudo_upatch *u)
+const __u8 *upatch_signed_unload_payload(const struct upatch *u)
{
return u->map ? u->signed_unload_payload : NULL;
}
-const void *upatch_loader(const struct shirudo_upatch *u)
+const void *upatch_loader(const struct upatch *u)
{
if (!u->map)
return NULL;
return u->map + u->hdr.loader_insns_off;
}
-const void *upatch_signature(const struct shirudo_upatch *u)
+const void *upatch_signature(const struct upatch *u)
{
if (!u->map)
return NULL;
return u->map + u->hdr.signature_off;
}
-const void *upatch_metadata(const struct shirudo_upatch *u)
+const void *upatch_metadata(const struct upatch *u)
{
if (!u->map || u->hdr.metadata_len == 0)
return NULL;
return u->map + u->hdr.metadata_off;
}
-const void *upatch_data(const struct shirudo_upatch *u)
+const void *upatch_data(const struct upatch *u)
{
if (!u->map || u->hdr.data_len == 0)
return NULL;
return u->map + u->hdr.data_off;
}
-bool upatch_is_unload(const struct shirudo_upatch *u)
+bool upatch_is_unload(const struct upatch *u)
{
return (u->hdr.flags & DIRECTIVE_UNLOAD) != 0;
}
-const char *upatch_type_str(const struct shirudo_upatch *u)
+const char *upatch_type_str(const struct upatch *u)
{
return "bpf";
}
-bool upatch_has_decoders(const struct shirudo_upatch *u)
+bool upatch_has_decoders(const struct upatch *u)
{
return u->map && u->decoder_blob && u->nr_decoders > 0;
}
-int upatch_decoder_view(const struct shirudo_upatch *u, __u32 idx,
+int upatch_decoder_view(const struct upatch *u, __u32 idx,
struct upatch_decoder_view *out)
{
- struct shirudo_upatch_decoder_entry d;
+ struct upatch_decoder_entry d;
const __u8 *bp;
if (!out)
@@ -418,7 +418,7 @@ int upatch_decoder_view(const struct shirudo_upatch *u, __u32 idx,
return -ENOENT;
bp = (const __u8 *)u->decoder_blob;
- memcpy(&d, bp + sizeof(struct shirudo_upatch_decoder_blob) +
+ memcpy(&d, bp + sizeof(struct upatch_decoder_blob) +
(size_t)idx * sizeof(d), sizeof(d));
out->language = le32_to_cpu(d.language);
out->api_version = le32_to_cpu(d.api_version);
@@ -457,7 +457,7 @@ int upatch_select(const struct dirent *e)
return n > 7 && strcmp(e->d_name + n - 7, ".upatch") == 0;
}
-void prog_specs_free(struct shirudo_prog_spec *specs, __u32 nr_progs)
+void prog_specs_free(struct prog_spec *specs, __u32 nr_progs)
{
__u32 i;
@@ -475,10 +475,10 @@ void prog_specs_free(struct shirudo_prog_spec *specs, __u32 nr_progs)
}
int prog_specs_parse(const void *metadata, __u32 metadata_len,
- __u32 nr_progs, struct shirudo_prog_spec **out)
+ __u32 nr_progs, struct prog_spec **out)
{
- struct shirudo_upatch_prog_metadata md;
- struct shirudo_prog_spec *specs = NULL;
+ struct upatch_prog_metadata md;
+ struct prog_spec *specs = NULL;
const __u8 *cursor, *end;
size_t base_len;
__u32 magic, version, count, i, nr_uprobes = 0;
@@ -500,10 +500,10 @@ int prog_specs_parse(const void *metadata, __u32 metadata_len,
if (count != nr_progs || le32_to_cpu(md.reserved) != 0)
return -EINVAL;
if (count > (UINT32_MAX - sizeof(md)) /
- sizeof(struct shirudo_upatch_prog_entry))
+ sizeof(struct upatch_prog_entry))
return -EOVERFLOW;
base_len = sizeof(md) + (size_t)count *
- sizeof(struct shirudo_upatch_prog_entry);
+ sizeof(struct upatch_prog_entry);
if (metadata_len < base_len)
return -EINVAL;
specs = xcalloc(nr_progs, sizeof(*specs));
@@ -513,8 +513,8 @@ int prog_specs_parse(const void *metadata, __u32 metadata_len,
specs[i].target_fd = -1;
for (i = 0; i < nr_progs; i++) {
- struct shirudo_upatch_prog_entry prog;
- struct shirudo_prog_spec *spec = &specs[i];
+ struct upatch_prog_entry prog;
+ struct prog_spec *spec = &specs[i];
__u32 role, kind;
memcpy(&prog, (const __u8 *)metadata + sizeof(md) +
@@ -599,10 +599,10 @@ int prog_specs_parse(const void *metadata, __u32 metadata_len,
cursor = (const __u8 *)metadata + base_len;
end = (const __u8 *)metadata + metadata_len;
if ((size_t)(end - cursor) <
- sizeof(struct shirudo_upatch_uprobe_targets))
+ sizeof(struct upatch_uprobe_targets))
goto out;
{
- struct shirudo_upatch_uprobe_targets targets;
+ struct upatch_uprobe_targets targets;
__u32 nr_targets;
memcpy(&targets, cursor, sizeof(targets));
@@ -616,8 +616,8 @@ int prog_specs_parse(const void *metadata, __u32 metadata_len,
goto out;
for (i = 0; i < nr_targets; i++) {
- struct shirudo_upatch_uprobe_target record;
- struct shirudo_prog_spec *spec;
+ struct upatch_uprobe_target record;
+ struct prog_spec *spec;
__u32 prog_idx, path_len, build_id_len, nr_offsets, j;
size_t payload_len;
diff --git a/util/upatch.h b/util/upatch.h
index 88d80a4b..7e13ec6e 100644
--- a/util/upatch.h
+++ b/util/upatch.h
@@ -18,8 +18,8 @@
/* The largest container the parser accepts. */
#define UPATCH_FILE_MAX (16u * 1024u * 1024u)
-/* struct shirudo_upatch_header as parse_header() reads it, in host order. */
-struct shirudo_upatch_host_header {
+/* struct upatch_header as parse_header() reads it, in host order. */
+struct upatch_host_header {
__u64 magic;
__u32 version;
__u32 flags;
@@ -41,13 +41,13 @@ struct shirudo_upatch_host_header {
__u32 reserved1;
};
-struct shirudo_upatch {
- struct shirudo_upatch_host_header hdr;
+struct upatch {
+ struct upatch_host_header hdr;
const __u8 *map;
size_t map_size;
bool mapped;
bool rodata_offset_valid;
- const struct shirudo_upatch_decoder_blob *decoder_blob;
+ const struct upatch_decoder_blob *decoder_blob;
__u32 decoder_blob_len;
__u32 nr_decoders;
const char *signed_name; /* UPATCH_NAME_MAX */
@@ -73,26 +73,26 @@ struct upatch_decoder_view {
* Returns 0 on success, -errno on failure. Logs nothing -- caller
* decides whether to emit user-facing diagnostics.
*/
-int upatch_open(const char *path, struct shirudo_upatch *out);
-int upatch_open_fd(int fd, struct shirudo_upatch *out);
+int upatch_open(const char *path, struct upatch *out);
+int upatch_open_fd(int fd, struct upatch *out);
int upatch_open_memory(const void *data, size_t size,
- struct shirudo_upatch *out);
-void upatch_close(struct shirudo_upatch *u);
+ struct upatch *out);
+void upatch_close(struct upatch *u);
/*
* Section accessors. Pointers reference the mmap; valid only until
* upatch_close().
*/
-const void *upatch_loader(const struct shirudo_upatch *u);
-const void *upatch_signature(const struct shirudo_upatch *u);
-const void *upatch_metadata(const struct shirudo_upatch *u);
-const void *upatch_data(const struct shirudo_upatch *u);
+const void *upatch_loader(const struct upatch *u);
+const void *upatch_signature(const struct upatch *u);
+const void *upatch_metadata(const struct upatch *u);
+const void *upatch_data(const struct upatch *u);
-bool upatch_is_unload(const struct shirudo_upatch *u);
-const char *upatch_type_str(const struct shirudo_upatch *u);
+bool upatch_is_unload(const struct upatch *u);
+const char *upatch_type_str(const struct upatch *u);
-bool upatch_has_decoders(const struct shirudo_upatch *u);
-int upatch_decoder_view(const struct shirudo_upatch *u, __u32 idx,
+bool upatch_has_decoders(const struct upatch *u);
+int upatch_decoder_view(const struct upatch *u, __u32 idx,
struct upatch_decoder_view *out);
/*
@@ -102,10 +102,10 @@ int upatch_decoder_view(const struct shirudo_upatch *u, __u32 idx,
* A load or unload refuses what it needs and does not find; inspection
* shows what there is.
*/
-const char *upatch_signed_name(const struct shirudo_upatch *u);
-const void *upatch_signed_attach(const struct shirudo_upatch *u,
+const char *upatch_signed_name(const struct upatch *u);
+const void *upatch_signed_attach(const struct upatch *u,
__u32 *len);
-const __u8 *upatch_signed_unload_payload(const struct shirudo_upatch *u);
+const __u8 *upatch_signed_unload_payload(const struct upatch *u);
/*
* Validate an externally-provided upatch name: non-empty, doesn't
@@ -117,7 +117,7 @@ bool upatch_name_valid(const char *name);
/* A scandir() filter for the archived .upatch files. */
int upatch_select(const struct dirent *e);
-struct shirudo_prog_spec {
+struct prog_spec {
__u32 role;
__u32 kind;
__u64 offset;
@@ -138,8 +138,8 @@ struct shirudo_prog_spec {
* per program, target_fd -1. 0 or -errno; free with prog_specs_free().
*/
int prog_specs_parse(const void *metadata, __u32 metadata_len,
- __u32 nr_progs, struct shirudo_prog_spec **out);
-void prog_specs_free(struct shirudo_prog_spec *specs, __u32 nr_progs);
+ __u32 nr_progs, struct prog_spec **out);
+void prog_specs_free(struct prog_spec *specs, __u32 nr_progs);
/*
* The target's upatch lifecycle, which builtin-upatch.c implements for
diff --git a/util/upatch_decode.c b/util/upatch_decode.c
index 0e587018..db8a522f 100644
--- a/util/upatch_decode.c
+++ b/util/upatch_decode.c
@@ -12,7 +12,7 @@
#ifndef HAVE_LUAJIT
-int upatch_decode_map_json(const struct shirudo_map_view *v,
+int upatch_decode_map_json(const struct map_view *v,
char **out, size_t *out_len)
{
if (!v || !out || !out_len)
@@ -22,7 +22,7 @@ int upatch_decode_map_json(const struct shirudo_map_view *v,
return -EOPNOTSUPP;
}
-int upatch_decode_map_json_limit(const struct shirudo_map_view *v,
+int upatch_decode_map_json_limit(const struct map_view *v,
size_t max_bytes,
char **out, size_t *out_len)
{
@@ -30,14 +30,14 @@ int upatch_decode_map_json_limit(const struct shirudo_map_view *v,
return upatch_decode_map_json(v, out, out_len);
}
-int upatch_decode_map_otel(const struct shirudo_map_view *v,
+int upatch_decode_map_otel(const struct map_view *v,
char **out, size_t *out_len)
{
return upatch_decode_map_json(v, out, out_len);
}
int upatch_decode_map_file_json(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
(void)path;
@@ -45,7 +45,7 @@ int upatch_decode_map_file_json(const char *path,
}
int upatch_decode_map_file_json_limit(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
size_t max_bytes, char **out,
size_t *out_len)
{
@@ -55,7 +55,7 @@ int upatch_decode_map_file_json_limit(const char *path,
}
int upatch_decode_map_file_otel(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
(void)path;
@@ -1066,7 +1066,7 @@ static void lua_push_hex(lua_State *L, const void *data, size_t len)
lua_remove(L, -2);
}
-static void lua_push_map_input(lua_State *L, const struct shirudo_map_view *v)
+static void lua_push_map_input(lua_State *L, const struct map_view *v)
{
__u64 now_ns = decoder_realtime_ns();
__u64 start_ns = v->lifetime_start_ns ?: now_ns;
@@ -1115,7 +1115,7 @@ static void lua_push_map_input(lua_State *L, const struct shirudo_map_view *v)
/* Raw bytes are always available, including when BTF rendering is not. */
lua_newtable(L);
for (i = 0; i < v->n_entries; i++) {
- const struct shirudo_map_entry *entry = &v->entries[i];
+ const struct map_entry *entry = &v->entries[i];
size_t value_bytes = (size_t)v->value_stride * v->n_cpus;
lua_newtable(L);
@@ -1129,7 +1129,7 @@ static void lua_push_map_input(lua_State *L, const struct shirudo_map_view *v)
lua_newtable(L);
for (p = 0; p < v->n_serial_pages; p++) {
- const struct shirudo_serial_page *page = &v->serial_pages[p];
+ const struct serial_page *page = &v->serial_pages[p];
lua_newtable(L);
lua_pushnumber(L, page->page_index);
@@ -1172,7 +1172,7 @@ static int lua_get_decoder_entrypoint(lua_State *L, const char *entrypoint)
}
struct lua_decoder_call {
- const struct shirudo_map_view *view;
+ const struct map_view *view;
};
static int lua_call_decoder(lua_State *L)
@@ -1194,7 +1194,7 @@ static const char *lua_error_message(lua_State *L)
}
static int run_lua_decoder(const struct upatch_decoder_view *d,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
bool otel, size_t max_bytes,
char **out, size_t *out_len)
{
@@ -1277,7 +1277,7 @@ out_close:
}
static int decoder_matches(const struct upatch_decoder_view *d,
- const struct shirudo_map_view *v)
+ const struct map_view *v)
{
if (d->language != UPATCH_DECODER_LANG_LUA ||
d->api_version != 1 ||
@@ -1299,7 +1299,7 @@ static int decoder_matches(const struct upatch_decoder_view *d,
* than run, signed or not.
*/
static int archive_open(const char *path, bool archived,
- struct shirudo_upatch *u)
+ struct upatch *u)
{
int fd, ret;
@@ -1314,11 +1314,11 @@ static int archive_open(const char *path, bool archived,
}
static int decode_map_open(const char *path, bool archived,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
bool otel, size_t max_bytes,
char **out, size_t *out_len)
{
- struct shirudo_upatch u;
+ struct upatch u;
__u32 i;
int ret;
@@ -1346,17 +1346,17 @@ static int decode_map_open(const char *path, bool archived,
return ret;
}
-static int decode_map_file(const char *path, const struct shirudo_map_view *v,
+static int decode_map_file(const char *path, const struct map_view *v,
bool otel, size_t max_bytes,
char **out, size_t *out_len)
{
return decode_map_open(path, false, v, otel, max_bytes, out, out_len);
}
-int upatch_decode_map_signal(const struct shirudo_map_view *v,
+int upatch_decode_map_signal(const struct map_view *v,
__u32 *signal_out)
{
- struct shirudo_upatch u;
+ struct upatch u;
char path[PATH_MAX];
__u32 i;
int ret;
@@ -1384,7 +1384,7 @@ int upatch_decode_map_signal(const struct shirudo_map_view *v,
return ret;
}
-static int decode_map(const struct shirudo_map_view *v, bool otel,
+static int decode_map(const struct map_view *v, bool otel,
size_t max_bytes, char **out, size_t *out_len)
{
char path[PATH_MAX];
@@ -1397,7 +1397,7 @@ static int decode_map(const struct shirudo_map_view *v, bool otel,
return decode_map_open(path, true, v, otel, max_bytes, out, out_len);
}
-int upatch_decode_map_json(const struct shirudo_map_view *v,
+int upatch_decode_map_json(const struct map_view *v,
char **out, size_t *out_len)
{
return upatch_decode_map_json_limit(v,
@@ -1405,7 +1405,7 @@ int upatch_decode_map_json(const struct shirudo_map_view *v,
out, out_len);
}
-int upatch_decode_map_json_limit(const struct shirudo_map_view *v,
+int upatch_decode_map_json_limit(const struct map_view *v,
size_t max_bytes,
char **out, size_t *out_len)
{
@@ -1414,14 +1414,14 @@ int upatch_decode_map_json_limit(const struct shirudo_map_view *v,
return decode_map(v, false, max_bytes, out, out_len);
}
-int upatch_decode_map_otel(const struct shirudo_map_view *v,
+int upatch_decode_map_otel(const struct map_view *v,
char **out, size_t *out_len)
{
return decode_map(v, true, JSON_MAX_BYTES, out, out_len);
}
int upatch_decode_map_file_json(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
return upatch_decode_map_file_json_limit(path, v,
@@ -1430,7 +1430,7 @@ int upatch_decode_map_file_json(const char *path,
}
int upatch_decode_map_file_json_limit(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
size_t max_bytes, char **out,
size_t *out_len)
{
@@ -1440,7 +1440,7 @@ int upatch_decode_map_file_json_limit(const char *path,
}
int upatch_decode_map_file_otel(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
return decode_map_file(path, v, true, JSON_MAX_BYTES,
diff --git a/util/upatch_decode.h b/util/upatch_decode.h
index 7aeb4ea7..c5fee3dd 100644
--- a/util/upatch_decode.h
+++ b/util/upatch_decode.h
@@ -12,37 +12,37 @@
#include <shirudo/misc.h>
-struct shirudo_map_view;
+struct map_view;
/*
* The decoder is the signed one in the archived upatch. *out is
* xmalloc'd; -ENOENT without a usable decoder, which an export treats
* as failing the map.
*/
-int upatch_decode_map_json(const struct shirudo_map_view *v,
+int upatch_decode_map_json(const struct map_view *v,
char **out, size_t *out_len);
/* Variant for consumers such as S3 archival with a larger output budget. */
-int upatch_decode_map_json_limit(const struct shirudo_map_view *v,
+int upatch_decode_map_json_limit(const struct map_view *v,
size_t max_bytes,
char **out, size_t *out_len);
-int upatch_decode_map_otel(const struct shirudo_map_view *v,
+int upatch_decode_map_otel(const struct map_view *v,
char **out, size_t *out_len);
/* Explicit-artifact variants used by offline consumers and tests. */
int upatch_decode_map_file_json(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len);
int upatch_decode_map_file_json_limit(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
size_t max_bytes, char **out,
size_t *out_len);
int upatch_decode_map_file_otel(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len);
-int upatch_decode_map_signal(const struct shirudo_map_view *v,
+int upatch_decode_map_signal(const struct map_view *v,
__u32 *signal_out);
#endif /* SHIRUDO_UTIL_UPATCH_DECODE_H */
diff --git a/util/upatch_maps.c b/util/upatch_maps.c
index 091a8b7f..76a7521a 100644
--- a/util/upatch_maps.c
+++ b/util/upatch_maps.c
@@ -44,7 +44,7 @@
*/
#define BTF_MAX_DEPTH 6
-static void resolve_map_location(struct shirudo_map_view *v)
+static void resolve_map_location(struct map_view *v)
{
struct btf *vbtf;
@@ -78,7 +78,7 @@ static __u32 map_value_stride(__u32 type, __u32 value_size)
return (value_size + 7U) & ~7U;
}
-__u32 upatch_map_value_stride(const struct shirudo_map_view *v)
+__u32 upatch_map_value_stride(const struct map_view *v)
{
return v->value_stride ? v->value_stride : v->value_size;
}
@@ -681,7 +681,7 @@ static char *format_value(const void *value, __u32 value_size,
}
}
-char *upatch_map_format_percpu_sum(const struct shirudo_map_view *v,
+char *upatch_map_format_percpu_sum(const struct map_view *v,
const void *values_per_cpu,
const char *btf_type)
{
@@ -794,7 +794,7 @@ static int validate_serial_map(const struct bpf_map_info *info)
return -EINVAL;
if (info->key_size != sizeof(__u32))
return -EINVAL;
- if (info->value_size != sizeof(struct shirudo_serial_chunk))
+ if (info->value_size != sizeof(struct serial_chunk))
return -EINVAL;
if (info->max_entries == 0 ||
info->max_entries > SERIAL_MAX_CHUNKS)
@@ -822,8 +822,8 @@ static int clear_serial_map(int fd, const struct bpf_map_info *info)
return 0;
}
-static int append_serial_page(struct shirudo_map_view *out,
- struct shirudo_serial_page *page)
+static int append_serial_page(struct map_view *out,
+ struct serial_page *page)
{
void *p;
@@ -841,9 +841,9 @@ static int read_serial_page(int serial_fd,
const struct bpf_map_info *serial_info,
__u32 want_page_index, __u64 want_cursor,
__u64 invocation_id,
- struct shirudo_serial_page *page)
+ struct serial_page *page)
{
- struct shirudo_serial_chunk *chunk;
+ struct serial_chunk *chunk;
__u32 key, total_chunks, bytes_total, copied = 0;
__u32 page_index, flags;
__u64 cursor, next_cursor;
@@ -941,7 +941,7 @@ out_chunk:
}
static int try_read_serialized(const char *upatch, const char *map,
- __u32 flags, struct shirudo_map_view *out)
+ __u32 flags, struct map_view *out)
{
struct bpf_map_info serial_info = {};
__u64 cursor = 0, bytes_total = 0, invocation_id;
@@ -980,8 +980,8 @@ static int try_read_serialized(const char *upatch, const char *map,
for (page_index = 0; page_index < SERIAL_MAX_PAGES;
page_index++) {
- struct shirudo_serialize_ctx ctx = {};
- struct shirudo_serial_page page = {};
+ struct serialize_ctx ctx = {};
+ struct serial_page page = {};
__u32 retval = 0;
ret = clear_serial_map(serial_fd, &serial_info);
@@ -1074,7 +1074,7 @@ out:
return ret;
}
-static int read_entries(int fd, struct shirudo_map_view *v,
+static int read_entries(int fd, struct map_view *v,
__u32 cap)
{
size_t value_count = upatch_map_is_percpu(v->type) ?
@@ -1191,7 +1191,7 @@ static int read_entries(int fd, struct shirudo_map_view *v,
return -EOPNOTSUPP;
}
-void map_view_free(struct shirudo_map_view *v)
+void map_view_free(struct map_view *v)
{
size_t value_alloc;
__u32 i;
@@ -1228,7 +1228,7 @@ void map_view_free(struct shirudo_map_view *v)
int upatch_maps_read(const char *upatch, const char *map,
__u32 max_entries_cap, __u32 flags,
- struct shirudo_map_view *out)
+ struct map_view *out)
{
struct bpf_map_info info = {};
char upatch_dir[PATH_MAX];
@@ -1315,8 +1315,8 @@ int upatch_maps_read(const char *upatch, const char *map,
return ret;
}
-static void summary_append(struct shirudo_map_summary **list, size_t *n,
- size_t *cap, const struct shirudo_map_summary *one)
+static void summary_append(struct map_summary **list, size_t *n,
+ size_t *cap, const struct map_summary *one)
{
if (*n == *cap) {
size_t nc = *cap ? *cap * 2 : 8;
@@ -1331,7 +1331,7 @@ static void summary_append(struct shirudo_map_summary **list, size_t *n,
}
static void scan_upatch_maps(const char *upatch,
- struct shirudo_map_summary **list, size_t *n,
+ struct map_summary **list, size_t *n,
size_t *cap)
{
char dir[PATH_MAX];
@@ -1349,7 +1349,7 @@ static void scan_upatch_maps(const char *upatch,
return;
while ((e = readdir(d))) {
struct bpf_map_info info = {};
- struct shirudo_map_summary one = {};
+ struct map_summary one = {};
int fd, ret;
if (e->d_name[0] == '.')
@@ -1379,10 +1379,10 @@ static void scan_upatch_maps(const char *upatch,
}
int upatch_maps_list_one(const char *upatch,
- struct shirudo_map_summary **out,
+ struct map_summary **out,
size_t *n_out)
{
- struct shirudo_map_summary *list = NULL;
+ struct map_summary *list = NULL;
size_t n = 0, cap = 0;
scan_upatch_maps(upatch, &list, &n, &cap);
@@ -1391,10 +1391,10 @@ int upatch_maps_list_one(const char *upatch,
return 0;
}
-int upatch_maps_list_all(struct shirudo_map_summary **out,
+int upatch_maps_list_all(struct map_summary **out,
size_t *n_out)
{
- struct shirudo_map_summary *list = NULL;
+ struct map_summary *list = NULL;
size_t n = 0, cap = 0;
struct dirent *e;
DIR *d;
@@ -1421,13 +1421,13 @@ int upatch_maps_list_all(struct shirudo_map_summary **out,
return 0;
}
-void map_summary_free(struct shirudo_map_summary *list, size_t n)
+void map_summary_free(struct map_summary *list, size_t n)
{
if (list)
xfree(list, n * sizeof(*list));
}
-void upatch_maps_print_summary(const struct shirudo_map_summary *list,
+void upatch_maps_print_summary(const struct map_summary *list,
size_t n)
{
size_t i;
@@ -1439,7 +1439,7 @@ void upatch_maps_print_summary(const struct shirudo_map_summary *list,
printf(" %-22s %-16s %-18s %s\n", "UPATCH", "MAP", "TYPE",
"ENTRIES");
for (i = 0; i < n; i++) {
- const struct shirudo_map_summary *m = &list[i];
+ const struct map_summary *m = &list[i];
printf(" %-22s %-16s %-18s max=%u%s\n",
m->upatch, m->name, m->type_name, m->max_entries,
@@ -1447,7 +1447,7 @@ void upatch_maps_print_summary(const struct shirudo_map_summary *list,
}
}
-char *upatch_map_format_cell(const struct shirudo_map_view *v,
+char *upatch_map_format_cell(const struct map_view *v,
__u32 type_id, const void *bytes,
__u32 bytes_size,
const char *btf_name)
@@ -1495,7 +1495,7 @@ static void print_serialized_hex(const __u8 *data, __u32 len)
}
}
-void upatch_maps_print_detail(const struct shirudo_map_view *v)
+void upatch_maps_print_detail(const struct map_view *v)
{
__u32 i;
@@ -1520,7 +1520,7 @@ void upatch_maps_print_detail(const struct shirudo_map_view *v)
printf("Serialized bytes: %llu\n",
v->serial_bytes_total);
for (p = 0; p < v->n_serial_pages; p++) {
- const struct shirudo_serial_page *page =
+ const struct serial_page *page =
&v->serial_pages[p];
printf("\nPage %u:\n", page->page_index);
@@ -1562,7 +1562,7 @@ void upatch_maps_print_detail(const struct shirudo_map_view *v)
return;
printf("\nContents:\n");
for (i = 0; i < v->n_entries; i++) {
- const struct shirudo_map_entry *en = &v->entries[i];
+ const struct map_entry *en = &v->entries[i];
char *key_s;
key_s = upatch_map_format_cell(v, v->key_type_id,
@@ -1608,8 +1608,8 @@ void upatch_maps_print_detail(const struct shirudo_map_view *v)
}
}
-void upatch_maps_emit_json_fields(struct shirudo_json_emit *e,
- const struct shirudo_map_view *v)
+void upatch_maps_emit_json_fields(struct json_emit *e,
+ const struct map_view *v)
{
__u32 i, j;
@@ -1631,7 +1631,7 @@ void upatch_maps_emit_json_fields(struct shirudo_json_emit *e,
v->serial_bytes_total);
json_arr_open(e, "pages");
for (p = 0; p < v->n_serial_pages; p++) {
- const struct shirudo_serial_page *page =
+ const struct serial_page *page =
&v->serial_pages[p];
char *hex = hex_alloc(page->data,
page->bytes);
@@ -1682,7 +1682,7 @@ void upatch_maps_emit_json_fields(struct shirudo_json_emit *e,
}
json_arr_open(e, "entries");
for (i = 0; i < v->n_entries; i++) {
- const struct shirudo_map_entry *en = &v->entries[i];
+ const struct map_entry *en = &v->entries[i];
char *key_s;
key_s = upatch_map_format_cell(v, v->key_type_id,
@@ -1727,8 +1727,8 @@ void upatch_maps_emit_json_fields(struct shirudo_json_emit *e,
json_arr_close(e);
}
-void upatch_maps_emit_json_object(struct shirudo_json_emit *e,
- const struct shirudo_map_view *v)
+void upatch_maps_emit_json_object(struct json_emit *e,
+ const struct map_view *v)
{
if (!v)
return;
diff --git a/util/upatch_maps.h b/util/upatch_maps.h
index 8d85b03a..12c134af 100644
--- a/util/upatch_maps.h
+++ b/util/upatch_maps.h
@@ -23,9 +23,9 @@
#define MAP_NAME_MAX 16 /* BPF_OBJ_NAME_LEN */
#define MAP_TYPENAME_MAX 64
-struct shirudo_json_emit;
+struct json_emit;
-struct shirudo_map_entry {
+struct map_entry {
void *key; /* key_size bytes */
void *value; /* value_stride * (per-CPU ? n_cpus : 1) */
};
@@ -40,7 +40,7 @@ struct shirudo_map_entry {
struct btf;
-struct shirudo_serial_page {
+struct serial_page {
__u32 page_index;
__u64 cursor;
__u64 next_cursor;
@@ -51,7 +51,7 @@ struct shirudo_serial_page {
void *data;
};
-struct shirudo_map_view {
+struct map_view {
char upatch[UPATCH_NAME_MAX + 1];
char name[MAP_NAME_MAX + 1];
char location[UPATCH_LOCATION_MAX];
@@ -69,7 +69,7 @@ struct shirudo_map_view {
bool serialized;
__u32 n_serial_pages;
__u64 serial_bytes_total;
- struct shirudo_serial_page *serial_pages;
+ struct serial_page *serial_pages;
bool skipped;
const char *skipped_reason;
char btf_key_type[MAP_TYPENAME_MAX];
@@ -79,13 +79,13 @@ struct shirudo_map_view {
__u32 key_type_id;
__u32 value_type_id;
struct btf *btf; /* heap; owned by the view */
- struct shirudo_map_entry *entries; /* n_entries long */
+ struct map_entry *entries; /* n_entries long */
};
-void map_view_free(struct shirudo_map_view *v);
+void map_view_free(struct map_view *v);
/* Name, type and max_entries alone, without reading entries. */
-struct shirudo_map_summary {
+struct map_summary {
char upatch[UPATCH_NAME_MAX + 1];
char name[MAP_NAME_MAX + 1];
__u32 type;
@@ -94,12 +94,12 @@ struct shirudo_map_summary {
__u32 n_cpus;
};
-int upatch_maps_list_all(struct shirudo_map_summary **out,
+int upatch_maps_list_all(struct map_summary **out,
size_t *n_out);
int upatch_maps_list_one(const char *upatch,
- struct shirudo_map_summary **out,
+ struct map_summary **out,
size_t *n_out);
-void map_summary_free(struct shirudo_map_summary *list, size_t n);
+void map_summary_free(struct map_summary *list, size_t n);
/*
* Read one map's contents. <max_entries_cap> bounds the number of
@@ -114,25 +114,25 @@ void map_summary_free(struct shirudo_map_summary *list, size_t n);
int upatch_maps_read(const char *upatch, const char *map,
__u32 max_entries_cap, __u32 flags,
- struct shirudo_map_view *out);
+ struct map_view *out);
-void upatch_maps_print_summary(const struct shirudo_map_summary *list,
+void upatch_maps_print_summary(const struct map_summary *list,
size_t n);
-void upatch_maps_print_detail(const struct shirudo_map_view *v);
+void upatch_maps_print_detail(const struct map_view *v);
/* NULL v emits nothing. The shape is part of the status report. */
-void upatch_maps_emit_json_fields(struct shirudo_json_emit *e,
- const struct shirudo_map_view *v);
-void upatch_maps_emit_json_object(struct shirudo_json_emit *e,
- const struct shirudo_map_view *v);
+void upatch_maps_emit_json_fields(struct json_emit *e,
+ const struct map_view *v);
+void upatch_maps_emit_json_object(struct json_emit *e,
+ const struct map_view *v);
bool upatch_map_is_percpu(__u32 type);
-__u32 upatch_map_value_stride(const struct shirudo_map_view *v);
-char *upatch_map_format_cell(const struct shirudo_map_view *v,
+__u32 upatch_map_value_stride(const struct map_view *v);
+char *upatch_map_format_cell(const struct map_view *v,
__u32 type_id, const void *value,
__u32 value_size,
const char *btf_type);
-char *upatch_map_format_percpu_sum(const struct shirudo_map_view *v,
+char *upatch_map_format_percpu_sum(const struct map_view *v,
const void *values_per_cpu,
const char *btf_type);
diff --git a/util/upatch_maps_otel.c b/util/upatch_maps_otel.c
index ff158cd8..81ec243e 100644
--- a/util/upatch_maps_otel.c
+++ b/util/upatch_maps_otel.c
@@ -69,8 +69,8 @@ struct otel_response {
};
struct otel_state {
- enum shirudo_otel_signal signal;
- struct shirudo_otel_opts opts;
+ enum otel_signal signal;
+ struct otel_opts opts;
const char *decoder_path;
char endpoint[OTEL_ENDPOINT_MAX];
char host[256];
@@ -95,7 +95,7 @@ struct s3_snapshot {
struct otel_s3_state {
struct otel_state *otel;
- struct shirudo_otel_opts opts;
+ struct otel_opts opts;
char bucket[S3_BUCKET_MAX + 1];
char prefix[S3_PREFIX_MAX + 1];
char region[S3_REGION_MAX];
@@ -131,7 +131,7 @@ static const struct btf_type *unwrap_btf_type(const struct btf *btf,
return NULL;
}
-static int metric_type_from_view(const struct shirudo_map_view *v,
+static int metric_type_from_view(const struct map_view *v,
struct metric_type *out)
{
const struct btf_type *t;
@@ -148,8 +148,8 @@ static int metric_type_from_view(const struct shirudo_map_view *v,
return 0;
}
-int upatch_maps_otel_classify(const struct shirudo_map_view *v,
- enum shirudo_otel_signal *signal,
+int upatch_maps_otel_classify(const struct map_view *v,
+ enum otel_signal *signal,
char *reason, size_t reason_sz)
{
struct metric_type mt;
@@ -187,7 +187,7 @@ int upatch_maps_otel_classify(const struct shirudo_map_view *v,
return 0;
}
-static void otlp_kv_string(struct shirudo_json_emit *e, const char *key,
+static void otlp_kv_string(struct json_emit *e, const char *key,
const char *value)
{
json_obj_open(e);
@@ -198,7 +198,7 @@ static void otlp_kv_string(struct shirudo_json_emit *e, const char *key,
json_obj_close(e);
}
-static void otlp_kv_int(struct shirudo_json_emit *e, const char *key,
+static void otlp_kv_int(struct json_emit *e, const char *key,
__s64 value)
{
char num[32];
@@ -215,7 +215,7 @@ static void otlp_kv_int(struct shirudo_json_emit *e, const char *key,
json_obj_close(e);
}
-static void otlp_kv_bool(struct shirudo_json_emit *e, const char *key,
+static void otlp_kv_bool(struct json_emit *e, const char *key,
bool value)
{
json_obj_open(e);
@@ -226,7 +226,7 @@ static void otlp_kv_bool(struct shirudo_json_emit *e, const char *key,
json_obj_close(e);
}
-static void otlp_kvlist_begin(struct shirudo_json_emit *e, const char *key)
+static void otlp_kvlist_begin(struct json_emit *e, const char *key)
{
json_obj_open(e);
json_kv_string(e, "key", key);
@@ -235,7 +235,7 @@ static void otlp_kvlist_begin(struct shirudo_json_emit *e, const char *key)
json_arr_open(e, "values");
}
-static void otlp_kvlist_end(struct shirudo_json_emit *e)
+static void otlp_kvlist_end(struct json_emit *e)
{
json_arr_close(e);
json_obj_close(e);
@@ -243,7 +243,7 @@ static void otlp_kvlist_end(struct shirudo_json_emit *e)
json_obj_close(e);
}
-static void otlp_array_begin(struct shirudo_json_emit *e, const char *key)
+static void otlp_array_begin(struct json_emit *e, const char *key)
{
json_obj_open(e);
json_kv_string(e, "key", key);
@@ -252,7 +252,7 @@ static void otlp_array_begin(struct shirudo_json_emit *e, const char *key)
json_arr_open(e, "values");
}
-static void otlp_array_end(struct shirudo_json_emit *e)
+static void otlp_array_end(struct json_emit *e)
{
json_arr_close(e);
json_obj_close(e);
@@ -260,21 +260,21 @@ static void otlp_array_end(struct shirudo_json_emit *e)
json_obj_close(e);
}
-static void otlp_array_string(struct shirudo_json_emit *e, const char *value)
+static void otlp_array_string(struct json_emit *e, const char *value)
{
json_obj_open(e);
json_kv_string(e, "stringValue", value ? value : "");
json_obj_close(e);
}
-static void otlp_array_kvlist_begin(struct shirudo_json_emit *e)
+static void otlp_array_kvlist_begin(struct json_emit *e)
{
json_obj_open(e);
json_obj_open_key(e, "kvlistValue");
json_arr_open(e, "values");
}
-static void otlp_array_kvlist_end(struct shirudo_json_emit *e)
+static void otlp_array_kvlist_end(struct json_emit *e)
{
json_arr_close(e);
json_obj_close(e);
@@ -354,7 +354,7 @@ static int json_anyvalue_literal(struct json_anyvalue_ctx *c,
}
static int json_anyvalue_number(struct json_anyvalue_ctx *c,
- struct shirudo_json_emit *e)
+ struct json_emit *e)
{
const char *start = c->p;
bool fraction = false;
@@ -402,13 +402,13 @@ static int json_anyvalue_number(struct json_anyvalue_ctx *c,
}
static int json_anyvalue_emit_contents(struct json_anyvalue_ctx *c,
- struct shirudo_json_emit *e);
+ struct json_emit *e);
static int json_anyvalue_emit(struct json_anyvalue_ctx *c,
- struct shirudo_json_emit *e);
+ struct json_emit *e);
static int json_anyvalue_object(struct json_anyvalue_ctx *c,
- struct shirudo_json_emit *e, bool wrap)
+ struct json_emit *e, bool wrap)
{
int ret;
@@ -477,7 +477,7 @@ static int json_anyvalue_object(struct json_anyvalue_ctx *c,
}
static int json_anyvalue_array(struct json_anyvalue_ctx *c,
- struct shirudo_json_emit *e, bool wrap)
+ struct json_emit *e, bool wrap)
{
int ret = 0;
@@ -523,7 +523,7 @@ static int json_anyvalue_array(struct json_anyvalue_ctx *c,
}
static int json_anyvalue_emit_contents(struct json_anyvalue_ctx *c,
- struct shirudo_json_emit *e)
+ struct json_emit *e)
{
const char *start;
size_t len;
@@ -567,7 +567,7 @@ static int json_anyvalue_emit_contents(struct json_anyvalue_ctx *c,
}
static int json_anyvalue_emit(struct json_anyvalue_ctx *c,
- struct shirudo_json_emit *e)
+ struct json_emit *e)
{
int ret;
@@ -577,7 +577,7 @@ static int json_anyvalue_emit(struct json_anyvalue_ctx *c,
return ret;
}
-static int json_anyvalue_from_document(struct shirudo_json_emit *e,
+static int json_anyvalue_from_document(struct json_emit *e,
const char *json, size_t len, bool wrap)
{
struct json_anyvalue_ctx c = {
@@ -596,7 +596,7 @@ static int json_anyvalue_from_document(struct shirudo_json_emit *e,
return c.p == c.end ? 0 : -EINVAL;
}
-static void emit_resource_attributes(struct shirudo_json_emit *e)
+static void emit_resource_attributes(struct json_emit *e)
{
char hostname[256] = "unknown";
@@ -625,7 +625,7 @@ static int u64_decimal(__u64 value, char out[32])
}
/* An OTLP document down to its scope; otlp_close() ends it. */
-static void otlp_open(struct shirudo_json_emit *e, const char *resource_key,
+static void otlp_open(struct json_emit *e, const char *resource_key,
const char *scope_key, const char *scope_name)
{
json_obj_open(e);
@@ -642,7 +642,7 @@ static void otlp_open(struct shirudo_json_emit *e, const char *resource_key,
json_obj_close(e);
}
-static void otlp_close(struct shirudo_json_emit *e)
+static void otlp_close(struct json_emit *e)
{
json_obj_close(e);
json_arr_close(e);
@@ -652,7 +652,7 @@ static void otlp_close(struct shirudo_json_emit *e)
}
/* A logs document with its one record open; log_close() ends both. */
-static void log_open(struct shirudo_json_emit *e, const char *scope_name,
+static void log_open(struct json_emit *e, const char *scope_name,
int severity_number, const char *severity_text,
const char *event_name)
{
@@ -669,15 +669,15 @@ static void log_open(struct shirudo_json_emit *e, const char *scope_name,
json_kv_string(e, "eventName", event_name);
}
-static void log_close(struct shirudo_json_emit *e)
+static void log_close(struct json_emit *e)
{
json_obj_close(e);
json_arr_close(e);
otlp_close(e);
}
-static void emit_map_attributes(struct shirudo_json_emit *e,
- const struct shirudo_map_view *v)
+static void emit_map_attributes(struct json_emit *e,
+ const struct map_view *v)
{
otlp_kv_string(e, "shirudo.upatch.name", v->upatch);
otlp_kv_string(e, "shirudo.upatch.location", v->location);
@@ -690,8 +690,8 @@ static void emit_map_attributes(struct shirudo_json_emit *e,
otlp_kv_bool(e, "shirudo.map.truncated", v->truncated);
}
-static void emit_log_map_data(struct shirudo_json_emit *e,
- const struct shirudo_map_view *v)
+static void emit_log_map_data(struct json_emit *e,
+ const struct map_view *v)
{
__u32 i, j;
@@ -710,7 +710,7 @@ static void emit_log_map_data(struct shirudo_json_emit *e,
(__s64)v->serial_bytes_total);
otlp_array_begin(e, "pages");
for (p = 0; p < v->n_serial_pages; p++) {
- const struct shirudo_serial_page *page = &v->serial_pages[p];
+ const struct serial_page *page = &v->serial_pages[p];
char *hex = hex_alloc(page->data,
page->bytes);
@@ -750,7 +750,7 @@ static void emit_log_map_data(struct shirudo_json_emit *e,
}
otlp_array_begin(e, "entries");
for (i = 0; i < v->n_entries; i++) {
- const struct shirudo_map_entry *en = &v->entries[i];
+ const struct map_entry *en = &v->entries[i];
char *key;
key = upatch_map_format_cell(v, v->key_type_id,
@@ -795,11 +795,11 @@ static void emit_log_map_data(struct shirudo_json_emit *e,
/* record_max bounds the decoded body, 0 for none. */
static int build_log_payload(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
size_t record_max,
char **out, size_t *out_len)
{
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char *decoded = NULL;
size_t decoded_len = 0;
char *buf;
@@ -850,7 +850,7 @@ static int build_log_payload(const char *path,
}
int upatch_maps_otel_build_log_file(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
if (!path)
@@ -859,10 +859,10 @@ int upatch_maps_otel_build_log_file(const char *path,
}
static int build_metric_decoded_payload(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char *decoded = NULL, *decoded_buf, *buf;
size_t decoded_len = 0, decoded_alloc_len;
int ret;
@@ -903,17 +903,17 @@ static int build_metric_decoded_payload(const char *path,
return 0;
}
-static const char *signal_name(enum shirudo_otel_signal signal)
+static const char *signal_name(enum otel_signal signal)
{
return signal == SHIRUDO_OTEL_LOG ? "LOGS" : "METRICS";
}
-static const char *signal_path(enum shirudo_otel_signal signal)
+static const char *signal_path(enum otel_signal signal)
{
return signal == SHIRUDO_OTEL_LOG ? "v1/logs" : "v1/metrics";
}
-static const char *otel_signal_env(enum shirudo_otel_signal signal,
+static const char *otel_signal_env(enum otel_signal signal,
const char *suffix)
{
char name[128];
@@ -926,7 +926,7 @@ static const char *otel_signal_env(enum shirudo_otel_signal signal,
return value && value[0] ? value : NULL;
}
-static const char *otel_env(enum shirudo_otel_signal signal,
+static const char *otel_env(enum otel_signal signal,
const char *suffix)
{
const char *value = otel_signal_env(signal, suffix);
@@ -941,7 +941,7 @@ static const char *otel_env(enum shirudo_otel_signal signal,
return value && value[0] ? value : NULL;
}
-static int append_signal_path(const char *base, enum shirudo_otel_signal signal,
+static int append_signal_path(const char *base, enum otel_signal signal,
char *out, size_t out_sz)
{
size_t prefix_len;
@@ -1052,7 +1052,7 @@ out:
}
int upatch_maps_otel_build_metric_file(const char *path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
char **out, size_t *out_len)
{
if (!path)
@@ -1411,18 +1411,18 @@ int otel_retry_after(const char *value, time_t now, __u64 *seconds)
* string or a number, and the message is advisory: one that does not
* fit is left out rather than failing an export the collector took.
*/
-static int check_partial_success(enum shirudo_otel_signal signal,
+static int check_partial_success(enum otel_signal signal,
const char *body, size_t len)
{
const char *count = signal == SHIRUDO_OTEL_LOG ?
"rejectedLogRecords" : "rejectedDataPoints";
char rejected_text[32] = {};
char error[256] = {};
- struct shirudo_json_field partial[] = {
+ struct json_field partial[] = {
{ count, SHIRUDO_JSON_T_STRING, rejected_text,
sizeof(rejected_text), 0, NULL, 0 },
};
- struct shirudo_json_field root[] = {
+ struct json_field root[] = {
{ "partialSuccess", SHIRUDO_JSON_T_OBJECT, NULL, 0, 0,
partial, ARRAY_SIZE(partial) },
};
@@ -1433,7 +1433,7 @@ static int check_partial_success(enum shirudo_otel_signal signal,
return 0;
ret = json_parse(body, len, root, ARRAY_SIZE(root));
if (ret) {
- partial[0] = (struct shirudo_json_field){
+ partial[0] = (struct json_field){
count, SHIRUDO_JSON_T_INT, &rejected, 0, 0, NULL, 0 };
if (json_parse(body, len, root, ARRAY_SIZE(root)))
return -EBADMSG;
@@ -1445,7 +1445,7 @@ static int check_partial_success(enum shirudo_otel_signal signal,
if (rejected < 0)
return -EBADMSG;
if (rejected > 0) {
- partial[0] = (struct shirudo_json_field){
+ partial[0] = (struct json_field){
"errorMessage", SHIRUDO_JSON_T_STRING, error,
sizeof(error), 0, NULL, 0 };
if (json_parse(body, len, root, ARRAY_SIZE(root)))
@@ -1574,9 +1574,9 @@ static int otel_post(struct otel_state *st, const char *json, size_t json_len)
return ret;
}
-static int otel_open_transport(enum shirudo_otel_signal signal,
+static int otel_open_transport(enum otel_signal signal,
const char *spec,
- const struct shirudo_otel_opts *opts,
+ const struct otel_opts *opts,
const char *decoder_path, void **state)
{
struct otel_state *st;
@@ -1617,12 +1617,12 @@ err:
return ret;
}
-static int otel_open_common(const char *spec, const struct shirudo_map_view *v,
- const struct shirudo_otel_opts *opts,
- bool automatic, enum shirudo_otel_signal forced,
+static int otel_open_common(const char *spec, const struct map_view *v,
+ const struct otel_opts *opts,
+ bool automatic, enum otel_signal forced,
const char *decoder_path, void **state)
{
- enum shirudo_otel_signal signal;
+ enum otel_signal signal;
char reason[160];
int ret;
@@ -1642,7 +1642,7 @@ static int otel_open_common(const char *spec, const struct shirudo_map_view *v,
return otel_open_transport(signal, spec, opts, decoder_path, state);
}
-static int otel_emit(void *state, const struct shirudo_map_view *v)
+static int otel_emit(void *state, const struct map_view *v)
{
struct otel_state *st = state;
char *payload = NULL;
@@ -1694,7 +1694,7 @@ static int build_generic_log_payload(const char *scope_name,
char **out, size_t *out_len,
size_t *alloc_len)
{
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char *buf;
int ret;
size_t cap;
@@ -1738,7 +1738,7 @@ static int build_generic_log_payload(const char *scope_name,
return 0;
}
-int otel_send_log_json(const struct shirudo_otel_opts *opts,
+int otel_send_log_json(const struct otel_opts *opts,
const char *scope_name,
const char *event_name,
int severity_number,
@@ -1775,7 +1775,7 @@ struct snapshot_writer {
FILE *file;
z_stream z;
gz_header header;
- struct shirudo_sha256_ctx md;
+ struct sha256_ctx md;
__u64 json_bytes;
__u64 object_bytes;
bool deflate_ready;
@@ -1934,7 +1934,7 @@ static int snapshot_writer_finish(struct snapshot_writer *w,
}
static int build_s3_snapshot(const char *decoder_path,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
struct s3_snapshot *snapshot)
{
struct snapshot_writer writer;
@@ -2191,7 +2191,7 @@ static int escape_s3_path(const char *path, char *out, size_t out_sz)
}
static int build_s3_urls(const struct otel_s3_state *st,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
const struct s3_snapshot *snapshot,
char *url, size_t url_sz, char *uri, size_t uri_sz)
{
@@ -2236,7 +2236,7 @@ static int s3_header(struct curl_slist **headers, const char *line)
}
static int s3_headers(const struct otel_s3_state *st,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
const struct s3_snapshot *snapshot,
struct curl_slist **out)
{
@@ -2294,7 +2294,7 @@ static bool retryable_s3_http(long status)
}
static int s3_put(struct otel_s3_state *st,
- const struct shirudo_map_view *v,
+ const struct map_view *v,
struct s3_snapshot *snapshot, const char *url,
bool *already_present)
{
@@ -2390,11 +2390,11 @@ out:
return ret;
}
-static int build_s3_reference(const struct shirudo_map_view *v,
+static int build_s3_reference(const struct map_view *v,
const struct s3_snapshot *snapshot,
const char *uri, char **out, size_t *out_len)
{
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
char description[S3_URL_MAX + 64];
char *buf;
@@ -2451,8 +2451,8 @@ static void otel_s3_state_free(struct otel_s3_state *st)
xfree(st, sizeof(*st));
}
-static int otel_s3_open(const char *spec, const struct shirudo_map_view *v,
- const struct shirudo_otel_opts *opts,
+static int otel_s3_open(const char *spec, const struct map_view *v,
+ const struct otel_opts *opts,
const char *decoder_path,
void **state)
{
@@ -2491,7 +2491,7 @@ err:
return ret;
}
-static int otel_s3_emit(void *state, const struct shirudo_map_view *v)
+static int otel_s3_emit(void *state, const struct map_view *v)
{
struct otel_s3_state *st = state;
struct s3_snapshot snapshot = {};
@@ -2536,13 +2536,13 @@ static int otel_s3_close(void *state)
}
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 struct map_view *v,
+ enum otel_mode mode,
+ const struct otel_opts *opts)
{
const char *endpoint = opts ? opts->endpoint : NULL;
bool automatic = mode == SHIRUDO_OTEL_AUTO;
- enum shirudo_otel_signal signal;
+ enum otel_signal signal;
void *state = NULL;
int ret, close_rc;
@@ -2573,16 +2573,16 @@ int upatch_maps_otel_send_file(const char *decoder_path,
return ret ? ret : close_rc;
}
-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(const struct map_view *v,
+ enum otel_mode mode,
+ const struct otel_opts *opts)
{
return upatch_maps_otel_send_file(NULL, v, mode, 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 upatch_maps_otel_send_decoded(const struct map_view *v,
+ enum otel_signal signal,
+ const struct otel_opts *opts)
{
int ret;
diff --git a/util/upatch_maps_otel.h b/util/upatch_maps_otel.h
index 567b9445..c9b7269a 100644
--- a/util/upatch_maps_otel.h
+++ b/util/upatch_maps_otel.h
@@ -12,20 +12,20 @@
#include "upatch_maps.h"
-enum shirudo_otel_signal {
+enum otel_signal {
/* Keep these values aligned with SHIRUDO_UPATCH_DECODER_EXPORT_*. */
SHIRUDO_OTEL_LOG = 1,
SHIRUDO_OTEL_METRIC = 2,
};
-enum shirudo_otel_mode {
+enum otel_mode {
SHIRUDO_OTEL_AUTO,
SHIRUDO_OTEL_FORCE_LOG,
SHIRUDO_OTEL_FORCE_METRIC,
SHIRUDO_OTEL_S3,
};
-struct shirudo_otel_opts {
+struct otel_opts {
const char *endpoint;
const char *tenant_id;
const char *s3_uri;
@@ -35,34 +35,34 @@ struct shirudo_otel_opts {
__u32 otlp_max_bytes;
};
-int upatch_maps_otel_classify(const struct shirudo_map_view *v,
- enum shirudo_otel_signal *signal,
+int upatch_maps_otel_classify(const struct map_view *v,
+ enum 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,
+ const struct 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,
+ const struct map_view *v,
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(const struct map_view *v,
+ enum otel_mode mode,
+ const struct 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);
+ const struct map_view *v,
+ enum otel_mode mode,
+ const struct otel_opts *opts);
/* Export using the matching decoder's signed, static signal selection. */
-int 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 map_view *v,
+ enum otel_signal signal,
+ const struct 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 otel_send_log_json(const struct shirudo_otel_opts *opts,
+int otel_send_log_json(const struct otel_opts *opts,
const char *scope_name,
const char *event_name,
int severity_number,
diff --git a/util/upatch_rodata.c b/util/upatch_rodata.c
index a37d000c..11736055 100644
--- a/util/upatch_rodata.c
+++ b/util/upatch_rodata.c
@@ -153,7 +153,7 @@ static bool map_name_rodata(const char *name)
!strcmp(name + name_len - suffix_len, suffix);
}
-static int find_rodata_data(const struct shirudo_upatch *u,
+static int find_rodata_data(const struct upatch *u,
const struct btf *btf, __u32 datasec_id,
struct rodata_view *view)
{
@@ -231,7 +231,7 @@ static int find_rodata_data(const struct shirudo_upatch *u,
return ret;
}
-static int btf_rodata_btf(const struct shirudo_upatch *u,
+static int btf_rodata_btf(const struct upatch *u,
struct rodata_view *view)
{
const __u8 *data = upatch_data(u);
@@ -314,7 +314,7 @@ static int btf_rodata_btf(const struct shirudo_upatch *u,
return find_rodata_data(u, found, found_id, view);
}
-int upatch_rodata_data_offset(const struct shirudo_upatch *u, __u32 *offset)
+int upatch_rodata_data_offset(const struct upatch *u, __u32 *offset)
{
struct rodata_view view = {};
int ret;
@@ -328,9 +328,9 @@ int upatch_rodata_data_offset(const struct shirudo_upatch *u, __u32 *offset)
return ret;
}
-int upatch_rodata_symbol_range(const struct shirudo_upatch *u,
+int upatch_rodata_symbol_range(const struct upatch *u,
const char *symbol,
- struct shirudo_rodata_range *range)
+ struct rodata_range *range)
{
struct rodata_view view = {};
const struct btf_type *sec;
@@ -495,7 +495,7 @@ static int append_type_name(const struct btf *btf, __u32 id, char *buf,
return 0;
}
-static int json_number(struct shirudo_json_emit *e, __u64 value,
+static int json_number(struct json_emit *e, __u64 value,
bool is_signed)
{
char number[32];
@@ -541,7 +541,7 @@ static int btf_integer(const struct btf_type *t, const void *bytes,
return 0;
}
-static void json_hex(struct shirudo_json_emit *e, const void *bytes,
+static void json_hex(struct json_emit *e, const void *bytes,
size_t size)
{
static const char hex[] = "0123456789abcdef";
@@ -570,7 +570,7 @@ static void json_hex(struct shirudo_json_emit *e, const void *bytes,
xfree(text, cap);
}
-static int json_btf_value(struct shirudo_json_emit *e, const struct btf *btf,
+static int json_btf_value(struct json_emit *e, const struct btf *btf,
__u32 type_id, const __u8 *bytes, size_t size,
__u32 depth)
{
@@ -776,7 +776,7 @@ static void print_text(void *ctx, const char *fmt, va_list args)
vfprintf(fp, fmt, args);
}
-static int print_rodata_text(const struct shirudo_upatch *u,
+static int print_rodata_text(const struct upatch *u,
const char *path, const struct rodata_view *view)
{
struct btf_dump_type_data_opts opts = {
@@ -841,7 +841,7 @@ out:
return ret;
}
-static int print_rodata_json(const struct shirudo_upatch *u,
+static int print_rodata_json(const struct upatch *u,
const char *path, const struct rodata_view *view)
{
const struct btf_type *sec = btf__type_by_id(view->btf,
@@ -850,7 +850,7 @@ static int print_rodata_json(const struct shirudo_upatch *u,
(const struct btf_var_secinfo *)(sec + 1);
char name[UPATCH_NAME_MAX + 1];
char *buf = xmalloc(JSON_MAX_BYTES);
- struct shirudo_json_emit e = {};
+ struct json_emit e = {};
__u32 i, vlen = BTF_INFO_VLEN(sec->info);
int ret = 0;
@@ -920,7 +920,7 @@ static int print_rodata_json(const struct shirudo_upatch *u,
return ret;
}
-int upatch_rodata_print(const struct shirudo_upatch *u, const char *path,
+int upatch_rodata_print(const struct upatch *u, const char *path,
bool json)
{
struct rodata_view view = {};
diff --git a/util/upatch_rodata.h b/util/upatch_rodata.h
index dea52459..0ae5b9c2 100644
--- a/util/upatch_rodata.h
+++ b/util/upatch_rodata.h
@@ -12,16 +12,16 @@
#include "upatch.h"
-struct shirudo_rodata_range {
+struct rodata_range {
__u32 offset;
__u32 size;
};
-int upatch_rodata_print(const struct shirudo_upatch *u, const char *path,
+int upatch_rodata_print(const struct upatch *u, const char *path,
bool json);
-int upatch_rodata_symbol_range(const struct shirudo_upatch *u,
+int upatch_rodata_symbol_range(const struct upatch *u,
const char *symbol,
- struct shirudo_rodata_range *range);
-int upatch_rodata_data_offset(const struct shirudo_upatch *u, __u32 *offset);
+ struct rodata_range *range);
+int upatch_rodata_data_offset(const struct upatch *u, __u32 *offset);
#endif /* SHIRUDO_UTIL_UPATCH_RODATA_H */
diff --git a/util/upatch_table.c b/util/upatch_table.c
index 14a69c6a..47677bff 100644
--- a/util/upatch_table.c
+++ b/util/upatch_table.c
@@ -26,7 +26,7 @@ __s64 upatch_age_sec(const char *ts)
return (__s64)(time(NULL) - timegm(&tm));
}
-void upatch_table_print(const struct shirudo_upatch_table_row *rows,
+void upatch_table_print(const struct upatch_table_row *rows,
size_t n)
{
size_t i;
@@ -37,7 +37,7 @@ void upatch_table_print(const struct shirudo_upatch_table_row *rows,
printf(" %-24s %-28s %5s %-28s %s\n",
"NAME", "LOCATION", "MAPS", "STATUS", "AGE");
for (i = 0; i < n; i++) {
- const struct shirudo_upatch_table_row *r = &rows[i];
+ const struct upatch_table_row *r = &rows[i];
char age[16] = "?";
if (r->age_sec >= 0)
@@ -49,15 +49,15 @@ void upatch_table_print(const struct shirudo_upatch_table_row *rows,
}
}
-void upatch_table_emit_json(struct shirudo_json_emit *e,
- const struct shirudo_upatch_table_row *rows,
+void upatch_table_emit_json(struct json_emit *e,
+ const struct upatch_table_row *rows,
size_t n)
{
size_t i;
json_arr_open(e, "upatches_loaded");
for (i = 0; i < n; i++) {
- const struct shirudo_upatch_table_row *r = &rows[i];
+ const struct upatch_table_row *r = &rows[i];
json_obj_open(e);
json_kv_string(e, "name", r->name);
diff --git a/util/upatch_table.h b/util/upatch_table.h
index e4bbbdd3..ea94f475 100644
--- a/util/upatch_table.h
+++ b/util/upatch_table.h
@@ -15,9 +15,9 @@
#include "upatch_resolve.h"
-struct shirudo_json_emit;
+struct json_emit;
-struct shirudo_upatch_table_row {
+struct upatch_table_row {
char name[UPATCH_NAME_MAX + 1];
char location[UPATCH_LOCATION_MAX]; /* SEC()-style */
char loaded_at[32]; /* ISO-8601 UTC, "" if unknown */
@@ -27,11 +27,11 @@ struct shirudo_upatch_table_row {
char payload_sha256[65]; /* "" if unavailable; JSON only */
};
-void upatch_table_print(const struct shirudo_upatch_table_row *rows,
+void upatch_table_print(const struct upatch_table_row *rows,
size_t n);
-void upatch_table_emit_json(struct shirudo_json_emit *e,
- const struct shirudo_upatch_table_row *rows,
+void upatch_table_emit_json(struct json_emit *e,
+ const struct upatch_table_row *rows,
size_t n);
__s64 upatch_age_sec(const char *ts);