core/namespace: merge if blocks

This commit is contained in:
Mike Yuan
2023-10-18 19:23:42 +08:00
parent 9dc6a6af28
commit bbe92ea5cc

View File

@@ -2524,12 +2524,10 @@ int setup_namespace(const NamespaceParameters *p, char **error_path) {
if (mount(NULL, "/", NULL, mount_propagation_flag | MS_REC, NULL) < 0)
return log_debug_errno(errno, "Failed to remount '/' with desired mount flags: %m");
/* bind_mount_in_namespace() will MS_MOVE into that directory, and that's only
* supported for non-shared mounts. This needs to happen after remounting / or it will fail. */
if (setup_propagate) {
if (mount(NULL, p->incoming_dir, NULL, MS_SLAVE, NULL) < 0)
return log_debug_errno(errno, "Failed to remount %s with MS_SLAVE: %m", p->incoming_dir);
}
/* bind_mount_in_namespace() will MS_MOVE into that directory, and that's only supported for
* non-shared mounts. This needs to happen after remounting / or it will fail. */
if (setup_propagate && mount(NULL, p->incoming_dir, NULL, MS_SLAVE, NULL) < 0)
return log_debug_errno(errno, "Failed to remount %s with MS_SLAVE: %m", p->incoming_dir);
return 0;
}