1 |
commit: 126136fabaa7f90ff7d987ae6453ba0d1bb5f720 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Nov 27 00:17:19 2011 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Nov 27 00:17:19 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=126136fa |
7 |
|
8 |
scripts/{setup.py,paxmodule.c}: build with/without xattr support |
9 |
|
10 |
--- |
11 |
scripts/paxmodule.c | 17 +++++++++++++++++ |
12 |
scripts/setup.py | 22 +++++++++++++++++----- |
13 |
2 files changed, 34 insertions(+), 5 deletions(-) |
14 |
|
15 |
diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c |
16 |
index a106ff5..b665412 100644 |
17 |
--- a/scripts/paxmodule.c |
18 |
+++ b/scripts/paxmodule.c |
19 |
@@ -21,7 +21,10 @@ |
20 |
#include <string.h> |
21 |
|
22 |
#include <gelf.h> |
23 |
+ |
24 |
+#ifdef XATTR |
25 |
#include <attr/xattr.h> |
26 |
+#endif |
27 |
|
28 |
#include <sys/types.h> |
29 |
#include <sys/stat.h> |
30 |
@@ -29,7 +32,10 @@ |
31 |
#include <unistd.h> |
32 |
|
33 |
#define BUF_SIZE 7 //Buffer size for holding human readable flags |
34 |
+ |
35 |
+#ifdef XATTR |
36 |
#define PAX_NAMESPACE "user.pax" |
37 |
+#endif |
38 |
|
39 |
|
40 |
static PyObject * pax_getflags(PyObject *, PyObject *); |
41 |
@@ -106,6 +112,7 @@ get_pt_flags(int fd) |
42 |
} |
43 |
|
44 |
|
45 |
+#ifdef XATTR |
46 |
uint16_t |
47 |
get_xt_flags(int fd) |
48 |
{ |
49 |
@@ -114,6 +121,7 @@ get_xt_flags(int fd) |
50 |
fgetxattr(fd, PAX_NAMESPACE, &xt_flags, sizeof(uint16_t)); |
51 |
return xt_flags; |
52 |
} |
53 |
+#endif |
54 |
|
55 |
|
56 |
void |
57 |
@@ -161,6 +169,7 @@ pax_getflags(PyObject *self, PyObject *args) |
58 |
return NULL; |
59 |
} |
60 |
|
61 |
+#ifdef XATTR |
62 |
flags = get_xt_flags(fd); |
63 |
if( flags != UINT16_MAX ) |
64 |
{ |
65 |
@@ -169,13 +178,16 @@ pax_getflags(PyObject *self, PyObject *args) |
66 |
} |
67 |
else |
68 |
{ |
69 |
+#endif |
70 |
flags = get_pt_flags(fd); |
71 |
if( flags != UINT16_MAX ) |
72 |
{ |
73 |
memset(buf, 0, BUF_SIZE); |
74 |
bin2string(flags, buf); |
75 |
} |
76 |
+#ifdef XATTR |
77 |
} |
78 |
+#endif |
79 |
|
80 |
close(fd); |
81 |
|
82 |
@@ -237,11 +249,13 @@ set_pt_flags(int fd, uint16_t pt_flags) |
83 |
} |
84 |
|
85 |
|
86 |
+#ifdef XATTR |
87 |
void |
88 |
set_xt_flags(int fd, uint16_t xt_flags) |
89 |
{ |
90 |
fsetxattr(fd, PAX_NAMESPACE, &xt_flags, sizeof(uint16_t), 0); |
91 |
} |
92 |
+#endif |
93 |
|
94 |
|
95 |
static PyObject * |
96 |
@@ -266,7 +280,10 @@ pax_setflags(PyObject *self, PyObject *args) |
97 |
flags = (uint16_t) iflags; |
98 |
|
99 |
set_pt_flags(fd, flags); |
100 |
+ |
101 |
+#ifdef XATTR |
102 |
set_xt_flags(fd, flags); |
103 |
+#endif |
104 |
|
105 |
close(fd); |
106 |
|
107 |
|
108 |
diff --git a/scripts/setup.py b/scripts/setup.py |
109 |
index 3170930..40aecdb 100755 |
110 |
--- a/scripts/setup.py |
111 |
+++ b/scripts/setup.py |
112 |
@@ -1,12 +1,24 @@ |
113 |
#!/usr/bin/env python |
114 |
|
115 |
+import os |
116 |
from distutils.core import setup, Extension |
117 |
|
118 |
-module1 = Extension( |
119 |
- name='pax', |
120 |
- sources = ['paxmodule.c'], |
121 |
- libraries = ['elf', 'attr'], |
122 |
-) |
123 |
+xattr = os.getenv('XATTR') |
124 |
+ |
125 |
+if xattr != None: |
126 |
+ module1 = Extension( |
127 |
+ name='pax', |
128 |
+ sources = ['paxmodule.c'], |
129 |
+ libraries = ['elf', 'attr'], |
130 |
+ define_macros = [('XATTR', None)] |
131 |
+ ) |
132 |
+else: |
133 |
+ module1 = Extension( |
134 |
+ name='pax', |
135 |
+ sources = ['paxmodule.c'], |
136 |
+ libraries = ['elf'], |
137 |
+ undef_macros = ['XATTR'] |
138 |
+ ) |
139 |
|
140 |
setup( |
141 |
name = 'PaxPython', |