• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <assert.h>
2 #include <stdlib.h>
3 #include <sys/capability.h>
4 
5 /*
6  * Original from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=400591
7  *
8  * Modified to test more functions.. AGM - 2008/07/06.
9  */
10 
main(int argc,char * argv[])11 int main (int argc, char *argv[])
12 {
13   cap_t caps, caps2;
14   ssize_t size, copy_size;
15   void *buffer;
16   char *text1, *text2;
17 
18   assert((caps = cap_get_pid(1)));
19 
20   text1 = cap_to_text(caps, NULL);
21   assert(text1);
22 
23   size = cap_size (caps);
24   assert (size>0  && size<1024);
25 
26   buffer = malloc (size);
27   assert (buffer);
28 
29   copy_size = cap_copy_ext (buffer, caps, size);
30   assert (copy_size == size);
31 
32   caps2 = cap_copy_int(buffer);
33   assert (caps2);
34 
35   text2 = cap_to_text(caps2, NULL);
36   assert(text2);
37 
38   assert(strcmp(text1, text2) == 0);
39 
40   assert(cap_compare(caps, caps2) == 0);
41 
42   return 0;
43 }
44