From 2aa9cb933394848935c8796669eb6c6788989f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=C2=A0Miros=C5=82aw?= Date: Thu, 22 Jun 2023 17:38:33 +0200 Subject: [PATCH] rpc: Support setting images_dir by path. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Google's RPC client process is in a different pidns and has more privileges -- CRIU can't open its /proc//fd/. For images_dir_fd to be useful here it would need to refer to a passed or CRIU's fd. From: Michał Cłapiński Change-Id: Icbfb5af6844b21939a15f6fbb5b02264c12341b1 Signed-off-by: Michał Mirosław --- criu/cr-service.c | 8 +++++++- images/rpc.proto | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/criu/cr-service.c b/criu/cr-service.c index f62245d5f..61a04c5ff 100644 --- a/criu/cr-service.c +++ b/criu/cr-service.c @@ -382,8 +382,14 @@ static int setup_opts_from_req(int sk, CriuOpts *req) */ if (imgs_changed_by_rpc_conf) strncpy(images_dir_path, opts.imgs_dir, PATH_MAX - 1); - else + else if (req->images_dir_fd != -1) sprintf(images_dir_path, "/proc/%d/fd/%d", ids.pid, req->images_dir_fd); + else if (req->images_dir) + strncpy(images_dir_path, req->images_dir, PATH_MAX - 1); + else { + pr_err("Neither images_dir_fd nor images_dir was passed by RPC client.\n"); + goto err; + } if (req->parent_img) SET_CHAR_OPTS(img_parent, req->parent_img); diff --git a/images/rpc.proto b/images/rpc.proto index 8748bdaff..1a4722a9c 100644 --- a/images/rpc.proto +++ b/images/rpc.proto @@ -61,7 +61,8 @@ enum criu_pre_dump_mode { }; message criu_opts { - required int32 images_dir_fd = 1; + required int32 images_dir_fd = 1 [default = -1]; + optional string images_dir = 68; /* used only if images_dir_fd == -1 */ optional int32 pid = 2; /* if not set on dump, will dump requesting process */ optional bool leave_running = 3;