more misc plan9 work; it works now

Change-Id: Iafc4ee41dd4d7ba9b9907c8e13bb1e161c8f78e3
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2025-03-03 16:07:31 -08:00
parent 8a9bc098ab
commit f3011fce04
15 changed files with 112 additions and 25 deletions

View File

@@ -1032,6 +1032,14 @@ func (ss *sshSession) startWithStdPipes() (err error) {
}
func envForUser(u *userMeta) []string {
if runtime.GOOS == "plan9" {
return []string{
fmt.Sprintf("shell=%s", u.LoginShell()),
"service=ssh",
fmt.Sprintf("USER=%s", u.Username),
fmt.Sprintf("home=%s", u.HomeDir),
}
}
return []string{
fmt.Sprintf("SHELL=%s", u.LoginShell()),
fmt.Sprintf("USER=%s", u.Username),
@@ -1108,7 +1116,7 @@ func (ia *incubatorArgs) loginArgs(loginCmdPath string) []string {
func shellArgs(isShell bool, cmd string) []string {
if isShell {
if runtime.GOOS == freebsd || runtime.GOOS == openbsd {
if runtime.GOOS == freebsd || runtime.GOOS == openbsd || runtime.GOOS == "plan9" {
// bsd shells don't support the "-l" option, so we can't run as a login shell
return []string{}
}

View File

@@ -672,7 +672,6 @@ type sshSession struct {
wrStdin io.WriteCloser
rdStdout io.ReadCloser
rdStderr io.ReadCloser // rdStderr is nil for pty sessions
ptyReq *ssh.Pty // non-nil for pty sessions
// childPipes is a list of pipes that need to be closed when the process exits.
// For pty sessions, this is the tty fd.
@@ -903,7 +902,7 @@ func (ss *sshSession) run() {
defer t.Stop()
}
if euid := os.Geteuid(); euid != 0 {
if euid := os.Geteuid(); euid != 0 && runtime.GOOS != "plan9" {
if lu.Uid != fmt.Sprint(euid) {
ss.logf("can't switch to user %q from process euid %v", lu.Username, euid)
fmt.Fprintf(ss, "can't switch user\r\n")