diff options
| author | Matt Kraai <kraai@debian.org> | 2001-04-26 18:55:29 +0000 |
|---|---|---|
| committer | Matt Kraai <kraai@debian.org> | 2001-04-26 18:55:29 +0000 |
| commit | 6aabfd5e30087bb0ffdb6404aa6d650014de2dc0 (patch) | |
| tree | 12ef0086ec67d48f835567c56e94ef9f749e5e7a /coreutils | |
| parent | ca85cdbe4c414f5892b57a3c0fb2439f3061496c (diff) | |
| download | busybox-w32-6aabfd5e30087bb0ffdb6404aa6d650014de2dc0.tar.gz busybox-w32-6aabfd5e30087bb0ffdb6404aa6d650014de2dc0.tar.bz2 busybox-w32-6aabfd5e30087bb0ffdb6404aa6d650014de2dc0.zip | |
Fix handling of permission addition and removal (e.g., o-r).
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/chmod.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/coreutils/chmod.c b/coreutils/chmod.c index 742770e90..9139b3f4d 100644 --- a/coreutils/chmod.c +++ b/coreutils/chmod.c | |||
| @@ -29,13 +29,11 @@ | |||
| 29 | #include <getopt.h> | 29 | #include <getopt.h> |
| 30 | #include "busybox.h" | 30 | #include "busybox.h" |
| 31 | 31 | ||
| 32 | |||
| 33 | struct stat theMode; | ||
| 34 | |||
| 35 | |||
| 36 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | 32 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) |
| 37 | { | 33 | { |
| 38 | if (chmod(fileName, theMode.st_mode) == 0) | 34 | if (!parse_mode((char *)junk, &(statbuf->st_mode))) |
| 35 | error_msg_and_die("internal error"); | ||
| 36 | if (chmod(fileName, statbuf->st_mode) == 0) | ||
| 39 | return (TRUE); | 37 | return (TRUE); |
| 40 | perror(fileName); | 38 | perror(fileName); |
| 41 | return (FALSE); | 39 | return (FALSE); |
| @@ -43,6 +41,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | |||
| 43 | 41 | ||
| 44 | int chmod_main(int argc, char **argv) | 42 | int chmod_main(int argc, char **argv) |
| 45 | { | 43 | { |
| 44 | int i; | ||
| 46 | int opt; | 45 | int opt; |
| 47 | int recursiveFlag = FALSE; | 46 | int recursiveFlag = FALSE; |
| 48 | 47 | ||
| @@ -59,7 +58,8 @@ int chmod_main(int argc, char **argv) | |||
| 59 | 58 | ||
| 60 | if (argc > optind && argc > 2 && argv[optind]) { | 59 | if (argc > optind && argc > 2 && argv[optind]) { |
| 61 | /* Parse the specified mode */ | 60 | /* Parse the specified mode */ |
| 62 | if (parse_mode(argv[optind], &(theMode.st_mode)) == FALSE) { | 61 | mode_t mode; |
| 62 | if (parse_mode(argv[optind], &mode) == FALSE) { | ||
| 63 | error_msg_and_die( "unknown mode: %s", argv[optind]); | 63 | error_msg_and_die( "unknown mode: %s", argv[optind]); |
| 64 | } | 64 | } |
| 65 | } else { | 65 | } else { |
| @@ -67,9 +67,9 @@ int chmod_main(int argc, char **argv) | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | /* Ok, ready to do the deed now */ | 69 | /* Ok, ready to do the deed now */ |
| 70 | while (++optind < argc) { | 70 | for (i = optind + 1; i < argc; i++) { |
| 71 | if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE, | 71 | if (recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction, |
| 72 | fileAction, fileAction, NULL) == FALSE) { | 72 | fileAction, argv[optind]) == FALSE) { |
| 73 | return EXIT_FAILURE; | 73 | return EXIT_FAILURE; |
| 74 | } | 74 | } |
| 75 | } | 75 | } |
