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

fix: scp permission denied #1944

Merged
merged 2 commits into from
Aug 22, 2023
Merged

fix: scp permission denied #1944

merged 2 commits into from
Aug 22, 2023

Conversation

qyz87
Copy link
Contributor

@qyz87 qyz87 commented Aug 3, 2023

What type of PR is this?

/kind bug

What this PR does / why we need it:

fix scp permission denied err

Which issue(s) this PR fixes:

Fixes #1880

Special notes for reviewers:


when do sudoscp  first call r.Conn.MkDirAll  to make remoteTmp  dir,  then scp file to remoteTmp  dir , 
at last move remoteTmp   to remote.   
   note:  remoteTmp   = filepath.Join(common.TmpDir, remote)

pkg/core/connector/runner.go
   func (r *Runner) SudoScp(local, remote string) error {
            ...
            if err := r.Conn.MkDirAll(baseRemotePath, "", r.Host); err != nil {
		return err
	   }
           ...
   }

pkg/core/connector/ssh.go
      func (c *connection) MkDirAll(path string, mode string, host Host) error {
	if mode == "" {
		mode = "775"
	}
	mkDstDir := fmt.Sprintf("mkdir -p -m %s %s || true", mode, path)
	...
    }

   the reason for "scp  permission denied"  is  command "mkdir -p -m" only affect the last dir in path,   for example :
            mkdir -p -m 775   /tmp/kubekey/usr/local/bin/kube-scripts
           "mkdir -p -m"  only  set  kube-scripts  is 775 , other dir is affected by umask
   

Does this PR introduced a user-facing change?


Additional documentation, usage docs, etc.:


MkDirAll chmod
@ks-ci-bot ks-ci-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 3, 2023
@pixiake
Copy link
Collaborator

pixiake commented Aug 22, 2023

@qyz87 Thanks for this contributions !

/lgtm
/approve

@ks-ci-bot ks-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 22, 2023
@ks-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pixiake, qyz87

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ks-ci-bot
Copy link
Collaborator

LGTM label has been added.

Git tree hash: 1b35369fc0fb49d740863a35659aec384b2676fd

@ks-ci-bot ks-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 22, 2023
@ks-ci-bot ks-ci-bot merged commit 4fea211 into kubesphere:master Aug 22, 2023
7 checks passed
@pixiake
Copy link
Collaborator

pixiake commented Aug 24, 2023

@all-contributors please add @qyz87 for code

@allcontributors
Copy link
Contributor

@pixiake

@qyz87 already contributed before to code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
3 participants