Commit 3716fd67 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: check only existent capabilities

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: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a1144f9f
...@@ -27,15 +27,29 @@ struct cap_data { ...@@ -27,15 +27,29 @@ struct cap_data {
int capget(struct cap_hdr *hdrp, struct cap_data *datap); int capget(struct cap_hdr *hdrp, struct cap_data *datap);
int capset(struct cap_hdr *hdrp, const 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) int main(int argc, char **argv)
{ {
task_waiter_t t; task_waiter_t t;
int pid, result_pipe[2]; int pid, result_pipe[2];
char res = 'x'; char res = 'x';
FILE *f;
test_init(argc, argv); test_init(argc, argv);
task_waiter_init(&t); 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)) { if (pipe(result_pipe)) {
err("Can't create pipe\n"); err("Can't create pipe\n");
return 1; return 1;
...@@ -68,6 +82,13 @@ int main(int argc, char **argv) ...@@ -68,6 +82,13 @@ int main(int argc, char **argv)
capget(&hdr, data_2); 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) { if (data[0].eff != data_2[0].eff) {
res = '1'; res = '1';
goto bad; goto bad;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment