Skip to content

Commit 984213f

Browse files
committed
deploy: Install detached signatures if present
When installing a kernel, initramfs or device tree, also install a detached signature (.sig) file if present. Intended to support GRUB GPG signature enforcement. This does not currently lead to a fully-functional secure solution, due to GRUB's pubkey verifier also checking config files, but it allows the `verify_detached` command to work, and could be part of a future solution coordinating a lockdown verifier (to determine which file types must be verified) with a relaxed pubkey verifier that does not immediately reject unsigned files.
1 parent b7efd16 commit 984213f

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

src/libostree/ostree-sysroot-deploy.c

+38-8
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ sysroot_flags_to_copy_flags (GLnxFileCopyFlags defaults,
101101
* hardlink if we're on the same partition.
102102
*/
103103
static gboolean
104-
install_into_boot (OstreeRepo *repo,
105-
OstreeSePolicy *sepolicy,
106-
int src_dfd,
107-
const char *src_subpath,
108-
int dest_dfd,
109-
const char *dest_subpath,
110-
GCancellable *cancellable,
111-
GError **error)
104+
install_into_boot_alone (OstreeRepo *repo,
105+
OstreeSePolicy *sepolicy,
106+
int src_dfd,
107+
const char *src_subpath,
108+
int dest_dfd,
109+
const char *dest_subpath,
110+
GCancellable *cancellable,
111+
GError **error)
112112
{
113113
if (linkat (src_dfd, src_subpath, dest_dfd, dest_subpath, 0) == 0)
114114
return TRUE; /* Note early return */
@@ -175,6 +175,36 @@ install_into_boot (OstreeRepo *repo,
175175
return TRUE;
176176
}
177177

178+
/* As install_into_boot_alone, but also copies a detached signature if any */
179+
static gboolean
180+
install_into_boot (OstreeRepo *repo,
181+
OstreeSePolicy *sepolicy,
182+
int src_dfd,
183+
const char *src_subpath,
184+
int dest_dfd,
185+
const char *dest_subpath,
186+
GCancellable *cancellable,
187+
GError **error)
188+
{
189+
if (!install_into_boot_alone (repo, sepolicy, src_dfd, src_subpath,
190+
dest_dfd, dest_subpath, cancellable, error))
191+
return FALSE;
192+
193+
/* If the source file has a detached signature, install it too */
194+
g_autofree char *src_sig_subpath = g_strdup_printf("%s.sig", src_subpath);
195+
if (!glnx_fstatat_allow_noent (src_dfd, src_sig_subpath, NULL, AT_SYMLINK_NOFOLLOW, error))
196+
return FALSE;
197+
if (errno != ENOENT)
198+
{
199+
g_autofree char *dest_sig_subpath = g_strdup_printf("%s.sig", dest_subpath);
200+
if (!install_into_boot_alone (repo, sepolicy, src_dfd, src_sig_subpath,
201+
dest_dfd, dest_sig_subpath, cancellable, error))
202+
return FALSE;
203+
}
204+
205+
return TRUE;
206+
}
207+
178208
/* Copy ownership, mode, and xattrs from source directory to destination */
179209
static gboolean
180210
dirfd_copy_attributes_and_xattrs (int src_parent_dfd,

0 commit comments

Comments
 (0)