aboutsummaryrefslogtreecommitdiff
path: root/cmd/fscrypt/commands.go
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2021-09-14 14:37:46 -0700
committerEric Biggers <ebiggers3@gmail.com>2021-09-14 15:41:35 -0700
commit92b1e9a8670ccd3916a7d24a06cab1e4c9815bc4 (patch)
tree31da96cb92f570a77d1d4613f2f3717978743a95 /cmd/fscrypt/commands.go
parent1db83610c3361f2663d908ad3b9b96fde48ac225 (diff)
cmd/fscrypt: recognize no-key names containing hyphen
In Linux 5.15, the no-key name format is changing again; see https://git.kernel.org/linus/ba47b515f5940603. isPossibleNoKeyName() sometimes doesn't recognize the new no-key names. Update it accordingly to recognize all possible no-key names. Note: isPossibleNoKeyName() is only used as a heuristic to check whether a v1-encrypted directory is incompletely locked or not. Therefore, it's not too important whether it works. However, this change is needed for cli-tests/t_v1_policy to pass.
Diffstat (limited to 'cmd/fscrypt/commands.go')
-rw-r--r--cmd/fscrypt/commands.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd/fscrypt/commands.go b/cmd/fscrypt/commands.go
index 6a25fda..9ebcc27 100644
--- a/cmd/fscrypt/commands.go
+++ b/cmd/fscrypt/commands.go
@@ -539,8 +539,10 @@ func isPossibleNoKeyName(filename string) bool {
if len(filename) < 22 {
return false
}
- // No-key names contain only base64 characters and underscore.
- validChars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,_"
+ // On the latest kernels, no-key names contain only base64url characters
+ // (A-Z, a-z, 0-9, -, and _). On older kernels, the + and , characters
+ // were used too. Allow all of these characters.
+ validChars := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_+,"
for _, char := range filename {
if !strings.ContainsRune(validChars, char) {
return false