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

Quote parsing in configuration settings leads to unintended parses #761

Open
kampfflunder opened this issue Apr 6, 2022 · 3 comments
Open
Labels

Comments

@kampfflunder
Copy link

I have in config.ini:

tokencmd: security find-generic-password -s 'matterhorn' -a 'myaccount' -w

It fails on startup with:

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
Error loading config: Could not execute token command: failed

But if I run the same command in a terminal, it works and prints the correct token.

tokencmd: echo "mytoken"

works, but that is of course a bad solution.

MacOS 11.6.5, matterhorn 50200.15.0 from macports

@jtdaugherty
Copy link
Member

Hi @kampfflunder - thanks for reporting this. Out of curiosity, are you running matterhorn within any kind of terminal multiplexer like tmux or screen? This doesn't seem likely to me to be caused by Matterhorn itself since it just runs the command you give it. Incidentally I personally use this same technique and it works for me. The only difference between your command and mine is that I don't use the -a option, but I doubt that would have a big impact on this. This behavior you are seeing makes me wonder about the environment that matterhorn is running in, such as the user account running it, or some other environmental thing that is getting in the way of keychain access.

@kampfflunder
Copy link
Author

Bamm!

One must NOT use single or double quotes!

tokencmd: security find-generic-password -s 'matterhorn' -a 'myaccount' -w
tokencmd: security find-generic-password -s "matterhorn" -a "myaccount" -w

does not work, while

tokencmd: security find-generic-password -s matterhorn -a myaccount -w

does.
I think at some point the parser for the ini file fails
Not sure if this has to be considered a bug?

@jtdaugherty
Copy link
Member

That might be a bug in the config parser library, yeah. I could see it either way because quotes can be used to quote the config values themselves, which means that quotes could be ambiguous. However, at the end of the day it's still important for people to be able to use quotes for settings like tokencmd so we should do something about it. I'm glad you found out what the problem was! I'm going to leave this open as a reminder to follow up on this.

@jtdaugherty jtdaugherty changed the title tokencmd on MacOS Quote parsing in configuration settings leads to unintended parses Apr 6, 2022
@jtdaugherty jtdaugherty added the bug label Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants