]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: EROFS for chowning mount points is not fatal (#7122)
authorLauri Tirkkonen <lotheac@iki.fi>
Tue, 24 Oct 2017 17:40:50 +0000 (20:40 +0300)
committerLennart Poettering <lennart@poettering.net>
Tue, 24 Oct 2017 17:40:50 +0000 (19:40 +0200)
This fixes --read-only with --private-users. mkdir_userns_p may return
-EROFS if either mkdir or lchown fails; lchown failing is fine as the
mount point will just be overmounted, and if mkdir fails then the
following mount() will also fail (with ENOENT).

src/nspawn/nspawn-mount.c

index 531f29cb7b5e062e6e3c425e74ac804678ea375c..9b7ceb6bdc7b4768bafac900f3ce35a093c2520f 100644 (file)
@@ -598,11 +598,15 @@ int mount_all(const char *dest,
 
                 r = mkdir_userns_p(dest, where, 0755, mount_settings, uid_shift);
                 if (r < 0 && r != -EEXIST) {
-                        if (fatal)
+                        if (fatal && r != -EROFS)
                                 return log_error_errno(r, "Failed to create directory %s: %m", where);
 
                         log_debug_errno(r, "Failed to create directory %s: %m", where);
-                        continue;
+                        /* If we failed mkdir() or chown() due to the root
+                         * directory being read only, attempt to mount this fs
+                         * anyway and let mount_verbose log any errors */
+                        if (r != -EROFS)
+                                continue;
                 }
 
                 o = mount_table[k].options;