internal/app/spaccount: apply default in shim
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m19s
Test / Hpkg (push) Successful in 4m6s
Test / Hakurei (race detector) (push) Successful in 5m20s
Test / Sandbox (race detector) (push) Successful in 2m10s
Test / Hakurei (push) Successful in 2m13s
Test / Flake checks (push) Successful in 1m37s
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m19s
Test / Hpkg (push) Successful in 4m6s
Test / Hakurei (race detector) (push) Successful in 5m20s
Test / Sandbox (race detector) (push) Successful in 2m10s
Test / Hakurei (push) Successful in 2m13s
Test / Flake checks (push) Successful in 1m37s
The original code clobbers hst.Config, and was not changed when being ported over. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
50f6fcb326
commit
23084888a0
@ -14,30 +14,35 @@ func init() { gob.Register(spAccountOp{}) }
|
|||||||
type spAccountOp struct{}
|
type spAccountOp struct{}
|
||||||
|
|
||||||
func (s spAccountOp) toSystem(state *outcomeStateSys) error {
|
func (s spAccountOp) toSystem(state *outcomeStateSys) error {
|
||||||
const fallbackUsername = "chronos"
|
|
||||||
|
|
||||||
// do checks here to fail before fork/exec
|
// do checks here to fail before fork/exec
|
||||||
if state.Container == nil || state.Container.Home == nil || state.Container.Shell == nil {
|
if state.Container == nil || state.Container.Home == nil || state.Container.Shell == nil {
|
||||||
// unreachable
|
// unreachable
|
||||||
return syscall.ENOTRECOVERABLE
|
return syscall.ENOTRECOVERABLE
|
||||||
}
|
}
|
||||||
if state.Container.Username == "" {
|
|
||||||
state.Container.Username = fallbackUsername
|
// default is applied in toContainer
|
||||||
} else if !isValidUsername(state.Container.Username) {
|
if state.Container.Username != "" && !isValidUsername(state.Container.Username) {
|
||||||
return newWithMessage(fmt.Sprintf("invalid user name %q", state.Container.Username))
|
return newWithMessage(fmt.Sprintf("invalid user name %q", state.Container.Username))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s spAccountOp) toContainer(state *outcomeStateParams) error {
|
func (s spAccountOp) toContainer(state *outcomeStateParams) error {
|
||||||
|
const fallbackUsername = "chronos"
|
||||||
|
|
||||||
|
username := state.Container.Username
|
||||||
|
if username == "" {
|
||||||
|
username = fallbackUsername
|
||||||
|
}
|
||||||
|
|
||||||
state.params.Dir = state.Container.Home
|
state.params.Dir = state.Container.Home
|
||||||
state.env["HOME"] = state.Container.Home.String()
|
state.env["HOME"] = state.Container.Home.String()
|
||||||
state.env["USER"] = state.Container.Username
|
state.env["USER"] = username
|
||||||
state.env["SHELL"] = state.Container.Shell.String()
|
state.env["SHELL"] = state.Container.Shell.String()
|
||||||
|
|
||||||
state.params.
|
state.params.
|
||||||
Place(fhs.AbsEtc.Append("passwd"),
|
Place(fhs.AbsEtc.Append("passwd"),
|
||||||
[]byte(state.Container.Username+":x:"+
|
[]byte(username+":x:"+
|
||||||
state.mapuid.String()+":"+
|
state.mapuid.String()+":"+
|
||||||
state.mapgid.String()+
|
state.mapgid.String()+
|
||||||
":Hakurei:"+
|
":Hakurei:"+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user