execve_hook/README.md

47 lines
973 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 拦截execve系统调用以达到对用户命令执行检查的功能
## 前置依赖:
- jsonc
```bash
# Ubuntu/Debian
sudo apt-get install libjson-c-dev
# CentOS/RHEL
sudo yum install json-c-devel
```
## 编译:
- cd execve_hook && make
## 测试:
- ./test_bash.sh
## 配置文件格式:
```json
[
{
"cmd": "nvidia-smi", // 将匹配的命令
"type": "warn", // 如果为warn则会提示是否继续执行
"msg": "在沐曦环境下请执行mx-smi" // 提示信息
},
{
"cmd": "rm", // 匹配的命令
"type": "error", // 如果为error则会拦截命令执行
"msg": "Error: rm command is forbidden" // 提示信息
},
{
"cmd": "pip", // 匹配的命令
"type": "warn",
"msg": "使用pip安装torch时请注意使用厂家支持版本",
"args": ["install", "torch"] //当存在args则这里的参数必须全部存在
}
]
```