forked from seveas/python-prctl
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
executable file
·74 lines (64 loc) · 2.31 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·74 lines (64 loc) · 2.31 KB
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
#!/usr/bin/python
fromdistutils.coreimportsetup, Extension
importglob
importos
importsubprocess
importsys
# Check our environment
# - Need to be on linux
# - Need kernel 2.6.18+
# - Need python 2.4+
# - Need gcc
# - Need C headers
# - Need libcap headers
ifnotsys.platform.startswith('linux'):
sys.stderr.write("This module only works on linux\n")
sys.exit(1)
kvers=os.uname()[2]
ifkvers<'2.6.18'andnotos.environ.get("PRCTL_SKIP_KERNEL_CHECK",False):
sys.stderr.write("This module requires linux 2.6.18 or newer\n")
sys.exit(1)
ifsys.version_info[:2] < (2,4):
sys.stderr.write("This module requires python 2.4 or newer\n")
sys.exit(1)
exit=False
try:
subprocess.call(['gcc','-v'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except:
sys.stderr.write("You need to install gcc to build this module\n")
sys.exit(1)
sp=subprocess.Popen(['cpp'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sp.communicate('#include <sys/prctl.h>\n'.encode())
ifsp.returncode:
sys.stderr.write("You need to install libc development headers to build this module\n")
exit=True
sp=subprocess.Popen(['cpp'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sp.communicate('#include <sys/capability.h>\n'.encode())
ifsp.returncode:
sys.stderr.write("You need to install libcap development headers to build this module\n")
exit=True
ifexit:
sys.exit(1)
_prctl=Extension("_prctl",
sources= ['_prctlmodule.c'],
depends= ['securebits.h'],
libraries= ['cap'])
setup(name="python-prctl",
version="1.6.1",
author="Dennis Kaarsemaker",
author_email="dennis@kaarsemaker.net",
url="http://github.com/seveas/python-prctl",
description="Python(ic) interface to the linux prctl syscall",
py_modules= ["prctl"],
ext_modules= [_prctl],
classifiers= [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: POSIX :: Linux',
'Programming Language :: C',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Security',
]
)