reverse: enable init functionality
This commit is contained in:
parent
72efa5c9b1
commit
5fb6c5cf58
26
init_dir.go
26
init_dir.go
@ -11,15 +11,21 @@ import (
|
|||||||
"github.com/rfjakob/gocryptfs/internal/tlog"
|
"github.com/rfjakob/gocryptfs/internal/tlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// initDir initializes an empty directory for use as a gocryptfs cipherdir.
|
// initDir prepares a directory for use as a gocryptfs storage directory.
|
||||||
|
// In forward mode, this means creating the gocryptfs.conf and gocryptfs.diriv
|
||||||
|
// files in an empty directory.
|
||||||
|
// In reverse mode, we create .gocryptfs.reverse.conf and the directory does
|
||||||
|
// not to be empty.
|
||||||
func initDir(args *argContainer) {
|
func initDir(args *argContainer) {
|
||||||
err := checkDirEmpty(args.cipherdir)
|
var err error
|
||||||
if err != nil {
|
if !args.reverse {
|
||||||
tlog.Fatal.Printf("Invalid cipherdir: %v", err)
|
err = checkDirEmpty(args.cipherdir)
|
||||||
os.Exit(ERREXIT_INIT)
|
if err != nil {
|
||||||
|
tlog.Fatal.Printf("Invalid cipherdir: %v", err)
|
||||||
|
os.Exit(ERREXIT_INIT)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Choose password for config file
|
||||||
// Create gocryptfs.conf
|
|
||||||
if args.extpass == "" {
|
if args.extpass == "" {
|
||||||
tlog.Info.Printf("Choose a password for protecting your files.")
|
tlog.Info.Printf("Choose a password for protecting your files.")
|
||||||
} else {
|
} else {
|
||||||
@ -32,9 +38,9 @@ func initDir(args *argContainer) {
|
|||||||
tlog.Fatal.Println(err)
|
tlog.Fatal.Println(err)
|
||||||
os.Exit(ERREXIT_INIT)
|
os.Exit(ERREXIT_INIT)
|
||||||
}
|
}
|
||||||
|
// Forward mode with filename encryption enabled needs a gocryptfs.diriv
|
||||||
if !args.plaintextnames {
|
// in the root dir
|
||||||
// Create gocryptfs.diriv in the root dir
|
if !args.plaintextnames && !args.reverse {
|
||||||
err = nametransform.WriteDirIV(args.cipherdir)
|
err = nametransform.WriteDirIV(args.cipherdir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Println(err)
|
tlog.Fatal.Println(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user