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

Null argument causes keys not to be processed #123

Open
HaleTom opened this issue Aug 30, 2020 · 2 comments
Open

Null argument causes keys not to be processed #123

HaleTom opened this issue Aug 30, 2020 · 2 comments

Comments

@HaleTom
Copy link

HaleTom commented Aug 30, 2020

Keychain behaves strangely when encountering a null argument.

Here, $noask is null:

% printf "%q\n" "$noask"
''
% printf "%q\n" "$keys"                                     
id_4096_jvlk.me$'\n'id_4096rsa_20kdf$'\n'id_android$'\n'id_boxy_rsa
% 
% keychain --quiet -k all; eval $(keychain --eval --confhost --quick "$noask" "$keys")

 * keychain 2.8.5 ~ http://www.funtoo.org
 * Starting ssh-agent...

%

The exact command, but with $noask not surrounded by "s:

% keychain --quiet -k all; eval $(keychain --eval --confhost --quick $noask "$keys")

 * keychain 2.8.5 ~ http://www.funtoo.org
 * Starting ssh-agent...
 * Adding 4 ssh key(s): /home/ravi/.ssh/id_4096_jvlk.me /home/ravi/.ssh/id_4096rsa_20kdf /home/ravi/.ssh/id_android /home/ravi/.ssh/id_boxy_rsa
Enter passphrase for /home/ravi/.ssh/id_4096_jvlk.me:
 * ssh-add: Identities added: /home/ravi/.ssh/id_4096_jvlk.me /home/ravi/.ssh/id_4096rsa_20kdf /home/ravi/.ssh/id_android /home/ravi/.ssh/id_boxy_rsa

%

This is the context for why I want to do this:

function keychain_load {
  noask=''; [[ ! -t 0 || ! -t 1 ]] && noask='--noask'  # Don't ask for password if either STDIN or STDOUT is !isatty
  eval $(keychain --eval --quiet --agents ssh --inherit local-once --absolute --dir "$XDG_CACHE_HOME"/keychain --confhost --quick $noask "$keys")
}
export_function keychain_load
@HaleTom
Copy link
Author

HaleTom commented Aug 30, 2020

Strangely, it breaks when the null argument given before the keys are listed, so this works fine:

% keychain --quiet -k all; eval $(keychain --eval --confhost --quick "$keys" "$noask" ) 

 * keychain 2.8.5 ~ http://www.funtoo.org
 * Starting ssh-agent...
 * Adding 4 ssh key(s): /home/ravi/.ssh/id_4096_jvlk.me /home/ravi/.ssh/id_4096rsa_20kdf /home/ravi/.ssh/id_android /home/ravi/.ssh/id_boxy_rsa
Enter passphrase for /home/ravi/.ssh/id_4096_jvlk.me: ^C
% 

@mrl5
Copy link

mrl5 commented Jul 16, 2022

hello @HaleTom - if you'd like to report a bug kindly use https://bugs.funtoo.org/

you can also reach us on Discord - for more info check https://www.funtoo.org/Welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants