Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

secure script perm to 0700 #28212

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions communicator/ssh/communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ var (
// max time to wait for for a KeepAlive response before considering the
// connection to be dead.
maxKeepAliveDelay = 120 * time.Second

// default file permission given to the scripts
defaultScriptPerm = "0700"
)

// Communicator represents the SSH communicator
Expand Down Expand Up @@ -442,20 +445,20 @@ func (c *Communicator) UploadScript(path string, input io.Reader) error {
if c.connInfo.TargetPlatform != TargetPlatformWindows {
var stdout, stderr bytes.Buffer
cmd := &remote.Cmd{
Command: fmt.Sprintf("chmod 0777 %s", path),
Command: fmt.Sprintf("chmod %s %s", defaultScriptPerm, path),
Stdout: &stdout,
Stderr: &stderr,
}
if err := c.Start(cmd); err != nil {
return fmt.Errorf(
"Error chmodding script file to 0777 in remote "+
"machine: %s", err)
"Error chmodding script file to %s in remote "+
"machine: %s", defaultScriptPerm, err)
}

if err := cmd.Wait(); err != nil {
return fmt.Errorf(
"Error chmodding script file to 0777 in remote "+
"machine %v: %s %s", err, stdout.String(), stderr.String())
"Error chmodding script file to %s in remote "+
"machine %v: %s %s", defaultScriptPerm, err, stdout.String(), stderr.String())
}
}
return nil
Expand Down