[CRIU] [PATCH 4/6] crtools: move check_uid to util.c

Ruslan Kuprieiev kupruser at gmail.com
Tue Oct 1 11:08:43 PDT 2013


check_uid() is used to check if cr_service client is allowed to dump task.
We will need it in cr_restore too, so lets move it to util.c.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
-------------- next part --------------
---
diff --git a/cr-dump.c b/cr-dump.c
index ad9a5c8..194abbb 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1333,19 +1333,6 @@ err_cure:
 	goto err_free;
 }
 
-static int check_uid(uid)
-{
-	if (cr_service_client)
-		if ((cr_service_client->uid != uid) &&
-				(cr_service_client->uid != 0)) {
-			pr_err("UID (%d) != client's UID(%d)\n",
-				uid, cr_service_client->uid);
-			return -1;
-		}
-
-	return 0;
-}
-
 static int dump_one_task(struct pstree_item *item)
 {
 	pid_t pid = item->pid.real;
diff --git a/include/util.h b/include/util.h
index 3475700..e549f96 100644
--- a/include/util.h
+++ b/include/util.h
@@ -275,4 +275,6 @@ extern int read_fd_link(int lfd, char *buf, size_t size);
 #define USEC_PER_SEC	1000000L
 #define NSEC_PER_SEC    1000000000L
 
+int check_uid(int uid);
+
 #endif /* __CR_UTIL_H__ */
diff --git a/util.c b/util.c
index 5b1e6e6..e8d1d92 100644
--- a/util.c
+++ b/util.c
@@ -34,6 +34,7 @@
 #include "compiler.h"
 #include "asm/types.h"
 #include "list.h"
+#include "cr-service.h"
 #include "util.h"
 
 #include "crtools.h"
@@ -598,3 +599,16 @@ out:
 
 	return ret;
 }
+
+int check_uid(uid)
+{
+	if (cr_service_client)
+		if ((cr_service_client->uid != uid) &&
+				(cr_service_client->uid != 0)) {
+			pr_err("UID (%d) != client's UID(%d)\n",
+				uid, cr_service_client->uid);
+			return -1;
+		}
+
+	return 0;
+}


More information about the CRIU mailing list