diff options
| -rw-r--r-- | internal/configfile/config_file.go | 3 | ||||
| -rw-r--r-- | main.go | 13 | 
2 files changed, 14 insertions, 2 deletions
| diff --git a/internal/configfile/config_file.go b/internal/configfile/config_file.go index e27f2ad..b36980f 100644 --- a/internal/configfile/config_file.go +++ b/internal/configfile/config_file.go @@ -17,6 +17,9 @@ const (  	// The dot "." is not used in base64url (RFC4648), hence  	// we can never clash with an encrypted file.  	ConfDefaultName = "gocryptfs.conf" +	// In reverse mode, the config file gets stored next to the plain-text +	// files. Make it hidden (start with dot) to not annoy the user. +	ConfReverseName = ".gocryptfs.reverse.conf"  )  type ConfFile struct { @@ -24,6 +24,7 @@ import (  	"github.com/rfjakob/gocryptfs/internal/contentenc"  	"github.com/rfjakob/gocryptfs/internal/cryptocore"  	"github.com/rfjakob/gocryptfs/internal/fusefrontend" +	"github.com/rfjakob/gocryptfs/internal/fusefrontend_reverse"  	"github.com/rfjakob/gocryptfs/internal/nametransform"  	"github.com/rfjakob/gocryptfs/internal/prefer_openssl"  	"github.com/rfjakob/gocryptfs/internal/readpassword" @@ -43,7 +44,7 @@ const (  type argContainer struct {  	debug, init, zerokey, fusedebug, openssl, passwd, foreground, version,  	plaintextnames, quiet, nosyslog, wpanic, -	longnames, allow_other, ro bool +	longnames, allow_other, ro, reverse bool  	masterkey, mountpoint, cipherdir, cpuprofile, config, extpass,  	memprofile, o string  	notifypid, scryptn int @@ -193,6 +194,7 @@ func main() {  	flagSet.BoolVar(&args.allow_other, "allow_other", false, "Allow other users to access the filesystem. "+  		"Only works if user_allow_other is set in /etc/fuse.conf.")  	flagSet.BoolVar(&args.ro, "ro", false, "Mount the filesystem read-only") +	flagSet.BoolVar(&args.reverse, "reverse", false, "Reverse mode")  	flagSet.StringVar(&args.masterkey, "masterkey", "", "Mount with explicit master key")  	flagSet.StringVar(&args.cpuprofile, "cpuprofile", "", "Write cpu profile to specified file")  	flagSet.StringVar(&args.memprofile, "memprofile", "", "Write memory profile to specified file") @@ -258,6 +260,8 @@ func main() {  			os.Exit(ERREXIT_INIT)  		}  		tlog.Info.Printf("Using config file at custom location %s", args.config) +	} else if args.reverse { +		args.config = filepath.Join(args.cipherdir, configfile.ConfReverseName)  	} else {  		args.config = filepath.Join(args.cipherdir, configfile.ConfDefaultName)  	} @@ -401,7 +405,12 @@ func initFuseFrontend(key []byte, args argContainer, confFile *configfile.ConfFi  	jsonBytes, _ := json.MarshalIndent(frontendArgs, "", "\t")  	tlog.Debug.Printf("frontendArgs: %s", string(jsonBytes)) -	finalFs := fusefrontend.NewFS(frontendArgs) +	var finalFs pathfs.FileSystem +	if args.reverse { +		finalFs = fusefrontend_reverse.NewFS(frontendArgs) +	} else { +		finalFs = fusefrontend.NewFS(frontendArgs) +	}  	pathFsOpts := &pathfs.PathNodeFsOptions{ClientInodes: true}  	pathFs := pathfs.NewPathNodeFs(finalFs, pathFsOpts)  	fuseOpts := &nodefs.Options{ | 
