Skip to content

Commit

Permalink
cpu: add CPU_PWD environment variable
Browse files Browse the repository at this point in the history
sshd simulates a login and starts the process in $HOME.

Add CPU_PWD, derived from PWD on the client, which cpuns
can use to set the correct directory.

Signed-off-by: Ronald G. Minnich <[email protected]>
  • Loading branch information
rminnich committed Jul 21, 2024
1 parent 2aa6d23 commit 35a8e78
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmds/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func getPort(host, port string) string {
p = cp
}
}
if len(p) == 0 {
if len(p) == 0 {
p = defaultPort
verbose("getPort: return default %q", p)
}
Expand All @@ -134,8 +134,12 @@ func newCPU(host string, args ...string) (retErr error) {
// If running over ssh, *srvnfs is true, then
// we need to start cpuns, and pass the environment
// as an argument.
// Also, because of how sshd works, we need to pass in
// a PWD that is correct; otherwise it gets lost, since
// since ssh wants to simulate a login..
if *ssh {
envargs := "-env=" + strings.Join(os.Environ(), "\n")
env := append(os.Environ(), "CPU_PWD="+os.Getenv("PWD"))
envargs := "-env=" + strings.Join(env, "\n")
args = append([]string{"cpuns", envargs}, args...)
}
c := client.Command(host, args...)
Expand Down

0 comments on commit 35a8e78

Please sign in to comment.