From 3efc09accb5b4c7f879d3401d0380078d5f4b4fe Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Fri, 29 Jul 2016 14:43:57 -0700 Subject: [PATCH] ntfs-3g_apply.c: open $Secure --- NEWS | 3 +++ src/ntfs-3g_apply.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/NEWS b/NEWS index 4eac4fd7..2d21c49e 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,9 @@ Version 1.10.0-BETA: Reduced memory usage slightly. + When a WIM image is applied in NTFS-3G mode, security descriptors are + now created in NTFS v3.0 format when supported by the volume. + Workarounds for bugs in libntfs-3g version 2013.1.13 and earlier have been removed. Users are advised to upgrade to a later version of libntfs-3g. diff --git a/src/ntfs-3g_apply.c b/src/ntfs-3g_apply.c index 486f8890..b8b61296 100644 --- a/src/ntfs-3g_apply.c +++ b/src/ntfs-3g_apply.c @@ -914,6 +914,16 @@ ntfs_3g_extract(struct list_head *dentry_list, struct apply_ctx *_ctx) } ctx->vol = vol; + /* Opening $Secure is required to set security descriptors in NTFS v3.0 + * format, where security descriptors are stored in a per-volume index + * rather than being fully specified for each file. */ + if (ntfs_open_secure(vol) && vol->major_ver >= 3) { + ERROR_WITH_ERRNO("Unable to open security descriptor index of " + "NTFS volume \"%s\"", ctx->common.target); + ret = WIMLIB_ERR_NTFS_3G; + goto out_unmount; + } + /* Create all inodes and aliases, including short names, and set * metadata (attributes, security descriptors, and timestamps). */ @@ -948,6 +958,17 @@ ntfs_3g_extract(struct list_head *dentry_list, struct apply_ctx *_ctx) * ntfs_set_ntfs_dos_name() does, but we handle this elsewhere). */ out_unmount: + if (vol->secure_ni) { + ntfs_index_ctx_put(vol->secure_xsii); + ntfs_index_ctx_put(vol->secure_xsdh); + if (ntfs_inode_close(vol->secure_ni) && !ret) { + ERROR_WITH_ERRNO("Failed to close security descriptor " + "index of NTFS volume \"%s\"", + ctx->common.target); + ret = WIMLIB_ERR_NTFS_3G; + } + vol->secure_ni = NULL; + } if (ntfs_umount(ctx->vol, FALSE) && !ret) { ERROR_WITH_ERRNO("Failed to unmount \"%s\" with NTFS-3G", ctx->common.target); -- 2.43.0