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

Autoclip on generate broken #2023

Closed
acaloiaro opened this issue Nov 7, 2021 · 2 comments · Fixed by #2024
Closed

Autoclip on generate broken #2023

acaloiaro opened this issue Nov 7, 2021 · 2 comments · Fixed by #2024

Comments

@acaloiaro
Copy link

acaloiaro commented Nov 7, 2021

Summary

Currently, autoclip on generate does not work as I beieve was intended.

Clip-on-generate currently works by checking whether one of two conditions are met:

  1. Is the -c flag true
  2. Is autoclip true and is output being redirected

I belive (2.) to be incorrect autoclipping behavior, and discordant with the comment preceding it:

// copy to clipboard if:
// - explicitly requested with -c
// - autoclip=true, but only if output is not being redirected
if IsClip(ctx) || (s.cfg.AutoClip && !ctxutil.IsTerminal(ctx)) 

As can be seen, the code actually checks that output is being redirected, i.e. the output file descriptor is not a TTY.

Steps To Reproduce

  1. gopass config autoclip true
  2. gopass generate -f foobar 24
  3. Prints "Not printing secrets by default. Use 'gopass show foobar' to display the password.". Contents of foobar will not be copied to clipboard

Unexpected behavior

  1. gopass config autoclip true
  2. gopass generate -f foobar 24 | cat
  3. Prints "Copied to clipboard". Contents of foobar will be copied to clipboard

Expected behavior

In the above scenarios, I exect the contents of foobar to be copied to the clipboard in the first scenario, but not the second. In other words, the inverse of the actual behavior.

Environment

  • OS: Ubuntu 20.04
  • OS version: 5.13.0-7614-generic Support Windows #14163164715120.04930e87cdev-Ubuntu SMP Thu Sep 16 19:26:07 x86_64 x86_64 x86_64 GNU/Linux
  • gopass Version: gopass 1.12.8-git+HEAD go1.17.1 linux amd64
  • Installation method: go install of latest

Additional context

I'm happy to submit a PR for the fix if this is confirmed to be unexpected behavior.

@dominikschulz
Copy link
Member

Thanks for reporting this. I didn't get a chance to verify it, yet. But this sounds and looks like a logic bug.

Feel free to send a PR.

@acaloiaro
Copy link
Author

Once I have time to figure out how to write a test for output redirection, I'll submit the PR and test.

dominikschulz added a commit to dominikschulz/gopass that referenced this issue Nov 8, 2021
Fixes gopasspw#2023

RELEASE_NOTES=[BUGFIX] Fix AutoClip handling on generate

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
dominikschulz added a commit that referenced this issue Nov 9, 2021
Fixes #2023

RELEASE_NOTES=[BUGFIX] Fix AutoClip handling on generate

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
kpitt pushed a commit to kpitt/gopass that referenced this issue Jul 21, 2022
Fixes gopasspw#2023

RELEASE_NOTES=[BUGFIX] Fix AutoClip handling on generate

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants