aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Config.in5
-rw-r--r--Makefile2
-rw-r--r--include/applets.src.h5
-rw-r--r--libbb/pw_encrypt_sha.c50
-rw-r--r--miscutils/chat.c17
-rw-r--r--runit/runsvdir.c7
-rwxr-xr-xscripts/gen_build_files.sh6
-rw-r--r--shell/hush.c45
8 files changed, 75 insertions, 62 deletions
diff --git a/Config.in b/Config.in
index d9c823199..140572e2d 100644
--- a/Config.in
+++ b/Config.in
@@ -128,8 +128,9 @@ config INSTALL_NO_USR
128 default n 128 default n
129 depends on FEATURE_INSTALLER 129 depends on FEATURE_INSTALLER
130 help 130 help
131 Disable use of /usr. busybox --install will install applets 131 Disable use of /usr. busybox --install and "make install"
132 only to /bin and /sbin, never to /usr/bin or /usr/sbin. 132 will install applets only to /bin and /sbin,
133 never to /usr/bin or /usr/sbin.
133 134
134config LOCALE_SUPPORT 135config LOCALE_SUPPORT
135 bool "Enable locale support (system needs locale for this to work)" 136 bool "Enable locale support (system needs locale for this to work)"
diff --git a/Makefile b/Makefile
index 1a9b676b5..f690ff4f2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 1 1VERSION = 1
2PATCHLEVEL = 18 2PATCHLEVEL = 18
3SUBLEVEL = 0 3SUBLEVEL = 1
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Unnamed 5NAME = Unnamed
6 6
diff --git a/include/applets.src.h b/include/applets.src.h
index 06b4fff35..f4fab53ee 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -56,6 +56,11 @@ s - suid type:
56# define APPLET_NOFORK(name,main,l,s,name2) { #name, #main, l, s, 1, 1 }, 56# define APPLET_NOFORK(name,main,l,s,name2) { #name, #main, l, s, 1, 1 },
57#endif 57#endif
58 58
59#if ENABLE_INSTALL_NO_USR
60# define _BB_DIR_USR_BIN _BB_DIR_BIN
61# define _BB_DIR_USR_SBIN _BB_DIR_SBIN
62#endif
63
59 64
60INSERT 65INSERT
61IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) 66IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test))
diff --git a/libbb/pw_encrypt_sha.c b/libbb/pw_encrypt_sha.c
index e46848b71..8aeaacad6 100644
--- a/libbb/pw_encrypt_sha.c
+++ b/libbb/pw_encrypt_sha.c
@@ -3,7 +3,7 @@
3 */ 3 */
4 4
5/* Prefix for optional rounds specification. */ 5/* Prefix for optional rounds specification. */
6static const char str_rounds[] = "rounds=%u$"; 6static const char str_rounds[] ALIGN1 = "rounds=%u$";
7 7
8/* Maximum salt string length. */ 8/* Maximum salt string length. */
9#define SALT_LEN_MAX 16 9#define SALT_LEN_MAX 16
@@ -19,8 +19,8 @@ NOINLINE
19sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data) 19sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
20{ 20{
21 void (*sha_begin)(void *ctx) FAST_FUNC; 21 void (*sha_begin)(void *ctx) FAST_FUNC;
22 void (*sha_hash)(const void *buffer, size_t len, void *ctx) FAST_FUNC; 22 void (*sha_hash)(void *ctx, const void *buffer, size_t len) FAST_FUNC;
23 void (*sha_end)(void *resbuf, void *ctx) FAST_FUNC; 23 void (*sha_end)(void *ctx, void *resbuf) FAST_FUNC;
24 int _32or64; 24 int _32or64;
25 25
26 char *result, *resptr; 26 char *result, *resptr;
@@ -103,40 +103,40 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
103 103
104 /* Add KEY, SALT. */ 104 /* Add KEY, SALT. */
105 sha_begin(&ctx); 105 sha_begin(&ctx);
106 sha_hash(key_data, key_len, &ctx); 106 sha_hash(&ctx, key_data, key_len);
107 sha_hash(salt_data, salt_len, &ctx); 107 sha_hash(&ctx, salt_data, salt_len);
108 108
109 /* Compute alternate SHA sum with input KEY, SALT, and KEY. 109 /* Compute alternate SHA sum with input KEY, SALT, and KEY.
110 The final result will be added to the first context. */ 110 The final result will be added to the first context. */
111 sha_begin(&alt_ctx); 111 sha_begin(&alt_ctx);
112 sha_hash(key_data, key_len, &alt_ctx); 112 sha_hash(&alt_ctx, key_data, key_len);
113 sha_hash(salt_data, salt_len, &alt_ctx); 113 sha_hash(&alt_ctx, salt_data, salt_len);
114 sha_hash(key_data, key_len, &alt_ctx); 114 sha_hash(&alt_ctx, key_data, key_len);
115 sha_end(alt_result, &alt_ctx); 115 sha_end(&alt_ctx, alt_result);
116 116
117 /* Add result of this to the other context. */ 117 /* Add result of this to the other context. */
118 /* Add for any character in the key one byte of the alternate sum. */ 118 /* Add for any character in the key one byte of the alternate sum. */
119 for (cnt = key_len; cnt > _32or64; cnt -= _32or64) 119 for (cnt = key_len; cnt > _32or64; cnt -= _32or64)
120 sha_hash(alt_result, _32or64, &ctx); 120 sha_hash(&ctx, alt_result, _32or64);
121 sha_hash(alt_result, cnt, &ctx); 121 sha_hash(&ctx, alt_result, cnt);
122 122
123 /* Take the binary representation of the length of the key and for every 123 /* Take the binary representation of the length of the key and for every
124 1 add the alternate sum, for every 0 the key. */ 124 1 add the alternate sum, for every 0 the key. */
125 for (cnt = key_len; cnt != 0; cnt >>= 1) 125 for (cnt = key_len; cnt != 0; cnt >>= 1)
126 if ((cnt & 1) != 0) 126 if ((cnt & 1) != 0)
127 sha_hash(alt_result, _32or64, &ctx); 127 sha_hash(&ctx, alt_result, _32or64);
128 else 128 else
129 sha_hash(key_data, key_len, &ctx); 129 sha_hash(&ctx, key_data, key_len);
130 130
131 /* Create intermediate result. */ 131 /* Create intermediate result. */
132 sha_end(alt_result, &ctx); 132 sha_end(&ctx, alt_result);
133 133
134 /* Start computation of P byte sequence. */ 134 /* Start computation of P byte sequence. */
135 /* For every character in the password add the entire password. */ 135 /* For every character in the password add the entire password. */
136 sha_begin(&alt_ctx); 136 sha_begin(&alt_ctx);
137 for (cnt = 0; cnt < key_len; ++cnt) 137 for (cnt = 0; cnt < key_len; ++cnt)
138 sha_hash(key_data, key_len, &alt_ctx); 138 sha_hash(&alt_ctx, key_data, key_len);
139 sha_end(temp_result, &alt_ctx); 139 sha_end(&alt_ctx, temp_result);
140 140
141 /* NB: past this point, raw key_data is not used anymore */ 141 /* NB: past this point, raw key_data is not used anymore */
142 142
@@ -153,8 +153,8 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
153 /* For every character in the password add the entire password. */ 153 /* For every character in the password add the entire password. */
154 sha_begin(&alt_ctx); 154 sha_begin(&alt_ctx);
155 for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt) 155 for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt)
156 sha_hash(salt_data, salt_len, &alt_ctx); 156 sha_hash(&alt_ctx, salt_data, salt_len);
157 sha_end(temp_result, &alt_ctx); 157 sha_end(&alt_ctx, temp_result);
158 158
159 /* NB: past this point, raw salt_data is not used anymore */ 159 /* NB: past this point, raw salt_data is not used anymore */
160 160
@@ -174,22 +174,22 @@ sha_crypt(/*const*/ char *key_data, /*const*/ char *salt_data)
174 174
175 /* Add key or last result. */ 175 /* Add key or last result. */
176 if ((cnt & 1) != 0) 176 if ((cnt & 1) != 0)
177 sha_hash(p_bytes, key_len, &ctx); 177 sha_hash(&ctx, p_bytes, key_len);
178 else 178 else
179 sha_hash(alt_result, _32or64, &ctx); 179 sha_hash(&ctx, alt_result, _32or64);
180 /* Add salt for numbers not divisible by 3. */ 180 /* Add salt for numbers not divisible by 3. */
181 if (cnt % 3 != 0) 181 if (cnt % 3 != 0)
182 sha_hash(s_bytes, salt_len, &ctx); 182 sha_hash(&ctx, s_bytes, salt_len);
183 /* Add key for numbers not divisible by 7. */ 183 /* Add key for numbers not divisible by 7. */
184 if (cnt % 7 != 0) 184 if (cnt % 7 != 0)
185 sha_hash(p_bytes, key_len, &ctx); 185 sha_hash(&ctx, p_bytes, key_len);
186 /* Add key or last result. */ 186 /* Add key or last result. */
187 if ((cnt & 1) != 0) 187 if ((cnt & 1) != 0)
188 sha_hash(alt_result, _32or64, &ctx); 188 sha_hash(&ctx, alt_result, _32or64);
189 else 189 else
190 sha_hash(p_bytes, key_len, &ctx); 190 sha_hash(&ctx, p_bytes, key_len);
191 191
192 sha_end(alt_result, &ctx); 192 sha_end(&ctx, alt_result);
193 } 193 }
194 194
195 /* Append encrypted password to result buffer */ 195 /* Append encrypted password to result buffer */
diff --git a/miscutils/chat.c b/miscutils/chat.c
index 8b151fda4..d8370a963 100644
--- a/miscutils/chat.c
+++ b/miscutils/chat.c
@@ -175,23 +175,24 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
175 llist_add_to_end(&aborts, arg); 175 llist_add_to_end(&aborts, arg);
176#if ENABLE_FEATURE_CHAT_CLR_ABORT 176#if ENABLE_FEATURE_CHAT_CLR_ABORT
177 } else if (DIR_CLR_ABORT == key) { 177 } else if (DIR_CLR_ABORT == key) {
178 llist_t *l;
178 // remove the string from abort conditions 179 // remove the string from abort conditions
179 // N.B. gotta refresh maximum length too... 180 // N.B. gotta refresh maximum length too...
180#if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN 181# if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
181 max_abort_len = 0; 182 max_abort_len = 0;
182#endif 183# endif
183 for (llist_t *l = aborts; l; l = l->link) { 184 for (l = aborts; l; l = l->link) {
184#if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN 185# if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
185 size_t len = strlen(l->data); 186 size_t len = strlen(l->data);
186#endif 187# endif
187 if (!strcmp(arg, l->data)) { 188 if (strcmp(arg, l->data) == 0) {
188 llist_unlink(&aborts, l); 189 llist_unlink(&aborts, l);
189 continue; 190 continue;
190 } 191 }
191#if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN 192# if ENABLE_FEATURE_CHAT_VAR_ABORT_LEN
192 if (len > max_abort_len) 193 if (len > max_abort_len)
193 max_abort_len = len; 194 max_abort_len = len;
194#endif 195# endif
195 } 196 }
196#endif 197#endif
197 } else if (DIR_TIMEOUT == key) { 198 } else if (DIR_TIMEOUT == key) {
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index e77eeff04..166664237 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -312,8 +312,11 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv)
312 last_mtime = s.st_mtime; 312 last_mtime = s.st_mtime;
313 last_dev = s.st_dev; 313 last_dev = s.st_dev;
314 last_ino = s.st_ino; 314 last_ino = s.st_ino;
315 //if (now <= mtime) 315 /* if the svdir changed this very second, wait until the
316 // sleep(1); 316 * next second, because we won't be able to detect more
317 * changes within this second */
318 while (time(NULL) == last_mtime)
319 usleep(100000);
317 need_rescan = do_rescan(); 320 need_rescan = do_rescan();
318 while (fchdir(curdir) == -1) { 321 while (fchdir(curdir) == -1) {
319 warn2_cannot("change directory, pausing", ""); 322 warn2_cannot("change directory, pausing", "");
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 130269b10..620f49548 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -18,14 +18,14 @@ generate()
18 local src="$1" dst="$2" header="$3" insert="$4" 18 local src="$1" dst="$2" header="$3" insert="$4"
19 #chk "${dst}" 19 #chk "${dst}"
20 ( 20 (
21 echo "${header}" 21 printf "%s\n" "${header}"
22 if grep -qs '^INSERT$' "${src}"; then 22 if grep -qs '^INSERT$' "${src}"; then
23 sed -n '1,/^INSERT$/p' "${src}" 23 sed -n '1,/^INSERT$/p' "${src}"
24 echo "${insert}" 24 printf "%s\n" "${insert}"
25 sed -n '/^INSERT$/,$p' "${src}" 25 sed -n '/^INSERT$/,$p' "${src}"
26 else 26 else
27 if [ -n "${insert}" ]; then 27 if [ -n "${insert}" ]; then
28 echo "ERROR: INSERT line missing in: ${src}" 1>&2 28 printf "%s\n" "ERROR: INSERT line missing in: ${src}" 1>&2
29 fi 29 fi
30 cat "${src}" 30 cat "${src}"
31 fi 31 fi
diff --git a/shell/hush.c b/shell/hush.c
index 26a50744e..fa7e4f563 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6995,27 +6995,30 @@ static int run_list(struct pipe *pi)
6995 6995
6996#if ENABLE_HUSH_LOOPS 6996#if ENABLE_HUSH_LOOPS
6997 /* Check syntax for "for" */ 6997 /* Check syntax for "for" */
6998 for (struct pipe *cpipe = pi; cpipe; cpipe = cpipe->next) { 6998 {
6999 if (cpipe->res_word != RES_FOR && cpipe->res_word != RES_IN) 6999 struct pipe *cpipe;
7000 continue; 7000 for (cpipe = pi; cpipe; cpipe = cpipe->next) {
7001 /* current word is FOR or IN (BOLD in comments below) */ 7001 if (cpipe->res_word != RES_FOR && cpipe->res_word != RES_IN)
7002 if (cpipe->next == NULL) { 7002 continue;
7003 syntax_error("malformed for"); 7003 /* current word is FOR or IN (BOLD in comments below) */
7004 debug_leave(); 7004 if (cpipe->next == NULL) {
7005 debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level); 7005 syntax_error("malformed for");
7006 return 1; 7006 debug_leave();
7007 } 7007 debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level);
7008 /* "FOR v; do ..." and "for v IN a b; do..." are ok */ 7008 return 1;
7009 if (cpipe->next->res_word == RES_DO) 7009 }
7010 continue; 7010 /* "FOR v; do ..." and "for v IN a b; do..." are ok */
7011 /* next word is not "do". It must be "in" then ("FOR v in ...") */ 7011 if (cpipe->next->res_word == RES_DO)
7012 if (cpipe->res_word == RES_IN /* "for v IN a b; not_do..."? */ 7012 continue;
7013 || cpipe->next->res_word != RES_IN /* FOR v not_do_and_not_in..."? */ 7013 /* next word is not "do". It must be "in" then ("FOR v in ...") */
7014 ) { 7014 if (cpipe->res_word == RES_IN /* "for v IN a b; not_do..."? */
7015 syntax_error("malformed for"); 7015 || cpipe->next->res_word != RES_IN /* FOR v not_do_and_not_in..."? */
7016 debug_leave(); 7016 ) {
7017 debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level); 7017 syntax_error("malformed for");
7018 return 1; 7018 debug_leave();
7019 debug_printf_exec("run_list lvl %d return 1\n", G.run_list_level);
7020 return 1;
7021 }
7019 } 7022 }
7020 } 7023 }
7021#endif 7024#endif