# include "config.h"
#endif
+#include <errno.h>
+
#include "wimlib/win32_common.h"
+#include "wimlib/assert.h"
#include "wimlib/capture.h"
#include "wimlib/dentry.h"
#include "wimlib/encoding.h"
#include "wimlib/paths.h"
#include "wimlib/reparse.h"
-#include <errno.h>
-
struct winnt_scan_stats {
unsigned long num_get_sd_access_denied;
unsigned long num_get_sacl_priv_notheld;
size_t full_path_nchars,
const wchar_t *filename,
size_t filename_nchars,
- struct add_image_params *params,
+ struct capture_params *params,
struct winnt_scan_stats *stats,
u32 vol_flags);
wchar_t *full_path,
size_t full_path_nchars,
struct wim_dentry *parent,
- struct add_image_params *params,
+ struct capture_params *params,
struct winnt_scan_stats *stats,
u32 vol_flags)
{
}
static int
-winnt_rpfix_progress(struct add_image_params *params, const wchar_t *path,
+winnt_rpfix_progress(struct capture_params *params, const wchar_t *path,
const struct reparse_data *rpdata, int scan_status)
{
size_t print_name_nchars = rpdata->print_name_nbytes / sizeof(wchar_t);
static int
winnt_try_rpfix(u8 *rpbuf, u16 *rpbuflen_p,
u64 capture_root_ino, u64 capture_root_dev,
- const wchar_t *path, struct add_image_params *params)
+ const wchar_t *path, struct capture_params *params)
{
struct reparse_data rpdata;
const wchar_t *rel_target;
*/
static int
winnt_get_reparse_data(HANDLE h, const wchar_t *path,
- struct add_image_params *params,
+ struct capture_params *params,
u8 *rpbuf, u16 *rpbuflen_ret)
{
DWORD bytes_returned;
size_t full_path_nchars,
const wchar_t *filename,
size_t filename_nchars,
- struct add_image_params *params,
+ struct capture_params *params,
struct winnt_scan_stats *stats,
u32 vol_flags)
{
u8 *rpbuf;
u16 rpbuflen;
u16 not_rpfixed;
+ ACCESS_MASK requestedPerms;
ret = try_exclude(full_path, full_path_nchars, params);
if (ret < 0) /* Excluded? */
goto out;
/* Open the file. */
+ requestedPerms = FILE_READ_DATA |
+ FILE_READ_ATTRIBUTES |
+ READ_CONTROL |
+ ACCESS_SYSTEM_SECURITY |
+ SYNCHRONIZE;
+retry_open:
status = winnt_openat(cur_dir,
(cur_dir ? filename : full_path),
(cur_dir ? filename_nchars : full_path_nchars),
- FILE_READ_DATA |
- FILE_READ_ATTRIBUTES |
- READ_CONTROL |
- ACCESS_SYSTEM_SECURITY |
- SYNCHRONIZE,
+ requestedPerms,
&h);
if (unlikely(!NT_SUCCESS(status))) {
if (status == STATUS_DELETE_PENDING) {
WARNING("\"%ls\": Deletion pending; skipping file",
printable_path(full_path));
ret = 0;
- } else {
- set_errno_from_nt_status(status);
- ERROR_WITH_ERRNO("\"%ls\": Can't open file "
- "(status=0x%08"PRIx32")",
- printable_path(full_path), (u32)status);
- if (status == STATUS_FVE_LOCKED_VOLUME)
- ret = WIMLIB_ERR_FVE_LOCKED_VOLUME;
- else
- ret = WIMLIB_ERR_OPEN;
+ goto out;
+ }
+ if (status == STATUS_ACCESS_DENIED &&
+ (requestedPerms & FILE_READ_DATA)) {
+ /* This happens on encrypted files. */
+ requestedPerms &= ~FILE_READ_DATA;
+ goto retry_open;
}
- /* XXX: Provide option to exclude files that fail with
- * STATUS_SHARING_VIOLATION? */
+
+ if (status == STATUS_FVE_LOCKED_VOLUME) {
+ ERROR("\"%ls\": Can't open file "
+ "(encrypted volume has not been unlocked)",
+ printable_path(full_path));
+ ret = WIMLIB_ERR_FVE_LOCKED_VOLUME;
+ goto out;
+ }
+
+ set_errno_from_nt_status(status);
+ ERROR_WITH_ERRNO("\"%ls\": Can't open file "
+ "(status=0x%08"PRIx32")",
+ printable_path(full_path), (u32)status);
+ ret = WIMLIB_ERR_OPEN;
goto out;
}
}
}
+ if (unlikely(!(requestedPerms & FILE_READ_DATA)) &&
+ !(file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_ENCRYPTED))
+ {
+ ERROR("\"%ls\": Permission to read data was denied",
+ printable_path(full_path));
+ ret = WIMLIB_ERR_OPEN;
+ goto out;
+ }
+
if (unlikely(!cur_dir)) {
/* Root of tree being captured; get volume information. */
int
win32_build_dentry_tree(struct wim_dentry **root_ret,
const wchar_t *root_disk_path,
- struct add_image_params *params)
+ struct capture_params *params)
{
wchar_t *path;
int ret;