From vda at busybox.net Thu Feb 1 15:11:06 2007 From: vda at busybox.net (vda at busybox.net) Date: Thu, 1 Feb 2007 15:11:06 -0800 (PST) Subject: svn commit: branches/busybox_1_3_stable/networking Message-ID: <20070201231106.6EB4848613@busybox.net> Author: vda Date: 2007-02-01 15:11:04 -0800 (Thu, 01 Feb 2007) New Revision: 17700 Log: backport htons(ntransmitted++) fix Modified: branches/busybox_1_3_stable/networking/ping.c branches/busybox_1_3_stable/networking/ping6.c Changeset: Modified: branches/busybox_1_3_stable/networking/ping.c =================================================================== --- branches/busybox_1_3_stable/networking/ping.c 2007-02-01 19:20:16 UTC (rev 17699) +++ branches/busybox_1_3_stable/networking/ping.c 2007-02-01 23:11:04 UTC (rev 17700) @@ -217,9 +217,10 @@ pkt->icmp_type = ICMP_ECHO; pkt->icmp_code = 0; pkt->icmp_cksum = 0; - pkt->icmp_seq = htons(ntransmitted++); + pkt->icmp_seq = htons(ntransmitted); pkt->icmp_id = myid; CLR(ntohs(pkt->icmp_seq) % MAX_DUP_CHK); + ntransmitted++; gettimeofday((struct timeval *) &pkt->icmp_dun, NULL); pkt->icmp_cksum = in_cksum((unsigned short *) pkt, sizeof(packet)); Modified: branches/busybox_1_3_stable/networking/ping6.c =================================================================== --- branches/busybox_1_3_stable/networking/ping6.c 2007-02-01 19:20:16 UTC (rev 17699) +++ branches/busybox_1_3_stable/networking/ping6.c 2007-02-01 23:11:04 UTC (rev 17700) @@ -205,9 +205,10 @@ pkt->icmp6_type = ICMP6_ECHO_REQUEST; pkt->icmp6_code = 0; pkt->icmp6_cksum = 0; - pkt->icmp6_seq = htons(ntransmitted++); + pkt->icmp6_seq = htons(ntransmitted); pkt->icmp6_id = myid; CLR(pkt->icmp6_seq % MAX_DUP_CHK); + ntransmitted++; gettimeofday((struct timeval *) &pkt->icmp6_data8[4], NULL); From bugs at busybox.net Thu Feb 1 15:11:35 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 1 Feb 2007 15:11:35 -0800 Subject: [BusyBox 0001168]: networking/ping.c:220: warning: operation on 'ntransmitted' may be undefined Message-ID: <581d7966a15bb6d6838716684b7b47b9@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1168 ====================================================================== Reported By: gzp Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1168 Category: Networking Support Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 01-22-2007 02:03 PST Last Modified: 02-01-2007 15:11 PST ====================================================================== Summary: networking/ping.c:220: warning: operation on 'ntransmitted' may be undefined Description: CC networking/ping.o cc1: warnings being treated as errors networking/ping.c: In function 'sendping': networking/ping.c:220: warning: operation on 'ntransmitted' may be undefined make[1]: *** [networking/ping.o] Error 1 make: *** [networking] Error 2 ====================================================================== ---------------------------------------------------------------------- vda - 01-22-07 15:25 ---------------------------------------------------------------------- ?! 1.4.0, line 220: 219 signal(SIGALRM, sendping); 220 if (pingcount == 0 || ntransmitted < pingcount) { 221 alarm(PINGINTERVAL); 222 } else { We compare two unsigned longs. It's 100% ok. In which version do you see th warning? Or show code snippet around line 220. ---------------------------------------------------------------------- gzp - 01-23-07 00:17 ---------------------------------------------------------------------- This is 1.3.2, here is the complete tarball in precompiled stage: http://gzp.hu/tmp/busybox-1.3.2/ http://gzp.hu/tmp/busybox-1.3.2/log.make ---------------------------------------------------------------------- vicser - 01-30-07 07:53 ---------------------------------------------------------------------- bbox-1.3.2-ping.c.patch solves the issue ---------------------------------------------------------------------- vda - 02-01-07 15:11 ---------------------------------------------------------------------- already fixed in svn. applying to busybox_1_3_stable Issue History Date Modified Username Field Change ====================================================================== 01-22-07 02:03 gzp New Issue 01-22-07 02:03 gzp Status new => assigned 01-22-07 02:03 gzp Assigned To => BusyBox 01-22-07 15:25 vda Note Added: 0002033 01-23-07 00:17 gzp Note Added: 0002035 01-30-07 07:52 vicser File Added: bbox-1.3.2-ping.c.patch 01-30-07 07:53 vicser Note Added: 0002073 02-01-07 15:11 vda Status assigned => closed 02-01-07 15:11 vda Note Added: 0002083 ====================================================================== From bugs at busybox.net Thu Feb 1 16:59:44 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 1 Feb 2007 16:59:44 -0800 Subject: [BusyBox 0001189]: runit sv command bug Message-ID: <307e031ccf3863e8a3f235ee0ba3d8a9@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1189 ====================================================================== Reported By: netvipe Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1189 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 01-31-2007 12:28 PST Last Modified: 02-01-2007 16:59 PST ====================================================================== Summary: runit sv command bug Description: hi, i've experienced a problem with the runit "sv" utility. - running sv without args shows the usage() - running sv with a valid service name shows the status > # sv klogd > run: klogd: (pid 727) 2103s - running sv with any further option produces a failure > # sv stop -v -w 3 klogd > fail: -v: cannot change to service directory: No such file or directory > fail: -w: cannot change to service directory: No such file or directory > fail: 3: cannot change to service directory: No such file or directory > fail: stop: cannot change to service directory: No such file or directory > run: klogd: (pid 727) 2200s > # sv stop -w 3 klogd > fail: -w: cannot change to service directory: No such file or directory > fail: 3: cannot change to service directory: No such file or directory > fail: stop: cannot change to service directory: No such file or directory > run: klogd: (pid 727) 2207s > # sv stop klogd > fail: stop: cannot change to service directory: No such file or directory > run: klogd: (pid 727) 2210s it seems that argv processing has a problem to identify any kind of options ====================================================================== ---------------------------------------------------------------------- netvipe - 01-31-07 12:32 ---------------------------------------------------------------------- figured out that problem for all versions incl. current svn trunk ---------------------------------------------------------------------- vda - 02-01-07 16:59 ---------------------------------------------------------------------- Yes it is buggy indeed. Please replace sv.c with attached one, and recompile. Issue History Date Modified Username Field Change ====================================================================== 01-31-07 12:28 netvipe New Issue 01-31-07 12:28 netvipe Status new => assigned 01-31-07 12:28 netvipe Assigned To => BusyBox 01-31-07 12:32 netvipe Note Added: 0002080 01-31-07 13:00 netvipe Issue Monitored: netvipe 02-01-07 16:59 vda File Added: sv.c 02-01-07 16:59 vda Note Added: 0002085 ====================================================================== From vda at busybox.net Thu Feb 1 17:16:09 2007 From: vda at busybox.net (vda at busybox.net) Date: Thu, 1 Feb 2007 17:16:09 -0800 (PST) Subject: svn commit: trunk/busybox/networking/udhcp Message-ID: <20070202011609.9E82B485E5@busybox.net> Author: vda Date: 2007-02-01 17:16:08 -0800 (Thu, 01 Feb 2007) New Revision: 17708 Log: udhcpd: allow "domain" to be a list of DNS servers, not just one Modified: trunk/busybox/networking/udhcp/files.c trunk/busybox/networking/udhcp/options.c Changeset: Modified: trunk/busybox/networking/udhcp/files.c =================================================================== --- trunk/busybox/networking/udhcp/files.c 2007-02-02 01:03:29 UTC (rev 17707) +++ trunk/busybox/networking/udhcp/files.c 2007-02-02 01:16:08 UTC (rev 17708) @@ -101,19 +101,8 @@ { struct option_set *existing, *new, **curr; - /* add it to an existing option */ existing = find_option(*opt_list, option->code); - if (existing) { - DEBUG("Attaching option %s to existing member of list", option->name); - if (option->flags & OPTION_LIST) { - if (existing->data[OPT_LEN] + length <= 255) { - existing->data = realloc(existing->data, - existing->data[OPT_LEN] + length + 2); - memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); - existing->data[OPT_LEN] += length; - } /* else, ignore the data, we could put this in a second option in the future */ - } /* else, ignore the new data */ - } else { + if (!existing) { DEBUG("Attaching option %s to list", option->name); /* make a new option */ @@ -129,7 +118,26 @@ new->next = *curr; *curr = new; + return; } + + /* add it to an existing option */ + DEBUG("Attaching option %s to existing member of list", option->name); + if (option->flags & OPTION_LIST) { + if (existing->data[OPT_LEN] + length <= 255) { + existing->data = xrealloc(existing->data, + existing->data[OPT_LEN] + length + 3); + if ((option->flags & TYPE_MASK) == OPTION_STRING) { + if (existing->data[OPT_LEN] + length >= 255) + return; + /* add space separator between STRING options in a list */ + existing->data[existing->data[OPT_LEN] + 2] = ' '; + existing->data[OPT_LEN]++; + } + memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); + existing->data[OPT_LEN] += length; + } /* else, ignore the data, we could put this in a second option in the future */ + } /* else, ignore the new data */ } Modified: trunk/busybox/networking/udhcp/options.c =================================================================== --- trunk/busybox/networking/udhcp/options.c 2007-02-02 01:03:29 UTC (rev 17707) +++ trunk/busybox/networking/udhcp/options.c 2007-02-02 01:16:08 UTC (rev 17708) @@ -23,7 +23,7 @@ {"lprsvr", OPTION_IP | OPTION_LIST, 0x09}, {"hostname", OPTION_STRING | OPTION_REQ, 0x0c}, {"bootsize", OPTION_U16, 0x0d}, - {"domain", OPTION_STRING | OPTION_REQ, 0x0f}, + {"domain", OPTION_STRING | OPTION_LIST | OPTION_REQ, 0x0f}, {"swapsvr", OPTION_IP, 0x10}, {"rootpath", OPTION_STRING, 0x11}, {"ipttl", OPTION_U8, 0x17}, From vda at busybox.net Thu Feb 1 17:16:33 2007 From: vda at busybox.net (vda at busybox.net) Date: Thu, 1 Feb 2007 17:16:33 -0800 (PST) Subject: svn commit: trunk/busybox/networking Message-ID: <20070202011633.C0E56485E7@busybox.net> Author: vda Date: 2007-02-01 17:16:33 -0800 (Thu, 01 Feb 2007) New Revision: 17709 Log: trivial warning fix Modified: trunk/busybox/networking/interface.c Changeset: Modified: trunk/busybox/networking/interface.c =================================================================== --- trunk/busybox/networking/interface.c 2007-02-02 01:16:08 UTC (rev 17708) +++ trunk/busybox/networking/interface.c 2007-02-02 01:16:33 UTC (rev 17709) @@ -839,7 +839,7 @@ unsigned val; sap->sa_family = ether_hwtype.type; - ptr = sap->sa_data; + ptr = (unsigned char*) sap->sa_data; i = 0; orig = bufp; From vda at busybox.net Thu Feb 1 17:17:52 2007 From: vda at busybox.net (vda at busybox.net) Date: Thu, 1 Feb 2007 17:17:52 -0800 (PST) Subject: svn commit: trunk/busybox/findutils Message-ID: <20070202011752.A643D485EA@busybox.net> Author: vda Date: 2007-02-01 17:17:52 -0800 (Thu, 01 Feb 2007) New Revision: 17710 Log: find -user support by Natanael Copa Modified: trunk/busybox/findutils/Config.in trunk/busybox/findutils/find.c Changeset: Modified: trunk/busybox/findutils/Config.in =================================================================== --- trunk/busybox/findutils/Config.in 2007-02-02 01:16:33 UTC (rev 17709) +++ trunk/busybox/findutils/Config.in 2007-02-02 01:17:52 UTC (rev 17710) @@ -83,6 +83,13 @@ Support the 'find -exec' option for executing commands based upon the files matched. +config FEATURE_FIND_USER + bool "Enable username/uid matching (-user) option" + default y + depends on FIND + help + Support the 'find -user' option for searching by username or uid. + config GREP bool "grep" default n Modified: trunk/busybox/findutils/find.c =================================================================== --- trunk/busybox/findutils/find.c 2007-02-02 01:16:33 UTC (rev 17709) +++ trunk/busybox/findutils/find.c 2007-02-02 01:17:52 UTC (rev 17710) @@ -68,6 +68,7 @@ USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;)) +USE_FEATURE_FIND_USER( ACTS(user, int uid;)) USE_DESKTOP( ACTS(paren, action ***subexpr;)) USE_DESKTOP( ACTS(size, off_t size;)) USE_DESKTOP( ACTS(prune)) @@ -212,6 +213,13 @@ } #endif +#if ENABLE_FEATURE_FIND_USER +ACTF(user) +{ + return (statbuf->st_uid == ap->uid); +} +#endif + #if ENABLE_FEATURE_FIND_PRINT0 ACTF(print0) { @@ -478,6 +486,17 @@ ap->subst_count[i] = count_subst(ap->exec_argv[i]); } #endif +#ifdef ENABLE_FEATURE_FIND_USER + else if (strcmp(arg, "-user") == 0) { + action_user *ap; + if (!*++argv) + bb_error_msg_and_die(bb_msg_requires_arg, arg); + ap = ALLOC_ACTION(user); + ap->uid = bb_strtou(arg1, NULL, 10); + if (errno) + ap->uid = xuname2uid(arg1); + } +#endif #if ENABLE_DESKTOP else if (LONE_CHAR(arg, '(')) { action_paren *ap; From vda at busybox.net Thu Feb 1 17:18:38 2007 From: vda at busybox.net (vda at busybox.net) Date: Thu, 1 Feb 2007 17:18:38 -0800 (PST) Subject: svn commit: trunk/busybox/networking Message-ID: <20070202011838.47A80485EA@busybox.net> Author: vda Date: 2007-02-01 17:18:37 -0800 (Thu, 01 Feb 2007) New Revision: 17711 Log: httpd: directory indexer example doesn't need piping thru dd anymore Modified: trunk/busybox/networking/httpd_index_cgi_example Changeset: Modified: trunk/busybox/networking/httpd_index_cgi_example =================================================================== --- trunk/busybox/networking/httpd_index_cgi_example 2007-02-02 01:17:52 UTC (rev 17710) +++ trunk/busybox/networking/httpd_index_cgi_example 2007-02-02 01:18:37 UTC (rev 17711) @@ -23,10 +23,6 @@ f=`dirname "$QUERY_STRING"` test "$f" = "/" && f="" -# Pipe thru dd (need to write header as single write(), -# or else httpd doesn't see "Content-type: text/html" -# in first read() and decides that it is not html) -{ printf "%s" \ $'HTTP/1.0 200 OK\r\n'\ $'Content-type: text/html\r\n\r\n'\ @@ -52,4 +48,3 @@ } done printf "
"$'\r\n' -} | dd bs=4k From vda at busybox.net Thu Feb 1 17:19:10 2007 From: vda at busybox.net (vda at busybox.net) Date: Thu, 1 Feb 2007 17:19:10 -0800 (PST) Subject: svn commit: trunk/busybox/runit Message-ID: <20070202011910.033E9485EA@busybox.net> Author: vda Date: 2007-02-01 17:19:09 -0800 (Thu, 01 Feb 2007) New Revision: 17712 Log: sv: fix incorrect option parsing and reduce size Modified: trunk/busybox/runit/sv.c Changeset: Modified: trunk/busybox/runit/sv.c =================================================================== --- trunk/busybox/runit/sv.c 2007-02-02 01:18:37 UTC (rev 17711) +++ trunk/busybox/runit/sv.c 2007-02-02 01:19:09 UTC (rev 17712) @@ -6,27 +6,15 @@ #include "busybox.h" #include "runit_lib.h" -static char *action; static const char *acts; -static const char *varservice = "/var/service/"; static char **service; -static char **servicex; -static unsigned services; static unsigned rc; -static unsigned verbose; -static unsigned long waitsec = 7; -static unsigned kll; -static struct taia tstart, tnow, tdiff; -static struct tai tstatus; - -static int (*act)(const char*); -static int (*cbk)(const char*); - -static int curdir, fd, r; +static struct taia tstart, tnow; static char svstatus[20]; #define usage() bb_show_usage() +static void fatal_cannot(const char *m1) ATTRIBUTE_NORETURN; static void fatal_cannot(const char *m1) { bb_perror_msg("fatal: cannot %s", m1); @@ -42,23 +30,34 @@ puts(""); /* will also flush the output */ } -#define FAIL "fail: " #define WARN "warning: " #define OK "ok: " -#define RUN "run: " -#define FINISH "finish: " -#define DOWN "down: " -#define TIMEOUT "timeout: " -#define KILL "kill: " -static void fail(const char *m1) { ++rc; out(FAIL, m1); } -static void failx(const char *m1) { errno = 0; fail(m1); } -static void warn_cannot(const char *m1) { ++rc; out("warning: cannot ", m1); } -static void warnx_cannot(const char *m1) { errno = 0; warn_cannot(m1); } -static void ok(const char *m1) { errno = 0; out(OK, m1); } +static void fail(const char *m1) { + ++rc; + out("fail: ", m1); +} +static void failx(const char *m1) { + errno = 0; + fail(m1); +} +static void warn_cannot(const char *m1) { + ++rc; + out("warning: cannot ", m1); +} +static void warnx_cannot(const char *m1) { + errno = 0; + warn_cannot(m1); +} +static void ok(const char *m1) { + errno = 0; + out(OK, m1); +} static int svstatus_get(void) { + int fd, r; + fd = open_write("supervise/ok"); if (fd == -1) { if (errno == ENODEV) { @@ -87,9 +86,11 @@ static unsigned svstatus_print(const char *m) { + long diff; int pid; int normallyup = 0; struct stat s; + struct tai tstatus; if (stat("down", &s) == -1) { if (errno != ENOENT) { @@ -105,17 +106,20 @@ tai_unpack(svstatus, &tstatus); if (pid) { switch (svstatus[19]) { - case 1: printf(RUN); break; - case 2: printf(FINISH); break; + case 1: printf("run: "); break; + case 2: printf("finish: "); break; } printf("%s: (pid %d) ", m, pid); + } else { + printf("down: %s: ", m); } - else { - printf(DOWN"%s: ", m); + diff = tnow.sec.x - tstatus.x; + printf("%lds", (diff < 0 ? 0L : diff)); + if (pid) { + if (!normallyup) printf(", normally down"); + } else { + if (normallyup) printf(", normally up"); } - printf("%lus", (unsigned long)(tnow.sec.x < tstatus.x ? 0 : tnow.sec.x-tstatus.x)); - if (pid && !normallyup) printf(", normally down"); - if (!pid && normallyup) printf(", normally up"); if (pid && svstatus[16]) printf(", paused"); if (!pid && (svstatus[17] == 'u')) printf(", want up"); if (pid && (svstatus[17] == 'd')) printf(", want down"); @@ -125,8 +129,11 @@ static int status(const char *unused) { + int r; + r = svstatus_get(); switch (r) { case -1: case 0: return 0; } + r = svstatus_print(*service); if (chdir("log") == -1) { if (errno != ENOENT) { @@ -175,22 +182,35 @@ static int check(const char *a) { + int r; unsigned pid; + struct tai tstatus; - if ((r = svstatus_get()) == -1) return -1; - if (r == 0) { if (*a == 'x') return 1; return -1; } + r = svstatus_get(); + if (r == -1) + return -1; + if (r == 0) { + if (*a == 'x') + return 1; + return -1; + } pid = (unsigned char)svstatus[15]; pid <<= 8; pid += (unsigned char)svstatus[14]; pid <<= 8; pid += (unsigned char)svstatus[13]; pid <<= 8; pid += (unsigned char)svstatus[12]; switch (*a) { - case 'x': return 0; + case 'x': + return 0; case 'u': if (!pid || svstatus[19] != 1) return 0; if (!checkscript()) return 0; break; - case 'd': if (pid) return 0; break; - case 'c': if (pid) if (!checkscript()) return 0; break; + case 'd': + if (pid) return 0; + break; + case 'c': + if (pid && !checkscript()) return 0; + break; case 't': if (!pid && svstatus[17] == 'd') break; tai_unpack(svstatus, &tstatus); @@ -210,6 +230,8 @@ static int control(const char *a) { + int fd, r; + if (svstatus_get() <= 0) return -1; if (svstatus[17] == *a) return 0; fd = open_write("supervise/control"); @@ -234,25 +256,33 @@ unsigned opt; unsigned i, want_exit; char *x; + char *action; + const char *varservice = "/var/service/"; + unsigned services; + char **servicex; + unsigned long waitsec = 7; + smallint kll = 0; + smallint verbose = 0; + int (*act)(const char*); + int (*cbk)(const char*); + int curdir; - for (i = strlen(*argv); i; --i) - if ((*argv)[i-1] == '/') - break; - *argv += i; + xfunc_error_retval = 100; + + x = getenv("SVDIR"); + if (x) varservice = x; + x = getenv("SVWAIT"); + if (x) waitsec = xatoul(x); + + opt = getopt32(argc, argv, "w:v", &x); + if (opt & 1) waitsec = xatoul(x); // -w + if (opt & 2) verbose = 1; // -v + argc -= optind; + argv += optind; + action = *argv++; + if (!action || !*argv) usage(); service = argv; - services = 1; - if ((x = getenv("SVDIR"))) varservice = x; - if ((x = getenv("SVWAIT"))) waitsec = xatoul(x); - /* TODO: V can be handled internally by getopt_ulflags */ - opt = getopt32(argc, argv, "w:vV", &x); - if (opt & 1) waitsec = xatoul(x); - if (opt & 2) verbose = 1; - if (opt & 4) usage(); - if (!(action = *argv++)) usage(); - --argc; - service = argv; - services = argc; - if (!*service) usage(); + services = argc - 1; taia_now(&tnow); tstart = tnow; @@ -262,62 +292,83 @@ act = &control; acts = "s"; - if (verbose) - cbk = ✓ + cbk = ✓ + switch (*action) { - case 'x': case 'e': - acts = "x"; break; - case 'X': case 'E': - acts = "x"; kll = 1; cbk = ✓ break; + case 'x': + case 'e': + acts = "x"; + if (!verbose) cbk = NULL; + break; + case 'X': + case 'E': + acts = "x"; + kll = 1; + break; case 'D': - acts = "d"; kll = 1; cbk = ✓ break; + acts = "d"; + kll = 1; + break; case 'T': - acts = "tc"; kll = 1; cbk = ✓ break; + acts = "tc"; + kll = 1; + break; case 'c': if (!str_diff(action, "check")) { - act = 0; + act = NULL; acts = "c"; - cbk = ✓ break; } case 'u': case 'd': case 'o': case 't': case 'p': case 'h': case 'a': case 'i': case 'k': case 'q': case '1': case '2': - action[1] = 0; acts = action; break; + action[1] = '\0'; + acts = action; + if (!verbose) cbk = NULL; + break; case 's': if (!str_diff(action, "shutdown")) { acts = "x"; - cbk = ✓ break; } if (!str_diff(action, "start")) { acts = "u"; - cbk = ✓ break; } if (!str_diff(action, "stop")) { acts = "d"; - cbk = ✓ break; } + /* "status" */ act = &status; cbk = NULL; break; case 'r': if (!str_diff(action, "restart")) { acts = "tcu"; - cbk = ✓ break; } usage(); case 'f': - if (!str_diff(action, "force-reload")) - { acts = "tc"; kll = 1; cbk = ✓ break; } - if (!str_diff(action, "force-restart")) - { acts = "tcu"; kll = 1; cbk = ✓ break; } - if (!str_diff(action, "force-shutdown")) - { acts = "x"; kll = 1; cbk = ✓ break; } - if (!str_diff(action, "force-stop")) - { acts = "d"; kll = 1; cbk = ✓ break; } + if (!str_diff(action, "force-reload")) { + acts = "tc"; + kll = 1; + break; + } + if (!str_diff(action, "force-restart")) { + acts = "tcu"; + kll = 1; + break; + } + if (!str_diff(action, "force-shutdown")) { + acts = "x"; + kll = 1; + break; + } + if (!str_diff(action, "force-stop")) { + acts = "d"; + kll = 1; + break; + } default: usage(); } @@ -325,59 +376,64 @@ servicex = service; for (i = 0; i < services; ++i) { if ((**service != '/') && (**service != '.')) { - if ((chdir(varservice) == -1) || (chdir(*service) == -1)) { - fail("cannot change to service directory"); - *service = 0; - } - } else if (chdir(*service) == -1) { + if (chdir(varservice) == -1) + goto chdir_failed_0; + } + if (chdir(*service) == -1) { + chdir_failed_0: fail("cannot change to service directory"); - *service = 0; + goto nullify_service_0; } - if (*service) if (act && (act(acts) == -1)) *service = 0; - if (fchdir(curdir) == -1) fatal_cannot("change to original directory"); + if (act && (act(acts) == -1)) { + nullify_service_0: + *service = NULL; + } + if (fchdir(curdir) == -1) + fatal_cannot("change to original directory"); service++; } - if (*cbk) { - for (;;) { -//TODO: tdiff resolution is way too high. seconds will be enough - taia_sub(&tdiff, &tnow, &tstart); - service = servicex; want_exit = 1; - for (i = 0; i < services; ++i, ++service) { - if (!*service) - continue; - if ((**service != '/') && (**service != '.')) { - if (chdir(varservice) == -1) - goto chdir_failed; - } - if (chdir(*service) == -1) { + if (cbk) while (1) { + //struct taia tdiff; + long diff; + + //taia_sub(&tdiff, &tnow, &tstart); + diff = tnow.sec.x - tstart.sec.x; + service = servicex; + want_exit = 1; + for (i = 0; i < services; ++i, ++service) { + if (!*service) + continue; + if ((**service != '/') && (**service != '.')) { + if (chdir(varservice) == -1) + goto chdir_failed; + } + if (chdir(*service) == -1) { chdir_failed: - fail("cannot change to service directory"); - goto nullify_service; + fail("cannot change to service directory"); + goto nullify_service; + } + if (cbk(acts) != 0) + goto nullify_service; + want_exit = 0; + if (diff >= waitsec) { + printf(kll ? "kill: " : "timeout: "); + if (svstatus_get() > 0) { + svstatus_print(*service); + ++rc; } - if (cbk(acts) != 0) - goto nullify_service; - want_exit = 0; - //if (taia_approx(&tdiff) > waitsec) - if (tdiff.sec.x >= waitsec) { - kll ? printf(KILL) : printf(TIMEOUT); - if (svstatus_get() > 0) { - svstatus_print(*service); - ++rc; - } - puts(""); /* will also flush the output */ - if (kll) - control("k"); + puts(""); /* will also flush the output */ + if (kll) + control("k"); nullify_service: - *service = NULL; - } - if (fchdir(curdir) == -1) - fatal_cannot("change to original directory"); + *service = NULL; } - if (want_exit) break; - usleep(420000); - taia_now(&tnow); + if (fchdir(curdir) == -1) + fatal_cannot("change to original directory"); } + if (want_exit) break; + usleep(420000); + taia_now(&tnow); } return rc > 99 ? 99 : rc; } From vda at busybox.net Thu Feb 1 17:57:24 2007 From: vda at busybox.net (vda at busybox.net) Date: Thu, 1 Feb 2007 17:57:24 -0800 (PST) Subject: svn commit: trunk/busybox/networking/udhcp Message-ID: <20070202015724.A136D485F0@busybox.net> Author: vda Date: 2007-02-01 17:57:24 -0800 (Thu, 01 Feb 2007) New Revision: 17717 Log: add a comment so that people won't get confused Modified: trunk/busybox/networking/udhcp/files.c Changeset: Modified: trunk/busybox/networking/udhcp/files.c =================================================================== --- trunk/busybox/networking/udhcp/files.c 2007-02-02 01:42:51 UTC (rev 17716) +++ trunk/busybox/networking/udhcp/files.c 2007-02-02 01:57:24 UTC (rev 17717) @@ -128,6 +128,7 @@ existing->data = xrealloc(existing->data, existing->data[OPT_LEN] + length + 3); if ((option->flags & TYPE_MASK) == OPTION_STRING) { + /* ' ' can bring us to 256 - bad */ if (existing->data[OPT_LEN] + length >= 255) return; /* add space separator between STRING options in a list */ From aldot at busybox.net Fri Feb 2 08:06:03 2007 From: aldot at busybox.net (aldot at busybox.net) Date: Fri, 2 Feb 2007 08:06:03 -0800 (PST) Subject: svn commit: trunk/busybox/networking Message-ID: <20070202160603.95EEF48616@busybox.net> Author: aldot Date: 2007-02-02 08:06:02 -0800 (Fri, 02 Feb 2007) New Revision: 17726 Log: - update helptext Modified: trunk/busybox/networking/Config.in Changeset: Modified: trunk/busybox/networking/Config.in =================================================================== --- trunk/busybox/networking/Config.in 2007-02-02 13:50:23 UTC (rev 17725) +++ trunk/busybox/networking/Config.in 2007-02-02 16:06:02 UTC (rev 17726) @@ -394,6 +394,7 @@ ip link -> iplink ip route -> iproute ip tunnel -> iptunnel + ip rule -> iprule Say N unless you desparately need the short form of the ip object commands. From aldot at busybox.net Fri Feb 2 08:11:24 2007 From: aldot at busybox.net (aldot at busybox.net) Date: Fri, 2 Feb 2007 08:11:24 -0800 (PST) Subject: svn commit: trunk/busybox/scripts Message-ID: <20070202161124.E212A48616@busybox.net> Author: aldot Date: 2007-02-02 08:11:24 -0800 (Fri, 02 Feb 2007) New Revision: 17727 Log: - minor tweak Modified: trunk/busybox/scripts/Makefile.IMA Changeset: Modified: trunk/busybox/scripts/Makefile.IMA =================================================================== --- trunk/busybox/scripts/Makefile.IMA 2007-02-02 16:06:02 UTC (rev 17726) +++ trunk/busybox/scripts/Makefile.IMA 2007-02-02 16:11:24 UTC (rev 17727) @@ -106,10 +106,11 @@ lib-all-y += $(patsubst %,libbb/%,$(sort $(lib-y))) lib-y:= +include Makefile.flags ifndef BB_VER BB_VER:="" endif -include Makefile.flags + CPPFLAGS+= -D"KBUILD_STR(s)=\#s" #-Q HOSTCC = gcc @@ -117,7 +118,7 @@ busybox: $(usage_stuff) $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_EXTRA) --combine -fwhole-program \ - -funit-at-a-time -Wno-error \ + -funit-at-a-time -Wno-error -std=gnu99 \ -o $(@)_unstripped $(lib-all-y:.o=.c) \ -Wl,--start-group -lcrypt -lm -Wl,--end-group cp $(@)_unstripped $@ From vda at busybox.net Fri Feb 2 16:52:18 2007 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 Feb 2007 16:52:18 -0800 (PST) Subject: svn commit: trunk/busybox/runit Message-ID: <20070203005218.1878D48635@busybox.net> Author: vda Date: 2007-02-02 16:52:17 -0800 (Fri, 02 Feb 2007) New Revision: 17729 Log: svlogd: do not set O_NONBLOCK on stdin permanently - that can affect other processes! Modified: trunk/busybox/runit/svlogd.c Changeset: Modified: trunk/busybox/runit/svlogd.c =================================================================== --- trunk/busybox/runit/svlogd.c 2007-02-02 16:15:51 UTC (rev 17728) +++ trunk/busybox/runit/svlogd.c 2007-02-03 00:52:17 UTC (rev 17729) @@ -44,16 +44,20 @@ static struct taia trotate; static char *line; -static unsigned exitasap; -static unsigned rotateasap; -static unsigned reopenasap; -static unsigned linecomplete = 1; -static unsigned tmaxflag; -static iopause_fd input; +static smallint exitasap; +static smallint rotateasap; +static smallint reopenasap; +static smallint linecomplete = 1; +static smallint tmaxflag; + +static char repl; static const char *replace = ""; -static char repl; +sigset_t blocked_sigset; +static iopause_fd input; +static int fl_flag_0; + static struct logdir { //// char *btmp; /* pattern list to match, in "aa\0bb\0\cc\0\0" form */ @@ -333,7 +337,7 @@ if (len > (ld->sizemax - ld->size)) len = ld->sizemax - ld->size; } - while ((i = write(ld->fdcur, s, len)) == -1) { + while ((i = full_write(ld->fdcur, s, len)) == -1) { if ((errno == ENOSPC) && (ld->nmin < ld->nmax)) { DIR *d; struct dirent *f; @@ -585,6 +589,17 @@ if (!ok) fatalx("no functional log directories"); } +/* Will look good in libbb one day */ +static ssize_t ndelay_read(int fd, void *buf, size_t count) +{ + if (!(fl_flag_0 & O_NONBLOCK)) + fcntl(fd, F_SETFL, fl_flag_0 | O_NONBLOCK); + count = safe_read(fd, buf, count); + if (!(fl_flag_0 & O_NONBLOCK)) + fcntl(fd, F_SETFL, fl_flag_0); + return count; +} + /* Used for reading stdin */ static int buffer_pread(int fd, char *s, unsigned len) { @@ -617,17 +632,10 @@ } while (1) { - /* Comment? */ - sig_unblock(SIGTERM); - sig_unblock(SIGCHLD); - sig_unblock(SIGALRM); - sig_unblock(SIGHUP); + sigprocmask(SIG_UNBLOCK, &blocked_sigset, NULL); iopause(&input, 1, &trotate, &now); - sig_block(SIGTERM); - sig_block(SIGCHLD); - sig_block(SIGALRM); - sig_block(SIGHUP); - i = safe_read(fd, s, len); + sigprocmask(SIG_BLOCK, &blocked_sigset, NULL); + i = ndelay_read(fd, s, len); if (i >= 0) break; if (errno != EAGAIN) { warn("cannot read standard input"); @@ -775,14 +783,17 @@ fndir = argv; input.fd = 0; input.events = IOPAUSE_READ; - /* I be damned. Linux 2.6.18: this somehow affects - * OTHER processes! Konsole starts to redraw itself much slower! - * This persists even after svlogd exits */ - ndelay_on(input.fd); - sig_block(SIGTERM); - sig_block(SIGCHLD); - sig_block(SIGALRM); - sig_block(SIGHUP); + /* We cannot set NONBLOCK on fd #0 permanently - this setting + * _isn't_ per-process! It is shared among all other processes + * with the same stdin */ + fl_flag_0 = fcntl(0, F_GETFL, 0); + + sigemptyset(&blocked_sigset); + sigaddset(&blocked_sigset, SIGTERM); + sigaddset(&blocked_sigset, SIGCHLD); + sigaddset(&blocked_sigset, SIGALRM); + sigaddset(&blocked_sigset, SIGHUP); + sigprocmask(SIG_BLOCK, &blocked_sigset, NULL); sig_catch(SIGTERM, sig_term_handler); sig_catch(SIGCHLD, sig_child_handler); sig_catch(SIGALRM, sig_alarm_handler); @@ -850,8 +861,13 @@ /* linelen == no of chars incl. '\n' (or == stdin_cnt) */ ch = lineptr[linelen-1]; - /* write out lineptr[0..linelen-1] to each log destination */ - /* (or lineptr[-26..linelen-1] if timestamping) */ + /* TODO: biggest performance hit is coming from the fact + * that we do not buffer writes. We may read many lines + * in one read() above, but will do one write() + * per line below. Should we use stdio? */ + + /* write out lineptr[0..linelen-1] to each log destination + * (or lineptr[-26..linelen-1] if timestamping) */ printlen = linelen; printptr = lineptr; if (timestamp) { From vda at busybox.net Fri Feb 2 16:53:43 2007 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 Feb 2007 16:53:43 -0800 (PST) Subject: svn commit: trunk/busybox/runit Message-ID: <20070203005343.456EC48636@busybox.net> Author: vda Date: 2007-02-02 16:53:43 -0800 (Fri, 02 Feb 2007) New Revision: 17731 Log: svlogd: fix performance problems: excessive write, gettimeofday calls. rt_sigprocmask were dealt with in previous commit Modified: trunk/busybox/runit/svlogd.c Changeset: Modified: trunk/busybox/runit/svlogd.c =================================================================== --- trunk/busybox/runit/svlogd.c 2007-02-03 00:52:39 UTC (rev 17730) +++ trunk/busybox/runit/svlogd.c 2007-02-03 00:53:43 UTC (rev 17731) @@ -59,7 +59,7 @@ static int fl_flag_0; static struct logdir { -//// char *btmp; + ////char *btmp; /* pattern list to match, in "aa\0bb\0\cc\0\0" form */ char *inst; char *processor; @@ -73,6 +73,7 @@ int ppid; int fddir; int fdcur; + FILE* filecur; //// int fdlock; struct taia trotate; char fnsave[FMT_PTIME]; @@ -300,11 +301,13 @@ } if (ld->size > 0) { - while (fsync(ld->fdcur) == -1) + while (fflush(ld->filecur) || fsync(ld->fdcur) == -1) pause2cannot("fsync current logfile", ld->name); while (fchmod(ld->fdcur, 0744) == -1) pause2cannot("set mode of current", ld->name); - close(ld->fdcur); + ////close(ld->fdcur); + fclose(ld->filecur); + if (verbose) { bb_error_msg(INFO"rename: %s/current %s %u", ld->name, ld->fnsave, ld->size); @@ -313,6 +316,9 @@ pause2cannot("rename current", ld->name); while ((ld->fdcur = open("current", O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600)) == -1) pause2cannot("create new current", ld->name); + /* we presume this cannot fail */ + ld->filecur = fdopen(ld->fdcur, "a"); //// + setvbuf(ld->filecur, NULL, _IOFBF, linelen); //// coe(ld->fdcur); ld->size = 0; while (fchmod(ld->fdcur, 0644) == -1) @@ -337,7 +343,12 @@ if (len > (ld->sizemax - ld->size)) len = ld->sizemax - ld->size; } - while ((i = full_write(ld->fdcur, s, len)) == -1) { + while (1) { + ////i = full_write(ld->fdcur, s, len); + ////if (i != -1) break; + i = fwrite(s, 1, len, ld->filecur); + if (i == len) break; + if ((errno == ENOSPC) && (ld->nmin < ld->nmax)) { DIR *d; struct dirent *f; @@ -399,11 +410,12 @@ ld->fddir = -1; if (ld->fdcur == -1) return; /* impossible */ - while (fsync(ld->fdcur) == -1) + while (fflush(ld->filecur) || fsync(ld->fdcur) == -1) pause2cannot("fsync current logfile", ld->name); while (fchmod(ld->fdcur, 0744) == -1) pause2cannot("set mode of current", ld->name); - close(ld->fdcur); + ////close(ld->fdcur); + fclose(ld->filecur); ld->fdcur = -1; if (ld->fdlock == -1) return; /* impossible */ @@ -560,6 +572,10 @@ } while ((ld->fdcur = open("current", O_WRONLY|O_NDELAY|O_APPEND|O_CREAT, 0600)) == -1) pause2cannot("open current", ld->name); + /* we presume this cannot fail */ + ld->filecur = fdopen(ld->fdcur, "a"); //// + setvbuf(ld->filecur, NULL, _IOFBF, linelen); //// + coe(ld->fdcur); while (fchmod(ld->fdcur, 0644) == -1) pause2cannot("set mode of current", ld->name); @@ -601,9 +617,8 @@ } /* Used for reading stdin */ -static int buffer_pread(int fd, char *s, unsigned len) +static int buffer_pread(int fd, char *s, unsigned len, struct taia *now) { - struct taia now; int i; if (rotateasap) { @@ -620,12 +635,11 @@ logdirs_reopen(); reopenasap = 0; } - taia_now(&now); taia_uint(&trotate, 2744); - taia_add(&trotate, &now, &trotate); + taia_add(&trotate, now, &trotate); for (i = 0; i < dirn; ++i) if (dir[i].tmax) { - if (taia_less(&dir[i].trotate, &now)) + if (taia_less(&dir[i].trotate, now)) rotate(dir+i); if (taia_less(&dir[i].trotate, &trotate)) trotate = dir[i].trotate; @@ -633,7 +647,7 @@ while (1) { sigprocmask(SIG_UNBLOCK, &blocked_sigset, NULL); - iopause(&input, 1, &trotate, &now); + iopause(&input, 1, &trotate, now); sigprocmask(SIG_BLOCK, &blocked_sigset, NULL); i = ndelay_read(fd, s, len); if (i >= 0) break; @@ -734,7 +748,6 @@ int svlogd_main(int argc, char **argv) { - struct taia now; char *r,*l,*b; ssize_t stdin_cnt = 0; int i; @@ -757,10 +770,10 @@ if (linemax == 0) linemax = BUFSIZ-26; if (linemax < 256) linemax = 256; } -//// if (opt & 8) { // -b -//// buflen = xatoi_u(b); -//// if (buflen == 0) buflen = 1024; -//// } + ////if (opt & 8) { // -b + //// buflen = xatoi_u(b); + //// if (buflen == 0) buflen = 1024; + ////} //if (opt & 0x10) timestamp++; // -t //if (opt & 0x20) verbose++; // -v //if (timestamp > 2) timestamp = 2; @@ -807,8 +820,11 @@ if (!timestamp) memRchr = memrchr; + setvbuf(stderr, NULL, _IOFBF, linelen); + /* Each iteration processes one or more lines */ while (1) { + struct taia now; char stamp[FMT_PTIME]; char *lineptr; char *printptr; @@ -817,9 +833,9 @@ char ch; lineptr = line; + taia_now(&now); /* Prepare timestamp if needed */ if (timestamp) { - taia_now(&now); switch (timestamp) { case 1: fmt_taia25(stamp, &now); @@ -839,7 +855,7 @@ if (!np && !exitasap) { i = linemax - stdin_cnt; /* avail. bytes at tail */ if (i >= 128) { - i = buffer_pread(0, lineptr + stdin_cnt, i); + i = buffer_pread(0, lineptr + stdin_cnt, i, &now); if (i <= 0) /* EOF or error on stdin */ exitasap = 1; else { @@ -861,10 +877,10 @@ /* linelen == no of chars incl. '\n' (or == stdin_cnt) */ ch = lineptr[linelen-1]; - /* TODO: biggest performance hit is coming from the fact - * that we do not buffer writes. We may read many lines - * in one read() above, but will do one write() - * per line below. Should we use stdio? */ + /* Biggest performance hit was coming from the fact + * that we did not buffer writes. We were reading many lines + * in one read() above, but wrote one line per write(). + * We are using stdio to fix that */ /* write out lineptr[0..linelen-1] to each log destination * (or lineptr[-26..linelen-1] if timestamping) */ @@ -882,7 +898,8 @@ if (ld->inst) logmatch(ld); if (ld->matcherr == 'e') - full_write(2, printptr, printlen); + ////full_write(2, printptr, printlen); + fwrite(lineptr, 1, linelen, stderr); if (ld->match != '+') continue; buffer_pwrite(i, printptr, printlen); } @@ -891,7 +908,8 @@ /* read/write repeatedly until we see it */ while (ch != '\n') { /* lineptr is emptied now, safe to use as buffer */ - stdin_cnt = exitasap ? -1 : buffer_pread(0, lineptr, linemax); + taia_now(&now); + stdin_cnt = exitasap ? -1 : buffer_pread(0, lineptr, linemax, &now); if (stdin_cnt <= 0) { /* EOF or error on stdin */ exitasap = 1; lineptr[0] = ch = '\n'; @@ -908,7 +926,8 @@ for (i = 0; i < dirn; ++i) { if (dir[i].fddir == -1) continue; if (dir[i].matcherr == 'e') - full_write(2, lineptr, linelen); + ////full_write(2, lineptr, linelen); + fwrite(lineptr, 1, linelen, stderr); if (dir[i].match != '+') continue; buffer_pwrite(i, lineptr, linelen); } @@ -925,6 +944,7 @@ /* Move unprocessed data to the front of line */ memmove((timestamp ? line+26 : line), lineptr, stdin_cnt); } + fflush(NULL);//// } for (i = 0; i < dirn; ++i) { From vda at busybox.net Fri Feb 2 17:47:56 2007 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 Feb 2007 17:47:56 -0800 (PST) Subject: svn commit: trunk/busybox/runit Message-ID: <20070203014756.DD8AE48641@busybox.net> Author: vda Date: 2007-02-02 17:47:56 -0800 (Fri, 02 Feb 2007) New Revision: 17732 Log: sigset_t blocked_sigset is too big for static (128 bytes) Modified: trunk/busybox/runit/svlogd.c Changeset: Modified: trunk/busybox/runit/svlogd.c =================================================================== --- trunk/busybox/runit/svlogd.c 2007-02-03 00:53:43 UTC (rev 17731) +++ trunk/busybox/runit/svlogd.c 2007-02-03 01:47:56 UTC (rev 17732) @@ -54,7 +54,7 @@ static char repl; static const char *replace = ""; -sigset_t blocked_sigset; +static sigset_t *blocked_sigset; static iopause_fd input; static int fl_flag_0; @@ -646,9 +646,9 @@ } while (1) { - sigprocmask(SIG_UNBLOCK, &blocked_sigset, NULL); + sigprocmask(SIG_UNBLOCK, blocked_sigset, NULL); iopause(&input, 1, &trotate, now); - sigprocmask(SIG_BLOCK, &blocked_sigset, NULL); + sigprocmask(SIG_BLOCK, blocked_sigset, NULL); i = ndelay_read(fd, s, len); if (i >= 0) break; if (errno != EAGAIN) { @@ -748,6 +748,7 @@ int svlogd_main(int argc, char **argv) { + sigset_t ss; char *r,*l,*b; ssize_t stdin_cnt = 0; int i; @@ -801,12 +802,13 @@ * with the same stdin */ fl_flag_0 = fcntl(0, F_GETFL, 0); - sigemptyset(&blocked_sigset); - sigaddset(&blocked_sigset, SIGTERM); - sigaddset(&blocked_sigset, SIGCHLD); - sigaddset(&blocked_sigset, SIGALRM); - sigaddset(&blocked_sigset, SIGHUP); - sigprocmask(SIG_BLOCK, &blocked_sigset, NULL); + blocked_sigset = &ss; + sigemptyset(&ss); + sigaddset(&ss, SIGTERM); + sigaddset(&ss, SIGCHLD); + sigaddset(&ss, SIGALRM); + sigaddset(&ss, SIGHUP); + sigprocmask(SIG_BLOCK, &ss, NULL); sig_catch(SIGTERM, sig_term_handler); sig_catch(SIGCHLD, sig_child_handler); sig_catch(SIGALRM, sig_alarm_handler); From vda at busybox.net Fri Feb 2 18:17:42 2007 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 Feb 2007 18:17:42 -0800 (PST) Subject: svn commit: trunk/busybox: include init libbb Message-ID: <20070203021742.1341048640@busybox.net> Author: vda Date: 2007-02-02 18:17:41 -0800 (Fri, 02 Feb 2007) New Revision: 17733 Log: Add BB_EXEC[LV]P() which encapsulate FEATURE_EXEC_PREFER_APPLETS (patch from Gabriel L. Somlo ) Modified: trunk/busybox/include/libbb.h trunk/busybox/init/init.c trunk/busybox/libbb/xfuncs.c Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-02-03 01:47:56 UTC (rev 17732) +++ trunk/busybox/include/libbb.h 2007-02-03 02:17:41 UTC (rev 17733) @@ -551,6 +551,16 @@ char *find_execable(const char *filename); int exists_execable(const char *filename); +#ifdef ENABLE_FEATURE_EXEC_PREFER_APPLETS +#define BB_EXECVP(prog,cmd) \ + execvp((find_applet_by_name(prog)) ? CONFIG_BUSYBOX_EXEC_PATH : prog, cmd) +#define BB_EXECLP(prog,cmd,...) \ + execlp((find_applet_by_name(prog)) ? CONFIG_BUSYBOX_EXEC_PATH : prog, cmd, __VA_ARGS__) +#else +#define BB_EXECVP(prog,cmd) execvp(prog,cmd) +#define BB_EXECLP(prog,cmd,...) execvp(prog,cmd, __VA_ARGS__) +#endif + USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out); int inflate(int in, int out); Modified: trunk/busybox/init/init.c =================================================================== --- trunk/busybox/init/init.c 2007-02-03 01:47:56 UTC (rev 17732) +++ trunk/busybox/init/init.c 2007-02-03 02:17:41 UTC (rev 17733) @@ -389,7 +389,6 @@ #include CUSTOMIZED_BANNER #endif "\nPlease press Enter to activate this console. "; - const char *prog; /* Block sigchild while forking. */ sigemptyset(&nmask); @@ -561,10 +560,7 @@ /* Now run it. The new program will take over this PID, * so nothing further in init.c should be run. */ - prog = cmdpath; - if (ENABLE_FEATURE_EXEC_PREFER_APPLETS && find_applet_by_name(prog)) - prog = CONFIG_BUSYBOX_EXEC_PATH; - execvp(prog, cmd); + BB_EXECVP(cmdpath, cmd); /* We're still here? Some error happened. */ message(LOG | CONSOLE, "Bummer, cannot run '%s': %m", cmdpath); @@ -682,7 +678,6 @@ { struct init_action *a, *tmp; sigset_t unblock_signals; - char *prog; for (a = init_action_list; a; a = tmp) { tmp = a->next; @@ -718,10 +713,7 @@ dup(0); messageD(CONSOLE | LOG, "Trying to re-exec %s", a->command); - prog = a->command; - if (ENABLE_FEATURE_EXEC_PREFER_APPLETS && find_applet_by_name(prog)) - prog = CONFIG_BUSYBOX_EXEC_PATH; - execlp(prog, a->command, NULL); + BB_EXECLP(a->command, a->command, NULL); message(CONSOLE | LOG, "exec of '%s' failed: %m", a->command); @@ -1076,10 +1068,7 @@ putenv("SELINUX_INIT=YES"); if (selinux_init_load_policy(&enforce) == 0) { - char *prog = argv[0]; - if (ENABLE_FEATURE_EXEC_PREFER_APPLETS && find_applet_by_name(prog)) - prog = CONFIG_BUSYBOX_EXEC_PATH; - execvp(prog, argv); + BB_EXECVP(argv[0], argv); } else if (enforce > 0) { /* SELinux in enforcing mode but load_policy failed */ /* At this point, we probably can't open /dev/console, so log() won't work */ Modified: trunk/busybox/libbb/xfuncs.c =================================================================== --- trunk/busybox/libbb/xfuncs.c 2007-02-03 01:47:56 UTC (rev 17732) +++ trunk/busybox/libbb/xfuncs.c 2007-02-03 02:17:41 UTC (rev 17733) @@ -184,17 +184,13 @@ /* Why static? */ static int failed; pid_t pid; - const char *prog; // Be nice to nommu machines. failed = 0; pid = vfork(); if (pid < 0) return pid; if (!pid) { - prog = argv[0]; - if (ENABLE_FEATURE_EXEC_PREFER_APPLETS && find_applet_by_name(prog)) - prog = CONFIG_BUSYBOX_EXEC_PATH; - execvp(prog, argv); + BB_EXECVP(argv[0], argv); // We're sharing a stack with blocked parent, let parent know we failed // and then exit to unblock parent (but don't run atexit() stuff, which From vda at busybox.net Fri Feb 2 18:42:49 2007 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 Feb 2007 18:42:49 -0800 (PST) Subject: svn commit: trunk/busybox: init libbb Message-ID: <20070203024249.329B64864A@busybox.net> Author: vda Date: 2007-02-02 18:42:47 -0800 (Fri, 02 Feb 2007) New Revision: 17734 Log: lineedit: add missing #if/#endif init: fix warnings Modified: trunk/busybox/init/init.c trunk/busybox/libbb/lineedit.c Changeset: Modified: trunk/busybox/init/init.c =================================================================== --- trunk/busybox/init/init.c 2007-02-03 02:17:41 UTC (rev 17733) +++ trunk/busybox/init/init.c 2007-02-03 02:42:47 UTC (rev 17734) @@ -727,20 +727,19 @@ static void shutdown_signal(int sig) { - char *m; + const char *m; int rb; shutdown_system(); + m = "halt"; + rb = RB_HALT_SYSTEM; if (sig == SIGTERM) { m = "reboot"; rb = RB_AUTOBOOT; } else if (sig == SIGUSR2) { m = "poweroff"; rb = RB_POWER_OFF; - } else { - m = "halt"; - rb = RB_HALT_SYSTEM; } message(CONSOLE | LOG, "Requesting system %s.", m); sync(); @@ -775,7 +774,7 @@ got_cont = 1; } -#endif /* ! ENABLE_DEBUG_INIT */ +#endif /* !ENABLE_DEBUG_INIT */ static void new_init_action(int action, const char *command, const char *cons) { Modified: trunk/busybox/libbb/lineedit.c =================================================================== --- trunk/busybox/libbb/lineedit.c 2007-02-03 02:17:41 UTC (rev 17733) +++ trunk/busybox/libbb/lineedit.c 2007-02-03 02:42:47 UTC (rev 17734) @@ -1269,8 +1269,10 @@ /* With null flags, no other fields are ever used */ state = st ? st : (line_input_t*) &const_int_0; +#if ENABLE_FEATURE_EDITING_SAVEHISTORY if (state->flags & SAVE_HISTORY) load_history(state->hist_file); +#endif /* prepare before init handlers */ cmdedit_y = 0; /* quasireal y, not true if line > xt*yt */ From vda at busybox.net Fri Feb 2 19:31:14 2007 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 Feb 2007 19:31:14 -0800 (PST) Subject: svn commit: trunk/busybox: findutils init networking shell Message-ID: <20070203033114.71BC04864B@busybox.net> Author: vda Date: 2007-02-02 19:31:13 -0800 (Fri, 02 Feb 2007) New Revision: 17735 Log: assorted fixes for bugs found with randomconfig Modified: trunk/busybox/findutils/find.c trunk/busybox/init/init.c trunk/busybox/networking/ether-wake.c trunk/busybox/networking/ping.c trunk/busybox/shell/hush.c Changeset: Modified: trunk/busybox/findutils/find.c =================================================================== --- trunk/busybox/findutils/find.c 2007-02-03 02:42:47 UTC (rev 17734) +++ trunk/busybox/findutils/find.c 2007-02-03 03:31:13 UTC (rev 17735) @@ -316,12 +316,15 @@ } #endif +#if ENABLE_FEATURE_FIND_PERM || ENABLE_FEATURE_FIND_MTIME \ + || ENABLE_FEATURE_FIND_MMIN static const char* plus_minus_num(const char* str) { if (*str == '-' || *str == '+') str++; return str; } +#endif static action*** parse_params(char **argv) { @@ -486,7 +489,7 @@ ap->subst_count[i] = count_subst(ap->exec_argv[i]); } #endif -#ifdef ENABLE_FEATURE_FIND_USER +#if ENABLE_FEATURE_FIND_USER else if (strcmp(arg, "-user") == 0) { action_user *ap; if (!*++argv) Modified: trunk/busybox/init/init.c =================================================================== --- trunk/busybox/init/init.c 2007-02-03 02:42:47 UTC (rev 17734) +++ trunk/busybox/init/init.c 2007-02-03 03:31:13 UTC (rev 17735) @@ -122,7 +122,7 @@ static char console[CONSOLE_BUFF_SIZE] = CONSOLE_DEV; #if !ENABLE_SYSLOGD -static char *log_console = VC_5; +static const char *log_console = VC_5; #endif #if !ENABLE_DEBUG_INIT static sig_atomic_t got_cont = 0; Modified: trunk/busybox/networking/ether-wake.c =================================================================== --- trunk/busybox/networking/ether-wake.c 2007-02-03 02:42:47 UTC (rev 17734) +++ trunk/busybox/networking/ether-wake.c 2007-02-03 03:31:13 UTC (rev 17735) @@ -107,7 +107,8 @@ int ether_wake_main(int argc, char *argv[]) { - char *ifname = "eth0", *pass = NULL; + const char *ifname = "eth0"; + char *pass = NULL; unsigned long flags; unsigned char wol_passwd[6]; int wol_passwd_sz = 0; Modified: trunk/busybox/networking/ping.c =================================================================== --- trunk/busybox/networking/ping.c 2007-02-03 02:42:47 UTC (rev 17734) +++ trunk/busybox/networking/ping.c 2007-02-03 03:31:13 UTC (rev 17735) @@ -190,7 +190,7 @@ len_and_sockaddr *lsa; #if ENABLE_PING6 sa_family_t af = AF_UNSPEC; - while (++argv[0][0]) == '-') { + while (++argv[0][0] == '-') { if (argv[0][1] == '4') { af = AF_INET; continue; Modified: trunk/busybox/shell/hush.c =================================================================== --- trunk/busybox/shell/hush.c 2007-02-03 02:42:47 UTC (rev 17734) +++ trunk/busybox/shell/hush.c 2007-02-03 03:31:13 UTC (rev 17735) @@ -2795,8 +2795,8 @@ } debug_printf("\nrunning script '%s'\n", argv[optind]); - global_argv = argv+optind; - global_argc = argc-optind; + global_argv = argv + optind; + global_argc = argc - optind; input = xfopen(argv[optind], "r"); opt = parse_file_outer(input); @@ -2809,8 +2809,8 @@ for (cur = top_vars; cur; cur = tmp) { tmp = cur->next; if (!cur->flg_read_only) { - free(cur->name); - free(cur->value); + free((char*)cur->name); + free((char*)cur->value); free(cur); } } From bugs at busybox.net Fri Feb 2 23:49:18 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 2 Feb 2007 23:49:18 -0800 Subject: [BusyBox 0001192]: applets/usage_compressed cannot parse od(1) output on Mac OS X (fix attached) Message-ID: The following issue has been SUBMITTED. ====================================================================== http://busybox.net/bugs/view.php?id=1192 ====================================================================== Reported By: mattj Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1192 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 02-02-2007 23:49 PST Last Modified: 02-02-2007 23:49 PST ====================================================================== Summary: applets/usage_compressed cannot parse od(1) output on Mac OS X (fix attached) Description: On Mac OS X (10.4.8) (and presumably other BSD systems) the output of od(1) differs from Linux. Mac: echo foo | od -v -t x1 0000000 66 6f 6f 0a Linux: 0000000 66 6f 6f 0a The multiple spaces result in sed producing a bogus C file that gives compile errors. static const char packed_usage[] = "\x \x42\x 5a\x 68\x 31\x 31\x 41\x 59\x 26\x 53\x 59\x 9b\x ea\x 54\x c8\x 00\x 00" A trivial patch to ignore extra spaces: --- usage_compressed.old 2007-02-03 16:36:59.000000000 +0900 +++ usage_compressed 2007-02-03 16:36:42.000000000 +0900 @@ -14,6 +14,6 @@ echo 'static const char packed_usage[] = ' "$loc/usage" | bzip2 -1 | od -v -t x1 \ -| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' +| $SED -e 's/^[^ ]*//' -e 's/ +\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' echo ';' echo '#define SIZEOF_usage_messages' `expr 0 + $sz` ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 02-02-07 23:49 mattj New Issue 02-02-07 23:49 mattj Status new => assigned 02-02-07 23:49 mattj Assigned To => BusyBox ====================================================================== From bugs at busybox.net Sat Feb 3 03:12:55 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 Feb 2007 03:12:55 -0800 Subject: [BusyBox 0001183]: Tar -t in busybox-1.4.1 segfaults Message-ID: <77e34945645a8dfad5b1f03b2e14891a@bugs.busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1183 ====================================================================== Reported By: espakman Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1183 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 01-29-2007 04:00 PST Last Modified: 02-03-2007 03:12 PST ====================================================================== Summary: Tar -t in busybox-1.4.1 segfaults Description: # tar -t Segmentation fault ====================================================================== ---------------------------------------------------------------------- vda - 01-29-07 17:00 ---------------------------------------------------------------------- Works for me: # cat busybox-1.4.1.tar | ./busybox tar t | head -10 busybox-1.4.1/ busybox-1.4.1/loginutils/ busybox-1.4.1/loginutils/su.c busybox-1.4.1/loginutils/Kbuild busybox-1.4.1/loginutils/adduser.c busybox-1.4.1/loginutils/login.c busybox-1.4.1/loginutils/passwd.c busybox-1.4.1/loginutils/getty.c busybox-1.4.1/loginutils/deluser.c busybox-1.4.1/loginutils/vlock.c Your .config, libc, gcc version? Strace output of "busybox tar t"? ---------------------------------------------------------------------- espakman - 01-30-07 11:30 ---------------------------------------------------------------------- My config is attached. Libc: uClibc-0.9.28 gcc: gcc-3.3.3 Strace: # strace ./busybox tar -t execve("./busybox", ["./busybox", "tar", "-t"], [/* 26 vars */]) = 0 old_mmap(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40005000 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libcrypt.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\224\4\0"..., 4096) = 4096 old_mmap(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 old_mmap(0x40007000, 7798, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40007000 old_mmap(0x40009000, 184, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x40009000 old_mmap(0x4000a000, 67036, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4000a000 close(3) = 0 munmap(0x40006000, 4096) = 0 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libc.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\316"..., 4096) = 4096 old_mmap(NULL, 266240, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001b000 old_mmap(0x4001b000, 239528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4001b000 old_mmap(0x40056000, 3616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3b000) = 0x40056000 old_mmap(0x40057000, 19192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40057000 close(3) = 0 munmap(0x40006000, 4096) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 getuid() = 0 getgid() = 0 setgid(0) = 0 setuid(0) = 0 brk(0) = 0x808dea0 brk(0x808eea0) = 0x808eea0 brk(0x808f000) = 0x808f000 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ ---------------------------------------------------------------------- espakman - 02-03-07 03:12 ---------------------------------------------------------------------- A small update, the segfault still exists with today's snapshot. Issue History Date Modified Username Field Change ====================================================================== 01-29-07 04:00 espakman New Issue 01-29-07 04:00 espakman Status new => assigned 01-29-07 04:00 espakman Assigned To => BusyBox 01-29-07 17:00 vda Note Added: 0002070 01-30-07 11:30 espakman Note Added: 0002076 01-30-07 11:30 espakman File Added: bbconfig 02-03-07 03:12 espakman Note Added: 0002087 ====================================================================== From vda at busybox.net Sat Feb 3 04:45:44 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 04:45:44 -0800 (PST) Subject: svn commit: trunk/busybox/applets Message-ID: <20070203124544.5C2D64863C@busybox.net> Author: vda Date: 2007-02-03 04:45:43 -0800 (Sat, 03 Feb 2007) New Revision: 17736 Log: usage_compressed: be more permissive in which od flavors we support Modified: trunk/busybox/applets/usage_compressed Changeset: Modified: trunk/busybox/applets/usage_compressed =================================================================== --- trunk/busybox/applets/usage_compressed 2007-02-03 03:31:13 UTC (rev 17735) +++ trunk/busybox/applets/usage_compressed 2007-02-03 12:45:43 UTC (rev 17736) @@ -14,6 +14,6 @@ echo 'static const char packed_usage[] = ' "$loc/usage" | bzip2 -1 | od -v -t x1 \ -| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' +| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' echo ';' echo '#define SIZEOF_usage_messages' `expr 0 + $sz` From bugs at busybox.net Sat Feb 3 04:46:17 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 Feb 2007 04:46:17 -0800 Subject: [BusyBox 0001192]: applets/usage_compressed cannot parse od(1) output on Mac OS X (fix attached) Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1192 ====================================================================== Reported By: mattj Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1192 Category: Other Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 02-02-2007 23:49 PST Last Modified: 02-03-2007 04:46 PST ====================================================================== Summary: applets/usage_compressed cannot parse od(1) output on Mac OS X (fix attached) Description: On Mac OS X (10.4.8) (and presumably other BSD systems) the output of od(1) differs from Linux. Mac: echo foo | od -v -t x1 0000000 66 6f 6f 0a Linux: 0000000 66 6f 6f 0a The multiple spaces result in sed producing a bogus C file that gives compile errors. static const char packed_usage[] = "\x \x42\x 5a\x 68\x 31\x 31\x 41\x 59\x 26\x 53\x 59\x 9b\x ea\x 54\x c8\x 00\x 00" A trivial patch to ignore extra spaces: --- usage_compressed.old 2007-02-03 16:36:59.000000000 +0900 +++ usage_compressed 2007-02-03 16:36:42.000000000 +0900 @@ -14,6 +14,6 @@ echo 'static const char packed_usage[] = ' "$loc/usage" | bzip2 -1 | od -v -t x1 \ -| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' +| $SED -e 's/^[^ ]*//' -e 's/ +\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/' echo ';' echo '#define SIZEOF_usage_messages' `expr 0 + $sz` ====================================================================== ---------------------------------------------------------------------- vda - 02-03-07 04:46 ---------------------------------------------------------------------- fixed in rev 17736, thanks Issue History Date Modified Username Field Change ====================================================================== 02-02-07 23:49 mattj New Issue 02-02-07 23:49 mattj Status new => assigned 02-02-07 23:49 mattj Assigned To => BusyBox 02-03-07 04:46 vda Status assigned => closed 02-03-07 04:46 vda Note Added: 0002088 ====================================================================== From vda at busybox.net Sat Feb 3 04:50:42 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 04:50:42 -0800 (PST) Subject: svn commit: trunk/busybox/scripts Message-ID: <20070203125042.1863E4862F@busybox.net> Author: vda Date: 2007-02-03 04:50:41 -0800 (Sat, 03 Feb 2007) New Revision: 17737 Log: add TODO Modified: trunk/busybox/scripts/mkconfigs Changeset: Modified: trunk/busybox/scripts/mkconfigs =================================================================== --- trunk/busybox/scripts/mkconfigs 2007-02-03 12:45:43 UTC (rev 17736) +++ trunk/busybox/scripts/mkconfigs 2007-02-03 12:50:41 UTC (rev 17737) @@ -40,12 +40,14 @@ * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. * - * This file is generated automatically by scripts/config/mkconfigs. + * This file is generated automatically by scripts/mkconfigs. * Do not edit. * */" echo "static const char * const bbconfig_config =" +# dash and probably ash produce wrong output (because of \n) +# TODO: check whether our ash is ok echo "`sed 's/\"/\\\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\\"" $0 "\\\\n\\"";}'`" echo ";" echo "#endif /* _BBCONFIGOPTS_H */" From aldot at busybox.net Sat Feb 3 04:52:33 2007 From: aldot at busybox.net (aldot at busybox.net) Date: Sat, 3 Feb 2007 04:52:33 -0800 (PST) Subject: svn commit: trunk/busybox/coreutils Message-ID: <20070203125233.9E07B48640@busybox.net> Author: aldot Date: 2007-02-03 04:52:25 -0800 (Sat, 03 Feb 2007) New Revision: 17738 Log: - include busybox.h before looking at an eventual #if ENABLE_DESKTOP Modified: trunk/busybox/coreutils/od.c Changeset: Modified: trunk/busybox/coreutils/od.c =================================================================== --- trunk/busybox/coreutils/od.c 2007-02-03 12:50:41 UTC (rev 17737) +++ trunk/busybox/coreutils/od.c 2007-02-03 12:52:25 UTC (rev 17738) @@ -12,13 +12,13 @@ */ +#include "busybox.h" #if ENABLE_DESKTOP /* This one provides -t (busybox's own build script needs it) */ #include "od_bloaty.c" #else +#include -#include -#include "busybox.h" #include "dump.h" #define isdecdigit(c) isdigit(c) From bugs at busybox.net Sat Feb 3 06:34:41 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 Feb 2007 06:34:41 -0800 Subject: [BusyBox 0001183]: Tar -t in busybox-1.4.1 segfaults Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1183 ====================================================================== Reported By: espakman Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1183 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 01-29-2007 04:00 PST Last Modified: 02-03-2007 06:34 PST ====================================================================== Summary: Tar -t in busybox-1.4.1 segfaults Description: # tar -t Segmentation fault ====================================================================== ---------------------------------------------------------------------- vda - 01-29-07 17:00 ---------------------------------------------------------------------- Works for me: # cat busybox-1.4.1.tar | ./busybox tar t | head -10 busybox-1.4.1/ busybox-1.4.1/loginutils/ busybox-1.4.1/loginutils/su.c busybox-1.4.1/loginutils/Kbuild busybox-1.4.1/loginutils/adduser.c busybox-1.4.1/loginutils/login.c busybox-1.4.1/loginutils/passwd.c busybox-1.4.1/loginutils/getty.c busybox-1.4.1/loginutils/deluser.c busybox-1.4.1/loginutils/vlock.c Your .config, libc, gcc version? Strace output of "busybox tar t"? ---------------------------------------------------------------------- espakman - 01-30-07 11:30 ---------------------------------------------------------------------- My config is attached. Libc: uClibc-0.9.28 gcc: gcc-3.3.3 Strace: # strace ./busybox tar -t execve("./busybox", ["./busybox", "tar", "-t"], [/* 26 vars */]) = 0 old_mmap(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40005000 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libcrypt.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\224\4\0"..., 4096) = 4096 old_mmap(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 old_mmap(0x40007000, 7798, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40007000 old_mmap(0x40009000, 184, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x40009000 old_mmap(0x4000a000, 67036, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4000a000 close(3) = 0 munmap(0x40006000, 4096) = 0 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libc.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\316"..., 4096) = 4096 old_mmap(NULL, 266240, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001b000 old_mmap(0x4001b000, 239528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4001b000 old_mmap(0x40056000, 3616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3b000) = 0x40056000 old_mmap(0x40057000, 19192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40057000 close(3) = 0 munmap(0x40006000, 4096) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 getuid() = 0 getgid() = 0 setgid(0) = 0 setuid(0) = 0 brk(0) = 0x808dea0 brk(0x808eea0) = 0x808eea0 brk(0x808f000) = 0x808f000 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ ---------------------------------------------------------------------- espakman - 02-03-07 03:12 ---------------------------------------------------------------------- A small update, the segfault still exists with today's snapshot. ---------------------------------------------------------------------- vda - 02-03-07 06:34 ---------------------------------------------------------------------- With uclibc this enters infinite loop in exit(): int main() { gethostbyname("127.0.0.1"); exit(1); } This does the same, with or without second fclose: int main() { FILE* fp; char buf[4*1024]; fp = fopen("/etc/resolv.conf", "r"); fclose(fp); fp = fopen("/etc/hosts", "r"); // fclose(fp); exit(1); } If even this can't work, all bets are off. uclibc mailing list and maintainer were informed. Twice. Issue History Date Modified Username Field Change ====================================================================== 01-29-07 04:00 espakman New Issue 01-29-07 04:00 espakman Status new => assigned 01-29-07 04:00 espakman Assigned To => BusyBox 01-29-07 17:00 vda Note Added: 0002070 01-30-07 11:30 espakman Note Added: 0002076 01-30-07 11:30 espakman File Added: bbconfig 02-03-07 03:12 espakman Note Added: 0002087 02-03-07 06:34 vda Note Added: 0002089 ====================================================================== From bugs at busybox.net Sat Feb 3 06:56:05 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 Feb 2007 06:56:05 -0800 Subject: [BusyBox 0001183]: Tar -t in busybox-1.4.1 segfaults Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1183 ====================================================================== Reported By: espakman Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1183 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 01-29-2007 04:00 PST Last Modified: 02-03-2007 06:56 PST ====================================================================== Summary: Tar -t in busybox-1.4.1 segfaults Description: # tar -t Segmentation fault ====================================================================== ---------------------------------------------------------------------- vda - 01-29-07 17:00 ---------------------------------------------------------------------- Works for me: # cat busybox-1.4.1.tar | ./busybox tar t | head -10 busybox-1.4.1/ busybox-1.4.1/loginutils/ busybox-1.4.1/loginutils/su.c busybox-1.4.1/loginutils/Kbuild busybox-1.4.1/loginutils/adduser.c busybox-1.4.1/loginutils/login.c busybox-1.4.1/loginutils/passwd.c busybox-1.4.1/loginutils/getty.c busybox-1.4.1/loginutils/deluser.c busybox-1.4.1/loginutils/vlock.c Your .config, libc, gcc version? Strace output of "busybox tar t"? ---------------------------------------------------------------------- espakman - 01-30-07 11:30 ---------------------------------------------------------------------- My config is attached. Libc: uClibc-0.9.28 gcc: gcc-3.3.3 Strace: # strace ./busybox tar -t execve("./busybox", ["./busybox", "tar", "-t"], [/* 26 vars */]) = 0 old_mmap(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40005000 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libcrypt.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\224\4\0"..., 4096) = 4096 old_mmap(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 old_mmap(0x40007000, 7798, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40007000 old_mmap(0x40009000, 184, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x40009000 old_mmap(0x4000a000, 67036, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4000a000 close(3) = 0 munmap(0x40006000, 4096) = 0 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libc.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\316"..., 4096) = 4096 old_mmap(NULL, 266240, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001b000 old_mmap(0x4001b000, 239528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4001b000 old_mmap(0x40056000, 3616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3b000) = 0x40056000 old_mmap(0x40057000, 19192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40057000 close(3) = 0 munmap(0x40006000, 4096) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 getuid() = 0 getgid() = 0 setgid(0) = 0 setuid(0) = 0 brk(0) = 0x808dea0 brk(0x808eea0) = 0x808eea0 brk(0x808f000) = 0x808f000 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ ---------------------------------------------------------------------- espakman - 02-03-07 03:12 ---------------------------------------------------------------------- A small update, the segfault still exists with today's snapshot. ---------------------------------------------------------------------- vda - 02-03-07 06:34 ---------------------------------------------------------------------- With uclibc this enters infinite loop in exit(): int main() { gethostbyname("127.0.0.1"); exit(1); } This does the same, with or without second fclose: int main() { FILE* fp; char buf[4*1024]; fp = fopen("/etc/resolv.conf", "r"); fclose(fp); fp = fopen("/etc/hosts", "r"); // fclose(fp); exit(1); } If even this can't work, all bets are off. uclibc mailing list and maintainer were informed. Twice. ---------------------------------------------------------------------- espakman - 02-03-07 06:56 ---------------------------------------------------------------------- Bad.... but I don't see a call to networking code in tar.c. I will patch uClibc with the code you propose anyway and report back. The strange thing is that tar -t with busybox-1.2.1 and uClibc-0.9.28 did work correct... Issue History Date Modified Username Field Change ====================================================================== 01-29-07 04:00 espakman New Issue 01-29-07 04:00 espakman Status new => assigned 01-29-07 04:00 espakman Assigned To => BusyBox 01-29-07 17:00 vda Note Added: 0002070 01-30-07 11:30 espakman Note Added: 0002076 01-30-07 11:30 espakman File Added: bbconfig 02-03-07 03:12 espakman Note Added: 0002087 02-03-07 06:34 vda Note Added: 0002089 02-03-07 06:56 espakman Note Added: 0002090 ====================================================================== From vda at busybox.net Sat Feb 3 09:27:15 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 09:27:15 -0800 (PST) Subject: svn commit: trunk/busybox: applets include Message-ID: <20070203172715.3AA754861D@busybox.net> Author: vda Date: 2007-02-03 09:27:14 -0800 (Sat, 03 Feb 2007) New Revision: 17739 Log: do not put all _main() declarations in busybox.h - this produces false dependencies Modified: trunk/busybox/applets/Kbuild trunk/busybox/applets/applets.c trunk/busybox/include/busybox.h Changeset: Modified: trunk/busybox/applets/Kbuild =================================================================== --- trunk/busybox/applets/Kbuild 2007-02-03 12:52:25 UTC (rev 17738) +++ trunk/busybox/applets/Kbuild 2007-02-03 17:27:14 UTC (rev 17739) @@ -10,7 +10,7 @@ # Generated file needs additional love -applets/applets.o: include/usage_compressed.h +applets/applets.o: .config include/usage_compressed.h hostprogs-y += usage always := $(hostprogs-y) Modified: trunk/busybox/applets/applets.c =================================================================== --- trunk/busybox/applets/applets.c 2007-02-03 12:52:25 UTC (rev 17738) +++ trunk/busybox/applets/applets.c 2007-02-03 17:27:14 UTC (rev 17739) @@ -12,9 +12,14 @@ * Licensed under GPLv2 or later, see file License in this tarball for details. */ +#include #include "busybox.h" -#include +#define PROTOTYPES +#include "applets.h" +#undef PROTOTYPES + + /* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */ #if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__) #warning Static linking against glibc produces buggy executables Modified: trunk/busybox/include/busybox.h =================================================================== --- trunk/busybox/include/busybox.h 2007-02-03 12:52:25 UTC (rev 17738) +++ trunk/busybox/include/busybox.h 2007-02-03 17:27:14 UTC (rev 17739) @@ -31,19 +31,9 @@ __extension__ enum SUIDRoot need_suid:4; }; -/* From busybox.c and applet.c */ +/* Defined in busybox.c and applet.c */ extern int busybox_main(int argc, char **argv); extern const struct BB_applet applets[]; extern const unsigned short NUM_APPLETS; -/* Automagically pull in all the applet function prototypes and - * applet usage strings. These are all of the form: - * extern int foo_main(int argc, char **argv); - * extern const char foo_usage[]; - * These are all autogenerated from the set of currently defined applets. - */ -#define PROTOTYPES -#include "applets.h" -#undef PROTOTYPES - -#endif /* _BB_INTERNAL_H_ */ +#endif /* _BB_INTERNAL_H_ */ From vda at busybox.net Sat Feb 3 09:28:42 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 09:28:42 -0800 (PST) Subject: svn commit: trunk/busybox: applets archival console-tools coreutils etc... Message-ID: <20070203172842.BB5A34861F@busybox.net> Author: vda Date: 2007-02-03 09:28:39 -0800 (Sat, 03 Feb 2007) New Revision: 17740 Log: suppress warnings about easch _main() having no preceding prototype Modified: trunk/busybox/applets/Kbuild trunk/busybox/applets/busybox.c trunk/busybox/archival/ar.c trunk/busybox/archival/bunzip2.c trunk/busybox/archival/cpio.c trunk/busybox/archival/dpkg.c trunk/busybox/archival/dpkg_deb.c trunk/busybox/archival/gunzip.c trunk/busybox/archival/gzip.c trunk/busybox/archival/rpm.c trunk/busybox/archival/rpm2cpio.c trunk/busybox/archival/tar.c trunk/busybox/archival/uncompress.c trunk/busybox/archival/unlzma.c trunk/busybox/archival/unzip.c trunk/busybox/console-tools/chvt.c trunk/busybox/console-tools/clear.c trunk/busybox/console-tools/deallocvt.c trunk/busybox/console-tools/dumpkmap.c trunk/busybox/console-tools/loadfont.c trunk/busybox/console-tools/loadkmap.c trunk/busybox/console-tools/openvt.c trunk/busybox/console-tools/reset.c trunk/busybox/console-tools/resize.c trunk/busybox/console-tools/setconsole.c trunk/busybox/console-tools/setkeycodes.c trunk/busybox/coreutils/basename.c trunk/busybox/coreutils/cal.c trunk/busybox/coreutils/cat.c trunk/busybox/coreutils/catv.c trunk/busybox/coreutils/chgrp.c trunk/busybox/coreutils/chmod.c trunk/busybox/coreutils/chown.c trunk/busybox/coreutils/chroot.c trunk/busybox/coreutils/cksum.c trunk/busybox/coreutils/cmp.c trunk/busybox/coreutils/comm.c trunk/busybox/coreutils/cp.c trunk/busybox/coreutils/cut.c trunk/busybox/coreutils/date.c trunk/busybox/coreutils/dd.c trunk/busybox/coreutils/df.c trunk/busybox/coreutils/diff.c trunk/busybox/coreutils/dirname.c trunk/busybox/coreutils/dos2unix.c trunk/busybox/coreutils/du.c trunk/busybox/coreutils/echo.c trunk/busybox/coreutils/env.c trunk/busybox/coreutils/expr.c trunk/busybox/coreutils/false.c trunk/busybox/coreutils/fold.c trunk/busybox/coreutils/head.c trunk/busybox/coreutils/hostid.c trunk/busybox/coreutils/id.c trunk/busybox/coreutils/install.c trunk/busybox/coreutils/length.c trunk/busybox/coreutils/ln.c trunk/busybox/coreutils/logname.c trunk/busybox/coreutils/ls.c trunk/busybox/coreutils/md5_sha1_sum.c trunk/busybox/coreutils/mkdir.c trunk/busybox/coreutils/mkfifo.c trunk/busybox/coreutils/mknod.c trunk/busybox/coreutils/mv.c trunk/busybox/coreutils/nice.c trunk/busybox/coreutils/nohup.c trunk/busybox/coreutils/od.c trunk/busybox/coreutils/od_bloaty.c trunk/busybox/coreutils/printenv.c trunk/busybox/coreutils/printf.c trunk/busybox/coreutils/pwd.c trunk/busybox/coreutils/realpath.c trunk/busybox/coreutils/rm.c trunk/busybox/coreutils/rmdir.c trunk/busybox/coreutils/seq.c trunk/busybox/coreutils/sleep.c trunk/busybox/coreutils/sort.c trunk/busybox/coreutils/stat.c trunk/busybox/coreutils/stty.c trunk/busybox/coreutils/sum.c trunk/busybox/coreutils/sync.c trunk/busybox/coreutils/tail.c trunk/busybox/coreutils/tee.c trunk/busybox/coreutils/test.c trunk/busybox/coreutils/touch.c trunk/busybox/coreutils/tr.c trunk/busybox/coreutils/true.c trunk/busybox/coreutils/tty.c trunk/busybox/coreutils/uname.c trunk/busybox/coreutils/uniq.c trunk/busybox/coreutils/usleep.c trunk/busybox/coreutils/uudecode.c trunk/busybox/coreutils/uuencode.c trunk/busybox/coreutils/watch.c trunk/busybox/coreutils/wc.c trunk/busybox/coreutils/who.c trunk/busybox/coreutils/whoami.c trunk/busybox/coreutils/yes.c trunk/busybox/debianutils/mktemp.c trunk/busybox/debianutils/pipe_progress.c trunk/busybox/debianutils/readlink.c trunk/busybox/debianutils/run_parts.c trunk/busybox/debianutils/start_stop_daemon.c trunk/busybox/debianutils/which.c trunk/busybox/docs/new-applet-HOWTO.txt trunk/busybox/e2fsprogs/chattr.c trunk/busybox/e2fsprogs/fsck.c trunk/busybox/e2fsprogs/lsattr.c trunk/busybox/e2fsprogs/old_e2fsprogs/chattr.c trunk/busybox/e2fsprogs/old_e2fsprogs/e2fsck.c trunk/busybox/e2fsprogs/old_e2fsprogs/fsck.c trunk/busybox/e2fsprogs/old_e2fsprogs/lsattr.c trunk/busybox/e2fsprogs/old_e2fsprogs/mke2fs.c trunk/busybox/e2fsprogs/old_e2fsprogs/tune2fs.c trunk/busybox/editors/awk.c trunk/busybox/editors/ed.c trunk/busybox/editors/patch.c trunk/busybox/editors/sed.c trunk/busybox/editors/vi.c trunk/busybox/findutils/find.c trunk/busybox/findutils/grep.c trunk/busybox/findutils/xargs.c trunk/busybox/include/libbb.h trunk/busybox/init/halt.c trunk/busybox/init/init.c trunk/busybox/init/mesg.c trunk/busybox/libbb/get_console.c trunk/busybox/loginutils/addgroup.c trunk/busybox/loginutils/adduser.c trunk/busybox/loginutils/deluser.c trunk/busybox/loginutils/getty.c trunk/busybox/loginutils/login.c trunk/busybox/loginutils/passwd.c trunk/busybox/loginutils/su.c trunk/busybox/loginutils/sulogin.c trunk/busybox/loginutils/vlock.c trunk/busybox/miscutils/adjtimex.c trunk/busybox/miscutils/bbconfig.c trunk/busybox/miscutils/crond.c trunk/busybox/miscutils/crontab.c trunk/busybox/miscutils/dc.c trunk/busybox/miscutils/devfsd.c trunk/busybox/miscutils/eject.c trunk/busybox/miscutils/hdparm.c trunk/busybox/miscutils/last.c trunk/busybox/miscutils/less.c trunk/busybox/miscutils/makedevs.c trunk/busybox/miscutils/mountpoint.c trunk/busybox/miscutils/mt.c trunk/busybox/miscutils/nmeter.c trunk/busybox/miscutils/raidautorun.c trunk/busybox/miscutils/readahead.c trunk/busybox/miscutils/runlevel.c trunk/busybox/miscutils/rx.c trunk/busybox/miscutils/setsid.c trunk/busybox/miscutils/strings.c trunk/busybox/miscutils/taskset.c trunk/busybox/miscutils/time.c trunk/busybox/miscutils/watchdog.c trunk/busybox/modutils/insmod.c trunk/busybox/modutils/lsmod.c trunk/busybox/modutils/modprobe.c trunk/busybox/modutils/rmmod.c trunk/busybox/networking/arp.c trunk/busybox/networking/arping.c trunk/busybox/networking/dnsd.c trunk/busybox/networking/ether-wake.c trunk/busybox/networking/ftpgetput.c trunk/busybox/networking/hostname.c trunk/busybox/networking/httpd.c trunk/busybox/networking/ifconfig.c trunk/busybox/networking/ifupdown.c trunk/busybox/networking/inetd.c trunk/busybox/networking/ip.c trunk/busybox/networking/ipaddr.c trunk/busybox/networking/ipcalc.c trunk/busybox/networking/iplink.c trunk/busybox/networking/iproute.c trunk/busybox/networking/iprule.c trunk/busybox/networking/iptunnel.c trunk/busybox/networking/isrv_identd.c trunk/busybox/networking/nameif.c trunk/busybox/networking/nc.c trunk/busybox/networking/netstat.c trunk/busybox/networking/nslookup.c trunk/busybox/networking/ping.c trunk/busybox/networking/route.c trunk/busybox/networking/telnet.c trunk/busybox/networking/telnetd.c trunk/busybox/networking/tftp.c trunk/busybox/networking/traceroute.c trunk/busybox/networking/udhcp/dhcpc.c trunk/busybox/networking/udhcp/dhcpd.c trunk/busybox/networking/udhcp/dhcprelay.c trunk/busybox/networking/udhcp/dumpleases.c trunk/busybox/networking/vconfig.c trunk/busybox/networking/wget.c trunk/busybox/networking/zcip.c trunk/busybox/procps/free.c trunk/busybox/procps/fuser.c trunk/busybox/procps/kill.c trunk/busybox/procps/pidof.c trunk/busybox/procps/ps.c trunk/busybox/procps/renice.c trunk/busybox/procps/sysctl.c trunk/busybox/procps/top.c trunk/busybox/procps/uptime.c trunk/busybox/runit/chpst.c trunk/busybox/runit/runsv.c trunk/busybox/runit/runsvdir.c trunk/busybox/runit/sv.c trunk/busybox/runit/svlogd.c trunk/busybox/shell/ash.c trunk/busybox/shell/bbsh.c trunk/busybox/shell/hush.c trunk/busybox/shell/lash.c trunk/busybox/shell/msh.c trunk/busybox/sysklogd/klogd.c trunk/busybox/sysklogd/logger.c trunk/busybox/sysklogd/logread.c trunk/busybox/sysklogd/syslogd.c trunk/busybox/util-linux/dmesg.c trunk/busybox/util-linux/fbset.c trunk/busybox/util-linux/fdformat.c trunk/busybox/util-linux/fdisk.c trunk/busybox/util-linux/freeramdisk.c trunk/busybox/util-linux/fsck_minix.c trunk/busybox/util-linux/getopt.c trunk/busybox/util-linux/hexdump.c trunk/busybox/util-linux/hwclock.c trunk/busybox/util-linux/ipcrm.c trunk/busybox/util-linux/ipcs.c trunk/busybox/util-linux/losetup.c trunk/busybox/util-linux/mdev.c trunk/busybox/util-linux/mkfs_minix.c trunk/busybox/util-linux/mkswap.c trunk/busybox/util-linux/more.c trunk/busybox/util-linux/mount.c trunk/busybox/util-linux/pivot_root.c trunk/busybox/util-linux/rdate.c trunk/busybox/util-linux/readprofile.c trunk/busybox/util-linux/setarch.c trunk/busybox/util-linux/swaponoff.c trunk/busybox/util-linux/switch_root.c trunk/busybox/util-linux/umount.c Changeset: Sorry, the patch is too large to include (3291 lines). Please use ViewCVS to see it! http://busybox.net/cgi-bin/viewcvs.cgi?view=rev&root=svn&rev=17740 From vda at busybox.net Sat Feb 3 09:29:14 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 09:29:14 -0800 (PST) Subject: svn commit: trunk/busybox: docs examples examples/bootfloppy Message-ID: <20070203172914.D356148621@busybox.net> Author: vda Date: 2007-02-03 09:29:14 -0800 (Sat, 03 Feb 2007) New Revision: 17741 Log: s/PREFIX/CONFIG_PREFIX/ Modified: trunk/busybox/INSTALL trunk/busybox/Makefile.help trunk/busybox/README trunk/busybox/docs/busybox_header.pod trunk/busybox/examples/bootfloppy/bootfloppy.txt trunk/busybox/examples/bootfloppy/mkrootfs.sh trunk/busybox/examples/busybox.spec Changeset: Modified: trunk/busybox/INSTALL =================================================================== --- trunk/busybox/INSTALL 2007-02-03 17:28:39 UTC (rev 17740) +++ trunk/busybox/INSTALL 2007-02-03 17:29:14 UTC (rev 17741) @@ -5,7 +5,7 @@ make menuconfig # This creates a file called ".config" make # This creates the "busybox" executable - make install # or make PREFIX=/path/from/root install + make install # or make CONFIG_PREFIX=/path/from/root install The full list of configuration and install options is available by typing: @@ -114,7 +114,7 @@ make O=/some/empty/directory allyesconfig cd /some/empty/directory make - make PREFIX=. install + make CONFIG_PREFIX=. install More Information: ================= Modified: trunk/busybox/Makefile.help =================================================================== --- trunk/busybox/Makefile.help 2007-02-03 17:28:39 UTC (rev 17740) +++ trunk/busybox/Makefile.help 2007-02-03 17:29:14 UTC (rev 17741) @@ -27,7 +27,7 @@ @echo ' make SED="$(objtree)/sed"' @echo @echo 'Installation:' - @echo ' install - install busybox into $(PREFIX)' + @echo ' install - install busybox into $(CONFIG_PREFIX)' @echo ' uninstall' @echo @echo 'Development:' Modified: trunk/busybox/README =================================================================== --- trunk/busybox/README 2007-02-03 17:28:39 UTC (rev 17740) +++ trunk/busybox/README 2007-02-03 17:29:14 UTC (rev 17741) @@ -50,10 +50,10 @@ The build automatically generates a file "busybox.links", which is used by 'make install' to create symlinks to the BusyBox binary for all compiled in - commands. This uses the PREFIX environment variable to specify where to - install, and installs hardlinks or symlinks depending on the configuration - preferences. (You can also manually run the install script at - "applets/install.sh"). + commands. This uses the CONFIG_PREFIX environment variable to specify + where to install, and installs hardlinks or symlinks depending + on the configuration preferences. (You can also manually run + the install script at "applets/install.sh"). ---------------- Modified: trunk/busybox/docs/busybox_header.pod =================================================================== --- trunk/busybox/docs/busybox_header.pod 2007-02-03 17:28:39 UTC (rev 17740) +++ trunk/busybox/docs/busybox_header.pod 2007-02-03 17:29:14 UTC (rev 17741) @@ -33,11 +33,11 @@ After the compile has finished, you should use 'make install' to install BusyBox. This will install the 'bin/busybox' binary, in the target directory -specified by PREFIX. PREFIX can be set when configuring BusyBox, or you can -specify an alternative location at install time (i.e., with a command line -like 'make PREFIX=/tmp/foo install'). If you enabled any applet installation -scheme (either as symlinks or hardlinks), these will also be installed in -the location pointed to by PREFIX. +specified by CONFIG_PREFIX. CONFIG_PREFIX can be set when configuring BusyBox, +or you can specify an alternative location at install time (i.e., with a +command line like 'make CONFIG_PREFIX=/tmp/foo install'). If you enabled +any applet installation scheme (either as symlinks or hardlinks), these will +also be installed in the location pointed to by CONFIG_PREFIX. =head1 USAGE Modified: trunk/busybox/examples/bootfloppy/bootfloppy.txt =================================================================== --- trunk/busybox/examples/bootfloppy/bootfloppy.txt 2007-02-03 17:28:39 UTC (rev 17740) +++ trunk/busybox/examples/bootfloppy/bootfloppy.txt 2007-02-03 17:29:14 UTC (rev 17741) @@ -72,7 +72,7 @@ - Install the Busybox binary and accompanying symlinks: (chdir to busybox directory) - make PREFIX=(path to)loop/ install + make CONFIG_PREFIX=(path to)loop/ install - Make device files in /dev: Modified: trunk/busybox/examples/bootfloppy/mkrootfs.sh =================================================================== --- trunk/busybox/examples/bootfloppy/mkrootfs.sh 2007-02-03 17:28:39 UTC (rev 17740) +++ trunk/busybox/examples/bootfloppy/mkrootfs.sh 2007-02-03 17:29:14 UTC (rev 17741) @@ -76,7 +76,7 @@ cd $BUSYBOX_DIR make distclean make CC=$BASE_DIR/$UCLIBC_DIR/extra/gcc-uClibc/i386-uclibc-gcc -make PREFIX=$BASE_DIR/$TARGET_DIR install +make CONFIG_PREFIX=$BASE_DIR/$TARGET_DIR install cd $BASE_DIR Modified: trunk/busybox/examples/busybox.spec =================================================================== --- trunk/busybox/examples/busybox.spec 2007-02-03 17:28:39 UTC (rev 17740) +++ trunk/busybox/examples/busybox.spec 2007-02-03 17:29:14 UTC (rev 17741) @@ -34,7 +34,7 @@ %Install rm -rf $RPM_BUILD_ROOT -make PREFIX=$RPM_BUILD_ROOT install +make CONFIG_PREFIX=$RPM_BUILD_ROOT install %Clean rm -rf $RPM_BUILD_ROOT From bugs at busybox.net Sat Feb 3 16:05:35 2007 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 Feb 2007 16:05:35 -0800 Subject: [BusyBox 0001183]: Tar -t in busybox-1.4.1 segfaults Message-ID: <7a2278597e7572269976a69d13d548f6@bugs.busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=1183 ====================================================================== Reported By: espakman Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1183 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 01-29-2007 04:00 PST Last Modified: 02-03-2007 16:05 PST ====================================================================== Summary: Tar -t in busybox-1.4.1 segfaults Description: # tar -t Segmentation fault ====================================================================== ---------------------------------------------------------------------- vda - 01-29-07 17:00 ---------------------------------------------------------------------- Works for me: # cat busybox-1.4.1.tar | ./busybox tar t | head -10 busybox-1.4.1/ busybox-1.4.1/loginutils/ busybox-1.4.1/loginutils/su.c busybox-1.4.1/loginutils/Kbuild busybox-1.4.1/loginutils/adduser.c busybox-1.4.1/loginutils/login.c busybox-1.4.1/loginutils/passwd.c busybox-1.4.1/loginutils/getty.c busybox-1.4.1/loginutils/deluser.c busybox-1.4.1/loginutils/vlock.c Your .config, libc, gcc version? Strace output of "busybox tar t"? ---------------------------------------------------------------------- espakman - 01-30-07 11:30 ---------------------------------------------------------------------- My config is attached. Libc: uClibc-0.9.28 gcc: gcc-3.3.3 Strace: # strace ./busybox tar -t execve("./busybox", ["./busybox", "tar", "-t"], [/* 26 vars */]) = 0 old_mmap(NULL, 20, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40005000 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libcrypt.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\224\4\0"..., 4096) = 4096 old_mmap(NULL, 81920, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000 old_mmap(0x40007000, 7798, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x40007000 old_mmap(0x40009000, 184, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x2000) = 0x40009000 old_mmap(0x4000a000, 67036, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4000a000 close(3) = 0 munmap(0x40006000, 4096) = 0 open("/root/Bering/src/bering-uclibc/buildtool/staging/lib/libc.so.0", O_RDONLY) = 3 old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40006000 read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\316"..., 4096) = 4096 old_mmap(NULL, 266240, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001b000 old_mmap(0x4001b000, 239528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0) = 0x4001b000 old_mmap(0x40056000, 3616, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x3b000) = 0x40056000 old_mmap(0x40057000, 19192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40057000 close(3) = 0 munmap(0x40006000, 4096) = 0 ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0 getuid() = 0 getgid() = 0 setgid(0) = 0 setuid(0) = 0 brk(0) = 0x808dea0 brk(0x808eea0) = 0x808eea0 brk(0x808f000) = 0x808f000 --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ ---------------------------------------------------------------------- espakman - 02-03-07 03:12 ---------------------------------------------------------------------- A small update, the segfault still exists with today's snapshot. ---------------------------------------------------------------------- vda - 02-03-07 06:34 ---------------------------------------------------------------------- With uclibc this enters infinite loop in exit(): int main() { gethostbyname("127.0.0.1"); exit(1); } This does the same, with or without second fclose: int main() { FILE* fp; char buf[4*1024]; fp = fopen("/etc/resolv.conf", "r"); fclose(fp); fp = fopen("/etc/hosts", "r"); // fclose(fp); exit(1); } If even this can't work, all bets are off. uclibc mailing list and maintainer were informed. Twice. ---------------------------------------------------------------------- espakman - 02-03-07 06:56 ---------------------------------------------------------------------- Bad.... but I don't see a call to networking code in tar.c. I will patch uClibc with the code you propose anyway and report back. The strange thing is that tar -t with busybox-1.2.1 and uClibc-0.9.28 did work correct... ---------------------------------------------------------------------- espakman - 02-03-07 16:05 ---------------------------------------------------------------------- It looks like the "gethostbyname" problem only exists with the SVN versions of uCLibc, 0.9.28 seems to work ok. But maybe I missed the irony and you were just saying that uClibc is buggy ;-) Issue History Date Modified Username Field Change ====================================================================== 01-29-07 04:00 espakman New Issue 01-29-07 04:00 espakman Status new => assigned 01-29-07 04:00 espakman Assigned To => BusyBox 01-29-07 17:00 vda Note Added: 0002070 01-30-07 11:30 espakman Note Added: 0002076 01-30-07 11:30 espakman File Added: bbconfig 02-03-07 03:12 espakman Note Added: 0002087 02-03-07 06:34 vda Note Added: 0002089 02-03-07 06:56 espakman Note Added: 0002090 02-03-07 16:05 espakman Note Added: 0002091 ====================================================================== From vda at busybox.net Sat Feb 3 16:09:18 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 16:09:18 -0800 (PST) Subject: svn commit: trunk/busybox/include Message-ID: <20070204000918.E768D48610@busybox.net> Author: vda Date: 2007-02-03 16:09:18 -0800 (Sat, 03 Feb 2007) New Revision: 17747 Log: BB_EXECLP should call execlp, not execvp Modified: trunk/busybox/include/libbb.h Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-02-03 23:09:04 UTC (rev 17746) +++ trunk/busybox/include/libbb.h 2007-02-04 00:09:18 UTC (rev 17747) @@ -561,7 +561,7 @@ execlp((find_applet_by_name(prog)) ? CONFIG_BUSYBOX_EXEC_PATH : prog, cmd, __VA_ARGS__) #else #define BB_EXECVP(prog,cmd) execvp(prog,cmd) -#define BB_EXECLP(prog,cmd,...) execvp(prog,cmd, __VA_ARGS__) +#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__) #endif USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out); From vda at busybox.net Sat Feb 3 18:38:22 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 18:38:22 -0800 (PST) Subject: svn commit: trunk/busybox/scripts Message-ID: <20070204023822.31C82485F4@busybox.net> Author: vda Date: 2007-02-03 18:38:21 -0800 (Sat, 03 Feb 2007) New Revision: 17748 Log: mkconfigs: remove echo "`...`" contortion Modified: trunk/busybox/scripts/mkconfigs Changeset: Modified: trunk/busybox/scripts/mkconfigs =================================================================== --- trunk/busybox/scripts/mkconfigs 2007-02-04 00:09:18 UTC (rev 17747) +++ trunk/busybox/scripts/mkconfigs 2007-02-04 02:38:21 UTC (rev 17748) @@ -21,21 +21,21 @@ # # Busybox version by Matteo Croce <3297627799 at wind.it> # -# Rules to generate bbconfig.h from .config: +# Rules to generate bbconfigopts.h from .config: # - Retain lines that begin with "CONFIG_" # - Retain lines that begin with "# CONFIG_" # - lines that use double-quotes must \\-escape-quote them +config="$1" if [ $# -lt 1 ] then config=.config -else config=$1 fi -echo "#ifndef _BBCONFIGOPTS_H" -echo "#define _BBCONFIGOPTS_H" -echo \ -"/* +echo "\ +#ifndef _BBCONFIGOPTS_H +#define _BBCONFIGOPTS_H +/* * busybox configuration settings. * * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. @@ -43,11 +43,10 @@ * This file is generated automatically by scripts/mkconfigs. * Do not edit. * - */" + */ +static const char * const bbconfig_config =" -echo "static const char * const bbconfig_config =" -# dash and probably ash produce wrong output (because of \n) -# TODO: check whether our ash is ok -echo "`sed 's/\"/\\\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\\"" $0 "\\\\n\\"";}'`" +sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}' + echo ";" echo "#endif /* _BBCONFIGOPTS_H */" From vda at busybox.net Sat Feb 3 18:39:08 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 18:39:08 -0800 (PST) Subject: svn commit: trunk/busybox: include libbb networking sysklogd Message-ID: <20070204023908.12D5548601@busybox.net> Author: vda Date: 2007-02-03 18:39:08 -0800 (Sat, 03 Feb 2007) New Revision: 17749 Log: add x to IPv6 functions which can die Modified: trunk/busybox/include/libbb.h trunk/busybox/libbb/xconnect.c trunk/busybox/networking/arping.c trunk/busybox/networking/dnsd.c trunk/busybox/networking/ftpgetput.c trunk/busybox/networking/nslookup.c trunk/busybox/networking/ping.c trunk/busybox/networking/tftp.c trunk/busybox/networking/wget.c trunk/busybox/sysklogd/syslogd.c Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/include/libbb.h 2007-02-04 02:39:08 UTC (rev 17749) @@ -317,13 +317,13 @@ * Currently will return IPv4 or IPv6 sockaddrs only * (depending on host), but in theory nothing prevents e.g. * UNIX socket address being returned, IPX sockaddr etc... */ -len_and_sockaddr* host2sockaddr(const char *host, int port); +len_and_sockaddr* xhost2sockaddr(const char *host, int port); #if ENABLE_FEATURE_IPV6 /* Same, useful if you want to force family (e.g. IPv6) */ -len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af); +len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af); #else -/* [we evaluate af: think about "host_and_af2sockaddr(..., af++)"] */ -#define host_and_af2sockaddr(host, port, af) ((void)(af), host2sockaddr((host), (port))) +/* [we evaluate af: think about "xhost_and_af2sockaddr(..., af++)"] */ +#define xhost_and_af2sockaddr(host, port, af) ((void)(af), xhost2sockaddr((host), (port))) #endif /* Assign sin[6]_port member if the socket is of corresponding type, * otherwise no-op. Useful for ftp. Modified: trunk/busybox/libbb/xconnect.c =================================================================== --- trunk/busybox/libbb/xconnect.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/libbb/xconnect.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -111,16 +111,19 @@ /* What? UNIX socket? IPX?? :) */ } +/* We hijack this constant to mean something else */ +/* It doesn't hurt because we will remove this bit anyway */ +#define DIE_ON_ERROR AI_CANONNAME + /* host: "1.2.3.4[:port]", "www.google.com[:port]" - * port: if neither of above specifies port # - */ + * port: if neither of above specifies port # */ static len_and_sockaddr* str2sockaddr( const char *host, int port, USE_FEATURE_IPV6(sa_family_t af,) int ai_flags) { int rc; - len_and_sockaddr *r; // = NULL; + len_and_sockaddr *r = NULL; struct addrinfo *result = NULL; const char *org_host = host; /* only for error msg */ const char *cp; @@ -158,14 +161,18 @@ /* Needed. Or else we will get each address thrice (or more) * for each possible socket type (tcp,udp,raw...): */ hint.ai_socktype = SOCK_STREAM; - hint.ai_flags = ai_flags; + hint.ai_flags = ai_flags & ~DIE_ON_ERROR; rc = getaddrinfo(host, NULL, &hint, &result); - if (rc || !result) - bb_error_msg_and_die("bad address '%s'", org_host); + if (rc || !result) { + if (ai_flags & DIE_ON_ERROR) + bb_error_msg_and_die("bad address '%s'", org_host); + goto ret; + } r = xmalloc(offsetof(len_and_sockaddr, sa) + result->ai_addrlen); r->len = result->ai_addrlen; memcpy(&r->sa, result->ai_addr, result->ai_addrlen); set_nport(r, htons(port)); + ret: freeaddrinfo(result); return r; } @@ -174,20 +181,20 @@ #endif #if ENABLE_FEATURE_IPV6 -len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af) +len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af) { - return str2sockaddr(host, port, af, 0); + return str2sockaddr(host, port, af, DIE_ON_ERROR); } #endif -len_and_sockaddr* host2sockaddr(const char *host, int port) +len_and_sockaddr* xhost2sockaddr(const char *host, int port) { - return str2sockaddr(host, port, AF_UNSPEC, 0); + return str2sockaddr(host, port, AF_UNSPEC, DIE_ON_ERROR); } -static len_and_sockaddr* dotted2sockaddr(const char *host, int port) +static len_and_sockaddr* xdotted2sockaddr(const char *host, int port) { - return str2sockaddr(host, port, AF_UNSPEC, NI_NUMERICHOST); + return str2sockaddr(host, port, AF_UNSPEC, AI_NUMERICHOST | DIE_ON_ERROR); } int xsocket_stream(len_and_sockaddr **lsap) @@ -220,10 +227,7 @@ len_and_sockaddr *lsa; if (bindaddr && bindaddr[0]) { - lsa = dotted2sockaddr(bindaddr, port); - /* currently NULL check is in str2sockaddr */ - //if (!lsa) - // bb_error_msg_and_die("bad address '%s'", bindaddr); + lsa = xdotted2sockaddr(bindaddr, port); /* user specified bind addr dictates family */ fd = xsocket(lsa->sa.sa_family, SOCK_STREAM, 0); } else { @@ -241,10 +245,7 @@ int fd; len_and_sockaddr *lsa; - lsa = host2sockaddr(peer, port); - /* currently NULL check is in str2sockaddr */ - //if (!lsa) - // bb_error_msg_and_die("bad address '%s'", peer); + lsa = xhost2sockaddr(peer, port); fd = xsocket(lsa->sa.sa_family, SOCK_STREAM, 0); setsockopt_reuseaddr(fd); xconnect(fd, &lsa->sa, lsa->len); Modified: trunk/busybox/networking/arping.c =================================================================== --- trunk/busybox/networking/arping.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/networking/arping.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -307,7 +307,7 @@ if (!inet_aton(target, &dst)) { len_and_sockaddr *lsa; - lsa = host_and_af2sockaddr(target, 0, AF_INET); + lsa = xhost_and_af2sockaddr(target, 0, AF_INET); memcpy(&dst, &lsa->sin.sin_addr.s_addr, 4); if (ENABLE_FEATURE_CLEAN_UP) free(lsa); Modified: trunk/busybox/networking/dnsd.c =================================================================== --- trunk/busybox/networking/dnsd.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/networking/dnsd.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -377,7 +377,7 @@ signal(SIGURG, SIG_IGN); #endif - lsa = host2sockaddr(listen_interface, port); + lsa = xhost2sockaddr(listen_interface, port); udps = xsocket(lsa->sa.sa_family, SOCK_DGRAM, 0); xbind(udps, &lsa->sa, lsa->len); // xlisten(udps, 50); - ?!! DGRAM sockets are never listened on I think? Modified: trunk/busybox/networking/ftpgetput.c =================================================================== --- trunk/busybox/networking/ftpgetput.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/networking/ftpgetput.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -346,7 +346,7 @@ /* We want to do exactly _one_ DNS lookup, since some * sites (i.e. ftp.us.debian.org) use round-robin DNS * and we want to connect to only one IP... */ - server->lsa = host2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21)); + server->lsa = xhost2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21)); if (verbose_flag) { printf("Connecting to %s (%s)\n", argv[0], xmalloc_sockaddr2dotted(&server->lsa->sa, server->lsa->len)); Modified: trunk/busybox/networking/nslookup.c =================================================================== --- trunk/busybox/networking/nslookup.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/networking/nslookup.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -49,7 +49,7 @@ static int print_host(const char *hostname, const char *header) { - /* We can't use host2sockaddr() - we want to get ALL addresses, + /* We can't use xhost2sockaddr() - we want to get ALL addresses, * not just one */ struct addrinfo *result = NULL; Modified: trunk/busybox/networking/ping.c =================================================================== --- trunk/busybox/networking/ping.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/networking/ping.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -211,9 +211,9 @@ bb_show_usage(); #if ENABLE_PING6 - lsa = host_and_af2sockaddr(hostname, 0, af); + lsa = xhost_and_af2sockaddr(hostname, 0, af); #else - lsa = host_and_af2sockaddr(hostname, 0, AF_INET); + lsa = xhost_and_af2sockaddr(hostname, 0, AF_INET); #endif /* Set timer _after_ DNS resolution */ signal(SIGALRM, noresp); @@ -743,9 +743,9 @@ af = AF_INET; if (option_mask32 & OPT_IPV6) af = AF_INET6; - lsa = host_and_af2sockaddr(hostname, 0, af); + lsa = xhost_and_af2sockaddr(hostname, 0, af); #else - lsa = host_and_af2sockaddr(hostname, 0, AF_INET); + lsa = xhost_and_af2sockaddr(hostname, 0, AF_INET); #endif dotted = xmalloc_sockaddr2dotted_noport(&lsa->sa, lsa->len); #if ENABLE_PING6 Modified: trunk/busybox/networking/tftp.c =================================================================== --- trunk/busybox/networking/tftp.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/networking/tftp.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -488,7 +488,7 @@ } port = bb_lookup_port(argv[optind + 1], "udp", 69); - peer_lsa = host2sockaddr(argv[optind], port); + peer_lsa = xhost2sockaddr(argv[optind], port); #if ENABLE_DEBUG_TFTP fprintf(stderr, "using server \"%s\", " Modified: trunk/busybox/networking/wget.c =================================================================== --- trunk/busybox/networking/wget.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/networking/wget.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -234,7 +234,7 @@ /* We want to do exactly _one_ DNS lookup, since some * sites (i.e. ftp.us.debian.org) use round-robin DNS * and we want to connect to only one IP... */ - lsa = host2sockaddr(server.host, server.port); + lsa = xhost2sockaddr(server.host, server.port); if (!(opt & WGET_OPT_QUIET)) { fprintf(stderr, "Connecting to %s (%s)\n", server.host, xmalloc_sockaddr2dotted(&lsa->sa, lsa->len)); @@ -354,7 +354,7 @@ server.port = target.port; } free(lsa); - lsa = host2sockaddr(server.host, server.port); + lsa = xhost2sockaddr(server.host, server.port); break; } } Modified: trunk/busybox/sysklogd/syslogd.c =================================================================== --- trunk/busybox/sysklogd/syslogd.c 2007-02-04 02:38:21 UTC (rev 17748) +++ trunk/busybox/sysklogd/syslogd.c 2007-02-04 02:39:08 UTC (rev 17749) @@ -566,7 +566,7 @@ #endif #if ENABLE_FEATURE_REMOTE_LOG if (option_mask32 & OPT_remotelog) { // -R - remoteAddr = host2sockaddr(opt_R, 514); + remoteAddr = xhost2sockaddr(opt_R, 514); } //if (option_mask32 & OPT_locallog) // -L #endif From vda at busybox.net Sat Feb 3 18:39:55 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 18:39:55 -0800 (PST) Subject: svn commit: trunk/busybox: include libbb util-linux Message-ID: <20070204023955.8820248601@busybox.net> Author: vda Date: 2007-02-03 18:39:55 -0800 (Sat, 03 Feb 2007) New Revision: 17750 Log: mount: (try to) support cifs with IPv6 Modified: trunk/busybox/include/libbb.h trunk/busybox/libbb/xconnect.c trunk/busybox/util-linux/mount.c Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-02-04 02:39:08 UTC (rev 17749) +++ trunk/busybox/include/libbb.h 2007-02-04 02:39:55 UTC (rev 17750) @@ -316,7 +316,10 @@ /* Return malloc'ed len_and_sockaddr with socket address of host:port * Currently will return IPv4 or IPv6 sockaddrs only * (depending on host), but in theory nothing prevents e.g. - * UNIX socket address being returned, IPX sockaddr etc... */ + * UNIX socket address being returned, IPX sockaddr etc... + * On error does bb_error_msg and returns NULL */ +len_and_sockaddr* host2sockaddr(const char *host, int port); +/* Versions which die on error */ len_and_sockaddr* xhost2sockaddr(const char *host, int port); #if ENABLE_FEATURE_IPV6 /* Same, useful if you want to force family (e.g. IPv6) */ Modified: trunk/busybox/libbb/xconnect.c =================================================================== --- trunk/busybox/libbb/xconnect.c 2007-02-04 02:39:08 UTC (rev 17749) +++ trunk/busybox/libbb/xconnect.c 2007-02-04 02:39:55 UTC (rev 17750) @@ -164,8 +164,9 @@ hint.ai_flags = ai_flags & ~DIE_ON_ERROR; rc = getaddrinfo(host, NULL, &hint, &result); if (rc || !result) { + bb_error_msg("bad address '%s'", org_host); if (ai_flags & DIE_ON_ERROR) - bb_error_msg_and_die("bad address '%s'", org_host); + sleep_and_die(); goto ret; } r = xmalloc(offsetof(len_and_sockaddr, sa) + result->ai_addrlen); @@ -187,6 +188,11 @@ } #endif +len_and_sockaddr* host2sockaddr(const char *host, int port) +{ + return str2sockaddr(host, port, AF_UNSPEC, 0); +} + len_and_sockaddr* xhost2sockaddr(const char *host, int port) { return str2sockaddr(host, port, AF_UNSPEC, DIE_ON_ERROR); Modified: trunk/busybox/util-linux/mount.c =================================================================== --- trunk/busybox/util-linux/mount.c 2007-02-04 02:39:08 UTC (rev 17749) +++ trunk/busybox/util-linux/mount.c 2007-02-04 02:39:55 UTC (rev 17750) @@ -687,6 +687,8 @@ static struct pmap p = {0, 0, 0, 0}; server_addr->sin_port = PMAPPORT; +/* glibc 2.4 (still) has pmap_getmaps(struct sockaddr_in *). + * I understand it like "IPv6 for this is not 100% ready" */ pmap = pmap_getmaps(server_addr); if (version > MAX_NFSPROT) @@ -1396,8 +1398,9 @@ && (mp->mnt_fsname[0]=='/' || mp->mnt_fsname[0]=='\\') && mp->mnt_fsname[0]==mp->mnt_fsname[1] ) { - struct hostent *he; - char ip[32], *s; + len_and_sockaddr *lsa; + char *ip, *dotted; + char *s; rc = 1; // Replace '/' with '\' and verify that unc points to "//server/share". @@ -1408,29 +1411,34 @@ // get server IP s = strrchr(mp->mnt_fsname, '\\'); - if (s == mp->mnt_fsname+1) goto report_error; + if (s <= mp->mnt_fsname+1) goto report_error; *s = '\0'; - he = gethostbyname(mp->mnt_fsname+2); + lsa = host2sockaddr(mp->mnt_fsname+2, 0); *s = '\\'; - if (!he) goto report_error; + if (!lsa) goto report_error; - // Insert ip=... option into string flags. (NOTE: Add IPv6 support.) + // insert ip=... option into string flags. - sprintf(ip, "ip=%d.%d.%d.%d", he->h_addr[0], he->h_addr[1], - he->h_addr[2], he->h_addr[3]); + dotted = xmalloc_sockaddr2dotted_noport(&lsa->sa, lsa->len); + ip = xasprintf("ip=%s", dotted); parse_mount_options(ip, &filteropts); // compose new unc '\\server-ip\share' + // (s => slash after hostname) - mp->mnt_fsname = xasprintf("\\\\%s%s", ip+3, - strchr(mp->mnt_fsname+2,'\\')); + mp->mnt_fsname = xasprintf("\\\\%s%s", dotted, s); // lock is required vfsflags |= MS_MANDLOCK; mp->mnt_type = (char*)"cifs"; rc = mount_it_now(mp, vfsflags, filteropts); - if (ENABLE_FEATURE_CLEAN_UP) free(mp->mnt_fsname); + if (ENABLE_FEATURE_CLEAN_UP) { + free(mp->mnt_fsname); + free(ip); + free(dotted); + free(lsa); + } goto report_error; } @@ -1508,8 +1516,9 @@ } } -report_error: - if (ENABLE_FEATURE_CLEAN_UP) free(filteropts); + report_error: + if (ENABLE_FEATURE_CLEAN_UP) + free(filteropts); if (rc && errno == EBUSY && ignore_busy) rc = 0; if (rc < 0) From vda at busybox.net Sat Feb 3 18:40:27 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 18:40:27 -0800 (PST) Subject: svn commit: trunk/busybox: include networking Message-ID: <20070204024027.C21CA485F4@busybox.net> Author: vda Date: 2007-02-03 18:40:27 -0800 (Sat, 03 Feb 2007) New Revision: 17751 Log: ifconfig: use IPv6 infrastructure Modified: trunk/busybox/include/libbb.h trunk/busybox/networking/ifconfig.c trunk/busybox/networking/traceroute.c Changeset: Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-02-04 02:39:55 UTC (rev 17750) +++ trunk/busybox/include/libbb.h 2007-02-04 02:40:27 UTC (rev 17751) @@ -344,7 +344,7 @@ char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen); char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen); // "old" (ipv4 only) API -// users: traceroute.c hostname.c ifconfig.c ping.c +// users: traceroute.c hostname.c struct hostent *xgethostbyname(const char *name); Modified: trunk/busybox/networking/ifconfig.c =================================================================== --- trunk/busybox/networking/ifconfig.c 2007-02-04 02:39:55 UTC (rev 17750) +++ trunk/busybox/networking/ifconfig.c 2007-02-04 02:40:27 UTC (rev 17751) @@ -266,9 +266,6 @@ { struct ifreq ifr; struct sockaddr_in sai; -#if ENABLE_FEATURE_IPV6 - struct sockaddr_in6 sai6; -#endif #if ENABLE_FEATURE_IFCONFIG_HW struct sockaddr sa; #endif @@ -389,31 +386,33 @@ sai.sin_addr.s_addr = (~sai_netmask) | (sai_hostname & sai_netmask); } #endif + else { + len_and_sockaddr *lsa = xhost2sockaddr(host, 0); #if ENABLE_FEATURE_IPV6 - else if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > 0) { - int sockfd6; - struct in6_ifreq ifr6; + if (lsa->sa.sa_family == AF_INET6) { + int sockfd6; + struct in6_ifreq ifr6; - memcpy((char *) &ifr6.ifr6_addr, - (char *) &sai6.sin6_addr, - sizeof(struct in6_addr)); + memcpy((char *) &ifr6.ifr6_addr, + (char *) &(lsa->sin6.sin6_addr), + sizeof(struct in6_addr)); - /* Create a channel to the NET kernel. */ - sockfd6 = xsocket(AF_INET6, SOCK_DGRAM, 0); - if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) - bb_perror_msg_and_die("SIOGIFINDEX"); - ifr6.ifr6_ifindex = ifr.ifr_ifindex; - ifr6.ifr6_prefixlen = prefix_len; - if (ioctl(sockfd6, a1op->selector, &ifr6) < 0) - bb_perror_msg_and_die(a1op->name); - continue; - } + /* Create a channel to the NET kernel. */ + sockfd6 = xsocket(AF_INET6, SOCK_DGRAM, 0); + if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) + bb_perror_msg_and_die("SIOGIFINDEX"); + ifr6.ifr6_ifindex = ifr.ifr_ifindex; + ifr6.ifr6_prefixlen = prefix_len; + if (ioctl(sockfd6, a1op->selector, &ifr6) < 0) + bb_perror_msg_and_die(a1op->name); + if (ENABLE_FEATURE_CLEAN_UP) + free(lsa); + continue; + } #endif - else if (inet_aton(host, &sai.sin_addr) == 0) { - /* It's not a dotted quad. */ - struct hostent *hp = xgethostbyname(host); - memcpy((char *) &sai.sin_addr, (char *) hp->h_addr_list[0], - sizeof(struct in_addr)); + sai.sin_addr = lsa->sin.sin_addr; + if (ENABLE_FEATURE_CLEAN_UP) + free(lsa); } #if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS if (mask & A_HOSTNAME) Modified: trunk/busybox/networking/traceroute.c =================================================================== --- trunk/busybox/networking/traceroute.c 2007-02-04 02:39:55 UTC (rev 17750) +++ trunk/busybox/networking/traceroute.c 2007-02-04 02:40:27 UTC (rev 17751) @@ -247,7 +247,7 @@ /* * UDP kernel structures and variables. */ -struct udpiphdr { +struct udpiphdr { struct ipovly ui_i; /* overlaid ip structure */ struct udphdr ui_u; /* udp header */ }; From vda at busybox.net Sat Feb 3 18:41:58 2007 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 Feb 2007 18:41:58 -0800 (PST) Subject: svn commit: trunk/busybox: console-tools include libbb networking/u etc... Message-ID: <20070204024158.52BBB485F4@busybox.net> Author: vda Date: 2007-02-03 18:41:57 -0800 (Sat, 03 Feb 2007) New Revision: 17752 Log: udhcp: use improved gethostbyname replacement from IPv6 code Modified: trunk/busybox/console-tools/setlogcons.c trunk/busybox/include/libbb.h trunk/busybox/libbb/xconnect.c trunk/busybox/networking/udhcp/files.c Changeset: Modified: trunk/busybox/console-tools/setlogcons.c =================================================================== --- trunk/busybox/console-tools/setlogcons.c 2007-02-04 02:40:27 UTC (rev 17751) +++ trunk/busybox/console-tools/setlogcons.c 2007-02-04 02:41:57 UTC (rev 17752) @@ -11,7 +11,8 @@ #include "busybox.h" -extern int setlogcons_main(int argc, char **argv) +int setlogcons_main(int argc, char **argv); +int setlogcons_main(int argc, char **argv) { struct { char fn; Modified: trunk/busybox/include/libbb.h =================================================================== --- trunk/busybox/include/libbb.h 2007-02-04 02:40:27 UTC (rev 17751) +++ trunk/busybox/include/libbb.h 2007-02-04 02:41:57 UTC (rev 17752) @@ -319,13 +319,15 @@ * UNIX socket address being returned, IPX sockaddr etc... * On error does bb_error_msg and returns NULL */ len_and_sockaddr* host2sockaddr(const char *host, int port); -/* Versions which die on error */ +/* Version which dies on error */ len_and_sockaddr* xhost2sockaddr(const char *host, int port); #if ENABLE_FEATURE_IPV6 /* Same, useful if you want to force family (e.g. IPv6) */ +len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af); len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af); #else -/* [