summaryrefslogtreecommitdiff
blob: 3452d6b1c79a7a3f7f6ce5f2fa5efe1c6cc2a124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Index: /trunk/src/vserver-info.c
===================================================================
--- a/src/vserver-info.c (revision 2589)
+++ b/src/vserver-info.c (revision 2717)
@@ -186,7 +186,9 @@
 verifyCap()
 {
+  int retried = 0;
   struct __user_cap_header_struct header;
-  struct __user_cap_data_struct user;
-  header.version = _LINUX_CAPABILITY_VERSION;
+  struct __user_cap_data_struct user[2];
+
+  header.version = _LINUX_CAPABILITY_VERSION_2;
   header.pid     = 0;
 
@@ -200,15 +202,22 @@
 //    return false;
 //  }
-  
-  if (capget(&header, &user)==-1) {
+
+retry:
+  if (capget(&header, user)==-1) {
+    if (!retried &&
+	header.version != _LINUX_CAPABILITY_VERSION_2) {
+      header.version = _LINUX_CAPABILITY_VERSION_1;
+      retried = 1;
+      goto retry;
+    }
     perror("capget()");
     return false;
   }
 
-  user.effective   = 0;
-  user.permitted   = 0;
-  user.inheritable = 0;
-
-  if (capset(&header, &user)==-1) {
+  user[0].effective   = user[1].effective   = 0;
+  user[0].permitted   = user[1].permitted   = 0;
+  user[0].inheritable = user[1].inheritable = 0;
+
+  if (capset(&header, user)==-1) {
     perror("capset()");
     return false;
Index: /trunk/src/rpm-fake.c
===================================================================
--- a/src/rpm-fake.c (revision 2693)
+++ b/src/rpm-fake.c (revision 2717)
@@ -420,20 +420,28 @@
 reduceCapabilities()
 {
+  int retried = 0;
   struct __user_cap_header_struct header;
-  struct __user_cap_data_struct user;
-  
-  header.version = _LINUX_CAPABILITY_VERSION;
+  struct __user_cap_data_struct user[2];
+  
+  header.version = _LINUX_CAPABILITY_VERSION_2;
   header.pid     = 0;
 
-  if (capget(&header, &user)==-1) {
+retry:
+  if (capget(&header, user)==-1) {
+    if (!retried &&
+	header.version != _LINUX_CAPABILITY_VERSION_2) {
+      header.version = _LINUX_CAPABILITY_VERSION_1;
+      retried = 1;
+      goto retry;
+    }
     perror("capget()");
     exit(wrapper_exit_code);
   }
 
-  user.effective   &= ~(1<<CAP_MKNOD);
-  user.permitted   &= ~(1<<CAP_MKNOD);
-  user.inheritable &= ~(1<<CAP_MKNOD);
-
-  if (capset(&header, &user)==-1) {
+  user[0].effective   &= ~(1<<CAP_MKNOD);
+  user[0].permitted   &= ~(1<<CAP_MKNOD);
+  user[0].inheritable &= ~(1<<CAP_MKNOD);
+
+  if (capset(&header, user)==-1) {
     perror("capset()");
     exit(wrapper_exit_code);
Index: /trunk/src/capability-compat.h
===================================================================
--- a/src/capability-compat.h (revision 1822)
+++ b/src/capability-compat.h (revision 2717)
@@ -30,2 +30,10 @@
 
 #endif
+
+#ifndef _LINUX_CAPABILITY_VERSION_1
+#  define _LINUX_CAPABILITY_VERSION_1	_LINUX_CAPABILITY_VERSION
+#endif
+
+#ifndef _LINUX_CAPABILITY_VERSION_2
+#  define _LINUX_CAPABILITY_VERSION_2	0x20071026
+#endif