diff options
author | Tom Gundersen <teg@jklm.no> | 2014-10-08 15:01:07 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-10-08 15:52:07 +0200 |
commit | 85614d663e4a09beee1c78aaa67f02943d50d5a0 (patch) | |
tree | c2777e9577a561c0a612ed87b2cd65f4d53bff01 | |
parent | 5a94946cdf38d3574bd32cd3151b32003df60e6a (diff) |
nspawn: copy /dev/net/tun from host
This enables tuntap support in the container (assumning the necessary capabilities are in place).
-rw-r--r-- | src/nspawn/nspawn.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 34436b82a2..da4c116f36 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1101,7 +1101,8 @@ static int copy_devnodes(const char *dest) { "full\0" "random\0" "urandom\0" - "tty\0"; + "tty\0" + "net/tun\0"; const char *d; int r = 0; @@ -1132,10 +1133,17 @@ static int copy_devnodes(const char *dest) { log_error("%s is not a char or block device, cannot copy", from); return -EIO; - } else if (mknod(to, st.st_mode, st.st_rdev) < 0) { + } else { + r = mkdir_parents(to, 0775); + if (r < 0) { + log_error("Failed to create parent directory of %s: %s", to, strerror(-r)); + return -r; + } - log_error("mknod(%s) failed: %m", dest); - return -errno; + if (mknod(to, st.st_mode, st.st_rdev) < 0) { + log_error("mknod(%s) failed: %m", dest); + return -errno; + } } } |