This commit is contained in:
Pan Qiancheng 2025-03-26 10:08:21 +08:00
parent 5415afe3e1
commit 1da5206101
2 changed files with 47 additions and 1 deletions

46
README.md Normal file
View File

@ -0,0 +1,46 @@
# 拦截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则这里的参数必须全部存在
}
]
```

View File

@ -13,6 +13,6 @@
"cmd": "pip",
"type": "warn",
"msg": "使用pip安装torch时请注意使用厂家支持版本",
"params": ["install", "torch"]
"args": ["install", "torch"]
}
]