[CRIU] [PATCH 1/3] cr-service: open FDs passed via inherit_fd option also in RPC mode

Adrian Reber adrian at lisas.de
Mon Jul 23 22:13:31 MSK 2018


From: Adrian Reber <areber at redhat.com>

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 criu/cr-service.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/criu/cr-service.c b/criu/cr-service.c
index 3a07d5b76..14fb45635 100644
--- a/criu/cr-service.c
+++ b/criu/cr-service.c
@@ -242,6 +242,8 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 	char images_dir_path[PATH_MAX];
 	char work_dir_path[PATH_MAX];
 	char status_fd[PATH_MAX];
+	char inherit_fd[PATH_MAX];
+	int fd;
 	int i;
 
 	if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
@@ -415,7 +417,11 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
 		goto err;
 	}
 	for (i = 0; i < req->n_inherit_fd; i++) {
-		if (inherit_fd_add(req->inherit_fd[i]->fd, req->inherit_fd[i]->key))
+		sprintf(inherit_fd, "/proc/%d/fd/%d", ids.pid, req->inherit_fd[i]->fd);
+		fd = open(inherit_fd, O_RDWR);
+		if (fd < 0)
+			goto err;
+		if (inherit_fd_add(fd, req->inherit_fd[i]->key))
 			goto err;
 	}
 
-- 
2.18.0



More information about the CRIU mailing list