From 31bc8c843e1862b2d28f31eff85eca3d1dbd4754 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 9 May 2020 14:04:47 -0700 Subject: cmd/fscrypt: add FSCRYPT_CONF environmental variable Allow overriding the location of fscrypt.conf by setting the FSCRYPT_CONF environmental variable. The CLI tests need this to avoid touching the real /etc/fscrypt.conf. --- cmd/fscrypt/fscrypt.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmd/fscrypt/fscrypt.go') diff --git a/cmd/fscrypt/fscrypt.go b/cmd/fscrypt/fscrypt.go index e260f7f..069cc96 100644 --- a/cmd/fscrypt/fscrypt.go +++ b/cmd/fscrypt/fscrypt.go @@ -31,6 +31,8 @@ import ( "os" "github.com/urfave/cli" + + "github.com/google/fscrypt/actions" ) // Current version of the program (set by Makefile) @@ -41,6 +43,10 @@ func main() { cli.CommandHelpTemplate = commandHelpTemplate cli.SubcommandHelpTemplate = subcommandHelpTemplate + if conffile := os.Getenv("FSCRYPT_CONF"); conffile != "" { + actions.ConfigFileLocation = conffile + } + // Create our command line application app := cli.NewApp() app.Usage = shortUsage -- cgit v1.2.3 From 8ff53630f1cc90ae23835e9571f9096e211dce67 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 9 May 2020 14:04:47 -0700 Subject: cmd/fscrypt: add FSCRYPT_ROOT_MNT environmental variable Allow overriding the mountpoint where login protectors are stored by setting the FSCRYPT_ROOT_MNT environmental variable. The CLI tests need this to avoid touching the real "/". --- cmd/fscrypt/fscrypt.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'cmd/fscrypt/fscrypt.go') diff --git a/cmd/fscrypt/fscrypt.go b/cmd/fscrypt/fscrypt.go index 069cc96..bbe16bb 100644 --- a/cmd/fscrypt/fscrypt.go +++ b/cmd/fscrypt/fscrypt.go @@ -46,6 +46,9 @@ func main() { if conffile := os.Getenv("FSCRYPT_CONF"); conffile != "" { actions.ConfigFileLocation = conffile } + if rootmnt := os.Getenv("FSCRYPT_ROOT_MNT"); rootmnt != "" { + actions.LoginProtectorMountpoint = rootmnt + } // Create our command line application app := cli.NewApp() -- cgit v1.2.3 From 5716215ceae3ab8b49a7b2ba410cb51a82c3176b Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 9 May 2020 14:04:47 -0700 Subject: cmd/fscrypt: add FSCRYPT_CONSISTENT_OUTPUT environmental variable Allow setting FSCRYPT_CONSISTENT_OUTPUT=1 in the environment to cause policies and protectors to sorted by last modification time. The CLI tests need this to make the output of 'fscrypt' ordered in a consistent way with regard to the operations performed. --- cmd/fscrypt/fscrypt.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmd/fscrypt/fscrypt.go') diff --git a/cmd/fscrypt/fscrypt.go b/cmd/fscrypt/fscrypt.go index bbe16bb..aa5b6f4 100644 --- a/cmd/fscrypt/fscrypt.go +++ b/cmd/fscrypt/fscrypt.go @@ -33,6 +33,7 @@ import ( "github.com/urfave/cli" "github.com/google/fscrypt/actions" + "github.com/google/fscrypt/filesystem" ) // Current version of the program (set by Makefile) @@ -49,6 +50,9 @@ func main() { if rootmnt := os.Getenv("FSCRYPT_ROOT_MNT"); rootmnt != "" { actions.LoginProtectorMountpoint = rootmnt } + if consistent := os.Getenv("FSCRYPT_CONSISTENT_OUTPUT"); consistent == "1" { + filesystem.SortDescriptorsByLastMtime = true + } // Create our command line application app := cli.NewApp() -- cgit v1.2.3