vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
|
215f8aeb
Keenan Nemetz
2d ago
|
1 | //go:build unix |
| 2 | ||
| 3 | package audit | |
| 4 | ||
| 5 | import ( | |
| 6 | "fmt" | |
| 7 | "io/fs" | |
| 8 | "os" | |
| 9 | "syscall" | |
| 10 | ||
| 11 | "rodent.software/vole/internal/secure" | |
| 12 | ) | |
| 13 | ||
| 14 | // verifySecretFile checks the two properties that make the log trustworthy: the | |
| 15 | // file is 0600 and this account owns it. Either one missing lets someone outside | |
| 16 | // the service read the log, or change whether privileged actions are recorded. | |
| 17 | // The platforms without unix file modes refuse to start instead; see | |
| 18 | // verifySecretFile in verify_other.go. | |
| 19 | func verifySecretFile(path string, st fs.FileInfo) error { | |
| 20 | if perm := st.Mode().Perm(); perm != secure.FileMode { | |
| 21 | return fmt.Errorf("audit: %s is %04o, expected %04o", path, perm, secure.FileMode) | |
| 22 | } | |
| 23 | if sys, ok := st.Sys().(*syscall.Stat_t); ok && int(sys.Uid) != os.Geteuid() { | |
| 24 | return fmt.Errorf("audit: %s is owned by uid %d, expected %d", path, sys.Uid, os.Geteuid()) | |
| 25 | } | |
| 26 | return nil | |
| 27 | } |