mirror of
https://github.com/gilbertchen/duplicacy
synced 2025-12-10 13:23:17 +00:00
Don't save passwords from env/pref to keyring
This commit is contained in:
@@ -199,6 +199,8 @@ func CreateStorage(preference Preference, resetPassword bool, threads int) (stor
|
|||||||
if username != "" {
|
if username != "" {
|
||||||
username = username[:len(username) - 1]
|
username = username[:len(username) - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If ssh_key_file is set, skip password-based login
|
||||||
keyFile := GetPasswordFromPreference(preference, "ssh_key_file")
|
keyFile := GetPasswordFromPreference(preference, "ssh_key_file")
|
||||||
|
|
||||||
password := ""
|
password := ""
|
||||||
|
|||||||
@@ -133,10 +133,19 @@ func GetPasswordFromPreference(preference Preference, passwordType string) (stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the password is stored in the preference, there is no need to include the storage name
|
||||||
|
// (i.e., preference.Name) in the key, so the key name should really be passwordType rather
|
||||||
|
// than passwordID; we're using passwordID here only for backward compatibility
|
||||||
if len(preference.Keys) > 0 && len(preference.Keys[passwordID]) > 0 {
|
if len(preference.Keys) > 0 && len(preference.Keys[passwordID]) > 0 {
|
||||||
LOG_DEBUG("PASSWORD_KEYCHAIN", "Reading %s from preferences", passwordID)
|
LOG_DEBUG("PASSWORD_KEYCHAIN", "Reading %s from preferences", passwordID)
|
||||||
return preference.Keys[passwordID]
|
return preference.Keys[passwordID]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(preference.Keys) > 0 && len(preference.Keys[passwordType]) > 0 {
|
||||||
|
LOG_DEBUG("PASSWORD_KEYCHAIN", "Reading %s from preferences", passwordType)
|
||||||
|
return preference.Keys[passwordType]
|
||||||
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +193,7 @@ func GetPassword(preference Preference, passwordType string, prompt string,
|
|||||||
|
|
||||||
// SavePassword saves the specified password in the keyring/keychain.
|
// SavePassword saves the specified password in the keyring/keychain.
|
||||||
func SavePassword(preference Preference, passwordType string, password string) {
|
func SavePassword(preference Preference, passwordType string, password string) {
|
||||||
|
|
||||||
if password == "" || RunInBackground {
|
if password == "" || RunInBackground {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -191,6 +201,12 @@ func SavePassword(preference Preference, passwordType string, password string) {
|
|||||||
if preference.DoNotSavePassword {
|
if preference.DoNotSavePassword {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the password is retrieved from env or preference, don't save it to keyring
|
||||||
|
if GetPasswordFromPreference(preference, passwordType) == password {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
passwordID := passwordType
|
passwordID := passwordType
|
||||||
if preference.Name != "default" {
|
if preference.Name != "default" {
|
||||||
passwordID = preference.Name + "_" + passwordID
|
passwordID = preference.Name + "_" + passwordID
|
||||||
|
|||||||
Reference in New Issue
Block a user