Skip to content

Commit fbbd926

Browse files
committed
fix: change the propagation type of the root mount to shared
The mount propagation type will be private,slave if a new mount namespace is creted by clone() and CLONE_NEWUSER is also used. Change it to shared,slave. Signed-off-by: reddevillg <reddevillg@gmail.com>
1 parent 8bca65a commit fbbd926

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

libs/utils/src/linglong/utils/namespace.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "linglong/utils/log/log.h"
1111

1212
#include <sys/capability.h>
13+
#include <sys/mount.h>
1314
#include <sys/prctl.h>
1415

1516
#include <fstream>
@@ -312,6 +313,11 @@ int runInNamespaceEntry(void *args)
312313
}
313314
}
314315

316+
if (mount("", "/", "", MS_SHARED | MS_REC, NULL) == -1) {
317+
LogW("failed to change propagation type of / to shared: {}",
318+
common::error::errorString(errno));
319+
}
320+
315321
LogD("run command {}", runInNamespaceArgs->argv[0]);
316322
for (int i = 1; i < runInNamespaceArgs->argc; ++i) {
317323
LogD("argv[{}]: {}", i, runInNamespaceArgs->argv[i]);

0 commit comments

Comments
 (0)