Compare commits

..

2 Commits

Author SHA1 Message Date
FliegendeWurst
f0bce36ee0
Merge pull request #34 from Ma27/pass-first-line-only 2022-08-14 13:39:27 +02:00
Maximilian Bosch
8131acc75a
pass login: Only use first line from result
It's possible to create multi-line entries in `pass(1)` where additional
lines have further metadata, e.g.

    $ pass show kit-access
    <secret pw>
    user: uXXXX

which can be helpful to persist e.g. the corresponding username.

However it's a convention that the password is only in the first line,
e.g. `pass show -c` (which is used by `passmenu` to copy a secret into
the clipboard) only the first line is used by default.

I switched to such an approach recently and realized that this is now a
problem because `KIT-ILIAS-Downloader` passes the entire string to the
SAML login, so I decided to just strip everything after the first line
in the output of `pass show`.

We may want to implement support for extracting usernames from such a
format in the future, but... that's an exercise left for the reader ;-)
2022-08-06 14:33:33 +02:00

View File

@ -201,8 +201,8 @@ pub fn ask_user_pass(opt: &Opt) -> Result<(String, String)> {
))? ))?
} else { } else {
pass = String::from_utf8(pw_out.stdout).map(|x| { pass = String::from_utf8(pw_out.stdout).map(|x| {
x.trim_end().to_string() x.lines().next().map(|x| x.to_owned()).ok_or_else(|| anyhow!("empty pass(1) entry!"))
}).expect("utf-8 decode of `pass(1)`-output failed"); })?.expect("utf-8 decode of `pass(1)`-output failed");
should_store = false; should_store = false;
} }
} else { } else {