GithubHelp home page GithubHelp logo

nsexec's Introduction

nsexec

Just like nsenter, nsexec run program in different namespaces.

The most significant benefit of nsexec is that it can run binaries that don't exist in the target namespace. For example, if the target namespace is a distroless image, the ls, bash and cat don't exist.

Example

nsexec -m /proc/xxxx/ns/mnt -l /bin/bash

The option --library-path should be set to the path of libnsenter.so. If you compile nsexec with cargo build --release --all, you can find it in ./target/release/libnsenter.so. The default library-path is /usr/local/lib/libnsenter.so

The option -l, --local means to load the binaries from the current mnt namespace (but not target namespace).

Implementation

nsexec has a lot of limitations. The best way to understand the limitation is to know the implementation and choose whether to use it in your situation.

Without -l, --local, the implementation is calling setns directly and spawn a new child process, which is nearly the same as nsenter.

With -l, --local, we will not call setns to set mount namespace in nsexec. Instead, nsexec will modify the LD_PRELOAD environment variable of the child process to preload a dynamic library. The library, as shown in /nsenter/src/lib.rs, will call setns to set mount namespace in the constructor.

Note

nsexec will also bypass some signals such as SIGTERM and SIGINT to the child process, for the convenience of killing processes.

nsexec's People

Contributors

yangkeao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.