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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file pysyslimit-0.5.0.tar.gz.

File metadata

  • Download URL: pysyslimit-0.5.0.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pysyslimit-0.5.0.tar.gz
Algorithm Hash digest
SHA256 3d75d5e4fe7ac23250b16db215a73a8056238b33a8970507edf1befe227a1d06
MD5 fecbc3dc72a939546411a041c93d72c9
BLAKE2b-256 d84aa1fa1e3245da2daad02e01ea2dc60452b645f4d317491995b1db44a6cbcb

See more details on using hashes here.

File details

Details for the file pysyslimit-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pysyslimit-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pysyslimit-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85be9e35608a07ab7e31a5d0902a81e8637f46c29b01ca64085928096ab89ad8
MD5 ef98f54f3f5c98dd09e968a053c9eac7
BLAKE2b-256 ba62f248858790a4d4175055908f581defaf031c208c4d81b1e30beecd09e2a1

See more details on using hashes here.

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