Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

init-fs: Add --epoch=2 #3230

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion man/ostree-admin-init-fs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
should only be mounted in the final deployment root. The main exception
is <literal>/boot</literal>, which may need to be mounted in some setups
before the target root.
</para></listitem>
</para>
<para>
Epoch 2 is the same as 1, except that the toplevel <literal>ostree</literal>
directory is mode 0700, denying access from unprivileged code. This
is a new recommended best practice as it avoids access to old configuration
files in <literal>/etc</literal> in previous deployments, as well as
potentially old setuid binaries in <literal>/ostree/repo</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
Expand Down
8 changes: 8 additions & 0 deletions src/ostree/ot-admin-builtin-init-fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invoca
return FALSE;
}
}
else if (opt_epoch == 2)
{
/* In epoch 2, ostree is 0700 - no access from unprivileged code. See
* https://github.com/ostreedev/ostree/issues/3211
*/
if (!glnx_shutil_mkdir_p_at (root_dfd, "ostree", 0700, cancellable, error))
return FALSE;
}

g_autoptr (GFile) dir = g_file_new_for_path (sysroot_path);
g_autoptr (OstreeSysroot) sysroot = ostree_sysroot_new (dir);
Expand Down
4 changes: 4 additions & 0 deletions tests/admin-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ for flag in --modern --epoch=1; do
assert_not_has_dir sysrootmin/home
rm sysrootmin -rf
done
mkdir sysrootmin
${CMD_PREFIX} ostree admin init-fs --epoch=2 sysrootmin
assert_streq "$(stat -c '%f' sysrootmin/ostree)" 41c0
assert_not_has_dir sysrootmin/home
echo "ok init-fs"

function validate_bootloader() {
Expand Down
Loading