import: lock tar into its own private network namespace

That way it cannot get access to the network
This commit is contained in:
Lennart Poettering
2015-01-22 18:19:58 +01:00
parent 2c140ded48
commit 7315edd36a
+5 -4
View File
@@ -507,11 +507,12 @@ int import_fork_tar(const char *path, pid_t *ret) {
fd_cloexec(STDOUT_FILENO, false);
fd_cloexec(STDERR_FILENO, false);
if (unshare(CLONE_NEWNET) < 0)
log_error_errno(errno, "Failed to lock tar into network namespace, ignoring: %m");
r = capability_bounding_set_drop(~retain, true);
if (r < 0) {
log_error_errno(errno, "Failed to drop capabilities, ignoring: %m");
_exit(EXIT_FAILURE);
}
if (r < 0)
log_error_errno(r, "Failed to drop capabilities, ignoring: %m");
execlp("tar", "tar", "--numeric-owner", "-C", path, "-px", NULL);
log_error_errno(errno, "Failed to execute tar: %m");