Ophestra Umiker
6bc5be7e5a
All checks were successful
test / test (push) Successful in 19s
This change helps tests stub out and simulate OS behaviour during the sealing process. This also removes dependency on XDG_RUNTIME_DIR as the internal.System implementation provided to App provides a compat directory inside the tmpdir-based share when XDG_RUNTIME_DIR is unavailable. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
31 lines
556 B
Go
31 lines
556 B
Go
package app
|
|
|
|
import (
|
|
"git.ophivana.moe/security/fortify/internal/fmsg"
|
|
)
|
|
|
|
const (
|
|
sudoAskPass = "SUDO_ASKPASS"
|
|
)
|
|
|
|
func (a *app) commandBuilderSudo(shimEnv string) (args []string) {
|
|
args = make([]string, 0, 8)
|
|
|
|
// -Hiu $USER
|
|
args = append(args, "-Hiu", a.seal.sys.user.Username)
|
|
|
|
// -A?
|
|
if _, ok := a.os.LookupEnv(sudoAskPass); ok {
|
|
fmsg.VPrintln(sudoAskPass, "set, adding askpass flag")
|
|
args = append(args, "-A")
|
|
}
|
|
|
|
// shim payload
|
|
args = append(args, shimEnv)
|
|
|
|
// -- $@
|
|
args = append(args, "--", a.seal.sys.executable, "shim")
|
|
|
|
return
|
|
}
|