Merge pull request #977 from richardmaw-codethink/machinectl-userns-login-v2
Fix machinectl login with containers in user namespaces (v2)
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
#include "bus-container.h"
|
||||
|
||||
int bus_container_connect_socket(sd_bus *b) {
|
||||
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
|
||||
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, usernsfd = -1, rootfd = -1;
|
||||
pid_t child;
|
||||
siginfo_t si;
|
||||
int r;
|
||||
@@ -45,7 +45,7 @@ int bus_container_connect_socket(sd_bus *b) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &rootfd);
|
||||
r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &usernsfd, &rootfd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -64,7 +64,7 @@ int bus_container_connect_socket(sd_bus *b) {
|
||||
if (child == 0) {
|
||||
pid_t grandchild;
|
||||
|
||||
r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd);
|
||||
r = namespace_enter(pidnsfd, mntnsfd, -1, usernsfd, rootfd);
|
||||
if (r < 0)
|
||||
_exit(255);
|
||||
|
||||
@@ -120,7 +120,7 @@ int bus_container_connect_socket(sd_bus *b) {
|
||||
|
||||
int bus_container_connect_kernel(sd_bus *b) {
|
||||
_cleanup_close_pair_ int pair[2] = { -1, -1 };
|
||||
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
|
||||
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, usernsfd = -1, rootfd = -1;
|
||||
union {
|
||||
struct cmsghdr cmsghdr;
|
||||
uint8_t buf[CMSG_SPACE(sizeof(int))];
|
||||
@@ -146,7 +146,7 @@ int bus_container_connect_kernel(sd_bus *b) {
|
||||
return r;
|
||||
}
|
||||
|
||||
r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &rootfd);
|
||||
r = namespace_open(b->nspid, &pidnsfd, &mntnsfd, NULL, &usernsfd, &rootfd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -162,7 +162,7 @@ int bus_container_connect_kernel(sd_bus *b) {
|
||||
|
||||
pair[0] = safe_close(pair[0]);
|
||||
|
||||
r = namespace_enter(pidnsfd, mntnsfd, -1, rootfd);
|
||||
r = namespace_enter(pidnsfd, mntnsfd, -1, usernsfd, rootfd);
|
||||
if (r < 0)
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user