tadfisher / pass-otp

A pass extension for managing one-time-password (OTP) tokens
GNU General Public License v3.0
1.26k stars 86 forks source link

Optional runtime dependency (Pass::OTP / otptool) causes stderr when missing #195

Open michaelhaaf opened 4 months ago

michaelhaaf commented 4 months ago

Problem

(NOTE: edits made).

The runtime dependency otptool ~is not listed in the installation requirements (unless I'm missing something). I've done a search online and I cannot find a binary/library that corresponds to otptool.~ is listed as optional (Pass::OTP), but not having it installed causes error messages to print to stderr.

The problematic line of code is here.

https://github.com/tadfisher/pass-otp/blob/a364d2a71ad24158a009c266102ce0d91149de67/otp.bash#L21

Here is the PR that added it: https://github.com/tadfisher/pass-otp/commit/0aadd4c82cf190ae8ac9c08e7eb142716ed33a85

Result

It's not devastating, oathtool works and the correct OTP is ultimately printed on the last line of stdout.

That said, the which command from Line 21 fails and is printed to stderr:

$ pass otp /pass/path/passwordfile
which: no otptool in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
403424

Resolution

~Does a tool referred to as otptool still exist? Am I missing something? Should it be added to the list of requirements? Or is it redundant since oathtool works without it, and then should it be removed? Maybe there's an easy answer I'm missing.~

Sorry, I forgot to check the git blame when I first opened the ticket. Some actual ideas:

  1. Redirect stderr of which command to /dev/null. For my machine, where I don't have Perl nor Pass::OTP but I do have oathtool, that would look like this:
$ test="$(which otptool 2> /dev/null || true)"
$ echo $test # no stderr, no exit code 1

$ test="$(which oathtool 2> /dev/null || true)"
$ echo $test
/usr/bin/oathtool
  1. Something else?
0xphk commented 1 month ago

Assumed that you are already using version 1.1.2, just install the missing dependency or maybe stick to v1.1.1

For Debian install libpass-otp-perl For Arch install perl-pass-otp from AUR

If you plan to use Steam OTP with pass-otp, then the dependency is mandatory as oathtool doesn't understand digitsless than 6 in the URI