Go to file
Pan Qiancheng 8585aafc7c welcome2 2025-03-26 16:43:06 +08:00
config README 2025-03-26 10:08:21 +08:00
logs logs 2025-03-26 16:24:42 +08:00
Makefile init 2025-03-26 09:58:34 +08:00
README.md README 2025-03-26 10:08:21 +08:00
execve_intercept.c hand write tee 2025-03-26 16:15:14 +08:00
intercept.so hand write tee 2025-03-26 16:15:14 +08:00
test_bash.sh welcome2 2025-03-26 16:43:06 +08:00

README.md

拦截execve系统调用以达到对用户命令执行检查的功能

前置依赖:

  • jsonc
# Ubuntu/Debian
sudo apt-get install libjson-c-dev

# CentOS/RHEL
sudo yum install json-c-devel

编译:

  • cd execve_hook && make

测试:

  • ./test_bash.sh

配置文件格式:

[
    {
        "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则这里的参数必须全部存在
    }
]