aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-18 17:35:20 +0900
committerOphestra <cat@gensokyo.uk>2025-10-18 17:35:20 +0900
commitf6f0cb56ae64a47dcb948134e19afbd241452fd9 (patch)
tree76514137d848cd0d1bcc49f7640a0cae72e91534
parentd4284c109d593fa1413a162734b3db5134c66d19 (diff)
internal/app/hsu: remove wrapper method
This was added to reduce the size of diffs. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--cmd/hakurei/command.go4
-rw-r--r--cmd/hakurei/parse.go2
-rw-r--r--cmd/hakurei/print.go2
-rw-r--r--internal/app/hsu.go8
-rw-r--r--internal/app/outcome.go2
-rw-r--r--internal/app/shim.go2
6 files changed, 9 insertions, 11 deletions
diff --git a/cmd/hakurei/command.go b/cmd/hakurei/command.go
index 0cf0ef1b..232b3234 100644
--- a/cmd/hakurei/command.go
+++ b/cmd/hakurei/command.go
@@ -94,7 +94,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
passwd *user.User
passwdOnce sync.Once
passwdFunc = func() {
- us := strconv.Itoa(app.HsuUid(new(app.Hsu).MustIDMsg(msg), flagIdentity))
+ us := strconv.Itoa(app.HsuUid(new(app.Hsu).MustID(msg), flagIdentity))
if u, err := user.LookupId(us); err != nil {
msg.Verbosef("cannot look up uid %s", us)
passwd = &user.User{
@@ -302,7 +302,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
var flagShort bool
c.NewCommand("ps", "List active instances", func(args []string) error {
var sc hst.Paths
- app.CopyPaths().Copy(&sc, new(app.Hsu).MustID())
+ app.CopyPaths().Copy(&sc, new(app.Hsu).MustID(nil))
printPs(os.Stdout, time.Now().UTC(), state.NewMulti(msg, sc.RunDirPath.String()), flagShort, flagJSON)
return errSuccess
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
diff --git a/cmd/hakurei/parse.go b/cmd/hakurei/parse.go
index 3d15f665..75d720d6 100644
--- a/cmd/hakurei/parse.go
+++ b/cmd/hakurei/parse.go
@@ -89,7 +89,7 @@ func tryShort(msg message.Msg, name string) (config *hst.Config, entry *state.St
msg.Verbose("argument looks like prefix")
var sc hst.Paths
- app.CopyPaths().Copy(&sc, new(app.Hsu).MustID())
+ app.CopyPaths().Copy(&sc, new(app.Hsu).MustID(nil))
s := state.NewMulti(msg, sc.RunDirPath.String())
if entries, err := state.Join(s); err != nil {
log.Printf("cannot join store: %v", err)
diff --git a/cmd/hakurei/print.go b/cmd/hakurei/print.go
index 07fec385..86fc1ed9 100644
--- a/cmd/hakurei/print.go
+++ b/cmd/hakurei/print.go
@@ -21,7 +21,7 @@ func printShowSystem(output io.Writer, short, flagJSON bool) {
t := newPrinter(output)
defer t.MustFlush()
- info := &hst.Info{User: new(app.Hsu).MustID()}
+ info := &hst.Info{User: new(app.Hsu).MustID(nil)}
app.CopyPaths().Copy(&info.Paths, info.User)
if flagJSON {
diff --git a/internal/app/hsu.go b/internal/app/hsu.go
index 9f0408ac..e53d9f3d 100644
--- a/internal/app/hsu.go
+++ b/internal/app/hsu.go
@@ -35,7 +35,8 @@ func (h *Hsu) ensureDispatcher() {
})
}
-// ID returns the current user hsurc identifier. ErrHsuAccess is returned if the current user is not in hsurc.
+// ID returns the current user hsurc identifier.
+// [ErrHsuAccess] is returned if the current user is not in hsurc.
func (h *Hsu) ID() (int, error) {
h.ensureDispatcher()
h.idOnce.Do(func() {
@@ -71,10 +72,7 @@ func (h *Hsu) ID() (int, error) {
}
// MustID calls [Hsu.ID] and terminates on error.
-func (h *Hsu) MustID() int { return h.MustIDMsg(nil) }
-
-// MustIDMsg implements MustID with a custom [container.Msg].
-func (h *Hsu) MustIDMsg(msg message.Msg) int {
+func (h *Hsu) MustID(msg message.Msg) int {
id, err := h.ID()
if err == nil {
return id
diff --git a/internal/app/outcome.go b/internal/app/outcome.go
index d9aad2a3..2f13c4f3 100644
--- a/internal/app/outcome.go
+++ b/internal/app/outcome.go
@@ -82,7 +82,7 @@ func newOutcomeState(k syscallDispatcher, msg message.Msg, id *state.ID, config
Shim: &shimParams{PrivPID: k.getpid(), Verbose: msg.IsVerbose()},
ID: id,
Identity: config.Identity,
- UserID: hsu.MustIDMsg(msg),
+ UserID: hsu.MustID(msg),
EnvPaths: copyPaths(k),
Container: config.Container,
}
diff --git a/internal/app/shim.go b/internal/app/shim.go
index 69028165..6be45746 100644
--- a/internal/app/shim.go
+++ b/internal/app/shim.go
@@ -36,7 +36,7 @@ type shimParams struct {
// Limits are enforced on the priv side.
WaitDelay time.Duration
- // Verbosity pass through from [container.Msg].
+ // Verbosity pass through from [message.Msg].
Verbose bool
// Outcome setup ops, contains setup state. Populated by outcome.finalise.