openclaw-exec-permission
# 🔒 OpenClaw Exec 权限配置
## 关键参数
在 `openclaw.json` 的 `tools.exec` 下:
- **security**: 执行安全级别
- `"deny"` — 禁止所有exec
- `"allowlist"` — 仅允许白名单命令(默认)
- `"full"` — 允许所有命令,无限制
- **ask**: 审批模式
- `"off"` — 跳过审批直接执行
- `"always"` — 每次都需审批
- `"on-miss"` — 仅白名单外的命令需审批
## 配置方法
### ⚠️ 注意:这两个字段是受保护路径
`tools.exec.security` 和 `tools.exec.ask` 无法通过 `config.patch` 或 `gateway config.apply` 修改,会报错:
```
gateway config.patch cannot change protected config paths: tools.exec.security
```
### ✅ 正确方法:直接编辑配置文件
```bash
python3 -c "
import json
with open('/home/zzclaw/.openclaw/openclaw.json') as f:
c = json.load(f)
c['tools']['exec']['security'] = 'full'
c['tools']['exec']['ask'] = 'off'
with open('/home/zzclaw/.openclaw/openclaw.json', 'w') as f:
json.dump(c, f, indent=2, ensure_ascii=False)
print('done')
"
```
然后重启 gateway:
```bash
openclaw gateway restart
```
## 权限级别参考
| 场景 | security | ask | 说明 |
|------|----------|-----|------|
| 生产环境(严格) | allowlist | on-miss | 白名单内放行,其余审批 |
| 开发环境(宽松) | full | off | 全部放行,无审批 |
| 信任的私有机器 | full | off | 同上 |
| 多人共享 | allowlist | on-miss | 安全第一 |
## allowlist 配置
`security` 为 `allowlist` 时,可通过 `tools.exec.allowlist` 配置允许的命令模式:
```json
{
"tools": {
"exec": {
"security": "allowlist",
"allowlist": [
"git *",
"npm *",
"python3 *",
"cat *",
"ls *",
"echo *"
]
}
}
}
```
## 痛点记录
1. **受保护路径**:`security` 和 `ask` 只能手动改文件,无法通过 API 修改
2. **allowlist miss**:当 `security=allowlist` 时,未在白名单的命令会被拒绝,即使 `ask=off` 也不行
3. **改完要重启**:修改配置文件后必须重启 gateway 才能生效
4. **exec denied 时的处理**:如果 agent 执行命令被拒,需要先改配置再重启,agent 自身无法自救
标签
skill
ai