[CRIU] [PATCH 1/2] kerndat: do not report errors on feature test

Dmitry Safonov dsafonov at odin.com
Mon Dec 28 07:31:25 PST 2015


prepare_loginuid() called on kerndat_loginuid where it tests for
loginuid restore feature. Let's omit error printing for feature test.

Signed-off-by: Dmitry Safonov <dsafonov at odin.com>
---
 cr-restore.c         | 6 +++---
 include/proc_parse.h | 2 +-
 kerndat.c            | 4 ++--
 proc_parse.c         | 6 ++++--
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index be83eb0..db55b97 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -866,7 +866,7 @@ static int prepare_proc_misc(pid_t pid, TaskCoreEntry *tc)
 	/* loginuid value is critical to restore */
 	if (kdat.has_loginuid && tc->has_loginuid &&
 			tc->loginuid != INVALID_UID) {
-		ret = prepare_loginuid(tc->loginuid);
+		ret = prepare_loginuid(tc->loginuid, LOG_ERROR);
 		if (ret < 0)
 			return ret;
 	}
@@ -1867,7 +1867,7 @@ static int prepare_userns_hook(void)
 	if (ret < 0)
 		return -1;
 
-	if (prepare_loginuid(INVALID_UID) < 0) {
+	if (prepare_loginuid(INVALID_UID, LOG_ERROR) < 0) {
 		pr_err("Setting loginuid for CT init task failed, CAP_AUDIT_CONTROL?");
 		return -1;
 	}
@@ -1880,7 +1880,7 @@ static void restore_origin_ns_hook(void)
 		return;
 
 	/* not critical: it does not affect CT in any way */
-	if (prepare_loginuid(saved_loginuid) < 0)
+	if (prepare_loginuid(saved_loginuid, LOG_ERROR) < 0)
 		pr_err("Restore original /proc/self/loginuid failed");
 }
 
diff --git a/include/proc_parse.h b/include/proc_parse.h
index 303a9f0..bd5317b 100644
--- a/include/proc_parse.h
+++ b/include/proc_parse.h
@@ -127,7 +127,7 @@ extern struct mount_info *parse_mountinfo(pid_t pid, struct ns_id *nsid, bool fo
 extern int parse_pid_stat(pid_t pid, struct proc_pid_stat *s);
 extern unsigned int parse_pid_loginuid(pid_t pid, int *err);
 extern int parse_pid_oom_score_adj(pid_t pid, int *err);
-extern int prepare_loginuid(unsigned int value);
+extern int prepare_loginuid(unsigned int value, unsigned int loglevel);
 extern int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list);
 extern int parse_self_maps_lite(struct vm_area_list *vms);
 extern int parse_pid_status(pid_t pid, struct proc_status_creds *);
diff --git a/kerndat.c b/kerndat.c
index 5a09b8b..a7c72a2 100644
--- a/kerndat.c
+++ b/kerndat.c
@@ -442,10 +442,10 @@ int kerndat_loginuid(bool only_dump)
 	 * on that rely dump/restore code.
 	 * See also: marc.info/?l=git-commits-head&m=138509506407067
 	 */
-	if (prepare_loginuid(INVALID_UID) < 0)
+	if (prepare_loginuid(INVALID_UID, LOG_WARN) < 0)
 		return 0;
 	/* Cleaning value back as it was */
-	if (prepare_loginuid(saved_loginuid) < 0)
+	if (prepare_loginuid(saved_loginuid, LOG_WARN) < 0)
 		return 0;
 
 	kdat.has_loginuid = true;
diff --git a/proc_parse.c b/proc_parse.c
index 22ad661..ddb20de 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -809,7 +809,7 @@ err:
 	return -1;
 }
 
-int prepare_loginuid(unsigned int value)
+int prepare_loginuid(unsigned int value, unsigned int loglevel)
 {
 	int fd, ret = 0;
 	char buf[11]; /* 4294967295 is maximum for u32 */
@@ -821,7 +821,9 @@ int prepare_loginuid(unsigned int value)
 	snprintf(buf, 11, "%u", value);
 
 	if (write(fd, buf, 11) < 0) {
-		pr_perror("Write %s to /proc/self/loginuid failed", buf);
+		print_on_level(loglevel,
+			"Write %s to /proc/self/loginuid failed: %s",
+			buf, strerror(errno));
 		ret = -1;
 	}
 	close(fd);
-- 
2.6.4



More information about the CRIU mailing list