Don't show encrypted password to stop confusion - fixes #656
This commit is contained in:
parent
618f2e33e8
commit
83849e0a36
3 changed files with 43 additions and 24 deletions
|
@ -99,8 +99,8 @@ Remote config
|
||||||
[secret]
|
[secret]
|
||||||
remote = remote:path
|
remote = remote:path
|
||||||
filename_encryption = standard
|
filename_encryption = standard
|
||||||
password = CfDxopZIXFG0Oo-ac7dPLWWOHkNJbw
|
password = *** ENCRYPTED ***
|
||||||
password2 = HYUpfuzHJL8qnX9fOaIYijq0xnVLwyVzp3y4SF3TwYqAU6HLysk
|
password2 = *** ENCRYPTED ***
|
||||||
--------------------
|
--------------------
|
||||||
y) Yes this is OK
|
y) Yes this is OK
|
||||||
e) Edit this remote
|
e) Edit this remote
|
||||||
|
|
50
fs/config.go
50
fs/config.go
|
@ -752,8 +752,21 @@ func ChooseNumber(what string, min, max int) int {
|
||||||
func ShowRemote(name string) {
|
func ShowRemote(name string) {
|
||||||
fmt.Printf("--------------------\n")
|
fmt.Printf("--------------------\n")
|
||||||
fmt.Printf("[%s]\n", name)
|
fmt.Printf("[%s]\n", name)
|
||||||
|
fs := MustFindByName(name)
|
||||||
for _, key := range ConfigFile.GetKeyList(name) {
|
for _, key := range ConfigFile.GetKeyList(name) {
|
||||||
fmt.Printf("%s = %s\n", key, ConfigFile.MustValue(name, key))
|
isPassword := false
|
||||||
|
for _, option := range fs.Options {
|
||||||
|
if option.Name == key && option.IsPassword {
|
||||||
|
isPassword = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value := ConfigFile.MustValue(name, key)
|
||||||
|
if isPassword && value != "" {
|
||||||
|
fmt.Printf("%s = *** ENCRYPTED ***\n", key)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%s = %s\n", key, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("--------------------\n")
|
fmt.Printf("--------------------\n")
|
||||||
}
|
}
|
||||||
|
@ -775,17 +788,20 @@ func OkRemote(name string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MustFindByName finds the RegInfo for the remote name passed in or
|
||||||
|
// exits with a fatal error.
|
||||||
|
func MustFindByName(name string) *RegInfo {
|
||||||
|
fsType := ConfigFile.MustValue(name, "type")
|
||||||
|
if fsType == "" {
|
||||||
|
log.Fatalf("Couldn't find type of fs for %q", name)
|
||||||
|
}
|
||||||
|
return MustFind(fsType)
|
||||||
|
}
|
||||||
|
|
||||||
// RemoteConfig runs the config helper for the remote if needed
|
// RemoteConfig runs the config helper for the remote if needed
|
||||||
func RemoteConfig(name string) {
|
func RemoteConfig(name string) {
|
||||||
fmt.Printf("Remote config\n")
|
fmt.Printf("Remote config\n")
|
||||||
fsName := ConfigFile.MustValue(name, "type")
|
f := MustFindByName(name)
|
||||||
if fsName == "" {
|
|
||||||
log.Fatalf("Couldn't find type of fs for %q", name)
|
|
||||||
}
|
|
||||||
f, err := Find(fsName)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Didn't find filing system: %v", err)
|
|
||||||
}
|
|
||||||
if f.Config != nil {
|
if f.Config != nil {
|
||||||
f.Config(name)
|
f.Config(name)
|
||||||
}
|
}
|
||||||
|
@ -864,10 +880,7 @@ func fsOption() *Option {
|
||||||
func NewRemote(name string) {
|
func NewRemote(name string) {
|
||||||
newType := ChooseOption(fsOption())
|
newType := ChooseOption(fsOption())
|
||||||
ConfigFile.SetValue(name, "type", newType)
|
ConfigFile.SetValue(name, "type", newType)
|
||||||
fs, err := Find(newType)
|
fs := MustFind(newType)
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Failed to find fs: %v", err)
|
|
||||||
}
|
|
||||||
for _, option := range fs.Options {
|
for _, option := range fs.Options {
|
||||||
ConfigFile.SetValue(name, option.Name, ChooseOption(&option))
|
ConfigFile.SetValue(name, option.Name, ChooseOption(&option))
|
||||||
}
|
}
|
||||||
|
@ -924,10 +937,7 @@ func EditConfig() {
|
||||||
switch i := Command(what); i {
|
switch i := Command(what); i {
|
||||||
case 'e':
|
case 'e':
|
||||||
name := ChooseRemote()
|
name := ChooseRemote()
|
||||||
fs, err := Find(ConfigFile.MustValue(name, "type"))
|
fs := MustFindByName(name)
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Failed to find fs: %v", err)
|
|
||||||
}
|
|
||||||
EditRemote(fs, name)
|
EditRemote(fs, name)
|
||||||
case 'n':
|
case 'n':
|
||||||
nameLoop:
|
nameLoop:
|
||||||
|
@ -1010,11 +1020,7 @@ func Authorize(args []string) {
|
||||||
log.Fatalf("Invalid number of arguments: %d", len(args))
|
log.Fatalf("Invalid number of arguments: %d", len(args))
|
||||||
}
|
}
|
||||||
newType := args[0]
|
newType := args[0]
|
||||||
fs, err := Find(newType)
|
fs := MustFind(newType)
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Failed to find fs: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if fs.Config == nil {
|
if fs.Config == nil {
|
||||||
log.Fatalf("Can't authorize fs %q", newType)
|
log.Fatalf("Can't authorize fs %q", newType)
|
||||||
}
|
}
|
||||||
|
|
13
fs/fs.go
13
fs/fs.go
|
@ -394,6 +394,19 @@ func Find(name string) (*RegInfo, error) {
|
||||||
return nil, errors.Errorf("didn't find filing system for %q", name)
|
return nil, errors.Errorf("didn't find filing system for %q", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MustFind looks for an Info object for the type name passed in
|
||||||
|
//
|
||||||
|
// Services are looked up in the config file
|
||||||
|
//
|
||||||
|
// Exits with a fatal error if not found
|
||||||
|
func MustFind(name string) *RegInfo {
|
||||||
|
fs, err := Find(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to find remote: %v", err)
|
||||||
|
}
|
||||||
|
return fs
|
||||||
|
}
|
||||||
|
|
||||||
// Pattern to match an rclone url
|
// Pattern to match an rclone url
|
||||||
var matcher = regexp.MustCompile(`^([\w_ -]+):(.*)$`)
|
var matcher = regexp.MustCompile(`^([\w_ -]+):(.*)$`)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue