Skip to main content

Python library which can manage linux permissions.

Project description

pysyslimit

PyPI PyPI - Python Version Loc Comments

Docs Deploy Code Test Badge Creation Package Release codecov

GitHub stars GitHub forks GitHub commit activity GitHub issues GitHub pulls Contributors GitHub license

pysyslimit is a light-weight library which can manage the permission in linux system.

Installation

Just install this package with the pip command

pip install pysyslimit

For further information, take a look at the Installation Page.

Quick Start

Please attention that many function in this library need root permission, so It is strongly recommended to run this with root.

Take a look at who I am

from pysyslimit import *

if __name__ == "__main__":
    print("current user:", SystemUser.current())
    print("current user's groups:", SystemUser.current().groups)
    print("current group:", SystemGroup.current())

The output should be

current user: root
current user's groups: [<SystemGroup root, id: 0>]
current group: root

Get and update the permission of files

from pysyslimit import *

if __name__ == "__main__":
    print(FilePermission.load_from_file("test_file"))

    chmod_del("test_file", "004")
    print(FilePermission.load_from_file("test_file"))

    chmod_add("test_file", "014")
    print(FilePermission.load_from_file("test_file"))

The output shall be

rw-rw-r--
rw-rw----
rw-rwxr--

Do calculation between permissions

from pysyslimit import *

if __name__ == "__main__":
    print(FilePermission.loads('463') + FilePermission.loads('615'))
    print(FilePermission.loads('463') | FilePermission.loads('615'))  # the same as +
    print(FilePermission.loads('463') - FilePermission.loads('615'))
    print(FilePermission.loads('463') & FilePermission.loads('615'))

The output shall be

rw-rwxrwx
rw-rwxrwx
---rw--w-
r-------x

Contributing

We appreciate all contributions to improve pysyslimit ,both logic and system designs. Please refer to CONTRIBUTING.md for more guides.

License

pysyslimit released under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysyslimit-0.5.0.tar.gz (17.6 kB view hashes)

Uploaded Source

Built Distribution

pysyslimit-0.5.0-py3-none-any.whl (23.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page