From d14c9340d6fb473e9837e91db8b6e869c37ad8e5 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Thu, 21 Oct 2021 15:58:19 +0200 Subject: cli: add -longnamemax Fixes https://github.com/rfjakob/gocryptfs/issues/499 --- internal/configfile/validate.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'internal') diff --git a/internal/configfile/validate.go b/internal/configfile/validate.go index 1611ab0..ab8917d 100644 --- a/internal/configfile/validate.go +++ b/internal/configfile/validate.go @@ -47,10 +47,10 @@ func (cf *ConfFile) Validate() error { } // Filename encryption { - if cf.IsFeatureFlagSet(FlagPlaintextNames) && cf.IsFeatureFlagSet(FlagEMENames) { - return fmt.Errorf("Can't have both PlaintextNames and EMENames feature flags") - } if cf.IsFeatureFlagSet(FlagPlaintextNames) { + if cf.IsFeatureFlagSet(FlagEMENames) { + return fmt.Errorf("PlaintextNames conflicts with EMENames feature flag") + } if cf.IsFeatureFlagSet(FlagDirIV) { return fmt.Errorf("PlaintextNames conflicts with DirIV feature flag") } @@ -60,10 +60,19 @@ func (cf *ConfFile) Validate() error { if cf.IsFeatureFlagSet(FlagRaw64) { return fmt.Errorf("PlaintextNames conflicts with Raw64 feature flag") } + if cf.IsFeatureFlagSet(FlagLongNameMax) { + return fmt.Errorf("PlaintextNames conflicts with LongNameMax feature flag") + } } if cf.IsFeatureFlagSet(FlagEMENames) { // All combinations of DirIV, LongNames, Raw64 allowed } + if cf.LongNameMax != 0 && !cf.IsFeatureFlagSet(FlagLongNameMax) { + return fmt.Errorf("LongNameMax=%d but the LongNameMax feature flag is NOT set", cf.LongNameMax) + } + if cf.LongNameMax == 0 && cf.IsFeatureFlagSet(FlagLongNameMax) { + return fmt.Errorf("LongNameMax=0 but the LongNameMax feature flag IS set") + } } return nil } -- cgit v1.2.3