Skip to content

Conversation

@tylerfanelli
Copy link
Member

@tylerfanelli tylerfanelli commented Nov 21, 2025

Avoid measuring the /etc/{hostname, hosts} files, as their values are influenced by the container ID when running containers. The container ID is an ephemeral value across reboots, and thus produces differing measurements for otherwise identical container root filesystems.

Avoid measuring the /etc/{hostname, hosts} files, as their values are
influenced by the container ID when running containers. The container ID
is an ephemeral value across reboots, and thus produces differing
measurements for otherwise identical container root filesystems.

Signed-off-by: Tyler Fanelli <[email protected]>
Comment on lines +116 to +122
measure &= (strstr(path, "rootfs/etc/hostname") == NULL);

/*
* Also avoid measuring /etc/hosts, which also contains the ephemeral
* hostname.
*/
measure &= (strstr(path, "rootfs/etc/hosts") == NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious, why'd you decide to do a bitwise operation here? would measure = (strstr(path, <other path>) == NULL) not be the same without the extra operation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would turn measure to false if the path is rootfs/etc/hostname OR rootfs/etc/hosts.

If path is rootfs/etc/hosts:

measure = true
measure &= (strstr(path, "rootfs/etc/hostname") == NULL) == true & true == true
measure &= (strstr(path, "rootfs/etc/hostname") == NULL) == true & false == false

@tylerfanelli tylerfanelli merged commit 4e3a27f into containers:main Nov 21, 2025
9 checks passed
@tylerfanelli tylerfanelli deleted the nitro-rootfs-nsm branch November 24, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants