aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-17 17:10:03 +0900
committerOphestra <cat@gensokyo.uk>2025-03-17 17:10:03 +0900
commit7c063833e01930b4b298a59363b783ab32cc0e41 (patch)
tree2e867242f35f74978905e7165b3b0e092af707ff /internal
parentaf3619d440d2d9c5bc0340653e4dd7cf98275e4a (diff)
internal/sys: wrap getuid/getgid
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/app/app_stub_test.go3
-rw-r--r--internal/sys/interface.go8
-rw-r--r--internal/sys/std.go3
3 files changed, 9 insertions, 5 deletions
diff --git a/internal/app/app_stub_test.go b/internal/app/app_stub_test.go
index 262055fe..be496177 100644
--- a/internal/app/app_stub_test.go
+++ b/internal/app/app_stub_test.go
@@ -17,7 +17,8 @@ type stubNixOS struct {
usernameErr map[string]error
}
-func (s *stubNixOS) Geteuid() int { return 1971 }
+func (s *stubNixOS) Getuid() int { return 1971 }
+func (s *stubNixOS) Getgid() int { return 100 }
func (s *stubNixOS) TempDir() string { return "/tmp" }
func (s *stubNixOS) MustExecutable() string { return "/run/wrappers/bin/fortify" }
func (s *stubNixOS) Exit(code int) { panic("called exit on stub with code " + strconv.Itoa(code)) }
diff --git a/internal/sys/interface.go b/internal/sys/interface.go
index 0d2ebaf3..935cee5c 100644
--- a/internal/sys/interface.go
+++ b/internal/sys/interface.go
@@ -12,8 +12,10 @@ import (
// State provides safe interaction with operating system state.
type State interface {
- // Geteuid provides [os.Geteuid].
- Geteuid() int
+ // Getuid provides [os.Getuid].
+ Getuid() int
+ // Getgid provides [os.Getgid].
+ Getgid() int
// LookupEnv provides [os.LookupEnv].
LookupEnv(key string) (string, bool)
// TempDir provides [os.TempDir].
@@ -47,7 +49,7 @@ type State interface {
// CopyPaths is a generic implementation of [System.Paths].
func CopyPaths(os State, v *fst.Paths) {
- v.SharePath = path.Join(os.TempDir(), "fortify."+strconv.Itoa(os.Geteuid()))
+ v.SharePath = path.Join(os.TempDir(), "fortify."+strconv.Itoa(os.Getuid()))
fmsg.Verbosef("process share directory at %q", v.SharePath)
diff --git a/internal/sys/std.go b/internal/sys/std.go
index 132f4c13..5e63396b 100644
--- a/internal/sys/std.go
+++ b/internal/sys/std.go
@@ -31,7 +31,8 @@ type Std struct {
uidMu sync.RWMutex
}
-func (s *Std) Geteuid() int { return os.Geteuid() }
+func (s *Std) Getuid() int { return os.Getuid() }
+func (s *Std) Getgid() int { return os.Getgid() }
func (s *Std) LookupEnv(key string) (string, bool) { return os.LookupEnv(key) }
func (s *Std) TempDir() string { return os.TempDir() }
func (s *Std) LookPath(file string) (string, error) { return exec.LookPath(file) }