Skip to content

Commit

Permalink
Don't read password for generate, help or self-update
Browse files Browse the repository at this point in the history
  • Loading branch information
greatroar committed Oct 5, 2020
1 parent a23d90d commit 05bb24b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 9 additions & 0 deletions changelog/unreleased/issue-2951
@@ -0,0 +1,9 @@
Bugfix: restic generate, help and self-update no longer check passwords

The commands restic generate, restic help and restic self-update don't need
passwords, but they previously did run the RESTIC_PASSWORD_COMMAND (if set in
the environment), prompting users to authenticate for no reason. They now skip
the password command.

https://github.com/restic/restic/issues/2951
https://github.com/restic/restic/pull/2987
13 changes: 12 additions & 1 deletion cmd/restic/main.go
Expand Up @@ -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")
Expand All @@ -71,6 +71,17 @@ directories in an encrypted repository stored on different backends.
},
}

// Distinguish commands that need the password from those that work without
// (#2951).
func needsPassword(cmd string) bool {
switch cmd {
case "generate", "help", "self-update", "version":
return false
default:
return true
}
}

var logBuffer = bytes.NewBuffer(nil)

func init() {
Expand Down

0 comments on commit 05bb24b

Please sign in to comment.