internal/app/hsu: remove wrapper method
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m11s
Test / Sandbox (race detector) (push) Successful in 3m53s
Test / Hpkg (push) Successful in 3m54s
Test / Hakurei (race detector) (push) Successful in 4m43s
Test / Hakurei (push) Successful in 2m13s
Test / Flake checks (push) Successful in 1m27s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m11s
Test / Sandbox (race detector) (push) Successful in 3m53s
Test / Hpkg (push) Successful in 3m54s
Test / Hakurei (race detector) (push) Successful in 4m43s
Test / Hakurei (push) Successful in 2m13s
Test / Flake checks (push) Successful in 1m27s
This was added to reduce the size of diffs. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
d4284c109d
commit
f6f0cb56ae
@ -94,7 +94,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
passwd *user.User
|
passwd *user.User
|
||||||
passwdOnce sync.Once
|
passwdOnce sync.Once
|
||||||
passwdFunc = func() {
|
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 {
|
if u, err := user.LookupId(us); err != nil {
|
||||||
msg.Verbosef("cannot look up uid %s", us)
|
msg.Verbosef("cannot look up uid %s", us)
|
||||||
passwd = &user.User{
|
passwd = &user.User{
|
||||||
@ -302,7 +302,7 @@ func buildCommand(ctx context.Context, msg message.Msg, early *earlyHardeningErr
|
|||||||
var flagShort bool
|
var flagShort bool
|
||||||
c.NewCommand("ps", "List active instances", func(args []string) error {
|
c.NewCommand("ps", "List active instances", func(args []string) error {
|
||||||
var sc hst.Paths
|
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)
|
printPs(os.Stdout, time.Now().UTC(), state.NewMulti(msg, sc.RunDirPath.String()), flagShort, flagJSON)
|
||||||
return errSuccess
|
return errSuccess
|
||||||
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
|
}).Flag(&flagShort, "short", command.BoolFlag(false), "Print instance id")
|
||||||
|
@ -89,7 +89,7 @@ func tryShort(msg message.Msg, name string) (config *hst.Config, entry *state.St
|
|||||||
msg.Verbose("argument looks like prefix")
|
msg.Verbose("argument looks like prefix")
|
||||||
|
|
||||||
var sc hst.Paths
|
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())
|
s := state.NewMulti(msg, sc.RunDirPath.String())
|
||||||
if entries, err := state.Join(s); err != nil {
|
if entries, err := state.Join(s); err != nil {
|
||||||
log.Printf("cannot join store: %v", err)
|
log.Printf("cannot join store: %v", err)
|
||||||
|
@ -21,7 +21,7 @@ func printShowSystem(output io.Writer, short, flagJSON bool) {
|
|||||||
t := newPrinter(output)
|
t := newPrinter(output)
|
||||||
defer t.MustFlush()
|
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)
|
app.CopyPaths().Copy(&info.Paths, info.User)
|
||||||
|
|
||||||
if flagJSON {
|
if flagJSON {
|
||||||
|
@ -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) {
|
func (h *Hsu) ID() (int, error) {
|
||||||
h.ensureDispatcher()
|
h.ensureDispatcher()
|
||||||
h.idOnce.Do(func() {
|
h.idOnce.Do(func() {
|
||||||
@ -71,10 +72,7 @@ func (h *Hsu) ID() (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MustID calls [Hsu.ID] and terminates on error.
|
// MustID calls [Hsu.ID] and terminates on error.
|
||||||
func (h *Hsu) MustID() int { return h.MustIDMsg(nil) }
|
func (h *Hsu) MustID(msg message.Msg) int {
|
||||||
|
|
||||||
// MustIDMsg implements MustID with a custom [container.Msg].
|
|
||||||
func (h *Hsu) MustIDMsg(msg message.Msg) int {
|
|
||||||
id, err := h.ID()
|
id, err := h.ID()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return id
|
return id
|
||||||
|
@ -82,7 +82,7 @@ func newOutcomeState(k syscallDispatcher, msg message.Msg, id *state.ID, config
|
|||||||
Shim: &shimParams{PrivPID: k.getpid(), Verbose: msg.IsVerbose()},
|
Shim: &shimParams{PrivPID: k.getpid(), Verbose: msg.IsVerbose()},
|
||||||
ID: id,
|
ID: id,
|
||||||
Identity: config.Identity,
|
Identity: config.Identity,
|
||||||
UserID: hsu.MustIDMsg(msg),
|
UserID: hsu.MustID(msg),
|
||||||
EnvPaths: copyPaths(k),
|
EnvPaths: copyPaths(k),
|
||||||
Container: config.Container,
|
Container: config.Container,
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ type shimParams struct {
|
|||||||
// Limits are enforced on the priv side.
|
// Limits are enforced on the priv side.
|
||||||
WaitDelay time.Duration
|
WaitDelay time.Duration
|
||||||
|
|
||||||
// Verbosity pass through from [container.Msg].
|
// Verbosity pass through from [message.Msg].
|
||||||
Verbose bool
|
Verbose bool
|
||||||
|
|
||||||
// Outcome setup ops, contains setup state. Populated by outcome.finalise.
|
// Outcome setup ops, contains setup state. Populated by outcome.finalise.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user