diff --git a/libntfs-3g/security.c b/libntfs-3g/security.c index d305fab0..2370f19e 100644 --- a/libntfs-3g/security.c +++ b/libntfs-3g/security.c @@ -1484,7 +1484,7 @@ static int update_secur_descr(ntfs_volume *vol, ntfs_attr_remove(ni, AT_SECURITY_DESCRIPTOR, AT_UNNAMED, 0); - } + } set_nino_flag(ni, v3_Extensions); ni->security_id = securid; ntfs_attr_close(na); @@ -3518,13 +3518,13 @@ int ntfs_set_owner_mode(struct SECURITY_CONTEXT *scx, ntfs_inode *ni, /* check whether target securid is known in cache */ isdir = (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) != 0; + wanted.uid = uid; + wanted.gid = gid; + wanted.dmode = mode & 07777; + if (isdir) wanted.dmode |= 0x10000; + wanted.variable = (void*)NULL; + wanted.varsize = 0; if (test_nino_flag(ni, v3_Extensions)) { - wanted.uid = uid; - wanted.gid = gid; - wanted.dmode = mode & 07777; - if (isdir) wanted.dmode |= 0x10000; - wanted.variable = (void*)NULL; - wanted.varsize = 0; cached = (const struct CACHED_SECURID*)ntfs_fetch_cache( scx->vol->securid_cache, GENERIC(&wanted), (cache_compare)compare); diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index e9f2e75e..f573d617 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -1065,14 +1065,16 @@ static int ntfs_fuse_create(const char *org_path, dev_t typemode, dev_t dev, * This is not possible for NTFS 1.x, and we will * have to build a security attribute later. */ - if (ctx->inherit || !ctx->security.usermapping) - securid = ntfs_inherited_id(&security, dir_path, + if (!ctx->security.usermapping) + securid = 0; + else + if (ctx->inherit) + securid = ntfs_inherited_id(&security, dir_path, dir_ni, S_ISDIR(type)); - else { - securid = ntfs_alloc_securid(&security, - security.uid, security.gid, perm, - S_ISDIR(type)); - } + else + securid = ntfs_alloc_securid(&security, + security.uid, security.gid, perm, + S_ISDIR(type)); /* Create object specified in @type. */ switch (type) { case S_IFCHR: