From 37862daf830804d402cb5f51a2f17e84fd7322c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Thu, 22 May 2014 09:52:42 +0200 Subject: [PATCH] Fixed getting inherited security ids from cache When using Windows inheritance, the cacheing of ACLs for files created within a directory only depended on the directory. Actually it also depends on the user who creates the file. With the patch, only the ACLs created by the owner of the directory are cached. --- libntfs-3g/security.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index 95efb817..ca178782 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -3941,12 +3941,14 @@ le32 ntfs_inherited_id(struct SECURITY_CONTEXT *scx, securid = const_cpu_to_le32(0); cached = (struct CACHED_PERMISSIONS*)NULL; /* - * Try to get inherited id from cache + * Try to get inherited id from cache, possible when + * the current process owns the parent directory */ if (test_nino_flag(dir_ni, v3_Extensions) && dir_ni->security_id) { cached = fetch_cache(scx, dir_ni); - if (cached) + if (cached + && (cached->uid == scx->uid) && (cached->gid == scx->gid)) securid = (fordir ? cached->inh_dirid : cached->inh_fileid); } @@ -3962,10 +3964,13 @@ le32 ntfs_inherited_id(struct SECURITY_CONTEXT *scx, free(parentattr); /* * Store the result into cache for further use + * if the current process owns the parent directory */ if (securid) { cached = fetch_cache(scx, dir_ni); - if (cached) { + if (cached + && (cached->uid == scx->uid) + && (cached->gid == scx->gid)) { if (fordir) cached->inh_dirid = securid; else