[CRIU] [PATCH] zdtm: check only existent capabilities

Andrey Vagin avagin at openvz.org
Fri Dec 28 06:32:30 EST 2012


Kernel started with 3.8-rc1 are not report non-existent caps in
/proc/pid/status, so crtools doesn't dump/restore such caps.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm/live/static/caps00.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/test/zdtm/live/static/caps00.c b/test/zdtm/live/static/caps00.c
index 54054b2..01cc1af 100644
--- a/test/zdtm/live/static/caps00.c
+++ b/test/zdtm/live/static/caps00.c
@@ -27,15 +27,29 @@ struct cap_data {
 int capget(struct cap_hdr *hdrp, struct cap_data *datap);
 int capset(struct cap_hdr *hdrp, const struct cap_data *datap);
 
+static int cap_last_cap = 63;
+#define NORM_CAPS(v, cap) v[1].cap &= (1LL << (cap_last_cap + 1 - 32)) - 1;
+
 int main(int argc, char **argv)
 {
 	task_waiter_t t;
 	int pid, result_pipe[2];
 	char res = 'x';
+	FILE *f;
 
 	test_init(argc, argv);
 	task_waiter_init(&t);
 
+	f = fopen("/proc/sys/kernel/cap_last_cap", "r");
+	if (f) {
+		if (fscanf(f, "%d", &cap_last_cap) != 1) {
+			err("Unable to read cal_last_cap");
+			return 1;
+		}
+		fclose(f);
+	} else
+		test_msg("/proc/sys/kernel/cap_last_cap is not available\n");
+
 	if (pipe(result_pipe)) {
 		err("Can't create pipe\n");
 		return 1;
@@ -68,6 +82,13 @@ int main(int argc, char **argv)
 
 		capget(&hdr, data_2);
 
+		NORM_CAPS(data, eff);
+		NORM_CAPS(data, prm);
+		NORM_CAPS(data, inh);
+		NORM_CAPS(data_2, eff);
+		NORM_CAPS(data_2, prm);
+		NORM_CAPS(data_2, inh);
+
 		if (data[0].eff != data_2[0].eff) {
 			res = '1';
 			goto bad;
-- 
1.7.11.7



More information about the CRIU mailing list