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

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
  • Loading branch information
Marcel Lauhoff committed Aug 19, 2022
1 parent ddb020a commit f2b3a7c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 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(dirPath string) error {
dir, err := os.Open(dirPath)
if err != nil {
return err
}
defer dir.Close()

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

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 @@ -225,6 +240,12 @@ 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 f2b3a7c

Please sign in to comment.