diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-05-11 15:55:41 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-05-11 15:55:41 +0000 |
| commit | 89d14cba0b1df26cf8a33da90e305906d00faff5 (patch) | |
| tree | 380b502b99eb028b2027c96f60f27f3eb862468c /coreutils | |
| parent | f2c4ee20d44e2ea00f1205a25108e6721ac724e6 (diff) | |
| download | busybox-w32-89d14cba0b1df26cf8a33da90e305906d00faff5.tar.gz busybox-w32-89d14cba0b1df26cf8a33da90e305906d00faff5.tar.bz2 busybox-w32-89d14cba0b1df26cf8a33da90e305906d00faff5.zip | |
This patch from Lars Kellogg-Stedman, fixes the behavior of
chown to be consistant with GNU chown, so that it follows
symlinks (who cares about the perms on a link anyways?) unless
the -h option is supplied.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@2606 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/chown.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/coreutils/chown.c b/coreutils/chown.c index 011403378..a65607204 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c | |||
| @@ -36,9 +36,11 @@ | |||
| 36 | static long uid; | 36 | static long uid; |
| 37 | static long gid; | 37 | static long gid; |
| 38 | 38 | ||
| 39 | static int (*chown_func)() = chown; | ||
| 40 | |||
| 39 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | 41 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) |
| 40 | { | 42 | { |
| 41 | if (lchown(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) { | 43 | if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) { |
| 42 | return (TRUE); | 44 | return (TRUE); |
| 43 | } | 45 | } |
| 44 | perror(fileName); | 46 | perror(fileName); |
| @@ -48,21 +50,27 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | |||
| 48 | int chown_main(int argc, char **argv) | 50 | int chown_main(int argc, char **argv) |
| 49 | { | 51 | { |
| 50 | int opt; | 52 | int opt; |
| 51 | int recursiveFlag = FALSE; | 53 | int recursiveFlag = FALSE, |
| 54 | noderefFlag = FALSE; | ||
| 52 | char *groupName=NULL; | 55 | char *groupName=NULL; |
| 53 | char *p=NULL; | 56 | char *p=NULL; |
| 54 | 57 | ||
| 55 | /* do normal option parsing */ | 58 | /* do normal option parsing */ |
| 56 | while ((opt = getopt(argc, argv, "R")) > 0) { | 59 | while ((opt = getopt(argc, argv, "Rh")) > 0) { |
| 57 | switch (opt) { | 60 | switch (opt) { |
| 58 | case 'R': | 61 | case 'R': |
| 59 | recursiveFlag = TRUE; | 62 | recursiveFlag = TRUE; |
| 60 | break; | 63 | break; |
| 64 | case 'h': | ||
| 65 | noderefFlag = TRUE; | ||
| 66 | break; | ||
| 61 | default: | 67 | default: |
| 62 | show_usage(); | 68 | show_usage(); |
| 63 | } | 69 | } |
| 64 | } | 70 | } |
| 65 | 71 | ||
| 72 | if (noderefFlag) chown_func = lchown; | ||
| 73 | |||
| 66 | if (argc > optind && argc > 2 && argv[optind]) { | 74 | if (argc > optind && argc > 2 && argv[optind]) { |
| 67 | /* First, check if there is a group name here */ | 75 | /* First, check if there is a group name here */ |
| 68 | groupName = strchr(argv[optind], '.'); | 76 | groupName = strchr(argv[optind], '.'); |
