Code Monkey home page Code Monkey logo

minisudo's Introduction

minisudo Build status

This is a small sudo-like privilege escalator for Unix-like operating systems.

It was written for learning, not to replace sudo, and has been tested on macOS and Linux.

$ minisudo whoami
Password for ben: [password hidden]
root

This project was inspired by kibi, a text editor written in ≤1024 lines of code. I’ve seen many people with the false impression that sudo is “magical” or special in some way, but it doesn’t do anything that’s not available to any other program. minisudo tries to implement its most popular use case — running programs as root after checking against a list of rules — with a couple pages of code and minimal dependencies.

Installation

minisudo is written in Rust, and uses just as its build script runner. To build and install:

$ just build
$ sudo just install

To uninstall:

$ sudo just uninstall

Debian users will need to have the libpam0g-dev package installed.

How it works

minisudo uses PAM as its authentication mechanism, which is how it knows what your password is. It installs a file into /etc/pam.d to allow it to do this.

The binary is installed with the setuid bit set, which is how it’s able to run programs as root.

Rules file

The rules for which users can run which programs are specified in a TOML file, /etc/minisudo-rules.toml. Here’s an example:

# The user ‘ben’ can run ‘ls’, but nothing else.
[[rule]]
user = "ben"
program = "/bin/ls"

# All members of the ‘staff’ group can run ‘whoami’, but nothing else.
[[rule]]
group = "staff"
program = "/usr/bin/whoami"

Binaries must be specified by their full path, not just their basename. Specify * to allow any program to be run.

Safety

Although no unsafe Rust code is present in the minisudo crate itself, its dependencies call functions in PAM and libc, so the project can never be entirely free of unsafe code.

Security vulnerabilities

Probably.

Licence

minisudo’s source code is under the MIT Licence.

minisudo's People

Contributors

ogham avatar

Watchers

 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.