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

Submitted by Kirill Tkhai on March 20, 2017, 11:58 a.m.

Details

Message ID 149001109981.11023.13147079375350681385.stgit@localhost.localdomain
State New
Series "net: Create child with CLONE_VM in prepare_net_namespaces()"
Headers show

Commit Message

Kirill Tkhai March 20, 2017, 11:58 a.m.
"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@virtuozzo.com>
---
 criu/include/namespaces.h |    1 +
 criu/namespaces.c         |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

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;