main: add "-passfile" option

Make it easier to read the password from a file. Internally this
is equivalent to "-extpass /bin/cat FILE".
This commit is contained in:
Jakob Unterwurzacher 2016-10-09 20:08:10 +02:00
parent 03c8b13371
commit e1c5e71b09
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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
}