# 错误：打开 /etc/shadow：权限被拒绝

- **ID:** `go/os-file-permission-denied`
- **领域:** go
- **类别:** auth_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

进程没有打开文件所需的文件系统权限，通常由于以非root用户运行。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## 解决方案

1. **Check permissions before opening and use appropriate user or sudo** (85% 成功率)
   ```
   if os.Geteuid() != 0 { return errors.New("must run as root") }
f, err := os.Open("/etc/shadow")
   ```

## 无效尝试

- **Running entire application as root** — Security risk; better to use capabilities or proper user. (30% 失败率)
