mirror of
https://github.com/restic/restic.git
synced 2025-12-13 12:02:59 +00:00
Merge pull request #2987 from greatroar/no-password-for-help
Don't read password for generate, help or self-update
This commit is contained in:
@@ -51,7 +51,7 @@ directories in an encrypted repository stored on different backends.
|
||||
return err
|
||||
}
|
||||
globalOptions.extended = opts
|
||||
if c.Name() == "version" {
|
||||
if !needsPassword(c.Name()) {
|
||||
return nil
|
||||
}
|
||||
pwd, err := resolvePassword(globalOptions, "RESTIC_PASSWORD")
|
||||
@@ -71,6 +71,18 @@ directories in an encrypted repository stored on different backends.
|
||||
},
|
||||
}
|
||||
|
||||
// Distinguish commands that need the password from those that work without,
|
||||
// so we don't run $RESTIC_PASSWORD_COMMAND for no reason (it might prompt the
|
||||
// user for authentication).
|
||||
func needsPassword(cmd string) bool {
|
||||
switch cmd {
|
||||
case "cache", "generate", "help", "options", "self-update", "version":
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var logBuffer = bytes.NewBuffer(nil)
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user