main: add "-nonempty" option
This commit is contained in:
parent
ff48dc1aab
commit
434ce50db3
@ -79,6 +79,10 @@ anybody on the machine who can execute "ps -auxwww".
|
|||||||
: Write memory profile to specified file. This is useful when debugging
|
: Write memory profile to specified file. This is useful when debugging
|
||||||
memory usage of gocryptfs.
|
memory usage of gocryptfs.
|
||||||
|
|
||||||
|
**-nonempty**
|
||||||
|
: Allow mounting over non-empty directories. FUSE by default disallows
|
||||||
|
this because to prevent accidential shadowing of files.
|
||||||
|
|
||||||
**-nosyslog**
|
**-nosyslog**
|
||||||
: Diagnostic messages are normally redirected to syslog once gocryptfs
|
: Diagnostic messages are normally redirected to syslog once gocryptfs
|
||||||
daemonizes. This option disables the redirection and messages will
|
daemonizes. This option disables the redirection and messages will
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
type argContainer struct {
|
type argContainer struct {
|
||||||
debug, init, zerokey, fusedebug, openssl, passwd, foreground, version,
|
debug, init, zerokey, fusedebug, openssl, passwd, foreground, version,
|
||||||
plaintextnames, quiet, nosyslog, wpanic,
|
plaintextnames, quiet, nosyslog, wpanic,
|
||||||
longnames, allow_other, ro, reverse, aessiv bool
|
longnames, allow_other, ro, reverse, aessiv, nonempty bool
|
||||||
masterkey, mountpoint, cipherdir, cpuprofile, extpass,
|
masterkey, mountpoint, cipherdir, cpuprofile, extpass,
|
||||||
memprofile, o string
|
memprofile, o string
|
||||||
// Configuration file name override
|
// Configuration file name override
|
||||||
@ -52,6 +52,7 @@ func parseCliOpts() (args argContainer) {
|
|||||||
flagSet.BoolVar(&args.ro, "ro", false, "Mount the filesystem read-only")
|
flagSet.BoolVar(&args.ro, "ro", false, "Mount the filesystem read-only")
|
||||||
flagSet.BoolVar(&args.reverse, "reverse", false, "Reverse mode")
|
flagSet.BoolVar(&args.reverse, "reverse", false, "Reverse mode")
|
||||||
flagSet.BoolVar(&args.aessiv, "aessiv", false, "AES-SIV encryption")
|
flagSet.BoolVar(&args.aessiv, "aessiv", false, "AES-SIV encryption")
|
||||||
|
flagSet.BoolVar(&args.nonempty, "nonempty", false, "Allow mounting over non-empty directories")
|
||||||
flagSet.StringVar(&args.masterkey, "masterkey", "", "Mount with explicit master key")
|
flagSet.StringVar(&args.masterkey, "masterkey", "", "Mount with explicit master key")
|
||||||
flagSet.StringVar(&args.cpuprofile, "cpuprofile", "", "Write cpu profile to specified file")
|
flagSet.StringVar(&args.cpuprofile, "cpuprofile", "", "Write cpu profile to specified file")
|
||||||
flagSet.StringVar(&args.memprofile, "memprofile", "", "Write memory profile to specified file")
|
flagSet.StringVar(&args.memprofile, "memprofile", "", "Write memory profile to specified file")
|
||||||
|
9
main.go
9
main.go
@ -236,7 +236,11 @@ func main() {
|
|||||||
tlog.Fatal.Printf("Invalid mountpoint: %v", err)
|
tlog.Fatal.Printf("Invalid mountpoint: %v", err)
|
||||||
os.Exit(ErrExitMountPoint)
|
os.Exit(ErrExitMountPoint)
|
||||||
}
|
}
|
||||||
err = checkDirEmpty(args.mountpoint)
|
if args.nonempty {
|
||||||
|
err = checkDir(args.mountpoint)
|
||||||
|
} else {
|
||||||
|
err = checkDirEmpty(args.mountpoint)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tlog.Fatal.Printf("Invalid mountpoint: %v", err)
|
tlog.Fatal.Printf("Invalid mountpoint: %v", err)
|
||||||
os.Exit(ErrExitMountPoint)
|
os.Exit(ErrExitMountPoint)
|
||||||
@ -348,6 +352,9 @@ func initFuseFrontend(key []byte, args argContainer, confFile *configfile.ConfFi
|
|||||||
// Make the kernel check the file permissions for us
|
// Make the kernel check the file permissions for us
|
||||||
mOpts.Options = append(mOpts.Options, "default_permissions")
|
mOpts.Options = append(mOpts.Options, "default_permissions")
|
||||||
}
|
}
|
||||||
|
if args.nonempty {
|
||||||
|
mOpts.Options = append(mOpts.Options, "nonempty")
|
||||||
|
}
|
||||||
// Set values shown in "df -T" and friends
|
// Set values shown in "df -T" and friends
|
||||||
// First column, "Filesystem"
|
// First column, "Filesystem"
|
||||||
mOpts.Options = append(mOpts.Options, "fsname="+args.cipherdir)
|
mOpts.Options = append(mOpts.Options, "fsname="+args.cipherdir)
|
||||||
|
@ -3,6 +3,7 @@ package normal
|
|||||||
// Test CLI operations like "-init", "-password" etc
|
// Test CLI operations like "-init", "-password" etc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
@ -146,3 +147,24 @@ func TestRo(t *testing.T) {
|
|||||||
t.Errorf("Create should have failed")
|
t.Errorf("Create should have failed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test "-nonempty"
|
||||||
|
func TestNonempty(t *testing.T) {
|
||||||
|
dir := test_helpers.InitFS(t)
|
||||||
|
mnt := dir + ".mnt"
|
||||||
|
err := os.Mkdir(mnt, 0700)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = ioutil.WriteFile(mnt+"/somefile", []byte("xyz"), 0600)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = test_helpers.Mount(dir, mnt, false, "-extpass=echo test")
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("Mounting over a file should fail per default")
|
||||||
|
}
|
||||||
|
// Should work with "-nonempty"
|
||||||
|
test_helpers.MountOrFatal(t, dir, mnt, "-nonempty", "-extpass=echo test")
|
||||||
|
test_helpers.UnmountPanic(mnt)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user