raoulh / mc-agent

Simple ssh-agent that loads keys stored from Moolticute
GNU General Public License v3.0
15 stars 8 forks source link

"mc-agent cli -c list" should not return exit code 0 on error #17

Open asashnov opened 5 years ago

asashnov commented 5 years ago

"mc-agent cli -c list" should not return exit code 0 on error

Currently mc-agent cli -c list always returns exit code 0, even there is some error, so Mooltipass GUI, SSH Keys tab can't distinct empty list of keys from any error occured.

Actual result:

$ mc-agent cli -c list
[]
$ echo $?
0

Now exit code is always 0 no matter what:

Expected result:

Exit code should be non-zero in a case of any error. Moolticute GUI, "SSH Keys" tab should show an error if SSH Keys was not loaded from a device.

Only absence of "moolticute ssh keys" file is a normal situation and exit code should be 0 if there is no such file on a Mooltipass device (mc-agent wasn't used yet).

oliverpool commented 2 years ago

I did some testing (with a Mini BLE), and apparently only the last case Getting "moolticute ssh keys" wasn't confirmed is indistinguishable from the missing file.

The other cases send a mp_disconnected or status_changed message and could be better handled to return some other exit code (I have a prototype here: https://git.sr.ht/~oliverpool/go-moolticute/tree/main/item/client.go)