added persistence option to HostWithPrivateDirs. also attached mount namespaces when mnexec -a is specified

This commit is contained in:
Cody Burkard
2014-06-19 15:08:26 -07:00
parent ebc1eae679
commit 6a81b6dfb3
3 changed files with 34 additions and 5 deletions
+14 -1
View File
@@ -133,6 +133,7 @@ int main(int argc, char *argv[])
perror("mount");
return 1;
}
break;
case 'p':
/* print pid */
@@ -140,7 +141,7 @@ int main(int argc, char *argv[])
fflush(stdout);
break;
case 'a':
/* Attach to pid's network namespace */
/* Attach to pid's network namespace and mount namespace*/
pid = atoi(optarg);
sprintf(path, "/proc/%d/ns/net", pid );
nsid = open(path, O_RDONLY);
@@ -152,6 +153,18 @@ int main(int argc, char *argv[])
perror("setns");
return 1;
}
sprintf(path, "/proc/%d/ns/mnt", pid );
nsid = open(path, O_RDONLY);
if (nsid < 0) {
perror(path);
return 1;
}
if (setns(nsid, 0) != 0) {
perror("setns");
return 1;
}
break;
case 'g':
/* Attach to cgroup */