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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
diff -Nur libcap-1.10/libcap/include/sys/capability.h libcap-1.10-python/libcap/include/sys/capability.h
--- libcap-1.10/libcap/include/sys/capability.h 1999-11-18 07:19:21.000000000 +0100
+++ libcap-1.10-python/libcap/include/sys/capability.h 2002-07-26 12:46:56.000000000 +0200
@@ -15,13 +15,25 @@
extern "C" {
#endif
+#ifdef SWIG
+%module libcap
+#endif
+
/*
* This file complements the kernel file by providing prototype
* information for the user library.
*/
+#ifdef SWIG
+%{
+#include <sys/types.h>
+#include <linux/capability.h>
+#include "libcap.h"
+%}
+#else
#include <sys/types.h>
#include <linux/capability.h>
+#endif
/*
* POSIX capability types
@@ -73,10 +85,12 @@
int cap_clear(cap_t);
/* libcap/cap_file.c */
+#ifndef SWIG
cap_t cap_get_fd(int);
cap_t cap_get_file(const char *);
int cap_set_fd(int, cap_t);
int cap_set_file(const char *, cap_t);
+#endif
/* libcap/cap_proc.c */
cap_t cap_get_proc(void);
@@ -96,6 +110,7 @@
* if the following _POSIX_SOURCE is _undefined_
*/
+#ifndef SWIG
#if !defined(_POSIX_SOURCE)
extern int capset(cap_user_header_t header, cap_user_data_t data);
@@ -105,6 +120,7 @@
extern char const *_cap_names[];
#endif /* !defined(_POSIX_SOURCE) */
+#endif
#ifdef __cplusplus
}
Binary files libcap-1.10/libcap/libcapmodule.so and libcap-1.10-python/libcap/libcapmodule.so differ
Binary files libcap-1.10/libcap/libcap_wrap.o and libcap-1.10-python/libcap/libcap_wrap.o differ
diff -Nur libcap-1.10/libcap/Makefile libcap-1.10-python/libcap/Makefile
--- libcap-1.10/libcap/Makefile 1999-04-18 00:16:31.000000000 +0200
+++ libcap-1.10-python/libcap/Makefile 2002-07-26 14:07:48.000000000 +0200
@@ -30,6 +30,7 @@
# Library version
#
LIBNAME=libcap.so
+PYTHONMODNAME=libcapmodule.so
#
FILES=cap_alloc cap_proc cap_extint cap_flag cap_text cap_sys
@@ -42,7 +43,11 @@
MAJLIBNAME=$(LIBNAME).$(VERSION)
MINLIBNAME=$(MAJLIBNAME).$(MINOR)
+ifdef PYTHON
+all: $(MINLIBNAME) $(PYTHONMODNAME)
+else
all: $(MINLIBNAME)
+endif
_makenames: _makenames.c cap_names.sed
$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
@@ -60,6 +65,12 @@
ln -sf $(MINLIBNAME) $(MAJLIBNAME)
ln -sf $(MAJLIBNAME) $(LIBNAME)
+libcap_wrap.c: include/sys/capability.h
+ swig -python -o libcap_wrap.c include/sys/capability.h
+
+$(PYTHONMODNAME): $(OBJS) libcap_wrap.o
+ $(LD) -x -shared -o $@ libcap_wrap.o $(OBJS)
+
%.o: %.c $(INCLS)
$(CC) $(CFLAGS) -c $< -o $@
@@ -71,10 +82,14 @@
ln -sf $(MINLIBNAME) $(LIBDIR)/$(MAJLIBNAME)
ln -sf $(MAJLIBNAME) $(LIBDIR)/$(LIBNAME)
-/sbin/ldconfig
+ifdef PYTHON
+ mkdir -p $(PYTHONMODDIR)
+ install -m 0644 $(PYTHONMODNAME) $(PYTHONMODDIR)/$(PYTHONMODNAME)
+endif
clean:
$(LOCALCLEAN)
rm -f $(OBJS) $(LIBNAME)*
- rm -f cap_names.h cap_names.sed _makenames
+ rm -f cap_names.h cap_names.sed _makenames libcap_wrap.c
cd include/sys && $(LOCALCLEAN)
diff -Nur libcap-1.10/Make.Rules libcap-1.10-python/Make.Rules
--- libcap-1.10/Make.Rules 1999-11-18 07:06:02.000000000 +0100
+++ libcap-1.10-python/Make.Rules 2002-07-26 14:03:26.000000000 +0200
@@ -33,6 +33,7 @@
SBINDIR=$(FAKEROOT)$(exec_prefix)/sbin
INCDIR=$(FAKEROOT)$(inc_prefix)/include
LIBDIR=$(FAKEROOT)$(lib_prefix)/lib
+PYTHONMODDIR=$(FAKEROOT)$(prefix)/lib/python/site-packages
# common defines for libcap (suitable for 2.2.1+ Linux kernels)
VERSION=1
|