From 2ccf36ae3ded1da48dd659d46a4ccabdee0e0775 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Fri, 4 Jan 2019 15:44:56 +0000
Subject: [PATCH] sysroot: Remove immutable bit from /etc/sysconfig/nfs

Work around for https://src.fedoraproject.org/rpms/nfs-utils/pull-request/7
Currently Fedora-only.
---
 src/libostree/ostree-sysroot-cleanup.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/libostree/ostree-sysroot-cleanup.c b/src/libostree/ostree-sysroot-cleanup.c
index 7a352e6b..b8ec9970 100644
--- a/src/libostree/ostree-sysroot-cleanup.c
+++ b/src/libostree/ostree-sysroot-cleanup.c
@@ -271,6 +271,22 @@ _ostree_sysroot_rmrf_deployment (OstreeSysroot *self,
     return FALSE;
   if (!glnx_shutil_rm_rf_at (self->sysroot_fd, origin_relpath, cancellable, error))
     return FALSE;
+
+  /* Special hack for Fedora's NFS package which is abusing the immutable bit
+   * https://src.fedoraproject.org/rpms/nfs-utils/pull-request/7
+   */
+  {
+    glnx_autofd int nfs_sysconfig_fd = -1;
+    if (!ot_openat_ignore_enoent (deployment_fd, "etc/sysconfig/nfs", &nfs_sysconfig_fd, error))
+      return FALSE;
+    if (nfs_sysconfig_fd != -1)
+      {
+        if (!_ostree_linuxfs_fd_alter_immutable_flag (nfs_sysconfig_fd, FALSE,
+                                                      cancellable, error))
+          return FALSE;
+      }
+  }
+
   if (!glnx_shutil_rm_rf_at (self->sysroot_fd, deployment_path, cancellable, error))
     return FALSE;

--
2.19.2
