All Projects → zalando → Python Nsenter

zalando / Python Nsenter

Licence: other
Enter kernel namespaces from Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Python Nsenter

Kmon
Linux Kernel Manager and Activity Monitor 🐧💻
Stars: ✭ 1,142 (+813.6%)
Mutual labels:  linux-kernel
Udev Joystick Blacklist
Fix for keyboard/mouse/tablet being detected as joystick in Linux
Stars: ✭ 97 (-22.4%)
Mutual labels:  linux-kernel
Liquorix Package
Liquorix Debian Package
Stars: ✭ 114 (-8.8%)
Mutual labels:  linux-kernel
Kernel Exploits
My proof-of-concept exploits for the Linux kernel
Stars: ✭ 1,173 (+838.4%)
Mutual labels:  linux-kernel
Thoron
Thoron Framework is a Linux post-exploitation framework that exploits Linux TCP vulnerability to provide a shell-like connection. Thoron Framework has the ability to create simple payloads to provide Linux TCP attack.
Stars: ✭ 87 (-30.4%)
Mutual labels:  linux-kernel
Fpga Soc Linux
FPGA+SoC+Linux+Device Tree Overlay+FPGA Manager U-Boot&Linux Kernel&Debian10 Images (for Xilinx:Zynq-Zybo:PYNQ-Z1 Altera:de0-nano-soc)
Stars: ✭ 106 (-15.2%)
Mutual labels:  linux-kernel
Traceshark
This is a tool for Linux kernel ftrace and perf events visualization
Stars: ✭ 63 (-49.6%)
Mutual labels:  linux-kernel
Ndctl
Helper tools and libraries for managing the libnvdimm (non-volatile memory device) sub-system in the Linux kernel
Stars: ✭ 122 (-2.4%)
Mutual labels:  linux-kernel
Lpic 1 Anki Flashcards
Deck of Anki flashcards for the LPIC-1 (Linux System Administrator) exams 101 and 102 of the Linux Professional Institute (LPI).
Stars: ✭ 90 (-28%)
Mutual labels:  linux-kernel
Ckernel
中国Linux内核开发者大会
Stars: ✭ 115 (-8%)
Mutual labels:  linux-kernel
Linux Baytrail Flexx10
Install GNU/Linux on NextBook Flexx 10.1
Stars: ✭ 73 (-41.6%)
Mutual labels:  linux-kernel
Linux 0.11
A heavily commented linux kernel source code in Chinese.
Stars: ✭ 81 (-35.2%)
Mutual labels:  linux-kernel
Ltp
Linux Test Project http://linux-test-project.github.io/
Stars: ✭ 1,654 (+1223.2%)
Mutual labels:  linux-kernel
Cubostratus
Blazingly fast Linux syscall collector
Stars: ✭ 68 (-45.6%)
Mutual labels:  linux-kernel
Raspberry Pi Os
Learning operating system development using Linux kernel and Raspberry Pi
Stars: ✭ 11,000 (+8700%)
Mutual labels:  linux-kernel
Simplefs
A simple file system for Linux kernel
Stars: ✭ 65 (-48%)
Mutual labels:  linux-kernel
Xia For Linux
XIA implementation for the Linux kernel
Stars: ✭ 98 (-21.6%)
Mutual labels:  linux-kernel
Kernel Roulette
A kernel module written in Rust
Stars: ✭ 124 (-0.8%)
Mutual labels:  linux-kernel
Huawei Wmi
Huawei WMI laptop extras linux driver
Stars: ✭ 120 (-4%)
Mutual labels:  linux-kernel
Virtualcar
A virtual car. Because you wouldn't download a car, would you?
Stars: ✭ 114 (-8.8%)
Mutual labels:  linux-kernel

======= NSEnter

.. image:: https://travis-ci.org/zalando/python-nsenter.svg?branch=master :target: https://travis-ci.org/zalando/python-nsenter :alt: Travis CI build status

NSEnter is a Python package that enables you to enter Linux kernel namespaces — mount, IPC, net, PID, user and UTS — with a single, simple "setns" syscall. The command line interface is similar to the nsenter_ C program.

Project Origins

When working with Docker_ containers, questions usually arise about how to connect into a running container without starting an explicit SSH daemon (which is considered a bad idea_). One way is to use Linux Kernel namespaces, which Docker uses to restrict the view from within containers.

The util-linux package provides the nsenter command line utility, but Ubuntu 16.04 LTS_ unfortunately does not. Jérôme Petazzoni provides a Docker recipe_ for nsenter on GitHub, or you can compile nsenter from source_. As there is only one simple syscall to enter a namespace, we can do the call directly from within Python using the ctypes module. We bundled this syscall to create NSEnter.

Additional Links

- "Entering Kernel Namespaces from Python," Zalando Tech `blog post`_
- On PyPi_

Requirements
````````````
- Python 2.6 or higher

Installation
````````````
From PyPI::

    sudo pip3 install nsenter

From git source::

    python3 setup.py install

Usage
`````
Example of command line usage::

    docker run -d --name=redis -t redis
    sudo nsenter --all --target=`docker inspect --format '{{ .State.Pid }}' redis` /bin/bash


Example of usage from Python:

.. code:: python

    import subprocess
    from nsenter import Namespace

    with Namespace(mypid, 'net'):
        # output network interfaces as seen from within the mypid's net NS:
        subprocess.check_output(['ip', 'a'])

    # or enter an arbitrary namespace:
    with Namespace('/var/run/netns/foo', 'net'):
        # output network interfaces as seen from within the net NS "foo":
        subprocess.check_output(['ip', 'a'])

Development Status

This project works as-is. There are currently no plans to extend it, but if you have an idea please submit an Issue to the maintainers.

License

See file_.

.. _Docker: https://www.docker.com/ .. _which is considered a bad idea: https://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/ .. _Ubuntu 16.04 LTS: https://askubuntu.com/questions/439056/why-there-is-no-nsenter-in-util-linux .. _Docker recipe: https://github.com/jpetazzo/nsenter .. _from source: https://askubuntu.com/questions/439056/why-there-is-no-nsenter-in-util-linux .. _nsenter: http://man7.org/linux/man-pages/man1/nsenter.1.html .. _blog post: http://tech.zalando.com/posts/entering-kernel-namespaces-with-python.html .. _PyPi: https://pypi.python.org/pypi/nsenter .. _file: https://github.com/zalando/python-nsenter/blob/master/LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].