Skip to content
Snippets Groups Projects
Commit e2184ffb authored by nimrod's avatar nimrod
Browse files

First commit.

parents
No related branches found
No related tags found
No related merge requests found
*~
~*
*.swp
*.swo
*.pyc
.DS_Store
build/
dist/
*.egg-info/
__pycache__/
*.log
.tox
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: cf550fcab3f12015f8676b8278b30e1a5bc10e70
hooks:
- id: check-added-large-files
- id: check-json
- id: check-xml
- id: check-yaml
- id: check-merge-conflict
- id: flake8
recursive-include unshare
exclude .pre-commit-config.yaml
Makefile 0 → 100644
.PHONY: clean test all
all: unshare/constants.py
unshare/constants.py:
# For now ignore MS_RMT_MASK macro.
echo '#include <linux/fs.h>\n#include <linux/sched.h>' | \
gcc -E -dM - | \
grep -v 'MS_RMT_MASK' | \
awk '/#define MS_|#define CLONE_/ {print $$2, "=", $$3}' > unshare/constants.py
clean:
rm -rf unshare/constants.py *.pyc __pycache__ unshare/*.pyc unshare/__pycache__
test: clean all
python test.py
python3 test.py
python-unshare
##############
This is a pure-Python module for accessing libc functions and macros needed
for dealing with Linux namespaces.
[bdist_wheel]
# This flag says that the code is written to work on both Python 2 and Python
# 3. If at all possible, it is good practice to do this. If you cannot, you
# will need to generate wheels for each Python version that you support.
universal=1
setup.py 0 → 100644
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
name='unshare',
version='0.2.0',
description='Pure Python Linux namespace management.',
long_description=open('README.rst', 'r').read(),
url='https://www.shore.co.il/git/python-unshare',
author='Nimrod Adar',
author_email='nimrod@shore.co.il',
license='MIT',
classifiers=[
'Development status :: 3 - Alpha',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 2.7',
'Intended Audience :: System Administrators',
'Topic :: Utilities',
],
keywords='containers namespace linux',
packages=find_packages(exclude=['tests']),
install_requires=[],
extras_require={
'dev': ['tox'],
'test': ['flake8', 'check-manifest', 'coverage', 'pytest']},
)
import unshare
def import_assestions():
for macro in 'CLONE_NEWUTS', 'MS_SHARED':
assert macro in dir(unshare)
for function in 'clone', 'pivot_root':
assert function in dir(unshare)
tox.ini 0 → 100644
[tox]
envlist = py{27,35}
[testenv]
basepython =
py27: python2.7
py35: python3.5
deps =
check-manifest
{py27,py35}: readme_renderer
flake8
commands =
check-manifest --ignore tox.ini,tests*
# py26 doesn't have "setup.py check"
{py27,py35}: python setup.py check -m -r -s
flake8 .
py.test tests
[flake8]
ignore=F403
exclude = .tox,*.egg,build,data,unshare/constants.py
select = E,W,F
#!/usr/bin/env python
import ctypes
try:
from constants import *
except ImportError:
try:
from unshare.constants import *
except BaseException as e:
raise e
libc = ctypes.CDLL('libc.so.6')
umount = libc.umount
umount2 = libc.umount2
mount = libc.mount
unshare = libc.unshare
pivot_root = libc.pivot_root
setns = libc.setns
sethostname = libc.sethostname
clone = libc.clone
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment