]> err.no Git - systemd/commitdiff
namespace: make ro bind mounts work
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Apr 2010 16:48:07 +0000 (18:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Apr 2010 16:48:07 +0000 (18:48 +0200)
namespace.c
test-ns.c

index 570b4ce387df6f84ad9c11b7a38b79f7c7fac291..880d5c33ebbf60e42044723e0dca0382a48bf201 100644 (file)
@@ -123,7 +123,6 @@ static int apply_mount(Path *p, const char *root_dir, const char *inaccessible_d
         const char *what;
         char *where;
         int r;
-        bool read_only = false;
 
         assert(p);
         assert(root_dir);
@@ -137,11 +136,11 @@ static int apply_mount(Path *p, const char *root_dir, const char *inaccessible_d
 
         case INACCESSIBLE:
                 what = inaccessible_dir;
-                read_only = true;
+                flags |= MS_RDONLY;
                 break;
 
         case READONLY:
-                read_only = true;
+                flags |= MS_RDONLY;
                 /* Fall through */
 
         case READWRITE:
@@ -160,14 +159,11 @@ static int apply_mount(Path *p, const char *root_dir, const char *inaccessible_d
                  * flags. If we want to set any flag we need
                  * to do so in a second indepdant step. */
                 if (flags)
-                        r = mount(NULL, where, NULL, MS_REMOUNT|MS_REC|flags, NULL);
+                        r = mount(NULL, where, NULL, MS_REMOUNT|MS_BIND|MS_REC|flags, NULL);
 
                 /* Avoid expontial growth of trees */
                 if (r >= 0 && path_equal(p->path, "/"))
-                        r = mount(NULL, where, NULL, MS_REMOUNT|MS_UNBINDABLE, NULL);
-
-                if (r >= 0 && read_only)
-                        r = mount(NULL, where, NULL, MS_REMOUNT|MS_RDONLY, NULL);
+                        r = mount(NULL, where, NULL, MS_REMOUNT|MS_BIND|MS_UNBINDABLE|flags, NULL);
 
                 if (r < 0) {
                         r = -errno;
index baf42f6d44de445fe825e6fc964b33b043bde4cb..d40f8beb6b1bfb23fca2a92e13c278988236d14d 100644 (file)
--- a/test-ns.c
+++ b/test-ns.c
@@ -34,7 +34,9 @@ int main(int argc, char *argv[]) {
         };
 
         const char * const readable[] = {
-                "/var",
+                "/",
+                "/usr",
+                "/boot",
                 NULL
         };