From 0cd584ccf6f472645dd48a5bd31c291f60a31ada Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 3 Oct 2016 13:09:37 -0400 Subject: [PATCH] postprocess: Silently clean up known-unnecessary files in /var Per OSTree design, /var can start out empty. However, our warning spam here is annoying. Let's first delete some known files - obviously this won't be exhaustive, but it's way faster than trying to fix all of this in the packages right now. The major one is the SELinux policy, which resulted in a lot of spam. Closes: #473 Approved by: jlebon --- src/libpriv/rpmostree-postprocess.c | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c index d0566bd4..31b6f7bd 100644 --- a/src/libpriv/rpmostree-postprocess.c +++ b/src/libpriv/rpmostree-postprocess.c @@ -650,7 +650,37 @@ convert_var_to_tmpfiles_d (int src_rootfs_dfd, { gboolean ret = FALSE; g_autoptr(GString) prefix = g_string_new ("/var"); + glnx_fd_close int var_dfd = -1; glnx_fd_close int tmpfiles_fd = -1; + /* List of files that shouldn't be in the tree */ + const char *known_state_files[] = { + "lib/systemd/random-seed", + "lib/systemd/catalog/database", + "lib/plymouth/boot-duration", + }; + + if (!glnx_opendirat (src_rootfs_dfd, "var", TRUE, &var_dfd, error)) + goto out; + + /* Here, delete some files ahead of time to avoid emitting warnings + * for things that are known to be harmless. + */ + for (guint i = 0; i < G_N_ELEMENTS (known_state_files); i++) + { + const char *path = known_state_files[i]; + if (unlinkat (var_dfd, path, 0) < 0) + { + if (errno != ENOENT) + { + glnx_set_error_from_errno (error); + goto out; + } + } + } + + /* Now, SELinux in Fedora >= 24: https://bugzilla.redhat.com/show_bug.cgi?id=1290659 */ + if (!glnx_shutil_rm_rf_at (var_dfd, "lib/selinux/targeted", cancellable, error)) + goto out; /* Append to an existing one for package layering */ if ((tmpfiles_fd = TEMP_FAILURE_RETRY (openat (dest_rootfs_dfd, "usr/lib/tmpfiles.d/rpm-ostree-1-autovar.conf",