@@ -1755,6 +1755,11 @@ static int setup_propagate(const char *root) {
17551755 if (mount (NULL , q , NULL , MS_BIND |MS_REMOUNT |MS_RDONLY , NULL ) < 0 )
17561756 return log_error_errno (errno , "Failed to make propagation mount read-only" );
17571757
1758+ /* machined will MS_MOVE into that directory, and that's only
1759+ * supported for non-shared mounts. */
1760+ if (mount (NULL , q , NULL , MS_SLAVE , NULL ) < 0 )
1761+ return log_error_errno (errno , "Failed to make propagation mount slave" );
1762+
17581763 return 0 ;
17591764}
17601765
@@ -2990,6 +2995,15 @@ static int outer_child(
29902995 if (mount (directory , directory , NULL , MS_BIND |MS_REC , NULL ) < 0 )
29912996 return log_error_errno (errno , "Failed to make bind mount: %m" );
29922997
2998+ /* Mark everything as shared so our mounts get propagated down. This is
2999+ * required to make new bind mounts available in systemd services
3000+ * inside the containter that create a new mount namespace.
3001+ * See https://github.com/systemd/systemd/issues/3860
3002+ * Further submounts (such as /dev) done after this will inherit the
3003+ * shared propagation mode.*/
3004+ if (mount (NULL , directory , NULL , MS_SHARED |MS_REC , NULL ) < 0 )
3005+ return log_error_errno (errno , "MS_SHARED|MS_REC failed: %m" );
3006+
29933007 r = recursive_chown (directory , arg_uid_shift , arg_uid_range );
29943008 if (r < 0 )
29953009 return r ;
0 commit comments