2024-09-22 00:29:36 +09:00
|
|
|
package app
|
|
|
|
|
|
|
|
import (
|
2024-10-21 20:47:02 +09:00
|
|
|
"git.ophivana.moe/security/fortify/internal/fmsg"
|
2024-09-22 00:29:36 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
sudoAskPass = "SUDO_ASKPASS"
|
|
|
|
)
|
|
|
|
|
2024-10-11 02:01:03 +09:00
|
|
|
func (a *app) commandBuilderSudo(shimEnv string) (args []string) {
|
|
|
|
args = make([]string, 0, 8)
|
2024-09-22 00:29:36 +09:00
|
|
|
|
|
|
|
// -Hiu $USER
|
2024-10-16 01:38:59 +09:00
|
|
|
args = append(args, "-Hiu", a.seal.sys.user.Username)
|
2024-09-22 00:29:36 +09:00
|
|
|
|
|
|
|
// -A?
|
2024-10-23 21:46:21 +09:00
|
|
|
if _, ok := a.os.LookupEnv(sudoAskPass); ok {
|
2024-10-21 20:47:02 +09:00
|
|
|
fmsg.VPrintln(sudoAskPass, "set, adding askpass flag")
|
2024-09-22 00:29:36 +09:00
|
|
|
args = append(args, "-A")
|
|
|
|
}
|
|
|
|
|
2024-10-11 02:01:03 +09:00
|
|
|
// shim payload
|
|
|
|
args = append(args, shimEnv)
|
2024-09-22 00:29:36 +09:00
|
|
|
|
|
|
|
// -- $@
|
2024-11-02 03:03:44 +09:00
|
|
|
args = append(args, "--", a.os.FshimPath())
|
2024-09-22 00:29:36 +09:00
|
|
|
|
|
|
|
return
|
|
|
|
}
|