]> wimlib.net Git - wimlib/commitdiff
Fix progress for exclusion of absolute symlinks
authorEric Biggers <ebiggers3@gmail.com>
Tue, 24 Dec 2013 16:58:21 +0000 (10:58 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 24 Dec 2013 16:58:21 +0000 (10:58 -0600)
include/wimlib.h
src/ntfs-3g_capture.c
src/unix_capture.c
src/win32_capture.c

index 71ef0a8e160d0270bf3497b3621f663bc2cfbe2e..afed2af1147b62ad37376af53cb150938e568ff8 100644 (file)
@@ -624,7 +624,10 @@ union wimlib_progress_info {
                        WIMLIB_SCAN_DENTRY_OK = 0,
 
                        /** File or directory is being excluded from capture due
                        WIMLIB_SCAN_DENTRY_OK = 0,
 
                        /** File or directory is being excluded from capture due
-                        * to the capture configuration file.  */
+                        * to the capture configuration file, or being an
+                        * absolute symbolic link that points outside of the
+                        * capture directory without ::WIMLIB_ADD_FLAG_NORPFIX.
+                        */
                        WIMLIB_SCAN_DENTRY_EXCLUDED,
 
                        /** File or directory is being excluded from capture due
                        WIMLIB_SCAN_DENTRY_EXCLUDED,
 
                        /** File or directory is being excluded from capture due
index 444cccbd69af5c72e77984dbcab791d6249e6f6b..9bcdcc5148fdb60692a14f8f55a9435356a4814e 100644 (file)
@@ -541,10 +541,8 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
        if (exclude_path(path, path_len, params->config, false)) {
                /* Exclude a file or directory tree based on the capture
                 * configuration file.  */
        if (exclude_path(path, path_len, params->config, false)) {
                /* Exclude a file or directory tree based on the capture
                 * configuration file.  */
-               params->progress.scan.cur_path = path;
-               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
                ret = 0;
                ret = 0;
-               goto out;
+               goto out_progress;
        }
 
        /* Get file attributes */
        }
 
        /* Get file attributes */
@@ -585,7 +583,7 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
        if (inode->i_nlink > 1) {
                /* Shared inode; nothing more to do */
                ret = 0;
        if (inode->i_nlink > 1) {
                /* Shared inode; nothing more to do */
                ret = 0;
-               goto out_progress_ok;
+               goto out_progress;
        }
 
        inode->i_creation_time    = le64_to_cpu(ni->creation_time);
        }
 
        inode->i_creation_time    = le64_to_cpu(ni->creation_time);
@@ -680,10 +678,15 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
                        DEBUG("No security ID for `%s'", path);
                }
        }
                        DEBUG("No security ID for `%s'", path);
                }
        }
+       if (ret)
+               goto out;
 
 
-out_progress_ok:
+out_progress:
        params->progress.scan.cur_path = path;
        params->progress.scan.cur_path = path;
-       do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
+       if (root == NULL)
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
+       else
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
 out:
        if (ret == 0)
                *root_ret = root;
 out:
        if (ret == 0)
                *root_ret = root;
index 114d03dd4876d9d8273da274eb12915a793150c4..0d9b3998094c6902194cf87c6990ee8d0e7b50b1 100644 (file)
@@ -207,10 +207,8 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        struct stat stbuf;
 
        if (exclude_path(path, path_len, params->config, true)) {
        struct stat stbuf;
 
        if (exclude_path(path, path_len, params->config, true)) {
-               params->progress.scan.cur_path = path;
-               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
                ret = 0;
                ret = 0;
-               goto out;
+               goto out_progress;
        }
 
        if ((params->add_flags & WIMLIB_ADD_FLAG_DEREFERENCE) ||
        }
 
        if ((params->add_flags & WIMLIB_ADD_FLAG_DEREFERENCE) ||
@@ -252,7 +250,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        if (inode->i_nlink > 1) {
                /* Already captured this inode? */
                ret = 0;
        if (inode->i_nlink > 1) {
                /* Already captured this inode? */
                ret = 0;
-               goto out_progress_ok;
+               goto out_progress;
        }
 
 #ifdef HAVE_STAT_NANOSECOND_PRECISION
        }
 
 #ifdef HAVE_STAT_NANOSECOND_PRECISION
@@ -286,9 +284,12 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        if (ret)
                goto out;
 
        if (ret)
                goto out;
 
-out_progress_ok:
+out_progress:
        params->progress.scan.cur_path = path;
        params->progress.scan.cur_path = path;
-       do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
+       if (root == NULL)
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
+       else
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
 out:
        if (ret)
                free_dentry_tree(root, params->lookup_table);
 out:
        if (ret)
                free_dentry_tree(root, params->lookup_table);
index 97855b3beb389453f655bbd3343a070512e2e575..fa3f04fbff8ef28235c9df2e690e3684669089dd 100644 (file)
@@ -1130,7 +1130,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        u8 *rpbuf;
        u16 rpbuflen;
        u16 not_rpfixed;
        u8 *rpbuf;
        u16 rpbuflen;
        u16 not_rpfixed;
-       HANDLE hFile;
+       HANDLE hFile = INVALID_HANDLE_VALUE;
        DWORD desiredAccess;
 
 
        DWORD desiredAccess;
 
 
@@ -1140,10 +1140,8 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
                        ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
                        goto out;
                }
                        ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
                        goto out;
                }
-               params->progress.scan.cur_path = path;
-               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
                ret = 0;
                ret = 0;
-               goto out;
+               goto out_progress;
        }
 
 #if 0
        }
 
 #if 0
@@ -1186,7 +1184,7 @@ again:
                ERROR_WITH_ERRNO("Failed to get file information for \"%ls\"",
                                 path);
                ret = WIMLIB_ERR_STAT;
                ERROR_WITH_ERRNO("Failed to get file information for \"%ls\"",
                                 path);
                ret = WIMLIB_ERR_STAT;
-               goto out_close_handle;
+               goto out;
        }
 
        if (file_info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
        }
 
        if (file_info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
@@ -1196,12 +1194,12 @@ again:
                if (ret < 0) {
                        /* WIMLIB_ERR_* (inverted) */
                        ret = -ret;
                if (ret < 0) {
                        /* WIMLIB_ERR_* (inverted) */
                        ret = -ret;
-                       goto out_close_handle;
+                       goto out;
                } else if (ret & RP_FIXED) {
                        not_rpfixed = 0;
                } else if (ret == RP_EXCLUDED) {
                        ret = 0;
                } else if (ret & RP_FIXED) {
                        not_rpfixed = 0;
                } else if (ret == RP_EXCLUDED) {
                        ret = 0;
-                       goto out_close_handle;
+                       goto out_progress;
                } else {
                        not_rpfixed = 1;
                }
                } else {
                        not_rpfixed = 1;
                }
@@ -1222,17 +1220,17 @@ again:
                                        (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)),
                                     &root);
        if (ret)
                                        (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)),
                                     &root);
        if (ret)
-               goto out_close_handle;
+               goto out;
 
        ret = win32_get_short_name(hFile, path, root);
        if (ret)
 
        ret = win32_get_short_name(hFile, path, root);
        if (ret)
-               goto out_close_handle;
+               goto out;
 
        inode = root->d_inode;
 
        if (inode->i_nlink > 1) {
                /* Shared inode; nothing more to do */
 
        inode = root->d_inode;
 
        if (inode->i_nlink > 1) {
                /* Shared inode; nothing more to do */
-               goto out_progress_ok;
+               goto out_progress;
        }
 
        inode->i_attributes = file_info.dwFileAttributes;
        }
 
        inode->i_attributes = file_info.dwFileAttributes;
@@ -1250,7 +1248,7 @@ again:
                                                    &params->sd_set, state,
                                                    params->add_flags);
                if (ret)
                                                    &params->sd_set, state,
                                                    params->add_flags);
                if (ret)
-                       goto out_close_handle;
+                       goto out;
        }
 
        file_size = ((u64)file_info.nFileSizeHigh << 32) |
        }
 
        file_size = ((u64)file_info.nFileSizeHigh << 32) |
@@ -1267,7 +1265,7 @@ again:
                                    file_size,
                                    vol_flags);
        if (ret)
                                    file_size,
                                    vol_flags);
        if (ret)
-               goto out_close_handle;
+               goto out;
 
        if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT) {
                /* Reparse point: set the reparse data (which we read already)
 
        if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT) {
                /* Reparse point: set the reparse data (which we read already)
@@ -1288,7 +1286,7 @@ again:
                                ERROR_WITH_ERRNO("Failed to reopen \"%ls\"",
                                                 path);
                                ret = WIMLIB_ERR_OPEN;
                                ERROR_WITH_ERRNO("Failed to reopen \"%ls\"",
                                                 path);
                                ret = WIMLIB_ERR_OPEN;
-                               goto out_close_handle;
+                               goto out;
                        }
                }
                ret = win32_recurse_directory(hFile,
                        }
                }
                ret = win32_recurse_directory(hFile,
@@ -1299,13 +1297,19 @@ again:
                                              state,
                                              vol_flags);
        }
                                              state,
                                              vol_flags);
        }
+       if (ret)
+               goto out;
+
        path[path_num_chars] = '\0';
        path[path_num_chars] = '\0';
-out_progress_ok:
+out_progress:
        params->progress.scan.cur_path = path;
        params->progress.scan.cur_path = path;
-       do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
-out_close_handle:
-       CloseHandle(hFile);
+       if (root == NULL)
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
+       else
+               do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
 out:
 out:
+       if (hFile != INVALID_HANDLE_VALUE)
+               CloseHandle(hFile);
        if (ret == 0)
                *root_ret = root;
        else
        if (ret == 0)
                *root_ret = root;
        else