Set $HOME env variable for root user when runAsElevated is true
cr
@@ -50,6 +50,7 @@ const (
catCmd = "cat"
scriptFlag = "-c"
homeEnvVariable = "HOME=/home/"
+ rootHomeEnvVariable = "HOME=/root"
groupsIdentifier = "groups="
)
@@ -141,6 +142,10 @@ func StartPty(
cmd.Env = append(cmd.Env, runAsUserHomeEnvVariable)
}
+ if shellProps.Linux.RunAsElevated {
+ cmd.Env = append(cmd.Env, rootHomeEnvVariable)
+ }
+
ptyFile, err = pty.Start(cmd)
if err != nil {
log.Errorf("Failed to start pty: %s\n", err)
