Blame SOURCES/0001-postprocess-Special-case-NFS-state-files.patch

7e991d
From 80c5811980c745c373351e52a85f3f847fe08d7b Mon Sep 17 00:00:00 2001
7e991d
From: Colin Walters <walters@verbum.org>
7e991d
Date: Mon, 5 Feb 2018 13:12:44 -0500
7e991d
Subject: [PATCH] postprocess: Special case NFS state files
7e991d
7e991d
Currently in RHELAH 7.4, `systemctl start nfs` fails because we've dropped
7e991d
`/var/lib/nfs/etab` at least:
7e991d
https://bugzilla.redhat.com/show_bug.cgi?id=1427537
7e991d
7e991d
Things appear to work in Fedora 27 Atomic Host; there's been a lot of changes in
7e991d
upstream nfs-utils in this area. I didn't fully try to analyze all of them, but
7e991d
I am guessing it's
7e991d
http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commit;h=8e98eed42b64aa388c09716e3276a53028a839bf
7e991d
that made things work here.
7e991d
7e991d
For now let's just special case these.  I debated having it in a RHEL-only
7e991d
build but I often do RHELAH treecomposes from my Fedora dev container, and
7e991d
eh...I think let's ask the RHEL nfs-utils maintainer to backport the patches
7e991d
to make this work, then we can drop our hack.
7e991d
7e991d
Closes: #1229
7e991d
Approved by: jlebon
7e991d
---
7e991d
 src/libpriv/rpmostree-postprocess.c | 40 +++++++++++++++++++++++--------------
7e991d
 1 file changed, 25 insertions(+), 15 deletions(-)
7e991d
7e991d
diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c
7e991d
index 7e9cde3d..71513134 100644
7e991d
--- a/src/libpriv/rpmostree-postprocess.c
7e991d
+++ b/src/libpriv/rpmostree-postprocess.c
7e991d
@@ -462,12 +462,20 @@ convert_var_to_tmpfiles_d_recurse (GOutputStream *tmpfiles_out,
7e991d
         case DT_LNK:
7e991d
           filetype_c = 'L';
7e991d
           break;
7e991d
+        case DT_REG:
7e991d
+          /* nfs-utils in RHEL7; https://bugzilla.redhat.com/show_bug.cgi?id=1427537 */
7e991d
+          if (g_str_has_prefix (prefix->str, "/var/lib/nfs"))
7e991d
+            {
7e991d
+              filetype_c = 'f';
7e991d
+              break;
7e991d
+            }
7e991d
+          /* Fallthrough */
7e991d
         default:
7e991d
+          if (!glnx_unlinkat (dfd_iter.fd, dent->d_name, 0, error))
7e991d
+            return FALSE;
7e991d
           g_print ("Ignoring non-directory/non-symlink '%s/%s'\n",
7e991d
                    prefix->str,
7e991d
                    dent->d_name);
7e991d
-          if (!glnx_unlinkat (dfd_iter.fd, dent->d_name, 0, error))
7e991d
-            return FALSE;
7e991d
           continue;
7e991d
         }
7e991d
 
7e991d
@@ -478,7 +486,7 @@ convert_var_to_tmpfiles_d_recurse (GOutputStream *tmpfiles_out,
7e991d
       g_string_append_c (tmpfiles_d_buf, '/');
7e991d
       g_string_append (tmpfiles_d_buf, dent->d_name);
7e991d
 
7e991d
-      if (filetype_c == 'd')
7e991d
+      if (filetype_c == 'd' || filetype_c == 'f')
7e991d
         {
7e991d
           struct stat stbuf;
7e991d
           if (!glnx_fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
7e991d
@@ -493,20 +501,20 @@ convert_var_to_tmpfiles_d_recurse (GOutputStream *tmpfiles_out,
7e991d
             return glnx_throw (error, "Failed to find group '%u' for %s", stbuf.st_gid, dent->d_name);
7e991d
           g_string_append_printf (tmpfiles_d_buf, " %s %s - -", user, group);
7e991d
 
7e991d
-          /* Push prefix */
7e991d
-          g_string_append_c (prefix, '/');
7e991d
-          g_string_append (prefix, dent->d_name);
7e991d
+          if (filetype_c == 'd')
7e991d
+            {
7e991d
+              /* Push prefix */
7e991d
+              gsize prev_len = prefix->len;
7e991d
+              g_string_append_c (prefix, '/');
7e991d
+              g_string_append (prefix, dent->d_name);
7e991d
 
7e991d
-          if (!convert_var_to_tmpfiles_d_recurse (tmpfiles_out, dfd, pwdb, prefix,
7e991d
-                                                  cancellable, error))
7e991d
-            return FALSE;
7e991d
+              if (!convert_var_to_tmpfiles_d_recurse (tmpfiles_out, dfd, pwdb, prefix,
7e991d
+                                                      cancellable, error))
7e991d
+                return FALSE;
7e991d
 
7e991d
-          /* Pop prefix */
7e991d
-          {
7e991d
-            char *r = memrchr (prefix->str, '/', prefix->len);
7e991d
-            g_assert (r != NULL);
7e991d
-            g_string_truncate (prefix, r - prefix->str);
7e991d
-          }
7e991d
+              /* Pop prefix */
7e991d
+              g_string_truncate (prefix, prev_len);
7e991d
+            }
7e991d
         }
7e991d
       else
7e991d
         {
7e991d
@@ -538,6 +546,8 @@ convert_var_to_tmpfiles_d (int            rootfs_dfd,
7e991d
                            GCancellable  *cancellable,
7e991d
                            GError       **error)
7e991d
 {
7e991d
+  GLNX_AUTO_PREFIX_ERROR ("Converting /var to tmpfiles.d", error);
7e991d
+
7e991d
   g_autoptr(RpmOstreePasswdDB) pwdb = rpmostree_passwddb_open (rootfs_dfd, cancellable, error);
7e991d
   if (!pwdb)
7e991d
     return FALSE;
7e991d
-- 
7e991d
2.14.3
7e991d