A noncompulsory access management CLI tool for shared machines.
Project description
轻量级权限管理工具:grantme || Lightweight access management tool: grantme
grantme是一个用python写的轻量级机器访问管理命令行工具。它可以授权用户一定时限内的共享访问权限(如,用于debug)和独占访问权限(如,用于性能测试),从而共享同一台机器的用户可以协调机器使用。它是非强制、纯建议性的因为它不能放置恶意用户无视访问权限授权地使用机器。
grantme is a lightweight machine access management CLI tool written in Python.
It can grant timed shared access (e.g., for debugging) and exclusive access (e.g., for performance evaluation) to individual users so that when users of shared machines can coordinate their usage.
It is noncompulsory and purely advisory because it cannot prevent malicious users from ignoring the access granted.
使用方式 || Usage
规则 || Rules
-
当未授权任何访问权限时,用户可任意获取共享或独占全县。
When no access is granted, users can require either shared or exclusive access.
-
当已授予共享访问时,未授权用户可获取共享权限。若仅一位用户被授予共享权限,该用户可升级其为独占权限。
When some shared access is granted, other users can require additional shared access. When there is only one user granted with shared access, that user can upgrade his/her access to be exclusive.
-
当已授予独占访问时,未授权用户不可获取任何权限。
When exclusive access is granted, other users cannot require any access.
-
权限在过期后自动失效。已授予权限的用户可提前放弃或延长所持有权限。
Grated access expires after given duration. Users with granted access can early revoke or prolong their access.
返回值 || Return values
grantme根据操作结果返回相应值。
grantme returns values according to operation results.
- 0:成功 || Success
- 6:升级权限失败 || Failed to upgrade access
- 7:获取权限失败 || Failed to obtain access
- 255:其他错误 || Other errors
这些返回值可于集成grantme于其他脚本(如,自动化测试)。
These return values can be used for integrating grantme into other scripts (e.g., automatic testing).
#!/bin/bash
./grantme --mode exclusive --duration 1h
if [ $? -ne 0 ]
then
echo "I can't get the lock, cry cry."
exit 1
fi
# do work
./grantme --revoke
依赖 || Requirements
grantme要求Python 3.7级以上版本。用户登陆是自动打印授权状态功能需要Ubuntu Linux发行版。
grantme requires Python 3.7+.
Automatically printing access status upon user login requires Ubuntu Linux distribution.
安装与卸载 || Installation and uninstallation
安装并初始化:
To install and initialize:
pip3 install grantme
grantme --init # 可能需要sudo权限 || potentially requires sudo privilege
grantme --init会创建/var/lib/grantme目录,并在Ubuntu Linux发行版下在/etc/update-motd.d生成<NN>-grantme-status(<NN>数字,具体值由机器状态决定)脚本文件用于用户登录时打印授权状态。卸载时需手动删除:
grantme --init creates /var/lib/grantme directory,and under Ubuntu Linux distribution it creates <NN>-grantme-status (<NN> are numbers, whose exact values depend on the machines) script file under /etc/update-motd.d directory for automatically printing access status upon user login.
To uninstall, you need to manually remove them:
# 可能需要sudo权限 || potentially requires sudo privilege
rm -r /var/lib/grantme
rm /etc/update-motd.d/<NN>-grantme-status # 将<NN>替换为具体数值 || replace <NN> with the actual numbers
参与开发 || Contribute
目前,grantme由个人维护。欢迎用户提交缺陷报告和Pull Request。
Currently, grantme is maintained by an individual.
Bug reports and pull requests are welcomed.
测试 || Testing
在项目根目录下执行以下命令以运行测试。
Execute the following command in the project's root directory to run tests.
python -m unittest discover
增加新功能、修补漏洞后请在tests目录下增加或修改相应测试。在所有测试通过后提交Pull Request。
Please add or modify test cases under the tests directory when adding new features or fixing bugs.
Make sure all tests have passed before submitting pull requests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grantme-0.1.0.tar.gz.
File metadata
- Download URL: grantme-0.1.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
965725548eea5237809731e5bddada42518296ff4ea750b5327de6ab9de614f1
|
|
| MD5 |
5dc82948013fb668b1e3c43b33c5a47b
|
|
| BLAKE2b-256 |
10a3dfe2d74dd06d405dbbf7b6eaafca4dd9d0005af8ac55104d3debba66a923
|
File details
Details for the file grantme-0.1.0-py3-none-any.whl.
File metadata
- Download URL: grantme-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba9d82cc92892d07e0f07e7b6303b91678e3735046f3ffb625d47f1b45e92d07
|
|
| MD5 |
d7e8cb22c30bcb279261a6f093369612
|
|
| BLAKE2b-256 |
0577699a5518eff7b36fac8e641ca2b2685b5889598f2134d4aa9b5312105526
|