[CRIU] [PATCH v2] tty: Don't forget to setup peers mode on restore

Cyrill Gorcunov gorcunov at gmail.com
Sat Jun 25 02:06:11 PDT 2016


In commit c6bc7259c we've started to carry @mode of the
files we're opening on restore, implying they are
static and should not be changed. This is true for
regular files but the pty peers are created
dynamically so if someone have set some special
mode beore the checkpoint procedure we will fail
on restore when regular file engine test it. So lets
setup @mode unconditionally.

https://travis-ci.org/xemul/criu/jobs/140011141

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---

Slightly improved version.

 criu/tty.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/criu/tty.c b/criu/tty.c
index 302dd54528bf..092e480bc52c 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -515,6 +515,27 @@ static void pty_free_fake_reg(struct reg_file_info **r)
 	}
 }
 
+static int do_open_tty_reg(int ns_root_fd, struct reg_file_info *rfi, void *arg)
+{
+	int fd;
+
+	fd = do_open_reg_noseek_flags(ns_root_fd, rfi, arg);
+	if (fd >= 0) {
+		/*
+		 * Peers might have differend modes set
+		 * after creation before we've dumped
+		 * them. So simply setup mode from image
+		 * the regular file engine will check
+		 * for this, so if we fail here it
+		 * gonna be catched anyway.
+		 */
+		if (rfi->rfe->has_mode)
+			fchmod(fd, rfi->rfe->mode);
+	}
+
+	return fd;
+}
+
 static int open_tty_reg(struct file_desc *reg_d, u32 flags)
 {
 	/*
@@ -522,7 +543,7 @@ static int open_tty_reg(struct file_desc *reg_d, u32 flags)
 	 * ctty magic happens only in tty_set_sid().
 	 */
 	flags |= O_NOCTTY;
-	return open_path(reg_d, do_open_reg_noseek_flags, &flags);
+	return open_path(reg_d, do_open_tty_reg, &flags);
 }
 
 static char *path_from_reg(struct file_desc *d)
-- 
2.5.5



More information about the CRIU mailing list