- info = OWNER_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- DACL_SECURITY_INFORMATION |
- SACL_SECURITY_INFORMATION;
-retry:
- if (!SetFileSecurity(path, info, (PSECURITY_DESCRIPTOR)desc)) {
- if (!(ctx->extract_flags & WIMLIB_EXTRACT_FLAG_STRICT_ACLS) &&
- GetLastError() == ERROR_PRIVILEGE_NOT_HELD &&
- (info & SACL_SECURITY_INFORMATION))
+ info = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION |
+ DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION;
+ h = INVALID_HANDLE_VALUE;
+
+#ifdef WITH_NTDLL
+ h = CreateFile(path, MAXIMUM_ALLOWED, 0, NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS |
+ FILE_FLAG_OPEN_REPARSE_POINT,
+ NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ ERROR_WITH_ERRNO("Can't open %ls (%u)", path, GetLastError());
+ goto error;
+ }
+#endif
+
+ for (;;) {
+ err = do_win32_set_security_descriptor(h, path, info,
+ (PSECURITY_DESCRIPTOR)desc);
+ if (err == ERROR_SUCCESS)
+ break;
+ if ((err == ERROR_PRIVILEGE_NOT_HELD ||
+ err == ERROR_ACCESS_DENIED) &&
+ !(ctx->extract_flags & WIMLIB_EXTRACT_FLAG_STRICT_ACLS))