pysyslimit
is a light-weight library which can manage the permission in linux system.
Just install this package with the pip command
pip install pysyslimit
For further information, take a look at the Installation Page.
Please attention that many function in this library need root permission, so It is strongly recommended to run this with root.
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
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--
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
We appreciate all contributions to improve pysyslimit
,both logic and system designs. Please refer to CONTRIBUTING.md for more guides.
pysyslimit
released under the Apache 2.0 license.