Skip to content

Commit

Permalink
backup store: support SMB/CIFS hidden share
Browse files Browse the repository at this point in the history
Longhorn 6660

Signed-off-by: Derek Su <derek.su@suse.com>
  • Loading branch information
derekbit authored and David Ko committed Sep 12, 2023
1 parent 421da08 commit db20015
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion types/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"fmt"
"net/url"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -1197,8 +1198,18 @@ func ValidateSetting(name, value string) (err error) {

switch sName {
case SettingNameBackupTarget:
// check whether have $ or , have been set in BackupTarget
u, err := url.Parse(value)
if err != nil {
return errors.Wrapf(err, "failed to parse %v as url", value)
}

// Check whether have $ or , have been set in BackupTarget
regStr := `[\$\,]`
if u.Scheme == "cifs" {
// The $ in SMB/CIFS URIs means that the share is hidden.
regStr = `[\,]`
}

reg := regexp.MustCompile(regStr)
findStr := reg.FindAllString(value, -1)
if len(findStr) != 0 {
Expand Down

0 comments on commit db20015

Please sign in to comment.