Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Copy functionality failes to retrieve password when GnuPG key wasn't unlocked earlier #1

Open
AntonVanAssche opened this issue Mar 28, 2023 · 1 comment · May be fixed by #2
Open
Assignees
Labels
Priority: high Priority: high Status: confirmed This is a confirmed issue Type: bug Something isn't working

Comments

@AntonVanAssche
Copy link
Owner

AntonVanAssche commented Mar 28, 2023

What is the bug?

When attempting to use the --copy option in BashPass-Remote, if the GnuPG key has not been unlocked on the server beforehand, the program will not prompt the user to enter the password like it does with the --list option. Instead, it will continuously attempt to decrypt the password file until it fails. Once it fails, the program will write an empty string to the clipboard instead of the correct password.

How can one reproduce the bug?

First we have to make sure that it will prompt us for a password. We can do this by executing the command below. No worries, gpg will start again by itself.

$ ssh -t <user>@<host> "gpgconf --kill gpg-agent"

Now we can try to retrieve the password and write it to our clipboard.

$ bashpass-remote <user>@<host> -c <password-name>

What is the expected behavior?

When the user tries to retrieve a password from the server using BashPass-Remote, it will prompt them to enter their GnuPG key password if it has not been unlocked before. This behavior is similar to that of the --list option, which also prompts the user for their password. Once the password is entered correctly, BashPass-Remote will successfully retrieve the password from the server and function as intended.

Do you have any screenshots?

  • Current behavior (sped up, as it takes more than a minute to finish):

copy-function

  • Intended behavior (from the --list option):

list-function

@AntonVanAssche AntonVanAssche added Priority: high Priority: high Status: confirmed This is a confirmed issue Status: untriaged Doesn't have an assigned priority yet Type: bug Something isn't working labels Mar 28, 2023
@AntonVanAssche AntonVanAssche self-assigned this Mar 28, 2023
@AntonVanAssche AntonVanAssche removed the Status: untriaged Doesn't have an assigned priority yet label Mar 28, 2023
@AntonVanAssche
Copy link
Owner Author

If we try to print out the password variable, it will literally print out the GnuPG prompt. So we just need to find a way to avoid this.

password=$(ssh -t "${user}@${host}" '$(command -v bashpass) --show' "${1}") || \
    error_out "failed to retrieve password '${1}' from remote" 1

printf '%s\n' "${password}"
password=${password#*: }
printf '%s\n' "${password}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: high Priority: high Status: confirmed This is a confirmed issue Type: bug Something isn't working
Projects
None yet
1 participant