[CRIU] [PATCH 2/3] criu: fetch kdat.has_loginuid value on C/R

Dmitry Safonov dsafonov at odin.com
Wed Dec 23 05:47:37 PST 2015


Dump/Restore loginuid value only when kdat.has_loginuid set.

Signed-off-by: Dmitry Safonov <dsafonov at odin.com>
---
 cr-dump.c    | 24 ++++++++++++++----------
 cr-restore.c |  3 ++-
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index fabf20a..8f7f505 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -327,17 +327,21 @@ static int dump_pid_misc(pid_t pid, TaskCoreEntry *tc)
 {
 	int ret;
 
-	pr_info("dumping /proc/%d/{oom_score_adj,loginuid}\n", pid);
+	if (kdat.has_loginuid) {
+		pr_info("dumping /proc/%d/{oom_score_adj,loginuid}\n", pid);
 
-	tc->has_loginuid = true;
-	tc->loginuid = parse_pid_loginuid(pid, &ret);
-	tc->loginuid = userns_uid(tc->loginuid);
-	/*
-	 * loginuid dumping is critical, as if not correctly
-	 * restored, you may loss ability to login via SSH to CT
-	 */
-	if (ret < 0)
-		return ret;
+		tc->has_loginuid = true;
+		tc->loginuid = parse_pid_loginuid(pid, &ret);
+		tc->loginuid = userns_uid(tc->loginuid);
+		/*
+		 * loginuid dumping is critical, as if not correctly
+		 * restored, you may loss ability to login via SSH to CT
+		 */
+		if (ret < 0)
+			return ret;
+	} else {
+		tc->has_loginuid = false;
+	}
 
 	tc->oom_score_adj = parse_pid_oom_score_adj(pid, &ret);
 	/*
diff --git a/cr-restore.c b/cr-restore.c
index 52d70a9..7941290 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -865,7 +865,8 @@ static int prepare_proc_misc(pid_t pid, TaskCoreEntry *tc)
 	int ret;
 
 	/* loginuid value is critical to restore */
-	if (tc->has_loginuid && tc->loginuid != INVALID_UID) {
+	if (kdat.has_loginuid && tc->has_loginuid &&
+			tc->loginuid != INVALID_UID) {
 		ret = prepare_loginuid(tc->loginuid);
 		if (ret < 0)
 			return ret;
-- 
2.6.4



More information about the CRIU mailing list