[CRIU] [PATCH v3 1/3] ns: Fix return collison in prepare_userns_creds()

Kirill Tkhai ktkhai at virtuozzo.com
Mon Mar 20 04:58:19 PDT 2017


"return" and "exit" are mixed in this function, and this is wrong.
Must be "return" only, because its callers don't want exit.

Also this patch exports prepare_userns_creds().

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/include/namespaces.h |    1 +
 criu/namespaces.c         |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 62fa091fb..f32787879 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -152,6 +152,7 @@ extern int read_ns_with_hookups(void);
 extern int set_ns_roots(void);
 extern int prepare_namespace_before_tasks(void);
 extern int prepare_namespace(struct pstree_item *item, unsigned long clone_flags);
+extern int prepare_userns_creds(void);
 
 extern int switch_ns(int pid, struct ns_desc *nd, int *rst);
 extern int switch_ns_by_fd(int nsfd, struct ns_desc *nd, int *rst);
diff --git a/criu/namespaces.c b/criu/namespaces.c
index a4c3063db..77308ccb6 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -2035,7 +2035,7 @@ int collect_namespaces(bool for_dump)
 	return 0;
 }
 
-static int prepare_userns_creds()
+int prepare_userns_creds(void)
 {
 	/* UID and GID must be set after restoring /proc/PID/{uid,gid}_maps */
 	if (setuid(0) || setgid(0) || setgroups(0, NULL)) {
@@ -2051,7 +2051,7 @@ static int prepare_userns_creds()
 	 */
 	if (prctl(PR_SET_DUMPABLE, 1, 0)) {
 		pr_perror("Unable to set PR_SET_DUMPABLE");
-		exit(1);
+		return -1;
 	}
 
 	return 0;



More information about the CRIU mailing list