Browse Source

package/makedevs: fix recursive chmod

The logic implemented in e745c0b to stop makedevs from recursively running
chmod() on dangling symlinks excluded everything that isn't a symlink.
Other file types or directories are skipped/ignored.

Logic has been updated to exit the function if mode shouldn't be changed
or if path is a dangling symlink.

Signed-off-by: Daniel Lang <d.lang@abatec.at>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit d6d8d60ee36fe2b509f12e81584aa9a5dfd77e62)
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Lang Daniel 2 years ago
parent
commit
0c6816b204
1 changed files with 6 additions and 5 deletions
  1. 6 5
      package/makedevs/makedevs.c

+ 6 - 5
package/makedevs/makedevs.c

@@ -446,11 +446,12 @@ int bb_recursive(const char *fpath, const struct stat *sb,
 	}
 	}
 
 
 	/* chmod() is optional, also skip if dangling symlink */
 	/* chmod() is optional, also skip if dangling symlink */
-	if (recursive_mode != -1 && tflag == FTW_SL && access(fpath, F_OK)) {
-		if (chmod(fpath, recursive_mode) < 0) {
-			bb_perror_msg("chmod failed for %s", fpath);
-			return -1;
-		}
+	if (recursive_mode == -1 || (tflag == FTW_SL && !access(fpath, F_OK)))
+		return 0;
+
+	if (chmod(fpath, recursive_mode) < 0) {
+		bb_perror_msg("chmod failed for %s", fpath);
+		return -1;
 	}
 	}
 
 
 	return 0;
 	return 0;