aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-01-27 09:52:18 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-01-27 09:52:18 +0100
commit1ecfe811fe2f70380170ef7d820e8150054e88ca (patch)
tree2ecabb7c7b054ae8146942d08f361380473fb0db
parent6968e081230fb6434a2a6f0eed39d538ea982f3f (diff)
downloadbusybox-w32-1_23_1.tar.gz
busybox-w32-1_23_1.tar.bz2
busybox-w32-1_23_1.zip
Apply post-1.23.0 patches, bump version to 1.23.11_23_1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--Makefile2
-rw-r--r--editors/vi.c12
-rw-r--r--modutils/depmod.c20
-rw-r--r--modutils/modprobe-small.c27
-rw-r--r--modutils/modprobe.c31
-rw-r--r--modutils/modutils.c8
-rw-r--r--networking/ftpd.c9
-rw-r--r--shell/ash.c18
8 files changed, 71 insertions, 56 deletions
diff --git a/Makefile b/Makefile
index b487f0457..d449fa511 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 1 1VERSION = 1
2PATCHLEVEL = 23 2PATCHLEVEL = 23
3SUBLEVEL = 0 3SUBLEVEL = 1
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Unnamed 5NAME = Unnamed
6 6
diff --git a/editors/vi.c b/editors/vi.c
index 70bdbab07..7b88e8e17 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -542,9 +542,6 @@ static void cookmode(void); // return to "cooked" mode on tty
542static int mysleep(int); 542static int mysleep(int);
543static int readit(void); // read (maybe cursor) key from stdin 543static int readit(void); // read (maybe cursor) key from stdin
544static int get_one_char(void); // read 1 char from stdin 544static int get_one_char(void); // read 1 char from stdin
545#if !ENABLE_FEATURE_VI_READONLY
546#define file_insert(fn, p, update_ro_status) file_insert(fn, p)
547#endif
548// file_insert might reallocate text[]! 545// file_insert might reallocate text[]!
549static int file_insert(const char *, char *, int); 546static int file_insert(const char *, char *, int);
550static int file_write(char *, char *, char *); 547static int file_write(char *, char *, char *);
@@ -1325,7 +1322,7 @@ static void colon(char *buf)
1325 q = next_line(q); 1322 q = next_line(q);
1326 { // dance around potentially-reallocated text[] 1323 { // dance around potentially-reallocated text[]
1327 uintptr_t ofs = q - text; 1324 uintptr_t ofs = q - text;
1328 size = file_insert(fn, q, /*update_ro:*/ 0); 1325 size = file_insert(fn, q, 0);
1329 q = text + ofs; 1326 q = text + ofs;
1330 } 1327 }
1331 if (size < 0) 1328 if (size < 0)
@@ -2905,7 +2902,7 @@ static char *get_input_line(const char *prompt)
2905} 2902}
2906 2903
2907// might reallocate text[]! 2904// might reallocate text[]!
2908static int file_insert(const char *fn, char *p, int update_ro_status) 2905static int file_insert(const char *fn, char *p, int initial)
2909{ 2906{
2910 int cnt = -1; 2907 int cnt = -1;
2911 int fd, size; 2908 int fd, size;
@@ -2918,7 +2915,8 @@ static int file_insert(const char *fn, char *p, int update_ro_status)
2918 2915
2919 fd = open(fn, O_RDONLY); 2916 fd = open(fn, O_RDONLY);
2920 if (fd < 0) { 2917 if (fd < 0) {
2921 status_line_bold_errno(fn); 2918 if (!initial)
2919 status_line_bold_errno(fn);
2922 return cnt; 2920 return cnt;
2923 } 2921 }
2924 2922
@@ -2946,7 +2944,7 @@ static int file_insert(const char *fn, char *p, int update_ro_status)
2946 close(fd); 2944 close(fd);
2947 2945
2948#if ENABLE_FEATURE_VI_READONLY 2946#if ENABLE_FEATURE_VI_READONLY
2949 if (update_ro_status 2947 if (initial
2950 && ((access(fn, W_OK) < 0) || 2948 && ((access(fn, W_OK) < 0) ||
2951 /* root will always have access() 2949 /* root will always have access()
2952 * so we check fileperms too */ 2950 * so we check fileperms too */
diff --git a/modutils/depmod.c b/modutils/depmod.c
index aa228ec85..a41b3e440 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -51,7 +51,11 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
51 51
52 info->dnext = info->dprev = info; 52 info->dnext = info->dprev = info;
53 info->name = xstrdup(fname + 2); /* skip "./" */ 53 info->name = xstrdup(fname + 2); /* skip "./" */
54 info->modname = xstrdup(filename2modname(fname, modname)); 54 info->modname = xstrdup(
55 filename2modname(
56 bb_get_last_path_component_nostrip(fname),
57 modname
58 ));
55 for (ptr = image; ptr < image + len - 10; ptr++) { 59 for (ptr = image; ptr < image + len - 10; ptr++) {
56 if (strncmp(ptr, "depends=", 8) == 0) { 60 if (strncmp(ptr, "depends=", 8) == 0) {
57 char *u; 61 char *u;
@@ -242,17 +246,18 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
242 if (!(option_mask32 & OPT_n)) 246 if (!(option_mask32 & OPT_n))
243 xfreopen_write("modules.alias", stdout); 247 xfreopen_write("modules.alias", stdout);
244 for (m = modules; m != NULL; m = m->next) { 248 for (m = modules; m != NULL; m = m->next) {
249 char modname[MODULE_NAME_LEN];
245 const char *fname = bb_basename(m->name); 250 const char *fname = bb_basename(m->name);
246 int fnlen = strchrnul(fname, '.') - fname; 251 filename2modname(fname, modname);
247 while (m->aliases) { 252 while (m->aliases) {
248 /* Last word can well be m->modname instead, 253 /* Last word can well be m->modname instead,
249 * but depmod from module-init-tools 3.4 254 * but depmod from module-init-tools 3.4
250 * uses module basename, i.e., no s/-/_/g. 255 * uses module basename, i.e., no s/-/_/g.
251 * (pathname and .ko.* are still stripped) 256 * (pathname and .ko.* are still stripped)
252 * Mimicking that... */ 257 * Mimicking that... */
253 printf("alias %s %.*s\n", 258 printf("alias %s %s\n",
254 (char*)llist_pop(&m->aliases), 259 (char*)llist_pop(&m->aliases),
255 fnlen, fname); 260 modname);
256 } 261 }
257 } 262 }
258#endif 263#endif
@@ -260,12 +265,13 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
260 if (!(option_mask32 & OPT_n)) 265 if (!(option_mask32 & OPT_n))
261 xfreopen_write("modules.symbols", stdout); 266 xfreopen_write("modules.symbols", stdout);
262 for (m = modules; m != NULL; m = m->next) { 267 for (m = modules; m != NULL; m = m->next) {
268 char modname[MODULE_NAME_LEN];
263 const char *fname = bb_basename(m->name); 269 const char *fname = bb_basename(m->name);
264 int fnlen = strchrnul(fname, '.') - fname; 270 filename2modname(fname, modname);
265 while (m->symbols) { 271 while (m->symbols) {
266 printf("alias symbol:%s %.*s\n", 272 printf("alias symbol:%s %s\n",
267 (char*)llist_pop(&m->symbols), 273 (char*)llist_pop(&m->symbols),
268 fnlen, fname); 274 modname);
269 } 275 }
270 } 276 }
271#endif 277#endif
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index b7990bff1..cf8a3f0fe 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -149,9 +149,13 @@ static void replace(char *s, char what, char with)
149static char *filename2modname(const char *filename, char *modname) 149static char *filename2modname(const char *filename, char *modname)
150{ 150{
151 int i; 151 int i;
152 char *from; 152 const char *from;
153 153
154 from = bb_get_last_path_component_nostrip(filename); 154 // Disabled since otherwise "modprobe dir/name" would work
155 // as if it is "modprobe name". It is unclear why
156 // 'basenamization' was here in the first place.
157 //from = bb_get_last_path_component_nostrip(filename);
158 from = filename;
155 for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++) 159 for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++)
156 modname[i] = (from[i] == '-') ? '_' : from[i]; 160 modname[i] = (from[i] == '-') ? '_' : from[i];
157 modname[i] = '\0'; 161 modname[i] = '\0';
@@ -631,6 +635,14 @@ static void process_module(char *name, const char *cmdline_options)
631 infovec = find_alias(name); 635 infovec = find_alias(name);
632 } 636 }
633 637
638 if (!infovec) {
639 /* both dirscan and find_alias found nothing */
640 if (!is_rmmod && applet_name[0] != 'd') /* it wasn't rmmod or depmod */
641 bb_error_msg("module '%s' not found", name);
642//TODO: _and_die()? or should we continue (un)loading modules listed on cmdline?
643 goto ret;
644 }
645
634 /* There can be more than one module for the given alias. For example, 646 /* There can be more than one module for the given alias. For example,
635 * "pci:v00008086d00007010sv00000000sd00000000bc01sc01i80" matches 647 * "pci:v00008086d00007010sv00000000sd00000000bc01sc01i80" matches
636 * ata_piix because it has alias "pci:v00008086d00007010sv*sd*bc*sc*i*" 648 * ata_piix because it has alias "pci:v00008086d00007010sv*sd*bc*sc*i*"
@@ -646,7 +658,8 @@ static void process_module(char *name, const char *cmdline_options)
646 int r; 658 int r;
647 char modname[MODULE_NAME_LEN]; 659 char modname[MODULE_NAME_LEN];
648 660
649 filename2modname(info->pathname, modname); 661 filename2modname(
662 bb_get_last_path_component_nostrip(info->pathname), modname);
650 r = delete_module(modname, O_NONBLOCK | O_EXCL); 663 r = delete_module(modname, O_NONBLOCK | O_EXCL);
651 dbg1_error_msg("delete_module('%s', O_NONBLOCK | O_EXCL):%d", modname, r); 664 dbg1_error_msg("delete_module('%s', O_NONBLOCK | O_EXCL):%d", modname, r);
652 if (r != 0) { 665 if (r != 0) {
@@ -669,14 +682,6 @@ static void process_module(char *name, const char *cmdline_options)
669 */ 682 */
670 } 683 }
671 684
672 if (!infovec) {
673 /* both dirscan and find_alias found nothing */
674 if (!is_rmmod && applet_name[0] != 'd') /* it wasn't rmmod or depmod */
675 bb_error_msg("module '%s' not found", name);
676//TODO: _and_die()? or should we continue (un)loading modules listed on cmdline?
677 goto ret;
678 }
679
680 infoidx = 0; 685 infoidx = 0;
681 while ((info = infovec[infoidx++]) != NULL) { 686 while ((info = infovec[infoidx++]) != NULL) {
682 /* Iterate thru dependencies, trying to (un)load them */ 687 /* Iterate thru dependencies, trying to (un)load them */
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index f0904285b..aedde5c90 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -229,26 +229,20 @@ static ALWAYS_INLINE struct module_entry *get_or_add_modentry(const char *module
229{ 229{
230 return helper_get_module(module, 1); 230 return helper_get_module(module, 1);
231} 231}
232static ALWAYS_INLINE struct module_entry *get_modentry(const char *module) 232/* So far this function always gets a module pathname, never an alias name.
233 * The crucial difference is that pathname needs dirname stripping,
234 * while alias name must NOT do it!
235 * Testcase where dirname stripping is likely to go wrong: "modprobe devname:snd/timer"
236 */
237static ALWAYS_INLINE struct module_entry *get_modentry(const char *pathname)
233{ 238{
234 return helper_get_module(module, 0); 239 return helper_get_module(bb_get_last_path_component_nostrip(pathname), 0);
235} 240}
236 241
237static void add_probe(const char *name) 242static void add_probe(const char *name)
238{ 243{
239 struct module_entry *m; 244 struct module_entry *m;
240 245
241 /*
242 * get_or_add_modentry() strips path from name and works
243 * on remaining basename.
244 * This would make "rmmod dir/name" and "modprobe dir/name"
245 * to work like "rmmod name" and "modprobe name",
246 * which is wrong, and can be abused via implicit modprobing:
247 * "ifconfig /usbserial up" tries to modprobe netdev-/usbserial.
248 */
249 if (strchr(name, '/'))
250 bb_error_msg_and_die("malformed module name '%s'", name);
251
252 m = get_or_add_modentry(name); 246 m = get_or_add_modentry(name);
253 if (!(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS)) 247 if (!(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS))
254 && (m->flags & MODULE_FLAG_LOADED) 248 && (m->flags & MODULE_FLAG_LOADED)
@@ -428,7 +422,7 @@ static int do_modprobe(struct module_entry *m)
428 422
429 rc = 0; 423 rc = 0;
430 fn = llist_pop(&m->deps); /* we leak it */ 424 fn = llist_pop(&m->deps); /* we leak it */
431 m2 = get_or_add_modentry(fn); 425 m2 = get_or_add_modentry(bb_get_last_path_component_nostrip(fn));
432 426
433 if (option_mask32 & OPT_REMOVE) { 427 if (option_mask32 & OPT_REMOVE) {
434 /* modprobe -r */ 428 /* modprobe -r */
@@ -510,7 +504,7 @@ static void load_modules_dep(void)
510 colon = last_char_is(tokens[0], ':'); 504 colon = last_char_is(tokens[0], ':');
511 if (colon == NULL) 505 if (colon == NULL)
512 continue; 506 continue;
513 *colon = 0; 507 *colon = '\0';
514 508
515 m = get_modentry(tokens[0]); 509 m = get_modentry(tokens[0]);
516 if (m == NULL) 510 if (m == NULL)
@@ -557,7 +551,6 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
557 551
558 if (opt & OPT_LIST_ONLY) { 552 if (opt & OPT_LIST_ONLY) {
559 int i; 553 int i;
560 char name[MODULE_NAME_LEN];
561 char *colon, *tokens[2]; 554 char *colon, *tokens[2];
562 parser_t *p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read); 555 parser_t *p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read);
563 556
@@ -569,10 +562,14 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
569 if (!colon) 562 if (!colon)
570 continue; 563 continue;
571 *colon = '\0'; 564 *colon = '\0';
572 filename2modname(tokens[0], name);
573 if (!argv[0]) 565 if (!argv[0])
574 puts(tokens[0]); 566 puts(tokens[0]);
575 else { 567 else {
568 char name[MODULE_NAME_LEN];
569 filename2modname(
570 bb_get_last_path_component_nostrip(tokens[0]),
571 name
572 );
576 for (i = 0; argv[i]; i++) { 573 for (i = 0; argv[i]; i++) {
577 if (fnmatch(argv[i], name, 0) == 0) { 574 if (fnmatch(argv[i], name, 0) == 0) {
578 puts(tokens[0]); 575 puts(tokens[0]);
diff --git a/modutils/modutils.c b/modutils/modutils.c
index 6187ca72f..ff79d3fac 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -48,13 +48,17 @@ int FAST_FUNC string_to_llist(char *string, llist_t **llist, const char *delim)
48char* FAST_FUNC filename2modname(const char *filename, char *modname) 48char* FAST_FUNC filename2modname(const char *filename, char *modname)
49{ 49{
50 int i; 50 int i;
51 char *from; 51 const char *from;
52 52
53 if (filename == NULL) 53 if (filename == NULL)
54 return NULL; 54 return NULL;
55 if (modname == NULL) 55 if (modname == NULL)
56 modname = xmalloc(MODULE_NAME_LEN); 56 modname = xmalloc(MODULE_NAME_LEN);
57 from = bb_get_last_path_component_nostrip(filename); 57 // Disabled since otherwise "modprobe dir/name" would work
58 // as if it is "modprobe name". It is unclear why
59 // 'basenamization' was here in the first place.
60 //from = bb_get_last_path_component_nostrip(filename);
61 from = filename;
58 for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++) 62 for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++)
59 modname[i] = (from[i] == '-') ? '_' : from[i]; 63 modname[i] = (from[i] == '-') ? '_' : from[i];
60 modname[i] = '\0'; 64 modname[i] = '\0';
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 6adcb1dee..0c10e1f25 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -1174,8 +1174,13 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
1174 1174
1175 //umask(077); - admin can set umask before starting us 1175 //umask(077); - admin can set umask before starting us
1176 1176
1177 /* Signals. We'll always take -EPIPE rather than a rude signal, thanks */ 1177 /* Signals */
1178 signal(SIGPIPE, SIG_IGN); 1178 bb_signals(0
1179 /* We'll always take EPIPE rather than a rude signal, thanks */
1180 + (1 << SIGPIPE)
1181 /* LIST command spawns chilren. Prevent zombies */
1182 + (1 << SIGCHLD)
1183 , SIG_IGN);
1179 1184
1180 /* Set up options on the command socket (do we need these all? why?) */ 1185 /* Set up options on the command socket (do we need these all? why?) */
1181 setsockopt(STDIN_FILENO, IPPROTO_TCP, TCP_NODELAY, &const_int_1, sizeof(const_int_1)); 1186 setsockopt(STDIN_FILENO, IPPROTO_TCP, TCP_NODELAY, &const_int_1, sizeof(const_int_1));
diff --git a/shell/ash.c b/shell/ash.c
index 90fb00fbd..c5ad96909 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6746,6 +6746,14 @@ varvalue(char *name, int varflags, int flags, struct strlist *var_str_list)
6746 len = strlen(p); 6746 len = strlen(p);
6747 if (!(subtype == VSPLUS || subtype == VSLENGTH)) 6747 if (!(subtype == VSPLUS || subtype == VSLENGTH))
6748 memtodest(p, len, syntax, quotes); 6748 memtodest(p, len, syntax, quotes);
6749#if ENABLE_UNICODE_SUPPORT
6750 if (subtype == VSLENGTH && len > 0) {
6751 reinit_unicode_for_ash();
6752 if (unicode_status == UNICODE_ON) {
6753 len = unicode_strlen(p);
6754 }
6755 }
6756#endif
6749 return len; 6757 return len;
6750 } 6758 }
6751 6759
@@ -6829,15 +6837,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list)
6829 varunset(p, var, 0, 0); 6837 varunset(p, var, 0, 0);
6830 6838
6831 if (subtype == VSLENGTH) { 6839 if (subtype == VSLENGTH) {
6832 ssize_t n = varlen; 6840 cvtnum(varlen > 0 ? varlen : 0);
6833 if (n > 0) {
6834 reinit_unicode_for_ash();
6835 if (unicode_status == UNICODE_ON) {
6836 const char *val = lookupvar(var);
6837 n = unicode_strlen(val);
6838 }
6839 }
6840 cvtnum(n > 0 ? n : 0);
6841 goto record; 6841 goto record;
6842 } 6842 }
6843 6843