trezor: exit with usage error if used together with -extpass
Using an external program for the Trezor PIN is not supported at the moment.
This commit is contained in:
parent
4bf02f4760
commit
8e5ca7299a
@ -221,6 +221,10 @@ func parseCliOpts() (args argContainer) {
|
|||||||
tlog.Fatal.Printf("The options -extpass and -masterkey cannot be used at the same time")
|
tlog.Fatal.Printf("The options -extpass and -masterkey cannot be used at the same time")
|
||||||
os.Exit(exitcodes.Usage)
|
os.Exit(exitcodes.Usage)
|
||||||
}
|
}
|
||||||
|
if args.extpass != "" && args.trezor {
|
||||||
|
tlog.Fatal.Printf("The options -extpass and -trezor cannot be used at the same time")
|
||||||
|
os.Exit(exitcodes.Usage)
|
||||||
|
}
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/internal/configfile"
|
"github.com/rfjakob/gocryptfs/internal/configfile"
|
||||||
|
"github.com/rfjakob/gocryptfs/internal/exitcodes"
|
||||||
|
|
||||||
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
"github.com/rfjakob/gocryptfs/tests/test_helpers"
|
||||||
)
|
)
|
||||||
@ -42,3 +43,13 @@ func TestInitTrezor(t *testing.T) {
|
|||||||
t.Error("Trezor flag should be set but is not")
|
t.Error("Trezor flag should be set but is not")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test using -trezor together with -extpass. Should fail with code 1 (usage error).
|
||||||
|
func TestTrezorExtpass(t *testing.T) {
|
||||||
|
cmd := exec.Command(test_helpers.GocryptfsBinary, "-init", "-trezor", "-extpass", "foo", "/tmp")
|
||||||
|
err := cmd.Run()
|
||||||
|
exitCode := test_helpers.ExtractCmdExitCode(err)
|
||||||
|
if exitCode != exitcodes.Usage {
|
||||||
|
t.Errorf("wrong exit code: want %d, have %d", exitcodes.Usage, exitCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user