diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-05 00:12:55 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-07-05 00:12:55 +0000 |
| commit | d166f83d74240e49bcc56ece0b709d773c2e8f62 (patch) | |
| tree | 0f3d1f75a26b83d935683035f6787580831ae4f5 /coreutils | |
| parent | 42b3dea9bfb8ac595c71089ee23012f44dd43eb2 (diff) | |
| download | busybox-w32-d166f83d74240e49bcc56ece0b709d773c2e8f62.tar.gz busybox-w32-d166f83d74240e49bcc56ece0b709d773c2e8f62.tar.bz2 busybox-w32-d166f83d74240e49bcc56ece0b709d773c2e8f62.zip | |
md5_sha1_sum: fix mishandling when run as /bin/md5sum (with path)
chown/chgrp: completely match coreutils 6.8 wrt symlink handling
function old new delta
recursive_action 411 422 +11
arith 2033 2042 +9
collect_blk 467 474 +7
dhcprelay_main 1122 1125 +3
fsck_main 1909 1911 +2
singlemount 4555 4547 -8
xmalloc_realpath 14 - -14
get_lcm 123 105 -18
ed_main 3111 3084 -27
chown_main 217 183 -34
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 5/4 up/down: 32/-101) Total: -69 bytes
text data bss dec hex filename
684132 2744 14000 700876 ab1cc busybox_old
684060 2744 14000 700804 ab184 busybox_unstripped
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/chown.c | 60 | ||||
| -rw-r--r-- | coreutils/md5_sha1_sum.c | 2 |
2 files changed, 32 insertions, 30 deletions
diff --git a/coreutils/chown.c b/coreutils/chown.c index 7579e1735..eb8d8c450 100644 --- a/coreutils/chown.c +++ b/coreutils/chown.c | |||
| @@ -65,6 +65,7 @@ int chown_main(int argc, char **argv); | |||
| 65 | int chown_main(int argc, char **argv) | 65 | int chown_main(int argc, char **argv) |
| 66 | { | 66 | { |
| 67 | int retval = EXIT_SUCCESS; | 67 | int retval = EXIT_SUCCESS; |
| 68 | int flags; | ||
| 68 | chown_fptr chown_func; | 69 | chown_fptr chown_func; |
| 69 | 70 | ||
| 70 | opt_complementary = "-2"; | 71 | opt_complementary = "-2"; |
| @@ -80,23 +81,21 @@ int chown_main(int argc, char **argv) | |||
| 80 | chown_func = lchown; | 81 | chown_func = lchown; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 84 | flags = ACTION_DEPTHFIRST; /* match coreutils order */ | ||
| 85 | if (OPT_RECURSE) | ||
| 86 | flags |= ACTION_RECURSE; | ||
| 87 | if (OPT_TRAVERSE_TOP) | ||
| 88 | flags |= ACTION_FOLLOWLINKS_L0; /* -H/-L: follow links on depth 0 */ | ||
| 89 | if (OPT_TRAVERSE) | ||
| 90 | flags |= ACTION_FOLLOWLINKS; /* follow links if -L */ | ||
| 91 | |||
| 83 | parse_chown_usergroup_or_die(&ugid, argv[0]); | 92 | parse_chown_usergroup_or_die(&ugid, argv[0]); |
| 84 | 93 | ||
| 85 | /* Ok, ready to do the deed now */ | 94 | /* Ok, ready to do the deed now */ |
| 86 | argv++; | 95 | argv++; |
| 87 | do { | 96 | do { |
| 88 | char *arg = *argv; | 97 | if (!recursive_action(*argv, |
| 89 | 98 | flags, /* flags */ | |
| 90 | if (OPT_TRAVERSE_TOP) { | ||
| 91 | /* resolves symlink (even recursive) */ | ||
| 92 | arg = xmalloc_realpath(arg); | ||
| 93 | if (!arg) | ||
| 94 | continue; | ||
| 95 | } | ||
| 96 | |||
| 97 | if (!recursive_action(arg, | ||
| 98 | (OPT_RECURSE ? ACTION_RECURSE : 0) | /* recurse */ | ||
| 99 | (OPT_TRAVERSE ? ACTION_FOLLOWLINKS : 0),/* follow links if -L */ | ||
| 100 | fileAction, /* file action */ | 99 | fileAction, /* file action */ |
| 101 | fileAction, /* dir action */ | 100 | fileAction, /* dir action */ |
| 102 | chown_func, /* user data */ | 101 | chown_func, /* user data */ |
| @@ -104,9 +103,6 @@ int chown_main(int argc, char **argv) | |||
| 104 | ) { | 103 | ) { |
| 105 | retval = EXIT_FAILURE; | 104 | retval = EXIT_FAILURE; |
| 106 | } | 105 | } |
| 107 | |||
| 108 | if (OPT_TRAVERSE_TOP) | ||
| 109 | free(arg); | ||
| 110 | } while (*++argv); | 106 | } while (*++argv); |
| 111 | 107 | ||
| 112 | return retval; | 108 | return retval; |
| @@ -137,8 +133,10 @@ create() { | |||
| 137 | tst() { | 133 | tst() { |
| 138 | create test1 | 134 | create test1 |
| 139 | create test2 | 135 | create test2 |
| 140 | (cd test1; $t1 $1) | 136 | echo "[$1]" >>test1.out |
| 141 | (cd test2; $t2 $1) | 137 | echo "[$1]" >>test2.out |
| 138 | (cd test1; $t1 $1) >>test1.out 2>&1 | ||
| 139 | (cd test2; $t2 $1) >>test2.out 2>&1 | ||
| 142 | (cd test1; ls -lnR) >out1 | 140 | (cd test1; ls -lnR) >out1 |
| 143 | (cd test2; ls -lnR) >out2 | 141 | (cd test2; ls -lnR) >out2 |
| 144 | echo "chown $1" >out.diff | 142 | echo "chown $1" >out.diff |
| @@ -152,18 +150,22 @@ tst_for_each() { | |||
| 152 | tst "$1 1:1 linkfile" | 150 | tst "$1 1:1 linkfile" |
| 153 | } | 151 | } |
| 154 | echo "If script produced 'out.diff' file, then at least one testcase failed" | 152 | echo "If script produced 'out.diff' file, then at least one testcase failed" |
| 153 | >test1.out | ||
| 154 | >test2.out | ||
| 155 | # These match coreutils 6.8: | 155 | # These match coreutils 6.8: |
| 156 | tst_for_each "" | 156 | tst_for_each "-v" |
| 157 | tst_for_each "-R" | 157 | tst_for_each "-vR" |
| 158 | tst_for_each "-RP" | 158 | tst_for_each "-vRP" |
| 159 | tst_for_each "-RL" | 159 | tst_for_each "-vRL" |
| 160 | tst_for_each "-RH" | 160 | tst_for_each "-vRH" |
| 161 | tst_for_each "-h" | 161 | tst_for_each "-vh" |
| 162 | tst_for_each "-hR" | 162 | tst_for_each "-vhR" |
| 163 | tst_for_each "-hRP" | 163 | tst_for_each "-vhRP" |
| 164 | # Below: with "chown linkdir" coreutils 6.8 will chown linkdir _target_, | 164 | tst_for_each "-vhRL" |
| 165 | # we lchown _the link_. I believe we are "more correct". | 165 | tst_for_each "-vhRH" |
| 166 | #tst_for_each "-hRL" | 166 | # Fix `name' in coreutils output |
| 167 | #tst_for_each "-hRH" | 167 | sed 's/`/'"'"'/g' -i test2.out |
| 168 | # Compare us with coreutils output | ||
| 169 | diff -u test1.out test2.out | ||
| 168 | 170 | ||
| 169 | */ | 171 | */ |
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c index 4523fa4ec..8bc203486 100644 --- a/coreutils/md5_sha1_sum.c +++ b/coreutils/md5_sha1_sum.c | |||
| @@ -84,7 +84,7 @@ int md5_sha1_sum_main(int argc, char **argv) | |||
| 84 | uint8_t *hash_value; | 84 | uint8_t *hash_value; |
| 85 | unsigned flags; | 85 | unsigned flags; |
| 86 | hash_algo_t hash_algo = ENABLE_MD5SUM | 86 | hash_algo_t hash_algo = ENABLE_MD5SUM |
| 87 | ? (ENABLE_SHA1SUM ? (**argv=='m' ? HASH_MD5 : HASH_SHA1) : HASH_MD5) | 87 | ? (ENABLE_SHA1SUM ? (applet_name[0] == 'm' ? HASH_MD5 : HASH_SHA1) : HASH_MD5) |
| 88 | : HASH_SHA1; | 88 | : HASH_SHA1; |
| 89 | 89 | ||
| 90 | if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) | 90 | if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) |
