Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/fscrypt/commands: allow disabling recovery passphrase #193

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions cmd/fscrypt/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var Encrypt = cli.Command{
immediately be used.`, directoryArg, shortDisplay(policyFlag),
shortDisplay(protectorFlag), mountpointArg),
Flags: []cli.Flag{policyFlag, unlockWithFlag, protectorFlag, sourceFlag,
userFlag, nameFlag, keyFileFlag, skipUnlockFlag},
userFlag, nameFlag, keyFileFlag, skipUnlockFlag, noRecoveryFlag},
Action: encryptAction,
}

Expand Down Expand Up @@ -239,13 +239,16 @@ func encryptPath(path string) (err error) {
}
}()

// Automatically generate a recovery passphrase if the protector
// is on a different filesystem from the policy. In practice,
// this happens for login passphrase-protected directories that
// Ask to generate a recovery passphrase if the protector is on
// a different filesystem from the policy. In practice, this
// happens for login passphrase-protected directories that
// aren't on the root filesystem, since login protectors are
// always stored on the root filesystem.
if ctx.Mount != protector.Context.Mount {
fmt.Printf("Generating recovery passphrase because protector is on a different filesystem.\n")
var needRecovery bool
if ctx.Mount != protector.Context.Mount && !noRecoveryFlag.Value {
needRecovery, err = askQuestion("Protector is on a different filesystem! Generate a recovery passphrase (recommended)?", true)
}
if needRecovery {
var recoveryProtector *actions.Protector
if recoveryPassphrase, recoveryProtector, err = actions.AddRecoveryPassphrase(
policy, filepath.Base(path)); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion cmd/fscrypt/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var (
allFlags = []prettyFlag{helpFlag, versionFlag, verboseFlag, quietFlag,
forceFlag, legacyFlag, skipUnlockFlag, timeTargetFlag,
sourceFlag, nameFlag, keyFileFlag, protectorFlag,
unlockWithFlag, policyFlag, allUsersFlag}
unlockWithFlag, policyFlag, allUsersFlag, noRecoveryFlag}
// universalFlags contains flags that should be on every command
universalFlags = []cli.Flag{verboseFlag, quietFlag, helpFlag}
)
Expand Down Expand Up @@ -178,6 +178,10 @@ var (
different from the one you're locking it as. This flag
is only implemented for v2 encryption policies.`,
}
noRecoveryFlag = &boolFlag{
Name: "no-recovery",
Usage: `Don't ask to generate a recovery passphrase.`,
}
)

// Option flags: used to specify options instead of being prompted for them
Expand Down