summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-10-09 20:08:10 +0200
committerJakob Unterwurzacher2016-10-09 20:08:10 +0200
commite1c5e71b0965b6d17e0902b60adadc67e01190fe (patch)
treea9d2d15b5378e4869358bce7b86ebeda1794ea53
parent03c8b133710c190364858de09b2f24c5fa891d88 (diff)
main: add "-passfile" option
Make it easier to read the password from a file. Internally this is equivalent to "-extpass /bin/cat FILE".
-rw-r--r--Documentation/MANPAGE.md4
-rw-r--r--cli_args.go8
2 files changed, 10 insertions, 2 deletions
diff --git a/Documentation/MANPAGE.md b/Documentation/MANPAGE.md
index b945a1d..1049703 100644
--- a/Documentation/MANPAGE.md
+++ b/Documentation/MANPAGE.md
@@ -108,6 +108,10 @@ built-in crypto is 4x slower unless your CPU has AES instructions and
you are using Go 1.6+. In mode "auto", gocrypts chooses the faster
option.
+**-passfile string**
+: Read password from the specified file. This is a shortcut for
+specifying "-extpass /bin/cat FILE".
+
**-passwd**
: Change password
diff --git a/cli_args.go b/cli_args.go
index 4f16cd4..2d5ad7e 100644
--- a/cli_args.go
+++ b/cli_args.go
@@ -17,7 +17,7 @@ type argContainer struct {
plaintextnames, quiet, nosyslog, wpanic,
longnames, allow_other, ro, reverse, aessiv, nonempty bool
masterkey, mountpoint, cipherdir, cpuprofile, extpass,
- memprofile, ko string
+ memprofile, ko, passfile string
// Configuration file name override
config string
notifypid, scryptn int
@@ -86,6 +86,7 @@ func parseCliOpts() (args argContainer) {
flagSet.StringVar(&args.memprofile, "memprofile", "", "Write memory profile to specified file")
flagSet.StringVar(&args.config, "config", "", "Use specified config file instead of CIPHERDIR/gocryptfs.conf")
flagSet.StringVar(&args.extpass, "extpass", "", "Use external program for the password prompt")
+ flagSet.StringVar(&args.passfile, "passfile", "", "Read password from file")
flagSet.StringVar(&args.ko, "ko", "", "Pass additional options directly to the kernel, comma-separated list")
flagSet.IntVar(&args.notifypid, "notifypid", 0, "Send USR1 to the specified process after "+
"successful mount - used internally for daemonization")
@@ -110,6 +111,9 @@ func parseCliOpts() (args argContainer) {
os.Exit(ErrExitUsage)
}
}
-
+ // "-passfile FILE" is a shortcut for "-extpass=/bin/cat FILE"
+ if args.passfile != "" {
+ args.extpass = "/bin/cat " + args.passfile
+ }
return args
}