Skip to content

Commit

Permalink
MB-48854: Make sure keyfile is empty when password is given before th…
Browse files Browse the repository at this point in the history
…rowing an error

Change-Id: I33ba69f3de05a758ba969b92634dad6e63ad5e07
Reviewed-on: http://review.couchbase.org/c/query/+/163605
Reviewed-by: Sitaram Vemulapalli <sitaram.vemulapalli@couchbase.com>
Reviewed-by: Donald Haggart <donald.haggart@couchbase.com>
Tested-by: Isha Kandaswamy <isha@couchbase.com>
  • Loading branch information
ikandaswamy committed Oct 13, 2021
1 parent f7c02a1 commit b364cf6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions shell/cbq/shell.go
Expand Up @@ -116,8 +116,8 @@ func init() {
}

/*
Option : -password or -p
Args : password
Option : -password, passphrase or -p
Args : password for username or passphrase for keyfile (Private Key Encryption)
Password for user given by -u. If -u is present and we provide -p, then
do not prompt for the password. Error out if username is not provided.
*/
Expand Down Expand Up @@ -559,8 +559,9 @@ func main() {
}
} else {
// If the -u option isnt specified and the -p option is specified
// then Invalid Username error.
if pwdFlag != "" {
// It could be using the passphrase instead of the username.
// Make sure the keyfile is also empty before throwing the error.
if pwdFlag != "" && keyFile == "" {
s_err := command.HandleError(errors.E_SHELL_INVALID_USERNAME, "")
command.PrintError(s_err)
os.Exit(1)
Expand Down

0 comments on commit b364cf6

Please sign in to comment.