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

feat: support guest login option #457

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions pkg/smb/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,34 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
}
}

requireUsernamePwdOption := true
for _, v := range mountFlags {
if v == "guest" {
// in guest login, username and password options are not needed
requireUsernamePwdOption = false
break
}
}

var mountOptions, sensitiveMountOptions []string
if runtime.GOOS == "windows" {
if domain == "" {
domain = defaultDomainName
}
if !strings.Contains(username, "\\") {
username = fmt.Sprintf("%s\\%s", domain, username)
if requireUsernamePwdOption {
if !strings.Contains(username, "\\") {
username = fmt.Sprintf("%s\\%s", domain, username)
}
mountOptions = []string{username}
sensitiveMountOptions = []string{password}
}
mountOptions = []string{username}
sensitiveMountOptions = []string{password}
} else {
if err := os.MkdirAll(targetPath, 0750); err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("MkdirAll %s failed with error: %v", targetPath, err))
}
sensitiveMountOptions = []string{fmt.Sprintf("%s=%s,%s=%s", usernameField, username, passwordField, password)}
if requireUsernamePwdOption {
sensitiveMountOptions = []string{fmt.Sprintf("%s=%s,%s=%s", usernameField, username, passwordField, password)}
}
mountOptions = mountFlags
if !gidPresent && volumeMountGroup != "" {
mountOptions = append(mountOptions, fmt.Sprintf("gid=%s", volumeMountGroup))
Expand Down