Skip to content

Commit

Permalink
[workaround] fscrypt: fsync encrypted dir after setting policy
Browse files Browse the repository at this point in the history
Remove if google/fscrypt#359 gets accepted
  • Loading branch information
Marcel Lauhoff committed Aug 12, 2022
1 parent f8e7ff7 commit ea30db9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions internal/util/fscrypt/fscrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ func createKeyFuncFromVolumeEncryption(
return keyFunc, nil
}

func fsyncEncryptedDirectory(path string) error {
dir, err := os.Open(path)
if err != nil {
return err
}
defer dir.Close()

err = dir.Sync()
if err != nil {
return nil
}

return nil
}

// unlockExisting tries to unlock an already set up fscrypt directory using keys from Ceph CSI.
func unlockExisting(
ctx context.Context,
Expand Down Expand Up @@ -222,6 +237,11 @@ func initializeAndUnlock(
return err
}

if err = fsyncEncryptedDirectory(encryptedPath); err != nil {
log.ErrorLog(ctx, "fscrypt: fsync encrypted dir - to flush kernel policy to disk failed %v", err)

return err
}
return nil
}

Expand Down

0 comments on commit ea30db9

Please sign in to comment.