Changeset 904


Ignore:
Timestamp:
Oct 25, 2006, 1:51:57 AM (11 years ago)
Author:
bruno
Message:

merge -r890:902 $SVN_M/branches/stable

Location:
trunk
Files:
44 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/mindi-busybox/.config

    r863 r904  
    355355# Linux Module Utilities
    356356#
    357 # CONFIG_INSMOD is not set
     357CONFIG_INSMOD=y
    358358# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
    359359# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
     
    361361# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
    362362# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
    363 # CONFIG_RMMOD is not set
    364 # CONFIG_LSMOD is not set
    365 # CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
    366 # CONFIG_MODPROBE is not set
    367 # CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS is not set
     363CONFIG_RMMOD=y
     364CONFIG_LSMOD=y
     365CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
     366CONFIG_MODPROBE=y
     367CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS=y
     368
     369#
     370# Options common to multiple modutils
     371#
    368372# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
    369 # CONFIG_FEATURE_2_4_MODULES is not set
    370 # CONFIG_FEATURE_2_6_MODULES is not set
     373CONFIG_FEATURE_2_4_MODULES=y
     374CONFIG_FEATURE_2_6_MODULES=y
    371375# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
    372376
  • trunk/mindi-busybox/Config.in

    r821 r904  
    7777    bool "Store applet usage messages in compressed form"
    7878    default y
    79     depends on CONFIG_SHOW_USAGE && CONFIG_NITPICK
     79    depends on CONFIG_SHOW_USAGE
    8080    help
    8181      Store usage messages in compressed form, uncompress them on-the-fly
  • trunk/mindi-busybox/Rules.mak

    r821 r904  
    1515MAJOR_VERSION   :=1
    1616MINOR_VERSION   :=2
    17 SUBLEVEL_VERSION:=1
     17SUBLEVEL_VERSION:=2
    1818EXTRAVERSION    :=
    1919VERSION   :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
     
    266266    CFLAGS +=-DNDEBUG
    267267    CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
    268     CHECKED_LDFLAGS += $(call check_ld,--gc-sections,)
     268    CHECKED_LDFLAGS += $(call check_ld,$(LD),--gc-sections,)
    269269endif
    270270
     
    296296
    297297ifeq ($(strip $(CONFIG_SELINUX)),y)
    298     LIBRARIES += -lselinux
     298    LIBRARIES += -lselinux -lsepol
    299299endif
    300300
  • trunk/mindi-busybox/VERSION

    r825 r904  
    1 1.2.1
     11.2.2
  • trunk/mindi-busybox/archival/Makefile.in

    r821 r904  
    1212
    1313ARCHIVAL-y:=
    14 ARCHIVAL-$(CONFIG_APT_GET)  +=
    1514ARCHIVAL-$(CONFIG_AR)       += ar.o
    1615ARCHIVAL-$(CONFIG_BUNZIP2)  += bunzip2.o
  • trunk/mindi-busybox/archival/libunarchive/decompress_uncompress.c

    r821 r904  
    7070static int maxbits = BITS;
    7171
    72 /* Input buffer */
    73 static unsigned char inbuf[IBUFSIZ + 64];
    74 
    75 /* Output buffer */
    76 static unsigned char outbuf[OBUFSIZ + 2048];
    77 
    78 
    79 static unsigned char htab[HSIZE];
    80 static unsigned short codetab[HSIZE];
    81 
    8272#define htabof(i)               htab[i]
    8373#define codetabof(i)            codetab[i]
     
    8575#define tab_suffixof(i)         ((unsigned char *)(htab))[i]
    8676#define de_stack                ((unsigned char *)&(htab[HSIZE-1]))
    87 #define clear_htab()            memset(htab, -1, sizeof(htab))
     77#define clear_htab()            memset(htab, -1, HSIZE)
    8878#define clear_tab_prefixof()    memset(codetab, 0, 256);
    8979
     
    113103    int n_bits;
    114104    int rsize = 0;
     105    RESERVE_CONFIG_UBUFFER(inbuf, IBUFSIZ + 64);
     106    RESERVE_CONFIG_UBUFFER(outbuf, OBUFSIZ + 2048);
     107    unsigned char htab[HSIZE];
     108    unsigned short codetab[HSIZE];
     109    memset(inbuf, 0, IBUFSIZ + 64);
     110    memset(outbuf, 0, OBUFSIZ + 2048);
    115111
    116112    insize = 0;
     
    160156        }
    161157
    162         if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
     158        if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
    163159            rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
    164160            insize += rsize;
     
    286282    }
    287283
     284    RELEASE_CONFIG_BUFFER(inbuf);
     285    RELEASE_CONFIG_BUFFER(outbuf);
    288286    return 0;
    289287}
  • trunk/mindi-busybox/archival/libunarchive/find_list_entry.c

    r821 r904  
    1414{
    1515    while (list) {
    16         if (fnmatch(list->data, filename, 0) == 0) {
     16        if (fnmatch(list->data, filename, FNM_LEADING_DIR) == 0) {
    1717            return (list);
    1818        }
  • trunk/mindi-busybox/changelog

    r821 r904  
    1 Various bug fixes that apply to busybox 1.2.0, cherry-picked from the
    2 ongoing development branch.  This will form the basis for busybox 1.2.1.
     1Various bug fixes that apply to busybox 1.2.1, cherry-picked from the
     2ongoing development branch.  This will form the basis for busybox 1.2.2.
    33
    44I'll append fixes to this as they come up.  (Check the file date, or the bug
    55list below.)  This file is basically a concatenation of the following:
    66
    7 http://busybox.net/downloads/patches/svn-15575.patch
    8 http://busybox.net/downloads/patches/svn-15653.patch
    9 http://busybox.net/downloads/patches/svn-15656.patch
    10 http://busybox.net/downloads/patches/svn-15658.patch
    11 http://busybox.net/downloads/patches/svn-15659.patch
    12 http://busybox.net/downloads/patches/svn-15660.patch
    13 http://busybox.net/downloads/patches/svn-15670.patch
    14 http://busybox.net/downloads/patches/svn-15698.patch
    15 http://busybox.net/downloads/patches/svn-15700.patch
    16 http://busybox.net/downloads/patches/svn-15702.patch
    17 http://busybox.net/downloads/patches/svn-15705.patch
    18 http://busybox.net/downloads/patches/svn-15727.patch
    19 
    20  ------------------------------------------------------------------------
    21 r15575 | landley | 2006-07-01 13:19:02 -0400 (Sat, 01 Jul 2006) | 2 lines
    22 Changed paths:
    23    M /trunk/busybox/shell/lash.c
    24 
    25 Patch from Shaun Jackman moving the var=value logic to where it can do some
    26 good.
    27 
    28  ------------------------------------------------------------------------
    29 Index: shell/lash.c
    30 ===================================================================
    31 --- shell/lash.c    (revision 15574)
    32 +++ shell/lash.c    (revision 15575)
    33 @@ -1171,12 +1171,6 @@
     7http://busybox.net/downloads/patches/svn-15746.patch
     8http://busybox.net/downloads/patches/svn-15751.patch
     9http://busybox.net/downloads/patches/svn-15753.patch
     10http://busybox.net/downloads/patches/svn-15769.patch
     11http://busybox.net/downloads/patches/svn-15745.patch
     12http://busybox.net/downloads/patches/svn-15765.patch
     13http://busybox.net/downloads/patches/svn-15766.patch
     14http://busybox.net/downloads/patches/svn-15772.patch
     15http://busybox.net/downloads/patches/svn-15773.patch
     16http://busybox.net/downloads/patches/svn-15782.patch
     17http://busybox.net/downloads/patches/svn-15787.patch
     18http://busybox.net/downloads/patches/svn-15788.patch
     19http://busybox.net/downloads/patches/svn-15795.patch
     20http://busybox.net/downloads/patches/svn-15800.patch
     21http://busybox.net/downloads/patches/svn-15806.patch
     22http://busybox.net/downloads/patches/svn-15826.patch
     23http://busybox.net/downloads/patches/svn-15855.patch
     24http://busybox.net/downloads/patches/svn-15890.patch
     25http://busybox.net/downloads/patches/svn-15905.patch
     26http://busybox.net/downloads/patches/svn-15906.patch
     27http://busybox.net/downloads/patches/svn-15984.patch
     28http://busybox.net/downloads/patches/svn-16004.patch
     29http://busybox.net/downloads/patches/svn-16008.patch
     30http://busybox.net/downloads/patches/svn-16026.patch
     31http://busybox.net/downloads/patches/svn-16032.patch
     32http://busybox.net/downloads/patches/svn-16033.patch
     33http://busybox.net/downloads/patches/svn-16045.patch
     34http://busybox.net/downloads/patches/svn-16056.patch
     35http://busybox.net/downloads/patches/svn-16057.patch
     36http://busybox.net/downloads/patches/svn-16062.patch
     37http://busybox.net/downloads/patches/svn-16067.patch
     38http://busybox.net/downloads/patches/svn-16109.patch
     39And an otherwise unmerged patch to dnsd (at the very end).
     40
     41That's a bugfix to sed, two fixes to documentation generation (BusyBox.html
     42shouldn't have USE() macros showing up in it anymore), fix umount to report
     43the right errno on failure and to handle umount block devices by name with
     44newer kernels, fix mount to handle symlinks properly, make mdev delete
     45device nodes when called for hotplug remove, a segfault in traceroute, a minor
     46portability fix to md5sum option parsing, a build fix for httpd with old gccs,
     47an options parsing tweak to hdparm, make test fail gracefully when getgroups()
     48returns -1, fix a race condition in modprobe when two instances run at once
     49(hotplug does this), make "tar xf foo.tar dir/dir" extract all subdirectories,
     50make our getty initialize the terminal more like mingetty, an selinux build
     51fix, endianness issue in ping6, fix for zcip defending addresses, clean up some
     52global variables in gzip to save memory, fix sulogin -tNNN, a help text tweak,
     53several warning fixes and build fixes, the dnsd fix, and a partridge in a pear
     54tree.
     55
     56It might have been nice to include 16042 and 16044, but they don't apply and
     57I'm not fixing them up right now.  16081 mixes unrelated changes in
     58with a bug fix, and thus disqualifies itself.
     59
     60This is the last release of BusyBox under the old "GPLv2 or later" dual
     61license.  Future versions (containing changes after svn 16112) will just be
     62GPLv2 only, without the "or later".  If this makes you mad enough to fork the
     63project, this release or svn-16112 are what to fork from.
     64
     65See http://busybox.net/license.html for details.
     66
     67It was fun, guys.  Later...
     68
     69 ------------------------------------------------------------------------
     70r15745 | landley | 2006-07-26 12:10:39 -0400 (Wed, 26 Jul 2006) | 2 lines
     71Changed paths:
     72   M /trunk/busybox/coreutils/md5_sha1_sum.c
     73
     74Patch from Shaun Jackman, set optind by hand if we don't call getopt.
     75
     76 ------------------------------------------------------------------------
     77Index: coreutils/md5_sha1_sum.c
     78===================================================================
     79--- coreutils/md5_sha1_sum.c    (revision 15744)
     80+++ coreutils/md5_sha1_sum.c    (revision 15745)
     81@@ -98,6 +98,7 @@
     82 
     83    if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
     84        flags = bb_getopt_ulflags(argc, argv, "scw");
     85+   else optind = 1;
     86 
     87    if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
     88        if (flags & FLAG_SILENT) {
     89 ------------------------------------------------------------------------
     90r15746 | landley | 2006-07-26 13:25:08 -0400 (Wed, 26 Jul 2006) | 5 lines
     91Changed paths:
     92   M /trunk/busybox/editors/sed.c
     93   M /trunk/busybox/testsuite/sed.tests
     94
     95Rich Filker spotted that sed -e 's/xxx/[/' didn't work right.  Did a smaller
     96fix than his, and shrank the code a bit on top of that so the net size is
     97smaller, and added a test to the test suite for this case.  Plus I cleaned up
     98the #includes and removed unnecessary "const"s while I was there.
     99
     100 ------------------------------------------------------------------------
     101Index: testsuite/sed.tests
     102===================================================================
     103--- testsuite/sed.tests (revision 15745)
     104+++ testsuite/sed.tests (revision 15746)
     105@@ -174,6 +174,8 @@
     106    "yes\n" "" ""
     107 rm ./-     # Clean up
     108 
     109+testing "sed s/xxx/[/" "sed -e 's/xxx/[/'" "[\n" "" "xxx\n"
     110+
     111 # Ponder this a bit more, why "woo not found" from gnu version?
     112 #testing "sed doesn't substitute in deleted line" \
     113 #  "sed -e '/ook/d;s/ook//;t woo;a bang;'" "bang" "" "ook\n"
     114Index: editors/sed.c
     115===================================================================
     116--- editors/sed.c   (revision 15745)
     117+++ editors/sed.c   (revision 15746)
     118@@ -58,12 +58,6 @@
     119    Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
     120 */
     121 
     122-#include <stdio.h>
     123-#include <unistd.h>        /* for getopt() */
     124-#include <errno.h>
     125-#include <ctype.h>     /* for isspace() */
     126-#include <stdlib.h>
     127-#include <string.h>
     128 #include "busybox.h"
     129 #include "xregex.h"
     130 
     131@@ -94,8 +88,6 @@
     132     struct sed_cmd_s *next;    /* Next command (linked list, NULL terminated) */
     133 } sed_cmd_t;
     134 
     135-static const char bad_format_in_subst[] =
     136-   "bad format in substitution expression";
     137 static const char *const semicolon_whitespace = "; \n\r\t\v";
     138 
     139 struct sed_globals
     140@@ -175,7 +167,7 @@
     141 
     142 /* strdup, replacing "\n" with '\n', and "\delimiter" with 'delimiter' */
     143 
     144-static void parse_escapes(char *dest, const char *string, int len, char from, char to)
     145+static void parse_escapes(char *dest, char *string, int len, char from, char to)
    34146 {
    35     struct built_in_command *x;
    36  
    37 -   /* Check if the command sets an environment variable. */
    38 -   if( strchr(child->argv[0], '=') != NULL ) {
    39 -       child->argv[1] = child->argv[0];
    40 -       _exit(builtin_export(child));
     147    int i=0;
     148 
     149@@ -192,7 +184,7 @@
     150    *dest=0;
     151 }
     152 
     153-static char *copy_parsing_escapes(const char *string, int len)
     154+static char *copy_parsing_escapes(char *string, int len)
     155 {
     156    char *dest=xmalloc(len+1);
     157 
     158@@ -205,18 +197,22 @@
     159  * index_of_next_unescaped_regexp_delim - walks left to right through a string
     160  * beginning at a specified index and returns the index of the next regular
     161  * expression delimiter (typically a forward * slash ('/')) not preceded by
     162- * a backslash ('\').
     163+ * a backslash ('\').  A negative delimiter disables square bracket checking.
     164  */
     165-static int index_of_next_unescaped_regexp_delim(const char delimiter,
     166-   const char *str)
     167+static int index_of_next_unescaped_regexp_delim(int delimiter, char *str)
     168 {
     169    int bracket = -1;
     170    int escaped = 0;
     171    int idx = 0;
     172    char ch;
     173 
     174+   if (delimiter < 0) {
     175+       bracket--;
     176+       delimiter *= -1;
     177+   }
     178+
     179    for (; (ch = str[idx]); idx++) {
     180-       if (bracket != -1) {
     181+       if (bracket >= 0) {
     182            if (ch == ']' && !(bracket == idx - 1 || (bracket == idx - 2
     183                    && str[idx - 1] == '^')))
     184                bracket = -1;
     185@@ -224,43 +220,38 @@
     186            escaped = 0;
     187        else if (ch == '\\')
     188            escaped = 1;
     189-       else if (ch == '[')
     190+       else if (bracket == -1 && ch == '[')
     191            bracket = idx;
     192        else if (ch == delimiter)
     193            return idx;
     194    }
     195 
     196    /* if we make it to here, we've hit the end of the string */
     197-   return -1;
     198+   bb_error_msg_and_die("unmatched '%c'",delimiter);
     199 }
     200 
     201 /*
     202  *  Returns the index of the third delimiter
     203  */
     204-static int parse_regex_delim(const char *cmdstr, char **match, char **replace)
     205+static int parse_regex_delim(char *cmdstr, char **match, char **replace)
     206 {
     207-   const char *cmdstr_ptr = cmdstr;
     208+   char *cmdstr_ptr = cmdstr;
     209    char delimiter;
     210    int idx = 0;
     211 
     212    /* verify that the 's' or 'y' is followed by something.  That something
     213     * (typically a 'slash') is now our regexp delimiter... */
     214-   if (*cmdstr == '\0') bb_error_msg_and_die(bad_format_in_subst);
     215+   if (*cmdstr == '\0')
     216+       bb_error_msg_and_die("bad format in substitution expression");
     217    delimiter = *(cmdstr_ptr++);
     218 
     219    /* save the match string */
     220    idx = index_of_next_unescaped_regexp_delim(delimiter, cmdstr_ptr);
     221-   if (idx == -1) {
     222-       bb_error_msg_and_die(bad_format_in_subst);
    41223-   }
     224    *match = copy_parsing_escapes(cmdstr_ptr, idx);
     225 
     226    /* save the replacement string */
     227    cmdstr_ptr += idx + 1;
     228-   idx = index_of_next_unescaped_regexp_delim(delimiter, cmdstr_ptr);
     229-   if (idx == -1) {
     230-       bb_error_msg_and_die(bad_format_in_subst);
     231-   }
     232+   idx = index_of_next_unescaped_regexp_delim(-delimiter, cmdstr_ptr);
     233    *replace = copy_parsing_escapes(cmdstr_ptr, idx);
     234 
     235    return ((cmdstr_ptr - cmdstr) + idx);
     236@@ -287,21 +278,18 @@
     237        if (*my_str == '\\') delimiter = *(++pos);
     238        else delimiter = '/';
     239        next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
     240-       if (next == -1)
     241-           bb_error_msg_and_die("unterminated match expression");
    42242-
    43     /* Check if the command matches any of the non-forking builtins.
    44      * Depending on context, this might be redundant.  But it's
    45      * easier to waste a few CPU cycles than it is to figure out
    46 @@ -1300,6 +1294,12 @@
    47          * is doomed to failure, and doesn't work on bash, either.
    48          */
    49         if (newjob->num_progs == 1) {
    50 +           /* Check if the command sets an environment variable. */
    51 +           if (strchr(child->argv[0], '=') != NULL) {
    52 +               child->argv[1] = child->argv[0];
    53 +               return builtin_export(child);
    54 +           }
     243-       temp=copy_parsing_escapes(pos,next);
     244+       temp = copy_parsing_escapes(pos,next);
     245        *regex = (regex_t *) xmalloc(sizeof(regex_t));
     246        xregcomp(*regex, temp, bbg.regex_type|REG_NEWLINE);
     247        free(temp);
     248        /* Move position to next character after last delimiter */
     249-       pos+=(next+1);
     250+       pos += (next+1);
     251    }
     252    return pos - my_str;
     253 }
     254 
     255 /* Grab a filename.  Whitespace at start is skipped, then goes to EOL. */
     256-static int parse_file_cmd(sed_cmd_t *sed_cmd, const char *filecmdstr, char **retval)
     257+static int parse_file_cmd(sed_cmd_t *sed_cmd, char *filecmdstr, char **retval)
     258 {
     259    int start = 0, idx, hack=0;
     260 
     261@@ -318,7 +306,7 @@
     262    return idx;
     263 }
     264 
     265-static int parse_subst_cmd(sed_cmd_t *const sed_cmd, char *substr)
     266+static int parse_subst_cmd(sed_cmd_t *sed_cmd, char *substr)
     267 {
     268    int cflags = bbg.regex_type;
     269    char *match;
     270@@ -569,7 +557,7 @@
     271    bbg.pipeline.buf[bbg.pipeline.idx++] = c;
     272 }
     273 
     274-static void do_subst_w_backrefs(const char *line, const char *replace)
     275+static void do_subst_w_backrefs(char *line, char *replace)
     276 {
     277    int i,j;
     278 
     279@@ -669,7 +657,7 @@
     280 }
     281 
     282 /* Set command pointer to point to this label.  (Does not handle null label.) */
     283-static sed_cmd_t *branch_to(const char *label)
     284+static sed_cmd_t *branch_to(char *label)
     285 {
     286    sed_cmd_t *sed_cmd;
     287 
     288 ------------------------------------------------------------------------
     289r15751 | landley | 2006-07-27 10:59:36 -0400 (Thu, 27 Jul 2006) | 7 lines
     290Changed paths:
     291   M /trunk/busybox/docs/autodocifier.pl
     292
     293I touched perl.  I feel dirty.
     294
     295Make autodocifier suck less.  It still doesn't handle nested USE( USE() ) case
     296(the inner USE() winds up in the output), but making it recursive involves
     297getting perl to accept a "for" loop and it's telling me that "break" is an
     298unrecognized bareword and I hate perl.  This is at least an improvement.
     299
     300 ------------------------------------------------------------------------
     301Index: docs/autodocifier.pl
     302===================================================================
     303--- docs/autodocifier.pl    (revision 15750)
     304+++ docs/autodocifier.pl    (revision 15751)
     305@@ -21,8 +21,8 @@
     306 # regex && eval away unwanted strings from documentation
     307 sub beautify {
     308    my $text = shift;
     309-   $text =~ s/USAGE_NOT\w+\(.*?"\s*\)//sxg;
     310-   $text =~ s/USAGE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
     311+   $text =~ s/SKIP_\w+\(.*?"\s*\)//sxg;
     312+   $text =~ s/USE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
     313    $text =~ s/"\s*"//sg;
     314    my @line = split("\n", $text);
     315    $text = join('',
     316 ------------------------------------------------------------------------
     317r15753 | landley | 2006-07-27 11:12:21 -0400 (Thu, 27 Jul 2006) | 2 lines
     318Changed paths:
     319   M /trunk/busybox/docs/autodocifier.pl
     320
     321And now, with a for loop, so it can handle the nested USE() case.
     322
     323 ------------------------------------------------------------------------
     324Index: docs/autodocifier.pl
     325===================================================================
     326--- docs/autodocifier.pl    (revision 15752)
     327+++ docs/autodocifier.pl    (revision 15753)
     328@@ -21,8 +21,12 @@
     329 # regex && eval away unwanted strings from documentation
     330 sub beautify {
     331    my $text = shift;
     332-   $text =~ s/SKIP_\w+\(.*?"\s*\)//sxg;
     333-   $text =~ s/USE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
     334+   for (;;) {
     335+       my $text2 = $text;
     336+       $text =~ s/SKIP_\w+\(.*?"\s*\)//sxg;
     337+       $text =~ s/USE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
     338+       last if ( $text2 eq $text );
     339+   }
     340    $text =~ s/"\s*"//sg;
     341    my @line = split("\n", $text);
     342    $text = join('',
     343 ------------------------------------------------------------------------
     344r15765 | rpjday | 2006-08-03 06:50:39 -0400 (Thu, 03 Aug 2006) | 2 lines
     345Changed paths:
     346   M /trunk/busybox/networking/httpd.c
     347
     348Move declaration to be compatible with older gcc's.
     349
     350 ------------------------------------------------------------------------
     351Index: networking/httpd.c
     352===================================================================
     353--- networking/httpd.c  (revision 15764)
     354+++ networking/httpd.c  (revision 15765)
     355@@ -863,6 +863,7 @@
     356 {
     357   struct sockaddr_in lsocket;
     358   int fd;
     359+  int on = 1;
     360 
     361   /* create the socket right now */
     362   /* inet_addr() returns a value that is already in network order */
     363@@ -873,7 +874,6 @@
     364   fd = bb_xsocket(AF_INET, SOCK_STREAM, 0);
     365   /* tell the OS it's OK to reuse a previous address even though */
     366   /* it may still be in a close down state.  Allows bind to succeed. */
     367-  int on = 1;
     368 #ifdef SO_REUSEPORT
     369   setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ;
     370 #else
     371 ------------------------------------------------------------------------
     372r15766 | rpjday | 2006-08-03 07:28:36 -0400 (Thu, 03 Aug 2006) | 2 lines
     373Changed paths:
     374   M /trunk/busybox/loginutils/Config.in
     375
     376Remove apparent typo in "bool" line.
     377
     378 ------------------------------------------------------------------------
     379Index: loginutils/Config.in
     380===================================================================
     381--- loginutils/Config.in    (revision 15765)
     382+++ loginutils/Config.in    (revision 15766)
     383@@ -14,7 +14,7 @@
     384      publicly readable.
     385 
     386 config CONFIG_USE_BB_SHADOW
     387-   bool #"  Use busybox shadow password functions"
     388+   bool "  Use busybox shadow password functions"
     389    default y
     390    depends on CONFIG_USE_BB_PWD_GRP && CONFIG_FEATURE_SHADOWPASSWDS
     391    help
     392 ------------------------------------------------------------------------
     393r15769 | landley | 2006-08-03 13:54:45 -0400 (Thu, 03 Aug 2006) | 5 lines
     394Changed paths:
     395   M /trunk/busybox/util-linux/umount.c
     396
     397Fix umount so loop device disassociation hopefully doesn't screw up errno on
     398a failed mount.  And while I'm at it, legacy mdev removal was only being done
     399in the _failure_ case?  That can't be right.  Plus minor header cleanups
     400and an option parsing tweak.
     401
     402 ------------------------------------------------------------------------
     403Index: util-linux/umount.c
     404===================================================================
     405--- util-linux/umount.c (revision 15768)
     406+++ util-linux/umount.c (revision 15769)
     407@@ -13,17 +13,15 @@
     408 #include "busybox.h"
     409 #include <mntent.h>
     410 #include <errno.h>
     411-#include <string.h>
     412 #include <getopt.h>
     413 
     414-#define OPTION_STRING      "flDnrvad"
     415+#define OPTION_STRING      "flDnravd"
     416 #define OPT_FORCE          1
     417 #define OPT_LAZY           2
     418 #define OPT_DONTFREELOOP   4
     419 #define OPT_NO_MTAB            8
     420 #define OPT_REMOUNT            16
     421-#define OPT_IGNORED            32  // -v is ignored
     422-#define OPT_ALL                (ENABLE_FEATURE_UMOUNT_ALL ? 64 : 0)
     423+#define OPT_ALL                (ENABLE_FEATURE_UMOUNT_ALL ? 32 : 0)
     424 
     425 int umount_main(int argc, char **argv)
     426 {
     427@@ -77,8 +74,6 @@
     428        m = 0;
     429        if (!argc) bb_show_usage();
     430    }
     431-
     432-
     433   
     434    // Loop through everything we're supposed to umount, and do so.
     435    for (;;) {
     436@@ -114,19 +109,20 @@
     437                         "%s busy - remounted read-only", m->device);
     438        }
     439 
     440-       /* De-allocate the loop device.  This ioctl should be ignored on any
     441-        * non-loop block devices. */
     442-       if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONTFREELOOP) && m)
     443-           del_loop(m->device);
     444-
     445        if (curstat) {
     446-           /* Yes, the ENABLE is redundant here, but the optimizer for ARM
     447-            * can't do simple constant propagation in local variables... */
     448-           if(ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
     449-               erase_mtab(m->dir);
     450            status = EXIT_FAILURE;
     451            bb_perror_msg("Couldn't umount %s", path);
     452+       } else {
     453+           /* De-allocate the loop device.  This ioctl should be ignored on
     454+            * any non-loop block devices. */
     455+           if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONTFREELOOP) && m)
     456+               del_loop(m->device);
     457+           if (ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
     458+               erase_mtab(m->dir);
     459        }
    55460+
    56             for (x = bltins; x->cmd; x++) {
    57                 if (strcmp(child->argv[0], x->cmd) == 0 ) {
    58                     int rcode;
    59  ------------------------------------------------------------------------
    60 r15653 | landley | 2006-07-05 21:09:21 -0400 (Wed, 05 Jul 2006) | 6 lines
    61 Changed paths:
    62    M /trunk/busybox/shell/ash.c
    63 
    64 Bug fix from Vladimir Oleynic via Paul Fox for:
    65 echo "+bond0" > /sys/class/net/bonding_masters
    66 while true; do
    67   echo hello
    68 done 
    69 
    70  ------------------------------------------------------------------------
    71 Index: shell/ash.c
    72 ===================================================================
    73 --- shell/ash.c (revision 15652)
    74 +++ shell/ash.c (revision 15653)
    75 @@ -3469,6 +3469,7 @@
    76     flushall();
    77  cmddone:
    78     exitstatus |= ferror(stdout);
    79 +   clearerr(stdout);
    80     commandname = savecmdname;
    81     exsig = 0;
    82     handler = savehandler;
    83  ------------------------------------------------------------------------
    84 r15656 | landley | 2006-07-06 12:41:56 -0400 (Thu, 06 Jul 2006) | 5 lines
    85 Changed paths:
    86    M /trunk/busybox/util-linux/dmesg.c
    87 
    88 Fix three embarassing thinkos in the new dmesg.c:
    89 1) the c argument shouldn't have had a : after that, dunno how that got there.
    90 2) the xgetlarg for level was using size
    91 3) because xgetlarg's error message _SUCKS_ (it does a show_usage() rather than giving any specific info about the range that was violated) I dropped the range down to 2 bytes.  (Which works fine, I dunno why we were nit-picking about that...)
    92 
    93  ------------------------------------------------------------------------
    94 Index: util-linux/dmesg.c
    95 ===================================================================
    96 --- util-linux/dmesg.c  (revision 15655)
    97 +++ util-linux/dmesg.c  (revision 15656)
    98 @@ -15,16 +15,16 @@
    99  int dmesg_main(int argc, char *argv[])
     461+
     462+
     463        // Find next matching mtab entry for -a or umount /dev
     464        while (m && (m = m->next))
     465            if ((opt & OPT_ALL) || !strcmp(path,m->device))
     466 ------------------------------------------------------------------------
     467r15772 | landley | 2006-08-03 16:22:37 -0400 (Thu, 03 Aug 2006) | 2 lines
     468Changed paths:
     469   M /trunk/busybox/miscutils/hdparm.c
     470
     471Patch from tito to improve options parsing.
     472
     473 ------------------------------------------------------------------------
     474Index: miscutils/hdparm.c
     475===================================================================
     476--- miscutils/hdparm.c  (revision 15771)
     477+++ miscutils/hdparm.c  (revision 15772)
     478@@ -1481,7 +1481,7 @@
    100479 {
    101     char *size, *level;
    102 -   int flags = bb_getopt_ulflags(argc, argv, "c:s:n:", &size, &level);
    103 +   int flags = bb_getopt_ulflags(argc, argv, "cs:n:", &size, &level);
    104  
    105     if (flags & 4) {
    106 -       if(klogctl(8, NULL, bb_xgetlarg(size, 10, 0, 10)))
    107 +       if(klogctl(8, NULL, bb_xgetlarg(level, 10, 0, 10)))
    108             bb_perror_msg_and_die("klogctl");
    109     } else {
    110         int len;
    111         char *buf;
    112  
    113 -       len = (flags & 2) ? bb_xgetlarg(size, 10, 4096, INT_MAX) : 16384;
    114 +       len = (flags & 2) ? bb_xgetlarg(size, 10, 2, INT_MAX) : 16384;
    115         buf = xmalloc(len);
    116         if (0 > (len = klogctl(3 + (flags & 1), buf, len)))
    117             bb_perror_msg_and_die("klogctl");
    118  ------------------------------------------------------------------------
    119 r15658 | pgf | 2006-07-06 16:00:43 -0400 (Thu, 06 Jul 2006) | 4 lines
    120 Changed paths:
    121    M /trunk/busybox/Makefile
    122 
    123 fix dependencies so that compressed usage gets rebuilt if
    124     a) include/usage.h is changed, and
    125     b) after "make clean".
    126 
    127  ------------------------------------------------------------------------
    128 Index: Makefile
    129 ===================================================================
    130 --- Makefile    (revision 15657)
    131 +++ Makefile    (revision 15658)
    132 @@ -436,13 +436,16 @@
    133  
    134  ifeq ($(strip $(CONFIG_FEATURE_COMPRESS_USAGE)),y)
    135  USAGE_BIN:=scripts/usage
    136 -$(USAGE_BIN): $(top_srcdir)/scripts/usage.c .config
    137 +$(USAGE_BIN): $(top_srcdir)/scripts/usage.c .config \
    138 +       $(top_srcdir)/include/usage.h
    139     $(do_link.h)
    140  
    141  DEP_INCLUDES += include/usage_compressed.h
    142  
    143 -include/usage_compressed.h: .config $(USAGE_BIN) $(top_srcdir)/scripts/usage_compressed
    144 -   $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed "$(top_builddir)/scripts" > $@
    145 +include/usage_compressed.h: .config $(USAGE_BIN) \
    146 +       $(top_srcdir)/scripts/usage_compressed
    147 +   $(Q)SED="$(SED)" $(SHELL) $(top_srcdir)/scripts/usage_compressed \
    148 +   "$(top_builddir)/scripts" > $@
    149  endif # CONFIG_FEATURE_COMPRESS_USAGE
    150  
    151  # workaround alleged bug in make-3.80, make-3.81
    152 @@ -470,7 +473,8 @@
    153         docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
    154         docs/busybox.net/BusyBox.html busybox.links \
    155         libbusybox.so* \
    156 -       .config.old busybox busybox_unstripped
    157 +       .config.old busybox busybox_unstripped \
    158 +       include/usage_compressed.h scripts/usage
    159     - rm -r -f _install testsuite/links
    160     - find . -name .\*.flags -o -name \*.o  -o -name \*.om -o -name \*.syn \
    161         -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
    162  ------------------------------------------------------------------------
    163 r15659 | landley | 2006-07-06 16:02:47 -0400 (Thu, 06 Jul 2006) | 3 lines
    164 Changed paths:
    165    M /trunk/busybox/libbb/Makefile
    166 
    167 Attempt to address Shaun Jackman's problem adding "busybox: busybox.bflt" to
    168 .config.mak.
    169 
    170  ------------------------------------------------------------------------
    171 Index: libbb/Makefile
    172 ===================================================================
    173 --- libbb/Makefile  (revision 15658)
    174 +++ libbb/Makefile  (revision 15659)
    175 @@ -12,6 +12,12 @@
    176  endif
    177  srcdir=$(top_srcdir)/libbb
    178  LIBBB_DIR:=./
    179 +
    180 +# Ensure "all" is still the default target when make is run by itself in
    181 +# libbb, even if the files we include define rules for targets.
    182 +
    183 +all:
    184 +
    185  include $(top_srcdir)/Rules.mak
    186  include $(top_builddir)/.config
    187  include Makefile.in
    188  ------------------------------------------------------------------------
    189 r15660 | landley | 2006-07-06 16:30:19 -0400 (Thu, 06 Jul 2006) | 3 lines
    190 Changed paths:
    191    M /trunk/busybox/archival/libunarchive/get_header_tar.c
    192 
    193 Fix tar so it can extract git-generated tarballs, based on a suggestion
    194 from Erik Frederiksen.
    195 
    196  ------------------------------------------------------------------------
    197 Index: archival/libunarchive/get_header_tar.c
    198 ===================================================================
    199 --- archival/libunarchive/get_header_tar.c  (revision 15659)
    200 +++ archival/libunarchive/get_header_tar.c  (revision 15660)
    201 @@ -137,10 +137,6 @@
    202     case '1':
    203         file_header->mode |= S_IFREG;
    204         break;
    205 -   case 'x':
    206 -   case 'g':
    207 -       bb_error_msg_and_die("pax is not tar");
    208 -       break;
    209     case '7':
    210         /* Reserved for high performance files, treat as normal file */
    211     case 0:
    212 @@ -188,8 +184,11 @@
    213     case 'N':   /* Old GNU for names > 100 characters */
    214     case 'S':   /* Sparse file */
    215     case 'V':   /* Volume header */
    216 -       bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
     480    unsigned int t;
     481 
     482-
     483+   printf(" (");
     484    if (standby == 0)
     485        printf("off");
     486    else if (standby == 252)
     487@@ -2082,7 +2082,7 @@
     488    USE_FEATURE_HDPARM_GET_IDENTITY("iI")
     489    USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::")
     490 #ifdef HDIO_DRIVE_CMD
     491-                                   "S::D::P::X::K::A::L::W::CyYzZ"
     492+                                   "S:D:P:X:K:A:L:W:CyYzZ"
    217493 #endif
    218 +   case 'g':   /* pax global header */
    219 +   case 'x':   /* pax extended header */
    220 +       bb_error_msg("Ignoring extension type %c", tar.formated.typeflag);
    221 +       break;
    222     default:
    223         bb_error_msg("Unknown typeflag: 0x%x", tar.formated.typeflag);
     494    USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("U:")
     495 #ifdef HDIO_GET_QDMA
     496 ------------------------------------------------------------------------
     497r15773 | landley | 2006-08-03 16:39:59 -0400 (Thu, 03 Aug 2006) | 3 lines
     498Changed paths:
     499   M /trunk/busybox/modutils/lsmod.c
     500
     501Try to make a "type-punned pointer" warning go away for somebody on the
     502buildroot list.
     503
     504 ------------------------------------------------------------------------
     505Index: modutils/lsmod.c
     506===================================================================
     507--- modutils/lsmod.c    (revision 15772)
     508+++ modutils/lsmod.c    (revision 15773)
     509@@ -93,8 +93,7 @@
     510    size_t bufsize, depsize, nmod, count, i, j;
     511 
     512    module_names = xmalloc(bufsize = 256);
     513-   if (my_query_module(NULL, QM_MODULES, (void **)&module_names, &bufsize,
     514-               &nmod)) {
     515+   if (my_query_module(NULL, QM_MODULES, &module_names, &bufsize, &nmod)) {
     516        bb_perror_msg_and_die("QM_MODULES");
    224517    }
    225  ------------------------------------------------------------------------
    226 r15670 | landley | 2006-07-09 13:03:07 -0400 (Sun, 09 Jul 2006) | 3 lines
    227 Changed paths:
    228    M /trunk/busybox/shell/lash.c
    229 
    230 Bugfix from Shaun Jackman (check that argv[optind] isn't null before
    231 dereferencing it) plus a bunch of tweaks from me.
    232 
    233  ------------------------------------------------------------------------
    234 Index: shell/lash.c
    235 ===================================================================
    236 --- shell/lash.c    (revision 15669)
    237 +++ shell/lash.c    (revision 15670)
    238 @@ -1498,6 +1498,8 @@
    239         remove_job(&job_list, job_list.fg);
    240     }
    241  }
    242 +#else
    243 +void free_memory(void);
    244  #endif
    245  
    246  #ifdef CONFIG_LASH_JOB_CONTROL
    247 @@ -1528,7 +1530,7 @@
    248     /* Put ourselves in our own process group.  */
    249     setsid();
    250     shell_pgrp = getpid ();
    251 -   setpgid (shell_pgrp, shell_pgrp);
    252 +   setpgid(shell_pgrp, shell_pgrp);
    253  
    254     /* Grab control of the terminal.  */
    255     tcsetpgrp(shell_terminal, shell_pgrp);
    256 @@ -1577,7 +1579,7 @@
    257                 argv = argv+optind;
    258                 break;
    259             case 'i':
    260 -               interactive = TRUE;
    261 +               interactive++;
    262                 break;
    263             default:
    264                 bb_show_usage();
    265 @@ -1591,18 +1593,18 @@
    266      *    standard output is a terminal
    267      *    Refer to Posix.2, the description of the `sh' utility. */
    268     if (argv[optind]==NULL && input==stdin &&
    269 -           isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
    270 -       interactive=TRUE;
    271 +           isatty(STDIN_FILENO) && isatty(STDOUT_FILENO))
    272 +   {
    273 +       interactive++;
    274     }
    275     setup_job_control();
    276 -   if (interactive==TRUE) {
    277 -       //printf( "optind=%d  argv[optind]='%s'\n", optind, argv[optind]);
    278 +   if (interactive) {
    279         /* Looks like they want an interactive shell */
    280 -#ifndef CONFIG_FEATURE_SH_EXTRA_QUIET
    281 -       printf( "\n\n%s Built-in shell (lash)\n", BB_BANNER);
    282 -       printf( "Enter 'help' for a list of built-in commands.\n\n");
    283 -#endif
    284 -   } else if (local_pending_command==NULL) {
    285 +       if (!ENABLE_FEATURE_SH_EXTRA_QUIET) {
    286 +           printf( "\n\n%s Built-in shell (lash)\n", BB_BANNER);
    287 +           printf( "Enter 'help' for a list of built-in commands.\n\n");
    288 +       }
    289 +   } else if (!local_pending_command && argv[optind]) {
    290         //printf( "optind=%d  argv[optind]='%s'\n", optind, argv[optind]);
    291         input = bb_xfopen(argv[optind], "r");
    292         /* be lazy, never mark this closed */
    293 @@ -1614,15 +1616,10 @@
    294     if (!cwd)
    295         cwd = bb_msg_unknown;
    296  
    297 -#ifdef CONFIG_FEATURE_CLEAN_UP
    298 -   atexit(free_memory);
    299 -#endif
    300 +   if (ENABLE_FEATURE_CLEAN_UP) atexit(free_memory);
    301  
    302 -#ifdef CONFIG_FEATURE_COMMAND_EDITING
    303 -   cmdedit_set_initial_prompt();
    304 -#else
    305 -   PS1 = NULL;
    306 -#endif
    307 +   if (ENABLE_FEATURE_COMMAND_EDITING) cmdedit_set_initial_prompt();
    308 +   else PS1 = NULL;
    309  
    310     return (busy_loop(input));
    311  }
    312  ------------------------------------------------------------------------
    313 r15698 | vapier | 2006-07-14 23:59:00 -0400 (Fri, 14 Jul 2006) | 2 lines
    314 Changed paths:
    315    M /trunk/busybox/libbb/obscure.c
    316 
    317 Tito writes: If the gecos field of an user is empty, obscure reports a false "similar to gecos" error.
    318 
    319  ------------------------------------------------------------------------
    320 Index: libbb/obscure.c
    321 ===================================================================
    322 --- libbb/obscure.c (revision 15697)
    323 +++ libbb/obscure.c (revision 15698)
    324 @@ -109,7 +109,7 @@
    325         return "similar to username";
    326     }
    327     /* no gecos as-is, as sub-string, reversed, capitalized, doubled */
    328 -   if (string_checker(new_p, pw->pw_gecos)) {
    329 +   if (*pw->pw_gecos && string_checker(new_p, pw->pw_gecos)) {
    330         return "similar to gecos";
    331     }
    332     /* hostname as-is, as sub-string, reversed, capitalized, doubled */
    333  ------------------------------------------------------------------------
    334 r15700 | landley | 2006-07-15 19:00:46 -0400 (Sat, 15 Jul 2006) | 4 lines
    335 Changed paths:
    336    M /trunk/busybox/include/libbb.h
    337    M /trunk/busybox/libbb/xfuncs.c
    338 
    339 We need xsetuid() and xsetgid() because per-user process resource limits can
    340 prevent a process from switching to a user that has too many processes, and
    341 when that happens WE'RE STILL ROOT.  See http://lwn.net/Articles/190331/
    342 
    343  ------------------------------------------------------------------------
    344 Index: libbb/xfuncs.c
    345 ===================================================================
    346 --- libbb/xfuncs.c  (revision 15699)
    347 +++ libbb/xfuncs.c  (revision 15700)
    348 @@ -232,3 +232,15 @@
    349     return 0;
    350  }
    351  #endif
    352 +
    353 +#ifdef L_setuid
    354 +void xsetgid(gid_t gid)
    355 +{
    356 +   if (setgid(gid)) bb_error_msg_and_die("setgid");
    357 +}
    358 +
    359 +void xsetuid(uid_t uid)
    360 +{
    361 +   if (setuid(uid)) bb_error_msg_and_die("setuid");
    362 +}
    363 +#endif
    364 Index: include/libbb.h
    365 ===================================================================
    366 --- include/libbb.h (revision 15699)
    367 +++ include/libbb.h (revision 15700)
    368 @@ -185,6 +185,8 @@
    369  extern bb_xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
    370  extern void bb_xlisten(int s, int backlog);
    371  extern void bb_xchdir(const char *path);
    372 +extern void xsetgid(gid_t gid);
    373 +extern void xsetuid(uid_t uid);
    374  
    375  #define BB_GETOPT_ERROR 0x80000000UL
    376  extern const char *bb_opt_complementally;
    377  ------------------------------------------------------------------------
    378 r15702 | landley | 2006-07-16 04:06:34 -0400 (Sun, 16 Jul 2006) | 2 lines
    379 Changed paths:
    380    M /trunk/busybox/loginutils/passwd.c
    381    M /trunk/busybox/networking/arping.c
    382    M /trunk/busybox/networking/ether-wake.c
    383    M /trunk/busybox/networking/fakeidentd.c
    384    M /trunk/busybox/networking/inetd.c
    385    M /trunk/busybox/networking/traceroute.c
    386 
    387 Convert setuid/setgid users to xsetuid/xsetgid.
    388 
    389  ------------------------------------------------------------------------
    390 Index: networking/fakeidentd.c
    391 ===================================================================
    392 --- networking/fakeidentd.c (revision 15701)
    393 +++ networking/fakeidentd.c (revision 15702)
    394 @@ -159,8 +159,8 @@
    395  
    396         close(0);
    397         inetbind();
    398 -       if (setgid(nogrp))   bb_error_msg_and_die("Could not setgid()");
    399 -       if (setuid(nobody))  bb_error_msg_and_die("Could not setuid()");
    400 +       xsetgid(nogrp);
    401 +       xsetuid(nobody);
    402         close(1);
    403         close(2);
    404  
    405 Index: networking/ether-wake.c
    406 ===================================================================
    407 --- networking/ether-wake.c (revision 15701)
    408 +++ networking/ether-wake.c (revision 15702)
    409 @@ -145,7 +145,7 @@
    410     s = make_socket();
    411  
    412     /* now that we have a raw socket we can drop root */
    413 -   setuid(getuid());
    414 +   xsetuid(getuid());
    415  
    416     /* look up the dest mac address */
    417     get_dest_addr(argv[optind], &eaddr);
    418 Index: networking/inetd.c
    419 ===================================================================
    420 --- networking/inetd.c  (revision 15701)
    421 +++ networking/inetd.c  (revision 15702)
    422 @@ -1513,11 +1513,11 @@
    423               if (sep->se_group) {
    424                 pwd->pw_gid = grp->gr_gid;
    425               }
    426 -             setgid ((gid_t) pwd->pw_gid);
    427 +             xsetgid ((gid_t) pwd->pw_gid);
    428               initgroups (pwd->pw_name, pwd->pw_gid);
    429 -             setuid ((uid_t) pwd->pw_uid);
    430 +             xsetuid((uid_t) pwd->pw_uid);
    431             } else if (sep->se_group) {
    432 -             setgid (grp->gr_gid);
    433 +             xsetgid(grp->gr_gid);
    434               setgroups (1, &grp->gr_gid);
     518 
     519@@ -111,7 +110,7 @@
     520            /* else choke */
     521            bb_perror_msg_and_die("module %s: QM_INFO", mn);
     522        }
     523-       if (my_query_module(mn, QM_REFS, (void **)&deps, &depsize, &count)) {
     524+       if (my_query_module(mn, QM_REFS, &deps, &depsize, &count)) {
     525            if (errno == ENOENT) {
     526                /* The module was removed out from underneath us. */
     527                continue;
     528 ------------------------------------------------------------------------
     529r15782 | landley | 2006-08-04 17:12:14 -0400 (Fri, 04 Aug 2006) | 2 lines
     530Changed paths:
     531   M /trunk/busybox/archival/Makefile.in
     532
     533We haven't got a CONFIG_APT_GET.
     534
     535 ------------------------------------------------------------------------
     536Index: archival/Makefile.in
     537===================================================================
     538--- archival/Makefile.in    (revision 15781)
     539+++ archival/Makefile.in    (revision 15782)
     540@@ -11,7 +11,6 @@
     541 srcdir=$(top_srcdir)/archival
     542 
     543 ARCHIVAL-y:=
     544-ARCHIVAL-$(CONFIG_APT_GET) +=
     545 ARCHIVAL-$(CONFIG_AR)      += ar.o
     546 ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
     547 ARCHIVAL-$(CONFIG_UNLZMA)  += unlzma.o
     548 ------------------------------------------------------------------------
     549r15787 | landley | 2006-08-06 16:41:11 -0400 (Sun, 06 Aug 2006) | 2 lines
     550Changed paths:
     551   M /trunk/busybox/util-linux/readprofile.c
     552
     553Make a warning go away on 64-bit systems.
     554
     555 ------------------------------------------------------------------------
     556Index: util-linux/readprofile.c
     557===================================================================
     558--- util-linux/readprofile.c    (revision 15786)
     559+++ util-linux/readprofile.c    (revision 15787)
     560@@ -47,7 +47,7 @@
     561    int proFd;
     562    const char *mapFile, *proFile, *mult=0;
     563    unsigned long len=0, indx=1;
     564-   unsigned long long add0=0;
     565+   uint64_t add0=0;
     566    unsigned int step;
     567    unsigned int *buf, total, fn_len;
     568    unsigned long long fn_add, next_add;          /* current and next address */
     569@@ -223,7 +223,7 @@
     570                    printf ("%s:\n", fn_name);
     571                    header_printed = 1;
     572                }
     573-               printf ("\t%llx\t%u\n", (indx - 1)*step + add0, buf[indx]);
     574+               printf ("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]);
    435575            }
    436             dup2 (ctrl, 0);
    437 Index: networking/traceroute.c
    438 ===================================================================
    439 --- networking/traceroute.c (revision 15701)
    440 +++ networking/traceroute.c (revision 15702)
    441 @@ -941,7 +941,6 @@
    442  #endif
    443     u_short off = 0;
    444     struct IFADDRLIST *al;
    445 -   int uid = getuid();
    446     char *device = NULL;
    447     int max_ttl = 30;
    448     char *max_ttl_str = NULL;
    449 @@ -1010,8 +1009,7 @@
    450          * set the ip source address of the outbound
    451          * probe (e.g., on a multi-homed host).
    452          */
    453 -        if (uid)
    454 -       bb_error_msg_and_die("-s %s: Permission denied", source);
    455 +        if (getuid()) bb_error_msg_and_die("-s %s: Permission denied", source);
    456     }
    457     if(waittime_str)
    458         waittime = str2val(waittime_str, "wait time", 2, 24 * 60 * 60);
    459 @@ -1160,8 +1158,8 @@
    460             sizeof(on));
    461  
    462     /* Revert to non-privileged user after opening sockets */
    463 -   setgid(getgid());
    464 -   setuid(uid);
    465 +   xsetgid(getgid());
    466 +   xsetuid(getuid());
    467  
    468     outip = (struct ip *)xcalloc(1, (unsigned)packlen);
    469  
    470 Index: networking/arping.c
    471 ===================================================================
    472 --- networking/arping.c (revision 15701)
    473 +++ networking/arping.c (revision 15702)
    474 @@ -262,7 +262,8 @@
    475     s = socket(PF_PACKET, SOCK_DGRAM, 0);
    476     ifindex = errno;
    477  
    478 -   setuid(getuid());
    479 +   // Drop suid root privileges
    480 +   xsetuid(getuid());
    481  
    482     {
    483         unsigned long opt;
    484 Index: loginutils/passwd.c
    485 ===================================================================
    486 --- loginutils/passwd.c (revision 15701)
    487 +++ loginutils/passwd.c (revision 15702)
    488 @@ -227,10 +227,7 @@
    489     signal(SIGINT, SIG_IGN);
    490     signal(SIGQUIT, SIG_IGN);
    491     umask(077);
    492 -   if (setuid(0)) {
    493 -       syslog(LOG_ERR, "can't setuid(0)");
    494 -       bb_error_msg_and_die( "Cannot change ID to root.\n");
    495 -   }
    496 +   xsetuid(0);
    497     if (!update_passwd(pw, crypt_passwd)) {
    498         syslog(LOG_INFO, "password for `%s' changed by user `%s'", name,
    499                myname);
    500  ------------------------------------------------------------------------
    501 r15705 | landley | 2006-07-16 14:58:18 -0400 (Sun, 16 Jul 2006) | 2 lines
    502 Changed paths:
    503    M /trunk/busybox/loginutils/adduser.c
    504 
    505 Bugfix from Tito to make sure /etc/group gets updated.
    506 
    507  ------------------------------------------------------------------------
    508 Index: loginutils/adduser.c
    509 ===================================================================
    510 --- loginutils/adduser.c    (revision 15704)
    511 +++ loginutils/adduser.c    (revision 15705)
    512 @@ -96,6 +96,7 @@
    513  static int adduser(struct passwd *p, unsigned long flags)
    514  {
    515     FILE *file;
    516 +   int addgroup = !p->pw_gid;
    517  
    518     /* make sure everything is kosher and setup uid && gid */
    519     file = bb_xfopen(bb_path_passwd_file, "a");
    520 @@ -132,9 +133,8 @@
    521     /* add to group */
    522     /* addgroup should be responsible for dealing w/ gshadow */
    523     /* if using a pre-existing group, don't create one */
    524 -   if (p->pw_gid == 0) {
    525 -       addgroup_wrapper(p);
    526 -   }
    527 +   if (addgroup) addgroup_wrapper(p);
    528 +
    529     /* Clear the umask for this process so it doesn't
    530      * * screw up the permissions on the mkdir and chown. */
     576            this += buf[indx++];
     577        }
     578 ------------------------------------------------------------------------
     579r15788 | landley | 2006-08-07 20:47:17 -0400 (Mon, 07 Aug 2006) | 3 lines
     580Changed paths:
     581   M /trunk/busybox/util-linux/mount.c
     582
     583Using lstat() instead of stat() means that attempting to loopback mount
     584a symlink doesn't work.
     585
     586 ------------------------------------------------------------------------
     587Index: util-linux/mount.c
     588===================================================================
     589--- util-linux/mount.c  (revision 15787)
     590+++ util-linux/mount.c  (revision 15788)
     591@@ -285,7 +285,7 @@
     592    // Look at the file.  (Not found isn't a failure for remount, or for
     593    // a synthetic filesystem like proc or sysfs.)
     594 
     595-   if (lstat(mp->mnt_fsname, &st));
     596+   if (stat(mp->mnt_fsname, &st));
     597    else if (!(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) {
     598        // Do we need to allocate a loopback device for it?
     599 
     600 ------------------------------------------------------------------------
     601r15795 | landley | 2006-08-09 21:09:37 -0400 (Wed, 09 Aug 2006) | 2 lines
     602Changed paths:
     603   M /trunk/busybox/util-linux/mdev.c
     604
     605Patch from Chris Steel to fix mdev deleting device nodes.
     606
     607 ------------------------------------------------------------------------
     608Index: util-linux/mdev.c
     609===================================================================
     610--- util-linux/mdev.c   (revision 15794)
     611+++ util-linux/mdev.c   (revision 15795)
     612@@ -37,18 +37,19 @@
     613     * because sscanf() will stop at the first nondigit, which \n is.  We
     614     * also depend on path having writeable space after it. */
     615 
     616-   strcat(path, "/dev");
     617-   fd = open(path, O_RDONLY);
     618-   len = read(fd, temp + 1, 64);
     619-   *temp++ = 0;
     620-   close(fd);
     621-   if (len < 1) return;
     622+   if (!delete) {
     623+       strcat(path, "/dev");
     624+       fd = open(path, O_RDONLY);
     625+       len = read(fd, temp + 1, 64);
     626+       *temp++ = 0;
     627+       close(fd);
     628+       if (len < 1) return;
     629+   }
     630 
     631    /* Determine device name, type, major and minor */
     632 
     633    device_name = strrchr(path, '/') + 1;
     634    type = path[5]=='c' ? S_IFCHR : S_IFBLK;
     635-   if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
     636 
     637    /* If we have a config file, look up permissions for this device */
     638 
     639@@ -164,6 +165,7 @@
     640 
    531641    umask(0);
    532  ------------------------------------------------------------------------
    533 r15727 | landley | 2006-07-19 17:33:42 -0400 (Wed, 19 Jul 2006) | 4 lines
    534 Changed paths:
    535    M /trunk/busybox/modutils/modprobe.c
    536 
    537 Patch from Yann Morin to look for modules.conf in the right place on 2.6.
    538 Fixes http://bugs.busybox.net/view.php?id=942
    539 
    540 
    541  ------------------------------------------------------------------------
    542 Index: modutils/modprobe.c
    543 ===================================================================
    544 --- modutils/modprobe.c (revision 15726)
    545 +++ modutils/modprobe.c (revision 15727)
    546 @@ -545,29 +545,37 @@
    547     }
    548     close ( fd );
    549  
    550 +   /*
    551 +    * First parse system-specific options and aliases
    552 +    * as they take precedence over the kernel ones.
    553 +    */
    554     if (!ENABLE_FEATURE_2_6_MODULES
    555             || ( fd = open ( "/etc/modprobe.conf", O_RDONLY )) < 0 )
    556         if (( fd = open ( "/etc/modules.conf", O_RDONLY )) < 0 )
    557 -           if (( fd = open ( "/etc/conf.modules", O_RDONLY )) < 0 )
    558 -               return first;
    559 +           fd = open ( "/etc/conf.modules", O_RDONLY );
    560  
    561 -   include_conf (&first, &current, buffer, sizeof(buffer), fd);
    562 -   close(fd);
    563 +   if (fd >= 0) {
    564 +       include_conf (&first, &current, buffer, sizeof(buffer), fd);
    565 +       close(fd);
    566 +   }
    567  
    568 -   filename = bb_xasprintf("/lib/modules/%s/modules.alias", un.release);
    569 -   fd = open ( filename, O_RDONLY );
    570 -   if (ENABLE_FEATURE_CLEAN_UP)
    571 -       free(filename);
    572 -   if (fd < 0) {
    573 -       /* Ok, that didn't work.  Fall back to looking in /lib/modules */
    574 -       if (( fd = open ( "/lib/modules/modules.alias", O_RDONLY )) < 0 ) {
    575 -           return first;
    576 +   /* Only 2.6 has a modules.alias file */
    577 +   if (ENABLE_FEATURE_2_6_MODULES) {
    578 +       /* Parse kernel-declared aliases */
    579 +       filename = bb_xasprintf("/lib/modules/%s/modules.alias", un.release);
    580 +       if ((fd = open ( filename, O_RDONLY )) < 0) {
    581 +           /* Ok, that didn't work.  Fall back to looking in /lib/modules */
    582 +           fd = open ( "/lib/modules/modules.alias", O_RDONLY );
    583         }
    584 +       if (ENABLE_FEATURE_CLEAN_UP)
    585 +           free(filename);
    586 +
    587 +       if (fd >= 0) {
    588 +           include_conf (&first, &current, buffer, sizeof(buffer), fd);
    589 +           close(fd);
     642    if (!delete) {
     643+       if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
     644        if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
     645            bb_perror_msg_and_die("mknod %s failed", device_name);
     646 
     647 ------------------------------------------------------------------------
     648r15800 | landley | 2006-08-10 17:46:43 -0400 (Thu, 10 Aug 2006) | 2 lines
     649Changed paths:
     650   M /trunk/busybox/shell/msh.c
     651
     652Make a warning go away when standalone shell is disabled.
     653
     654 ------------------------------------------------------------------------
     655Index: shell/msh.c
     656===================================================================
     657--- shell/msh.c (revision 15799)
     658+++ shell/msh.c (revision 15800)
     659@@ -3126,18 +3126,17 @@
     660    int i;
     661    char *sp, *tp;
     662    int eacces = 0, asis = 0;
     663-
     664-#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
     665    char *name = c;
     666 
     667-   optind = 1;
     668-   if (find_applet_by_name(name)) {
     669-       /* We have to exec here since we vforked.  Running
     670-        * run_applet_by_name() won't work and bad things
     671-        * will happen. */
     672-       execve(CONFIG_BUSYBOX_EXEC_PATH, v, envp);
     673+   if (ENABLE_FEATURE_SH_STANDALONE_SHELL) {
     674+       optind = 1;
     675+       if (find_applet_by_name(name)) {
     676+           /* We have to exec here since we vforked.  Running
     677+            * run_applet_by_name() won't work and bad things
     678+            * will happen. */
     679+           execve(CONFIG_BUSYBOX_EXEC_PATH, v, envp);
    590680+       }
    591681    }
    592  
    593 -   include_conf (&first, &current, buffer, sizeof(buffer), fd);
    594 -   close(fd);
     682-#endif
     683 
     684    DBGPRINTF(("REXECVE: c=%p, v=%p, envp=%p\n", c, v, envp));
     685 
     686 ------------------------------------------------------------------------
     687r15806 | landley | 2006-08-17 15:07:20 -0400 (Thu, 17 Aug 2006) | 13 lines
     688Changed paths:
     689   M /trunk/busybox/util-linux/umount.c
     690
     691The kernel can't handle umount /dev/hdc, we have to do it through mtab,
     692except that we still have to work when there is no mtab.
     693
     694Oh, and while we're at it, take advantage of the fact that modern processors
     695avoid branches via conditional assignment where possible.  ("x = a ? b : c;"
     696turns into "x = c; if (a) x = b;" because that way there's no branch to
     697potentially mispredict and thus never a bubble in the pipeline.  The if(a)
     698turns into an assembly test followed by a conditional assignment (rather
     699than a conditional jump).)  So since the compiler is going to do that _anyway_,
     700we might as well take advantage of it to produce a slightly smaller binary.
     701
     702So there.
     703
     704 ------------------------------------------------------------------------
     705Index: util-linux/umount.c
     706===================================================================
     707--- util-linux/umount.c (revision 15805)
     708+++ util-linux/umount.c (revision 15806)
     709@@ -78,6 +78,7 @@
     710    // Loop through everything we're supposed to umount, and do so.
     711    for (;;) {
     712        int curstat;
     713+       char *zapit = *argv;
     714 
     715        // Do we already know what to umount this time through the loop?
     716        if (m) safe_strncpy(path, m->dir, PATH_MAX);
     717@@ -86,32 +87,37 @@
     718        // Get next command line argument (and look it up in mtab list)
     719        else if (!argc--) break;
     720        else {
     721-           realpath(*argv++, path);
     722+           argv++;
     723+           realpath(zapit, path);
     724            for (m = mtl; m; m = m->next)
     725                if (!strcmp(path, m->dir) || !strcmp(path, m->device))
     726                    break;
     727        }
     728+       // If we couldn't find this sucker in /etc/mtab, punt by passing our
     729+       // command line argument straight to the umount syscall.  Otherwise,
     730+       // umount the directory even if we were given the block device.
     731+       if (m) zapit = m->dir;
     732 
     733        // Let's ask the thing nicely to unmount.
     734-       curstat = umount(path);
     735+       curstat = umount(zapit);
     736 
     737        // Force the unmount, if necessary.
     738        if (curstat && doForce) {
     739-           curstat = umount2(path, doForce);
     740+           curstat = umount2(zapit, doForce);
     741            if (curstat)
     742-               bb_error_msg_and_die("forced umount of %s failed!", path);
     743+               bb_error_msg_and_die("forced umount of %s failed!", zapit);
     744        }
     745 
     746        // If still can't umount, maybe remount read-only?
     747        if (curstat && (opt & OPT_REMOUNT) && errno == EBUSY && m) {
     748-           curstat = mount(m->device, path, NULL, MS_REMOUNT|MS_RDONLY, NULL);
     749+           curstat = mount(m->device, zapit, NULL, MS_REMOUNT|MS_RDONLY, NULL);
     750            bb_error_msg(curstat ? "Cannot remount %s read-only" :
     751                         "%s busy - remounted read-only", m->device);
     752        }
     753 
     754        if (curstat) {
     755            status = EXIT_FAILURE;
     756-           bb_perror_msg("Couldn't umount %s", path);
     757+           bb_perror_msg("Couldn't umount %s", zapit);
     758        } else {
     759            /* De-allocate the loop device.  This ioctl should be ignored on
     760             * any non-loop block devices. */
     761@@ -121,9 +127,9 @@
     762                erase_mtab(m->dir);
     763        }
     764 
    595765-
    596     return first;
     766-
     767        // Find next matching mtab entry for -a or umount /dev
     768+       // Note this means that "umount /dev/blah" will unmount all instances
     769+       // of /dev/blah, not just the most recent.
     770        while (m && (m = m->next))
     771            if ((opt & OPT_ALL) || !strcmp(path,m->device))
     772                break;
     773 ------------------------------------------------------------------------
     774r15826 | aldot | 2006-08-18 14:29:40 -0400 (Fri, 18 Aug 2006) | 2 lines
     775Changed paths:
     776   M /trunk/busybox/networking/traceroute.c
     777
     778- typo: s/optarg/nprobes_str; fixes segfault as reported by Raphael HUCK
     779
     780 ------------------------------------------------------------------------
     781Index: networking/traceroute.c
     782===================================================================
     783--- networking/traceroute.c (revision 15825)
     784+++ networking/traceroute.c (revision 15826)
     785@@ -1003,7 +1003,7 @@
     786    if(port_str)
     787        port = (u_short)str2val(port_str, "port", 1, (1 << 16) - 1);
     788    if(nprobes_str)
     789-       nprobes = str2val(optarg, "nprobes", 1, -1);
     790+       nprobes = str2val(nprobes_str, "nprobes", 1, -1);
     791    if(source) {
     792        /*
     793         * set the ip source address of the outbound
     794 ------------------------------------------------------------------------
     795r15855 | landley | 2006-08-20 19:13:33 -0400 (Sun, 20 Aug 2006) | 2 lines
     796Changed paths:
     797   M /trunk/busybox/Rules.mak
     798
     799Yann E. Morin spotted a broken check_ld macro.
     800
     801 ------------------------------------------------------------------------
     802Index: Rules.mak
     803===================================================================
     804--- Rules.mak   (revision 15854)
     805+++ Rules.mak   (revision 15855)
     806@@ -267,7 +267,7 @@
     807 else
     808     CFLAGS +=-DNDEBUG
     809     CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
     810-    CHECKED_LDFLAGS += $(call check_ld,--gc-sections,)
     811+    CHECKED_LDFLAGS += $(call check_ld,$(LD),--gc-sections,)
     812 endif
     813 
     814 ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y)
     815 ------------------------------------------------------------------------
     816r15890 | landley | 2006-08-21 13:42:03 -0400 (Mon, 21 Aug 2006) | 2 lines
     817Changed paths:
     818   M /trunk/busybox/miscutils/Makefile.in
     819
     820Michael Opdenacker spotted that makefile should use () instead of {}.
     821
     822 ------------------------------------------------------------------------
     823Index: miscutils/Makefile.in
     824===================================================================
     825--- miscutils/Makefile.in   (revision 15889)
     826+++ miscutils/Makefile.in   (revision 15890)
     827@@ -20,7 +20,7 @@
     828 MISCUTILS-$(CONFIG_EJECT)       += eject.o
     829 MISCUTILS-$(CONFIG_HDPARM)      += hdparm.o
     830 MISCUTILS-$(CONFIG_LAST)        += last.o
     831-MISCUTILS-${CONFIG_LESS}        += less.o
     832+MISCUTILS-$(CONFIG_LESS)        += less.o
     833 MISCUTILS-$(CONFIG_MAKEDEVS)    += makedevs.o
     834 MISCUTILS-$(CONFIG_MOUNTPOINT)  += mountpoint.o
     835 MISCUTILS-$(CONFIG_MT)          += mt.o
     836 ------------------------------------------------------------------------
     837r15905 | landley | 2006-08-22 19:40:28 -0400 (Tue, 22 Aug 2006) | 9 lines
     838Changed paths:
     839   M /trunk/busybox/coreutils/test.c
     840
     841"Jordan Crouse" <jordan.crouse@amd.com> says:
     842The following patch makes coreutils/test.c act fail gracefully if getgroups()
     843returns a -1.  This fixes a problem on the One Laptop Per Child ROM image
     844whereby we were getting odd Memory exhausted messages for '[' and 'test'.
     845
     846Found by Mitch Bradley <wmb@firmworks.com>
     847(Tweaked by Rob: no need to initialize a static to NULL, or realloc something
     848that's only allocated when it's NULL.)
     849
     850 ------------------------------------------------------------------------
     851Index: coreutils/test.c
     852===================================================================
     853--- coreutils/test.c    (revision 15904)
     854+++ coreutils/test.c    (revision 15905)
     855@@ -151,7 +151,7 @@
     856 
     857 static char **t_wp;
     858 static struct t_op const *t_wp_op;
     859-static gid_t *group_array = NULL;
     860+static gid_t *group_array;
     861 static int ngroups;
     862 
     863 static enum token t_lex(char *s);
     864@@ -547,8 +547,10 @@
     865 static void initialize_group_array(void)
     866 {
     867    ngroups = getgroups(0, NULL);
     868-   group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
     869-   getgroups(ngroups, group_array);
     870+   if (ngroups > 0) {
     871+       group_array = xmalloc(ngroups * sizeof(gid_t));
     872+       getgroups(ngroups, group_array);
     873+   }
    597874 }
    598875 
     876 /* Return non-zero if GID is one that we have in our groups list. */
     877 ------------------------------------------------------------------------
     878r15906 | landley | 2006-08-22 19:50:11 -0400 (Tue, 22 Aug 2006) | 3 lines
     879Changed paths:
     880   M /trunk/busybox/modutils/modprobe.c
     881
     882Patch from Yann Morin so modprobe won't return failure if the module gets
     883loaded while it's running (ala multi-device hotplug).
     884
     885 ------------------------------------------------------------------------
     886Index: modutils/modprobe.c
     887===================================================================
     888--- modutils/modprobe.c (revision 15905)
     889+++ modutils/modprobe.c (revision 15906)
     890@@ -679,7 +679,7 @@
     891            }
     892            if (!show_only) {
     893                int rc2 = wait4pid(bb_spawn(argv));
     894-               
     895+
     896                if (do_insert) {
     897                    rc = rc2; /* only last module matters */
     898                }
     899@@ -859,7 +859,16 @@
     900        }
     901 
     902        // process tail ---> head
     903-       rc = mod_process ( tail, 1 );
     904+       if ((rc = mod_process ( tail, 1 )) != 0) {
     905+           /*
     906+            * In case of using udev, multiple instances of modprobe can be
     907+            * spawned to load the same module (think of two same usb devices,
     908+            * for example; or cold-plugging at boot time). Thus we shouldn't
     909+            * fail if the module was loaded, and not by us.
     910+            */
     911+           if (already_loaded (mod) )
     912+               rc = 0;
     913+       }
     914    }
     915    else
     916        rc = 1;
     917 ------------------------------------------------------------------------
     918r15984 | landley | 2006-08-24 16:00:44 -0400 (Thu, 24 Aug 2006) | 6 lines
     919Changed paths:
     920   M /trunk/busybox/loginutils/getty.c
     921
     922Antti Seppala (with dots over the last two a's) wants our getty to initialize
     923the terminal the way mingetty does instead of the way agetty does.  It's
     924a bit ugly for somebody else to be writing to a console sitting at a
     925login: prompt, but it's uglier when newline doesn't work as expected if
     926they do.
     927
     928 ------------------------------------------------------------------------
     929Index: loginutils/getty.c
     930===================================================================
     931--- loginutils/getty.c  (revision 15983)
     932+++ loginutils/getty.c  (revision 15984)
     933@@ -474,7 +474,8 @@
     934        tp->c_cflag |= CLOCAL;
     935    }
     936 
     937-   tp->c_iflag = tp->c_lflag = tp->c_oflag = tp->c_line = 0;
     938+   tp->c_iflag = tp->c_lflag = tp->c_line = 0;
     939+   tp->c_oflag = OPOST | ONLCR;
     940    tp->c_cc[VMIN] = 1;
     941    tp->c_cc[VTIME] = 0;
     942 
     943 ------------------------------------------------------------------------
     944r16004 | landley | 2006-08-28 16:04:46 -0400 (Mon, 28 Aug 2006) | 3 lines
     945Changed paths:
     946   M /trunk/busybox/libbb/Makefile.in
     947
     948Jordan Crouse submitted a patch to only include xregcomp.c when we actually
     949use it, thus fixing building against uClibc with regex support disabled.
     950
     951 ------------------------------------------------------------------------
     952Index: libbb/Makefile.in
     953===================================================================
     954--- libbb/Makefile.in   (revision 16003)
     955+++ libbb/Makefile.in   (revision 16004)
     956@@ -29,7 +29,7 @@
     957    safe_strncpy.c setup_environment.c sha1.c simplify_path.c \
     958    trim.c u_signal_names.c vdprintf.c verror_msg.c \
     959    vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c xstat.c \
     960-   xgethostbyname.c xgethostbyname2.c xreadlink.c xregcomp.c xgetlarg.c \
     961+   xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
     962    bb_xsocket.c bb_xdaemon.c bb_xbind.c bb_xlisten.c bb_xchdir.c \
     963    get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \
     964    getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \
     965@@ -49,6 +49,20 @@
     966 LIBBB-$(CONFIG_DF)+= find_mount_point.c
     967 LIBBB-$(CONFIG_EJECT)+= find_mount_point.c
     968 
     969+# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
     970+# require regex.h to be in the include dir even if we don't need it thereby
     971+# allowing us to build busybox even if uclibc regex support is disabled.
     972+
     973+regex-y:=
     974+
     975+regex-$(CONFIG_AWK) += xregcomp.c
     976+regex-$(CONFIG_SED) += xregcomp.c
     977+regex-$(CONFIG_LESS) += xregcomp.c
     978+regex-$(CONFIG_DEVFSD) += xregcomp.c
     979+
     980+# Sort has the happy side efect of returning a unique list
     981+LIBBB-y += $(sort $(regex-y))
     982+
     983 LIBBB-y:=$(patsubst %,$(srcdir)/%,$(LIBBB-y))
     984 
     985 get-file-subparts = $(addsuffix .o,$(shell sed -n -e "s/^\#ifdef L_//p" ${1}))
     986 ------------------------------------------------------------------------
     987r16008 | vapier | 2006-08-28 19:24:38 -0400 (Mon, 28 Aug 2006) | 1 line
     988Changed paths:
     989   M /trunk/busybox/Rules.mak
     990
     991need libsepol in addtion to libselinux
     992 ------------------------------------------------------------------------
     993Index: Rules.mak
     994===================================================================
     995--- Rules.mak   (revision 16007)
     996+++ Rules.mak   (revision 16008)
     997@@ -298,7 +298,7 @@
     998 endif
     999 
     1000 ifeq ($(strip $(CONFIG_SELINUX)),y)
     1001-    LIBRARIES += -lselinux
     1002+    LIBRARIES += -lselinux -lsepol
     1003 endif
     1004 
     1005 ifeq ($(strip $(PREFIX)),)
     1006 ------------------------------------------------------------------------
     1007r16026 | vda | 2006-09-02 12:11:44 -0400 (Sat, 02 Sep 2006) | 2 lines
     1008Changed paths:
     1009   M /trunk/busybox/networking/ping6.c
     1010
     1011Fix endianness issue in ping6
     1012
     1013 ------------------------------------------------------------------------
     1014Index: networking/ping6.c
     1015===================================================================
     1016--- networking/ping6.c  (revision 16025)
     1017+++ networking/ping6.c  (revision 16026)
     1018@@ -198,7 +198,7 @@
     1019    pkt->icmp6_type = ICMP6_ECHO_REQUEST;
     1020    pkt->icmp6_code = 0;
     1021    pkt->icmp6_cksum = 0;
     1022-   pkt->icmp6_seq = ntransmitted++;
     1023+   pkt->icmp6_seq = SWAP_BE16(ntransmitted++);
     1024    pkt->icmp6_id = myid;
     1025    CLR(pkt->icmp6_seq % MAX_DUP_CHK);
     1026 
     1027 ------------------------------------------------------------------------
     1028r16032 | vda | 2006-09-02 14:40:10 -0400 (Sat, 02 Sep 2006) | 4 lines
     1029Changed paths:
     1030   M /trunk/busybox/archival/libunarchive/find_list_entry.c
     1031   M /trunk/busybox/testsuite/README
     1032   A /trunk/busybox/testsuite/tar/tar-extracts-all-subdirs
     1033
     1034tar: tar xf foo.tar dir/dir did not extract all subdirs.
     1035Added testsuite entry for this
     1036
     1037
     1038 ------------------------------------------------------------------------
     1039Index: archival/libunarchive/find_list_entry.c
     1040===================================================================
     1041--- archival/libunarchive/find_list_entry.c (revision 16031)
     1042+++ archival/libunarchive/find_list_entry.c (revision 16032)
     1043@@ -13,7 +13,7 @@
     1044 const llist_t *find_list_entry(const llist_t *list, const char *filename)
     1045 {
     1046    while (list) {
     1047-       if (fnmatch(list->data, filename, 0) == 0) {
     1048+       if (fnmatch(list->data, filename, FNM_LEADING_DIR) == 0) {
     1049            return (list);
     1050        }
     1051        list = list->link;
     1052Index: testsuite/tar/tar-extracts-all-subdirs
     1053===================================================================
     1054--- testsuite/tar/tar-extracts-all-subdirs  (revision 0)
     1055+++ testsuite/tar/tar-extracts-all-subdirs  (revision 16032)
     1056@@ -0,0 +1,12 @@
     1057+# FEATURE: CONFIG_FEATURE_TAR_CREATE
     1058+mkdir -p foo/{1,2,3}
     1059+mkdir -p foo/1/{10,11}
     1060+mkdir -p foo/1/10/{100,101,102}
     1061+tar cf foo.tar -C foo .
     1062+rm -rf foo/*
     1063+busybox tar xf foo.tar -C foo ./1/10
     1064+find foo | sort >logfile.bb
     1065+rm -rf foo/*
     1066+tar xf foo.tar -C foo ./1/10
     1067+find foo | sort >logfile.gnu
     1068+cmp logfile.gnu logfile.bb
     1069Index: testsuite/README
     1070===================================================================
     1071--- testsuite/README    (revision 16031)
     1072+++ testsuite/README    (revision 16032)
     1073@@ -1,3 +1,6 @@
     1074+Update: doesn't work as described. Try "make check" from parent dir...
     1075+* * *
     1076+
     1077 To run the test suite, change to this directory and run "./runtest".  It will
     1078 run all of the test cases, and list those with unexpected outcomes.  Adding the
     1079 -v option will cause it to show expected outcomes as well.  To only run the test
     1080 ------------------------------------------------------------------------
     1081r16033 | vda | 2006-09-03 08:20:36 -0400 (Sun, 03 Sep 2006) | 5 lines
     1082Changed paths:
     1083   M /trunk/busybox/networking/zcip.c
     1084
     1085zcip: apply patch from
     1086      http://bugs.busybox.net/view.php?id=1005
     1087      zcip does not claim another IP after defending
     1088
     1089
     1090 ------------------------------------------------------------------------
     1091Index: networking/zcip.c
     1092===================================================================
     1093--- networking/zcip.c   (revision 16032)
     1094+++ networking/zcip.c   (revision 16033)
     1095@@ -15,7 +15,7 @@
     1096  * certainly be used.  Its naming is built over multicast DNS.
     1097  */
     1098 
     1099-// #define      DEBUG
     1100+//#define DEBUG
     1101 
     1102 // TODO:
     1103 // - more real-world usage/testing, especially daemon mode
     1104@@ -43,12 +43,7 @@
     1105 
     1106 struct arp_packet {
     1107    struct ether_header hdr;
     1108-   // FIXME this part is netinet/if_ether.h "struct ether_arp"
     1109-   struct arphdr arp;
     1110-   struct ether_addr source_addr;
     1111-   struct in_addr source_ip;
     1112-   struct ether_addr target_addr;
     1113-   struct in_addr target_ip;
     1114+   struct ether_arp arp;
     1115 } ATTRIBUTE_PACKED;
     1116 
     1117 enum {
     1118@@ -68,10 +63,19 @@
     1119    DEFEND_INTERVAL = 10
     1120 };
     1121 
     1122-static const struct in_addr null_ip = { 0 };
     1123-static const struct ether_addr null_addr = { {0, 0, 0, 0, 0, 0} };
     1124+/* States during the configuration process. */
     1125+enum {
     1126+   PROBE = 0,
     1127+   RATE_LIMIT_PROBE,
     1128+   ANNOUNCE,
     1129+   MONITOR,
     1130+   DEFEND
     1131+};
     1132 
     1133-static int verbose = 0;
     1134+/* Implicitly zero-initialized */
     1135+static const struct in_addr null_ip;
     1136+static const struct ether_addr null_addr;
     1137+static int verbose;
     1138 
     1139 #define DBG(fmt,args...) \
     1140    do { } while (0)
     1141@@ -100,6 +104,7 @@
     1142    const struct ether_addr *target_addr, struct in_addr target_ip)
     1143 {
     1144    struct arp_packet p;
     1145+   memset(&p, 0, sizeof(p));
     1146 
     1147    // ether header
     1148    p.hdr.ether_type = htons(ETHERTYPE_ARP);
     1149@@ -107,15 +112,15 @@
     1150    memset(p.hdr.ether_dhost, 0xff, ETH_ALEN);
     1151 
     1152    // arp request
     1153-   p.arp.ar_hrd = htons(ARPHRD_ETHER);
     1154-   p.arp.ar_pro = htons(ETHERTYPE_IP);
     1155-   p.arp.ar_hln = ETH_ALEN;
     1156-   p.arp.ar_pln = 4;
     1157-   p.arp.ar_op = htons(op);
     1158-   memcpy(&p.source_addr, source_addr, ETH_ALEN);
     1159-   memcpy(&p.source_ip, &source_ip, sizeof (p.source_ip));
     1160-   memcpy(&p.target_addr, target_addr, ETH_ALEN);
     1161-   memcpy(&p.target_ip, &target_ip, sizeof (p.target_ip));
     1162+   p.arp.arp_hrd = htons(ARPHRD_ETHER);
     1163+   p.arp.arp_pro = htons(ETHERTYPE_IP);
     1164+   p.arp.arp_hln = ETH_ALEN;
     1165+   p.arp.arp_pln = 4;
     1166+   p.arp.arp_op = htons(op);
     1167+   memcpy(&p.arp.arp_sha, source_addr, ETH_ALEN);
     1168+   memcpy(&p.arp.arp_spa, &source_ip, sizeof (p.arp.arp_spa));
     1169+   memcpy(&p.arp.arp_tha, target_addr, ETH_ALEN);
     1170+   memcpy(&p.arp.arp_tpa, &target_ip, sizeof (p.arp.arp_tpa));
     1171 
     1172    // send it
     1173    if (sendto(fd, &p, sizeof (p), 0, saddr, sizeof (*saddr)) < 0) {
     1174@@ -196,11 +201,11 @@
     1175    int fd;
     1176    int ready = 0;
     1177    suseconds_t timeout = 0;    // milliseconds
     1178-   time_t defend = 0;
     1179    unsigned conflicts = 0;
     1180    unsigned nprobes = 0;
     1181    unsigned nclaims = 0;
     1182    int t;
     1183+   int state = PROBE;
     1184 
     1185    // parse commandline: prog [options] ifname script
     1186    while ((t = getopt(argc, argv, "fqr:v")) != EOF) {
     1187@@ -307,6 +312,9 @@
     1188        fds[0].events = POLLIN;
     1189        fds[0].revents = 0;
     1190 
     1191+       int source_ip_conflict = 0;
     1192+       int target_ip_conflict = 0;
     1193+
     1194        // poll, being ready to adjust current timeout
     1195        if (!timeout) {
     1196            timeout = ms_rdelay(PROBE_WAIT);
     1197@@ -314,6 +322,7 @@
     1198            // make the kernel filter out all packets except
     1199            // ones we'd care about.
     1200        }
     1201+       // set tv1 to the point in time when we timeout
     1202        gettimeofday(&tv1, NULL);
     1203        tv1.tv_usec += (timeout % 1000) * 1000;
     1204        while (tv1.tv_usec > 1000000) {
     1205@@ -326,64 +335,113 @@
     1206                timeout, intf, nprobes, nclaims);
     1207        switch (poll(fds, 1, timeout)) {
     1208 
     1209-       // timeouts trigger protocol transitions
     1210+       // timeout
     1211        case 0:
     1212-           // probes
     1213-           if (nprobes < PROBE_NUM) {
     1214-               nprobes++;
     1215-               VDBG("probe/%d %s@%s\n",
     1216-                       nprobes, intf, inet_ntoa(ip));
     1217-               (void)arp(fd, &saddr, ARPOP_REQUEST,
     1218-                       &addr, null_ip,
     1219-                       &null_addr, ip);
     1220+           VDBG("state = %d\n", state);
     1221+           switch (state) {
     1222+           case PROBE:
     1223+               // timeouts in the PROBE state means no conflicting ARP packets
     1224+               // have been received, so we can progress through the states
     1225                if (nprobes < PROBE_NUM) {
     1226+                   nprobes++;
     1227+                   VDBG("probe/%d %s@%s\n",
     1228+                           nprobes, intf, inet_ntoa(ip));
     1229+                   (void)arp(fd, &saddr, ARPOP_REQUEST,
     1230+                           &addr, null_ip,
     1231+                           &null_addr, ip);
     1232                    timeout = PROBE_MIN * 1000;
     1233                    timeout += ms_rdelay(PROBE_MAX
     1234                            - PROBE_MIN);
     1235-               } else
     1236-                   timeout = ANNOUNCE_WAIT * 1000;
     1237-           }
     1238-           // then announcements
     1239-           else if (nclaims < ANNOUNCE_NUM) {
     1240-               nclaims++;
     1241+               }
     1242+               else {
     1243+                   // Switch to announce state.
     1244+                   state = ANNOUNCE;
     1245+                   nclaims = 0;
     1246+                   VDBG("announce/%d %s@%s\n",
     1247+                           nclaims, intf, inet_ntoa(ip));
     1248+                   (void)arp(fd, &saddr, ARPOP_REQUEST,
     1249+                           &addr, ip,
     1250+                           &addr, ip);
     1251+                   timeout = ANNOUNCE_INTERVAL * 1000;
     1252+               }
     1253+               break;
     1254+           case RATE_LIMIT_PROBE:
     1255+               // timeouts in the RATE_LIMIT_PROBE state means no conflicting ARP packets
     1256+               // have been received, so we can move immediately to the announce state
     1257+               state = ANNOUNCE;
     1258+               nclaims = 0;
     1259                VDBG("announce/%d %s@%s\n",
     1260                        nclaims, intf, inet_ntoa(ip));
     1261                (void)arp(fd, &saddr, ARPOP_REQUEST,
     1262                        &addr, ip,
     1263                        &addr, ip);
     1264+               timeout = ANNOUNCE_INTERVAL * 1000;
     1265+               break;
     1266+           case ANNOUNCE:
     1267+               // timeouts in the ANNOUNCE state means no conflicting ARP packets
     1268+               // have been received, so we can progress through the states
     1269                if (nclaims < ANNOUNCE_NUM) {
     1270+                   nclaims++;
     1271+                   VDBG("announce/%d %s@%s\n",
     1272+                           nclaims, intf, inet_ntoa(ip));
     1273+                   (void)arp(fd, &saddr, ARPOP_REQUEST,
     1274+                           &addr, ip,
     1275+                           &addr, ip);
     1276                    timeout = ANNOUNCE_INTERVAL * 1000;
     1277-               } else {
     1278+               }
     1279+               else {
     1280+                   // Switch to monitor state.
     1281+                   state = MONITOR;
     1282                    // link is ok to use earlier
     1283+                   // FIXME update filters
     1284                    run(script, "config", intf, &ip);
     1285                    ready = 1;
     1286                    conflicts = 0;
     1287-                   timeout = -1;
     1288+                   timeout = -1; // Never timeout in the monitor state.
     1289 
     1290                    // NOTE:  all other exit paths
     1291                    // should deconfig ...
     1292                    if (quit)
     1293                        return EXIT_SUCCESS;
     1294-                   // FIXME update filters
     1295                }
     1296-           }
     1297-           break;
     1298-
     1299+               break;
     1300+           case DEFEND:
     1301+               // We won!  No ARP replies, so just go back to monitor.
     1302+               state = MONITOR;
     1303+               timeout = -1;
     1304+               conflicts = 0;
     1305+               break;
     1306+           default:
     1307+               // Invalid, should never happen.  Restart the whole protocol.
     1308+               state = PROBE;
     1309+               pick(&ip);
     1310+               timeout = 0;
     1311+               nprobes = 0;
     1312+               nclaims = 0;
     1313+               break;
     1314+           } // switch (state)
     1315+           break; // case 0 (timeout)
     1316        // packets arriving
     1317        case 1:
     1318-           // maybe adjust timeout
     1319+           // We need to adjust the timeout in case we didn't receive
     1320+           // a conflicting packet.
     1321            if (timeout > 0) {
     1322                struct timeval tv2;
     1323 
     1324                gettimeofday(&tv2, NULL);
     1325                if (timercmp(&tv1, &tv2, <)) {
     1326+                   // Current time is greater than the expected timeout time.
     1327+                   // Should never happen.
     1328+                   VDBG("missed an expected timeout\n");
     1329                    timeout = 0;
     1330                } else {
     1331+                   VDBG("adjusting timeout\n");
     1332                    timersub(&tv1, &tv2, &tv1);
     1333                    timeout = 1000 * tv1.tv_sec
     1334                            + tv1.tv_usec / 1000;
     1335                }
     1336            }
     1337+
     1338            if ((fds[0].revents & POLLIN) == 0) {
     1339                if (fds[0].revents & POLLERR) {
     1340                    // FIXME: links routinely go down;
     1341@@ -397,6 +455,7 @@
     1342                }
     1343                continue;
     1344            }
     1345+
     1346            // read ARP packet
     1347            if (recv(fd, &p, sizeof (p), 0) < 0) {
     1348                why = "recv";
     1349@@ -405,71 +464,102 @@
     1350            if (p.hdr.ether_type != htons(ETHERTYPE_ARP))
     1351                continue;
     1352 
     1353-           VDBG("%s recv arp type=%d, op=%d,\n",
     1354+#ifdef DEBUG
     1355+           {
     1356+               struct ether_addr * sha = (struct ether_addr *) p.arp.arp_sha;
     1357+               struct ether_addr * tha = (struct ether_addr *) p.arp.arp_tha;
     1358+               struct in_addr * spa = (struct in_addr *) p.arp.arp_spa;
     1359+               struct in_addr * tpa = (struct in_addr *) p.arp.arp_tpa;
     1360+               VDBG("%s recv arp type=%d, op=%d,\n",
     1361                    intf, ntohs(p.hdr.ether_type),
     1362-                   ntohs(p.arp.ar_op));
     1363-           VDBG("\tsource=%s %s\n",
     1364-                   ether_ntoa(&p.source_addr),
     1365-                   inet_ntoa(p.source_ip));
     1366-           VDBG("\ttarget=%s %s\n",
     1367-                   ether_ntoa(&p.target_addr),
     1368-                   inet_ntoa(p.target_ip));
     1369-           if (p.arp.ar_op != htons(ARPOP_REQUEST)
     1370-                   && p.arp.ar_op != htons(ARPOP_REPLY))
     1371+                   ntohs(p.arp.arp_op));
     1372+               VDBG("\tsource=%s %s\n",
     1373+                   ether_ntoa(sha),
     1374+                   inet_ntoa(*spa));
     1375+               VDBG("\ttarget=%s %s\n",
     1376+                   ether_ntoa(tha),
     1377+                   inet_ntoa(*tpa));
     1378+           }
     1379+#endif
     1380+           if (p.arp.arp_op != htons(ARPOP_REQUEST)
     1381+                   && p.arp.arp_op != htons(ARPOP_REPLY))
     1382                continue;
     1383 
     1384-           // some cases are always conflicts
     1385-           if ((p.source_ip.s_addr == ip.s_addr)
     1386-                   && (memcmp(&addr, &p.source_addr,
     1387-                           ETH_ALEN) != 0)) {
     1388-collision:
     1389-               VDBG("%s ARP conflict from %s\n", intf,
     1390-                       ether_ntoa(&p.source_addr));
     1391-               if (ready) {
     1392-                   time_t now = time(0);
     1393+           if (memcmp(p.arp.arp_spa, &ip.s_addr, sizeof(struct in_addr)) == 0 &&
     1394+               memcmp(&addr, &p.arp.arp_sha, ETH_ALEN) != 0) {
     1395+               source_ip_conflict = 1;
     1396+           }
     1397+           if (memcmp(p.arp.arp_tpa, &ip.s_addr, sizeof(struct in_addr)) == 0 &&
     1398+               p.arp.arp_op == htons(ARPOP_REQUEST) &&
     1399+               memcmp(&addr, &p.arp.arp_tha, ETH_ALEN) != 0) {
     1400+               target_ip_conflict = 1;
     1401+           }
     1402 
     1403-                   if ((defend + DEFEND_INTERVAL)
     1404-                           < now) {
     1405-                       defend = now;
     1406-                       (void)arp(fd, &saddr,
     1407-                               ARPOP_REQUEST,
     1408-                               &addr, ip,
     1409-                               &addr, ip);
     1410-                       VDBG("%s defend\n", intf);
     1411-                       timeout = -1;
     1412-                       continue;
     1413+           VDBG("state = %d, source ip conflict = %d, target ip conflict = %d\n",
     1414+               state, source_ip_conflict, target_ip_conflict);
     1415+           switch (state) {
     1416+           case PROBE:
     1417+           case ANNOUNCE:
     1418+               // When probing or announcing, check for source IP conflicts
     1419+               // and other hosts doing ARP probes (target IP conflicts).
     1420+               if (source_ip_conflict || target_ip_conflict) {
     1421+                   conflicts++;
     1422+                   if (conflicts >= MAX_CONFLICTS) {
     1423+                       VDBG("%s ratelimit\n", intf);
     1424+                       timeout = RATE_LIMIT_INTERVAL * 1000;
     1425+                       state = RATE_LIMIT_PROBE;
     1426                    }
     1427-                   defend = now;
     1428+
     1429+                   // restart the whole protocol
     1430+                   pick(&ip);
     1431+                   timeout = 0;
     1432+                   nprobes = 0;
     1433+                   nclaims = 0;
     1434+               }
     1435+               break;
     1436+           case MONITOR:
     1437+               // If a conflict, we try to defend with a single ARP probe.
     1438+               if (source_ip_conflict) {
     1439+                   VDBG("monitor conflict -- defending\n");
     1440+                   state = DEFEND;
     1441+                   timeout = DEFEND_INTERVAL * 1000;
     1442+                   (void)arp(fd, &saddr,
     1443+                           ARPOP_REQUEST,
     1444+                           &addr, ip,
     1445+                           &addr, ip);
     1446+               }
     1447+               break;
     1448+           case DEFEND:
     1449+               // Well, we tried.  Start over (on conflict).
     1450+               if (source_ip_conflict) {
     1451+                   state = PROBE;
     1452+                   VDBG("defend conflict -- starting over\n");
     1453                    ready = 0;
     1454                    run(script, "deconfig", intf, &ip);
     1455-                   // FIXME rm filters: setsockopt(fd,
     1456-                   // SO_DETACH_FILTER, ...)
     1457+
     1458+                   // restart the whole protocol
     1459+                   pick(&ip);
     1460+                   timeout = 0;
     1461+                   nprobes = 0;
     1462+                   nclaims = 0;
     1463                }
     1464-               conflicts++;
     1465-               if (conflicts >= MAX_CONFLICTS) {
     1466-                   VDBG("%s ratelimit\n", intf);
     1467-                   sleep(RATE_LIMIT_INTERVAL);
     1468-               }
     1469-               // restart the whole protocol
     1470+               break;
     1471+           default:
     1472+               // Invalid, should never happen.  Restart the whole protocol.
     1473+               VDBG("invalid state -- starting over\n");
     1474+               state = PROBE;
     1475                pick(&ip);
     1476                timeout = 0;
     1477                nprobes = 0;
     1478                nclaims = 0;
     1479-           }
     1480-           // two hosts probing one address is a collision too
     1481-           else if (p.target_ip.s_addr == ip.s_addr
     1482-                   && nclaims == 0
     1483-                   && p.arp.ar_op == htons(ARPOP_REQUEST)
     1484-                   && memcmp(&addr, &p.target_addr,
     1485-                           ETH_ALEN) != 0) {
     1486-               goto collision;
     1487-           }
     1488-           break;
     1489+               break;
     1490+           } // switch state
     1491 
     1492+           break; // case 1 (packets arriving)
     1493        default:
     1494            why = "poll";
     1495            goto bad;
     1496-       }
     1497+       } // switch poll
     1498    }
     1499 bad:
     1500    if (foreground)
     1501 ------------------------------------------------------------------------
     1502r16045 | vda | 2006-09-03 13:11:34 -0400 (Sun, 03 Sep 2006) | 3 lines
     1503Changed paths:
     1504   M /trunk/busybox/loginutils/sulogin.c
     1505
     1506sulogin: fix bug: -tNNN didn't work
     1507
     1508
     1509 ------------------------------------------------------------------------
     1510Index: loginutils/sulogin.c
     1511===================================================================
     1512--- loginutils/sulogin.c    (revision 16044)
     1513+++ loginutils/sulogin.c    (revision 16045)
     1514@@ -52,7 +52,7 @@
     1515 int sulogin_main(int argc, char **argv)
     1516 {
     1517    char *cp;
     1518-   char *device = (char *) 0;
     1519+   char *device = NULL;
     1520    const char *name = "root";
     1521    int timeout = 0;
     1522 
     1523@@ -68,14 +68,15 @@
     1524    openlog("sulogin", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
     1525    if (argc > 1) {
     1526        if (strncmp(argv[1], "-t", 2) == 0) {
     1527-           if (strcmp(argv[1], "-t") == 0) {
     1528+           if (argv[1][2] == '\0') { /* -t NN */
     1529                if (argc > 2) {
     1530                    timeout = atoi(argv[2]);
     1531                    if (argc > 3) {
     1532                        device = argv[3];
     1533                    }
     1534                }
     1535-           } else {
     1536+           } else { /* -tNNN */
     1537+               timeout = atoi(&argv[1][2]);
     1538                if (argc > 2) {
     1539                    device = argv[2];
     1540                }
     1541@@ -87,7 +88,7 @@
     1542            close(0);
     1543            close(1);
     1544            close(2);
     1545-           if (open(device, O_RDWR) >= 0) {
     1546+           if (open(device, O_RDWR) == 0) {
     1547                dup(0);
     1548                dup(0);
     1549            } else {
     1550 ------------------------------------------------------------------------
     1551r16056 | aldot | 2006-09-06 09:24:39 -0400 (Wed, 06 Sep 2006) | 2 lines
     1552Changed paths:
     1553   M /trunk/busybox/libbb/Makefile.in
     1554
     1555- mdev and grep use xregcomp. Closes bug #1021
     1556
     1557 ------------------------------------------------------------------------
     1558Index: libbb/Makefile.in
     1559===================================================================
     1560--- libbb/Makefile.in   (revision 16055)
     1561+++ libbb/Makefile.in   (revision 16056)
     1562@@ -56,11 +56,12 @@
     1563 # allowing us to build busybox even if uclibc regex support is disabled.
     1564 
     1565 regex-y:=
     1566-
     1567 regex-$(CONFIG_AWK) += xregcomp.c
     1568 regex-$(CONFIG_SED) += xregcomp.c
     1569 regex-$(CONFIG_LESS) += xregcomp.c
     1570 regex-$(CONFIG_DEVFSD) += xregcomp.c
     1571+regex-$(CONFIG_MDEV) += xregcomp.c
     1572+regex-$(CONFIG_GREP) += xregcomp.c
     1573 
     1574 # Sort has the happy side efect of returning a unique list
     1575 LIBBB-y += $(sort $(regex-y))
     1576 ------------------------------------------------------------------------
     1577r16057 | aldot | 2006-09-06 11:28:32 -0400 (Wed, 06 Sep 2006) | 16 lines
     1578Changed paths:
     1579   M /trunk/busybox/archival/libunarchive/decompress_uncompress.c
     1580
     1581- strip 399424 off the bss by making decompress_uncompress buffers config buffers.
     1582  Compile tested (too lazy to look for a small .Z on the net).
     1583$ size busybox.old busybox
     1584   text    data     bss     dec     hex filename
     1585 859555   10232  645732 1515519  171fff busybox.old
     1586 859683   10232  246308 1116223  11083f busybox
     1587$ make bloatcheck
     1588function                                             old     new   delta
     1589uncompress                                          1036    1160    +124
     1590inbuf                                               2116       4   -2112
     1591outbuf                                              4100       4   -4096
     1592htab                                              131072       - -131072
     1593codetab                                           262144       - -262144
     1594 ------------------------------------------------------------------------------
     1595(add/remove: 0/2 grow/shrink: 1/2 up/down: 124/-399424)   Total: -399300 bytes
     1596
     1597 ------------------------------------------------------------------------
     1598Index: archival/libunarchive/decompress_uncompress.c
     1599===================================================================
     1600--- archival/libunarchive/decompress_uncompress.c   (revision 16056)
     1601+++ archival/libunarchive/decompress_uncompress.c   (revision 16057)
     1602@@ -70,22 +70,12 @@
     1603 /* user settable max # bits/code */
     1604 static int maxbits = BITS;
     1605 
     1606-/* Input buffer */
     1607-static unsigned char inbuf[IBUFSIZ + 64];
     1608-
     1609-/* Output buffer */
     1610-static unsigned char outbuf[OBUFSIZ + 2048];
     1611-
     1612-
     1613-static unsigned char htab[HSIZE];
     1614-static unsigned short codetab[HSIZE];
     1615-
     1616 #define    htabof(i)               htab[i]
     1617 #define    codetabof(i)            codetab[i]
     1618 #define    tab_prefixof(i)         codetabof(i)
     1619 #define    tab_suffixof(i)         ((unsigned char *)(htab))[i]
     1620 #define    de_stack                ((unsigned char *)&(htab[HSIZE-1]))
     1621-#define    clear_htab()            memset(htab, -1, sizeof(htab))
     1622+#define    clear_htab()            memset(htab, -1, HSIZE)
     1623 #define    clear_tab_prefixof()    memset(codetab, 0, 256);
     1624 
     1625 
     1626@@ -113,6 +103,12 @@
     1627    long int maxmaxcode;
     1628    int n_bits;
     1629    int rsize = 0;
     1630+   RESERVE_CONFIG_UBUFFER(inbuf, IBUFSIZ + 64);
     1631+   RESERVE_CONFIG_UBUFFER(outbuf, OBUFSIZ + 2048);
     1632+   unsigned char htab[HSIZE];
     1633+   unsigned short codetab[HSIZE];
     1634+   memset(inbuf, 0, IBUFSIZ + 64);
     1635+   memset(outbuf, 0, OBUFSIZ + 2048);
     1636 
     1637    insize = 0;
     1638 
     1639@@ -160,7 +156,7 @@
     1640            posbits = 0;
     1641        }
     1642 
     1643-       if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
     1644+       if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
     1645            rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
     1646            insize += rsize;
     1647        }
     1648@@ -286,5 +282,7 @@
     1649        write(fd_out, outbuf, outpos);
     1650    }
     1651 
     1652+   RELEASE_CONFIG_BUFFER(inbuf);
     1653+   RELEASE_CONFIG_BUFFER(outbuf);
     1654    return 0;
     1655 }
     1656 ------------------------------------------------------------------------
     1657r16062 | vda | 2006-09-07 01:43:38 -0400 (Thu, 07 Sep 2006) | 4 lines
     1658Changed paths:
     1659   M /trunk/busybox/Config.in
     1660
     1661CONFIG_FEATURE_COMPRESS_USAGE was impossible to turn on
     1662if !CONFIG_NITPICK
     1663
     1664
     1665 ------------------------------------------------------------------------
     1666Index: Config.in
     1667===================================================================
     1668--- Config.in   (revision 16061)
     1669+++ Config.in   (revision 16062)
     1670@@ -76,7 +76,7 @@
     1671 config CONFIG_FEATURE_COMPRESS_USAGE
     1672    bool "Store applet usage messages in compressed form"
     1673    default y
     1674-   depends on CONFIG_SHOW_USAGE && CONFIG_NITPICK
     1675+   depends on CONFIG_SHOW_USAGE
     1676    help
     1677      Store usage messages in compressed form, uncompress them on-the-fly
     1678      when <applet> --help is called.
     1679 ------------------------------------------------------------------------
     1680r16067 | landley | 2006-09-07 20:01:02 -0400 (Thu, 07 Sep 2006) | 2 lines
     1681Changed paths:
     1682   M /trunk/busybox/editors/sed.c
     1683
     1684Bugfix for: echo '123456789' | sed 's/./|&/5'
     1685
     1686 ------------------------------------------------------------------------
     1687Index: editors/sed.c
     1688===================================================================
     1689--- editors/sed.c   (revision 16066)
     1690+++ editors/sed.c   (revision 16067)
     1691@@ -627,7 +627,7 @@
     1692           end of match and continue */
     1693        if(sed_cmd->which_match && sed_cmd->which_match!=match_count) {
     1694            for(i=0;i<bbg.regmatch[0].rm_eo;i++)
     1695-               pipe_putc(oldline[i]);
     1696+               pipe_putc(*(oldline++));
     1697            continue;
     1698        }
     1699 
     1700 ------------------------------------------------------------------------
     1701r16109 | landley | 2006-09-12 16:29:22 -0400 (Tue, 12 Sep 2006) | 2 lines
     1702Changed paths:
     1703   M /trunk/busybox/include/platform.h
     1704
     1705Fix from Bernhard for somebody trying to limp along with gcc 2.95.4.
     1706
     1707 ------------------------------------------------------------------------
     1708Index: include/platform.h
     1709===================================================================
     1710--- include/platform.h  (revision 16108)
     1711+++ include/platform.h  (revision 16109)
     1712@@ -83,6 +83,14 @@
     1713 # endif
     1714 #endif
     1715 
     1716+/* gcc-2.95 had no va_copy but only __va_copy. */
     1717+#if !__GNUC_PREREQ (3,0)
     1718+# include <stdarg.h>
     1719+# if !defined va_copy && defined __va_copy
     1720+#  define va_copy(d,s) __va_copy((d),(s))
     1721+# endif
     1722+#endif
     1723+
     1724 /* ---- Endian Detection ------------------------------------ */
     1725 
     1726 #if (defined __digital__ && defined __unix__)
     1727
     1728 ------------------------------------------------------------------------
     1729Patch from Roberto Foglietta to fix various things in dnsd (for example,
     1730don't segfault if dnsd.conf doesn't exist).
     1731
     1732--- networking/dnsd.c   2006-07-01 00:42:02.000000000 +0200
     1733+++ networking/dnsd.c   2006-10-17 18:11:22.000000000 +0200
     1734@@ -29,6 +29,11 @@ static char *fileconf = "/etc/dnsd.conf"
     1735 #define LOCK_FILE       "/var/run/dnsd.lock"
     1736 #define LOG_FILE        "/var/log/dnsd.log"
     1737 
     1738+#define is_daemon()  (flags&16)
     1739+#define is_verbose() (flags&32)
     1740+//#define DEBUG
     1741+
     1742+
     1743 enum {
     1744    MAX_HOST_LEN = 16,      // longest host name allowed is 15
     1745    IP_STRING_LEN = 18,     // .xxx.xxx.xxx.xxx\0
     1746@@ -223,29 +228,35 @@ static int listen_socket(char *iface_add
     1747 static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
     1748 {
     1749    int i;
     1750-   struct dns_entry *d=dnsentry;
     1751+   struct dns_entry *d = dnsentry;
     1752 
     1753-   do {
     1754+   if(d) do {
     1755 #ifdef DEBUG
     1756-       char *p,*q;
     1757-       q = (char *)&(qs[1]);
     1758-       p = &(d->name[1]);
     1759-       fprintf(stderr, "\ntest: %d <%s> <%s> %d", strlen(p), p, q, strlen(q));
     1760+       if(qs && d) {
     1761+           char *p,*q;
     1762+           q = (char *)&(qs[1]);
     1763+           p = &(d->name[1]);
     1764+           fprintf(stderr, "\n%s: %d/%d p:%s q:%s %d",
     1765+               __FUNCTION__, strlen(p), (int)(d->name[0]),
     1766+               p, q, strlen(q));
     1767+       }
     1768 #endif
     1769-       if (type == REQ_A) { /* search by host name */
     1770+       if (type == REQ_A) {            /* search by host name */
     1771            for(i = 1; i <= (int)(d->name[0]); i++)
     1772                if(tolower(qs[i]) != d->name[i])
     1773-                   continue;
     1774+                   break;
     1775+           if(i > (int)(d->name[0])) {
     1776 #ifdef DEBUG
     1777-           fprintf(stderr, " OK");
     1778+               fprintf(stderr, " OK");
     1779 #endif
     1780-           strcpy((char *)as, d->ip);
     1781+               strcpy((char *)as, d->ip);
     1782 #ifdef DEBUG
     1783-           fprintf(stderr, " %s ", as);
     1784+               fprintf(stderr, " as:%s\n", as);
     1785 #endif
     1786-                   return 0;
     1787-               }
     1788-       else if (type == REQ_PTR) { /* search by IP-address */
     1789+               return 0;
     1790+           }
     1791+       } else
     1792+       if (type == REQ_PTR) {          /* search by IP-address */
     1793            if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) {
     1794                strcpy((char *)as, d->name);
     1795                return 0;
     1796@@ -281,7 +292,7 @@ static int process_packet(uint8_t * buf)
     1797        eret("ignoring response packet");
     1798 
     1799    from = (void *)&head[1];    //  start of query string
     1800-   next = answb = from + strlen((char *)&head[1]) + 1 + sizeof(struct dns_prop);   // where to append answer block
     1801+   next = answb = from + strlen((char *)from) + 1 + sizeof(struct dns_prop);   // where to append answer block
     1802 
     1803    outr.rlen = 0;          // may change later
     1804    outr.r = NULL;
     1805@@ -305,9 +316,8 @@ static int process_packet(uint8_t * buf)
     1806        goto empty_packet;
     1807 
     1808    // We have a standard query
     1809-
     1810-   log_message(LOG_FILE, (char *)head);
     1811-   lookup_result = table_lookup(type, answstr, (uint8_t*)(&head[1]));
     1812+   log_message(LOG_FILE, (char *)from);
     1813+   lookup_result = table_lookup(type, answstr, (uint8_t*)from);
     1814    if (lookup_result != 0) {
     1815        outr.flags = 3 | 0x0400;    //name do not exist and auth
     1816        goto empty_packet;
     1817@@ -341,8 +351,7 @@ static int process_packet(uint8_t * buf)
     1818    memcpy(next, (void *)answstr, outr.rlen);
     1819    next += outr.rlen;
     1820 
     1821-      empty_packet:
     1822-
     1823+empty_packet:
     1824    flags = ntohs(head->flags);
     1825    // clear rcode and RA, set responsebit and our new flags
     1826    flags |= (outr.flags & 0xff80) | 0x8000;
     1827@@ -364,9 +373,6 @@ static void interrupt(int x)
     1828    exit(2);
     1829 }
     1830 
     1831-#define is_daemon()  (flags&16)
     1832-#define is_verbose() (flags&32)
     1833-//#define DEBUG 1
     1834 
     1835 int dnsd_main(int argc, char **argv)
     1836 {
     1837@@ -437,8 +443,8 @@ int dnsd_main(int argc, char **argv)
     1838                     (struct sockaddr *)&from,
     1839                     (void *)&fromlen);
     1840            if(is_verbose())
     1841-               fprintf(stderr, "\n--- Got UDP  ");
     1842-           log_message(LOG_FILE, "\n--- Got UDP  ");
     1843+               fprintf(stderr, "\n--- Got UDP size=%d ", r);
     1844+           log_message(LOG_FILE, "\n--- Got UDP ");
     1845 
     1846            if (r < 12 || r > 512) {
     1847                bb_error_msg("invalid packet size");
  • trunk/mindi-busybox/coreutils/md5_sha1_sum.c

    r821 r904  
    9999    if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
    100100        flags = bb_getopt_ulflags(argc, argv, "scw");
     101    else optind = 1;
    101102
    102103    if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
  • trunk/mindi-busybox/coreutils/test.c

    r821 r904  
    152152static char **t_wp;
    153153static struct t_op const *t_wp_op;
    154 static gid_t *group_array = NULL;
     154static gid_t *group_array;
    155155static int ngroups;
    156156
     
    548548{
    549549    ngroups = getgroups(0, NULL);
    550     group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
    551     getgroups(ngroups, group_array);
     550    if (ngroups > 0) {
     551        group_array = xmalloc(ngroups * sizeof(gid_t));
     552        getgroups(ngroups, group_array);
     553    }
    552554}
    553555
  • trunk/mindi-busybox/distributions/rpm/mindi-busybox.spec

    r903 r904  
    1313REQ
    1414ExcludeArch:    ppc
    15 Conflicts:  busybox
    1615OBS
    1716
  • trunk/mindi-busybox/docs/autodocifier.pl

    r821 r904  
    2222sub beautify {
    2323    my $text = shift;
    24     $text =~ s/USAGE_NOT\w+\(.*?"\s*\)//sxg;
    25     $text =~ s/USAGE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
     24    for (;;) {
     25        my $text2 = $text;
     26        $text =~ s/SKIP_\w+\(.*?"\s*\)//sxg;
     27        $text =~ s/USE_\w+\(\s*?(.*?)"\s*\)/$1"/sxg;
     28        last if ( $text2 eq $text );
     29    }
    2630    $text =~ s/"\s*"//sg;
    2731    my @line = split("\n", $text);
  • trunk/mindi-busybox/editors/sed.c

    r821 r904  
    5959*/
    6060
    61 #include <stdio.h>
    62 #include <unistd.h>     /* for getopt() */
    63 #include <errno.h>
    64 #include <ctype.h>      /* for isspace() */
    65 #include <stdlib.h>
    66 #include <string.h>
    6761#include "busybox.h"
    6862#include "xregex.h"
     
    9589} sed_cmd_t;
    9690
    97 static const char bad_format_in_subst[] =
    98     "bad format in substitution expression";
    9991static const char *const semicolon_whitespace = "; \n\r\t\v";
    10092
     
    176168/* strdup, replacing "\n" with '\n', and "\delimiter" with 'delimiter' */
    177169
    178 static void parse_escapes(char *dest, const char *string, int len, char from, char to)
     170static void parse_escapes(char *dest, char *string, int len, char from, char to)
    179171{
    180172    int i=0;
     
    193185}
    194186
    195 static char *copy_parsing_escapes(const char *string, int len)
     187static char *copy_parsing_escapes(char *string, int len)
    196188{
    197189    char *dest=xmalloc(len+1);
     
    206198 * beginning at a specified index and returns the index of the next regular
    207199 * expression delimiter (typically a forward * slash ('/')) not preceded by
    208  * a backslash ('\').
     200 * a backslash ('\').  A negative delimiter disables square bracket checking.
    209201 */
    210 static int index_of_next_unescaped_regexp_delim(const char delimiter,
    211     const char *str)
     202static int index_of_next_unescaped_regexp_delim(int delimiter, char *str)
    212203{
    213204    int bracket = -1;
     
    216207    char ch;
    217208
     209    if (delimiter < 0) {
     210        bracket--;
     211        delimiter *= -1;
     212    }
     213
    218214    for (; (ch = str[idx]); idx++) {
    219         if (bracket != -1) {
     215        if (bracket >= 0) {
    220216            if (ch == ']' && !(bracket == idx - 1 || (bracket == idx - 2
    221217                    && str[idx - 1] == '^')))
     
    225221        else if (ch == '\\')
    226222            escaped = 1;
    227         else if (ch == '[')
     223        else if (bracket == -1 && ch == '[')
    228224            bracket = idx;
    229225        else if (ch == delimiter)
     
    232228
    233229    /* if we make it to here, we've hit the end of the string */
    234     return -1;
     230    bb_error_msg_and_die("unmatched '%c'",delimiter);
    235231}
    236232
     
    238234 *  Returns the index of the third delimiter
    239235 */
    240 static int parse_regex_delim(const char *cmdstr, char **match, char **replace)
    241 {
    242     const char *cmdstr_ptr = cmdstr;
     236static int parse_regex_delim(char *cmdstr, char **match, char **replace)
     237{
     238    char *cmdstr_ptr = cmdstr;
    243239    char delimiter;
    244240    int idx = 0;
     
    246242    /* verify that the 's' or 'y' is followed by something.  That something
    247243     * (typically a 'slash') is now our regexp delimiter... */
    248     if (*cmdstr == '\0') bb_error_msg_and_die(bad_format_in_subst);
     244    if (*cmdstr == '\0')
     245        bb_error_msg_and_die("bad format in substitution expression");
    249246    delimiter = *(cmdstr_ptr++);
    250247
    251248    /* save the match string */
    252249    idx = index_of_next_unescaped_regexp_delim(delimiter, cmdstr_ptr);
    253     if (idx == -1) {
    254         bb_error_msg_and_die(bad_format_in_subst);
    255     }
    256250    *match = copy_parsing_escapes(cmdstr_ptr, idx);
    257251
    258252    /* save the replacement string */
    259253    cmdstr_ptr += idx + 1;
    260     idx = index_of_next_unescaped_regexp_delim(delimiter, cmdstr_ptr);
    261     if (idx == -1) {
    262         bb_error_msg_and_die(bad_format_in_subst);
    263     }
     254    idx = index_of_next_unescaped_regexp_delim(-delimiter, cmdstr_ptr);
    264255    *replace = copy_parsing_escapes(cmdstr_ptr, idx);
    265256
     
    288279        else delimiter = '/';
    289280        next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
    290         if (next == -1)
    291             bb_error_msg_and_die("unterminated match expression");
    292 
    293         temp=copy_parsing_escapes(pos,next);
     281        temp = copy_parsing_escapes(pos,next);
    294282        *regex = (regex_t *) xmalloc(sizeof(regex_t));
    295283        xregcomp(*regex, temp, bbg.regex_type|REG_NEWLINE);
    296284        free(temp);
    297285        /* Move position to next character after last delimiter */
    298         pos+=(next+1);
     286        pos += (next+1);
    299287    }
    300288    return pos - my_str;
     
    302290
    303291/* Grab a filename.  Whitespace at start is skipped, then goes to EOL. */
    304 static int parse_file_cmd(sed_cmd_t *sed_cmd, const char *filecmdstr, char **retval)
     292static int parse_file_cmd(sed_cmd_t *sed_cmd, char *filecmdstr, char **retval)
    305293{
    306294    int start = 0, idx, hack=0;
     
    319307}
    320308
    321 static int parse_subst_cmd(sed_cmd_t *const sed_cmd, char *substr)
     309static int parse_subst_cmd(sed_cmd_t *sed_cmd, char *substr)
    322310{
    323311    int cflags = bbg.regex_type;
     
    570558}
    571559
    572 static void do_subst_w_backrefs(const char *line, const char *replace)
     560static void do_subst_w_backrefs(char *line, char *replace)
    573561{
    574562    int i,j;
     
    640628        if(sed_cmd->which_match && sed_cmd->which_match!=match_count) {
    641629            for(i=0;i<bbg.regmatch[0].rm_eo;i++)
    642                 pipe_putc(oldline[i]);
     630                pipe_putc(*(oldline++));
    643631            continue;
    644632        }
     
    670658
    671659/* Set command pointer to point to this label.  (Does not handle null label.) */
    672 static sed_cmd_t *branch_to(const char *label)
     660static sed_cmd_t *branch_to(char *label)
    673661{
    674662    sed_cmd_t *sed_cmd;
  • trunk/mindi-busybox/include/platform.h

    r821 r904  
    7373# ifndef __extension__
    7474#  define __extension__
     75# endif
     76#endif
     77
     78/* gcc-2.95 had no va_copy but only __va_copy. */
     79#if !__GNUC_PREREQ (3,0)
     80# include <stdarg.h>
     81# if !defined va_copy && defined __va_copy
     82#  define va_copy(d,s) __va_copy((d),(s))
    7583# endif
    7684#endif
  • trunk/mindi-busybox/libbb/Makefile.in

    r821 r904  
    3030    trim.c u_signal_names.c vdprintf.c verror_msg.c \
    3131    vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c xstat.c \
    32     xgethostbyname.c xgethostbyname2.c xreadlink.c xregcomp.c xgetlarg.c \
     32    xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
    3333    bb_xsocket.c bb_xdaemon.c bb_xbind.c bb_xlisten.c bb_xchdir.c \
    3434    get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \
     
    5151LIBBB-$(CONFIG_DF)+= find_mount_point.c
    5252LIBBB-$(CONFIG_EJECT)+= find_mount_point.c
     53
     54# We shouldn't build xregcomp.c if we don't need it - this ensures we don't
     55# require regex.h to be in the include dir even if we don't need it thereby
     56# allowing us to build busybox even if uclibc regex support is disabled.
     57
     58regex-y:=
     59regex-$(CONFIG_AWK) += xregcomp.c
     60regex-$(CONFIG_SED) += xregcomp.c
     61regex-$(CONFIG_LESS) += xregcomp.c
     62regex-$(CONFIG_DEVFSD) += xregcomp.c
     63regex-$(CONFIG_MDEV) += xregcomp.c
     64regex-$(CONFIG_GREP) += xregcomp.c
     65
     66# Sort has the happy side efect of returning a unique list
     67LIBBB-y += $(sort $(regex-y))
    5368
    5469LIBBB-y:=$(patsubst %,$(srcdir)/%,$(LIBBB-y))
  • trunk/mindi-busybox/loginutils/Config.in

    r821 r904  
    1515
    1616config CONFIG_USE_BB_SHADOW
    17     bool #"  Use busybox shadow password functions"
     17    bool "  Use busybox shadow password functions"
    1818    default y
    1919    depends on CONFIG_USE_BB_PWD_GRP && CONFIG_FEATURE_SHADOWPASSWDS
  • trunk/mindi-busybox/loginutils/getty.c

    r821 r904  
    486486    }
    487487
    488     tp->c_iflag = tp->c_lflag = tp->c_oflag = tp->c_line = 0;
     488    tp->c_iflag = tp->c_lflag = tp->c_line = 0;
     489    tp->c_oflag = OPOST | ONLCR;
    489490    tp->c_cc[VMIN] = 1;
    490491    tp->c_cc[VTIME] = 0;
  • trunk/mindi-busybox/loginutils/sulogin.c

    r821 r904  
    4949{
    5050    char *cp;
    51     char *device = (char *) 0;
     51    char *device = NULL;
    5252    const char *name = "root";
    5353    int timeout = 0;
     
    6565    if (argc > 1) {
    6666        if (strncmp(argv[1], "-t", 2) == 0) {
    67             if (strcmp(argv[1], "-t") == 0) {
     67            if (argv[1][2] == '\0') { /* -t NN */
    6868                if (argc > 2) {
    6969                    timeout = atoi(argv[2]);
     
    7272                    }
    7373                }
    74             } else {
     74            } else { /* -tNNN */
     75                timeout = atoi(&argv[1][2]);
    7576                if (argc > 2) {
    7677                    device = argv[2];
     
    8485            close(1);
    8586            close(2);
    86             if (open(device, O_RDWR) >= 0) {
     87            if (open(device, O_RDWR) == 0) {
    8788                dup(0);
    8889                dup(0);
  • trunk/mindi-busybox/miscutils/Makefile.in

    r821 r904  
    2121MISCUTILS-$(CONFIG_HDPARM)      += hdparm.o
    2222MISCUTILS-$(CONFIG_LAST)        += last.o
    23 MISCUTILS-${CONFIG_LESS}        += less.o
     23MISCUTILS-$(CONFIG_LESS)        += less.o
    2424MISCUTILS-$(CONFIG_MAKEDEVS)    += makedevs.o
    2525MISCUTILS-$(CONFIG_MOUNTPOINT)  += mountpoint.o
  • trunk/mindi-busybox/miscutils/hdparm.c

    r821 r904  
    14961496    unsigned int t;
    14971497
    1498 
     1498    printf(" (");
    14991499    if (standby == 0)
    15001500        printf("off");
     
    20972097    USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::")
    20982098#ifdef HDIO_DRIVE_CMD
    2099                                     "S::D::P::X::K::A::L::W::CyYzZ"
     2099                                    "S:D:P:X:K:A:L:W:CyYzZ"
    21002100#endif
    21012101    USE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("U:")
  • trunk/mindi-busybox/modutils/lsmod.c

    r821 r904  
    9494
    9595    module_names = xmalloc(bufsize = 256);
    96     if (my_query_module(NULL, QM_MODULES, (void **)&module_names, &bufsize,
    97                 &nmod)) {
     96    if (my_query_module(NULL, QM_MODULES, &module_names, &bufsize, &nmod)) {
    9897        bb_perror_msg_and_die("QM_MODULES");
    9998    }
     
    112111            bb_perror_msg_and_die("module %s: QM_INFO", mn);
    113112        }
    114         if (my_query_module(mn, QM_REFS, (void **)&deps, &depsize, &count)) {
     113        if (my_query_module(mn, QM_REFS, &deps, &depsize, &count)) {
    115114            if (errno == ENOENT) {
    116115                /* The module was removed out from underneath us. */
  • trunk/mindi-busybox/modutils/modprobe.c

    r821 r904  
    689689            if (!show_only) {
    690690                int rc2 = wait4pid(bb_spawn(argv));
    691                
     691
    692692                if (do_insert) {
    693693                    rc = rc2; /* only last module matters */
     
    838838
    839839        // process tail ---> head
    840         rc = mod_process ( tail, 1 );
     840        if ((rc = mod_process ( tail, 1 )) != 0) {
     841            /*
     842             * In case of using udev, multiple instances of modprobe can be
     843             * spawned to load the same module (think of two same usb devices,
     844             * for example; or cold-plugging at boot time). Thus we shouldn't
     845             * fail if the module was loaded, and not by us.
     846             */
     847            if (already_loaded (mod) )
     848                rc = 0;
     849        }
    841850    }
    842851    else
  • trunk/mindi-busybox/networking/dnsd.c

    r821 r904  
    2929#define LOCK_FILE       "/var/run/dnsd.lock"
    3030#define LOG_FILE        "/var/log/dnsd.log"
     31
     32#define is_daemon()  (flags&16)
     33#define is_verbose() (flags&32)
     34//#define DEBUG
     35
    3136
    3237enum {
     
    224229{
    225230    int i;
    226     struct dns_entry *d=dnsentry;
    227 
    228     do {
     231    struct dns_entry *d = dnsentry;
     232
     233    if(d) do {
    229234#ifdef DEBUG
    230         char *p,*q;
    231         q = (char *)&(qs[1]);
    232         p = &(d->name[1]);
    233         fprintf(stderr, "\ntest: %d <%s> <%s> %d", strlen(p), p, q, strlen(q));
    234 #endif
    235         if (type == REQ_A) { /* search by host name */
     235        if(qs && d) {
     236            char *p,*q;
     237            q = (char *)&(qs[1]);
     238            p = &(d->name[1]);
     239            fprintf(stderr, "\n%s: %d/%d p:%s q:%s %d",
     240                __FUNCTION__, strlen(p), (int)(d->name[0]),
     241                p, q, strlen(q));
     242        }
     243#endif
     244        if (type == REQ_A) {            /* search by host name */
    236245            for(i = 1; i <= (int)(d->name[0]); i++)
    237246                if(tolower(qs[i]) != d->name[i])
    238                     continue;
     247                    break;
     248            if(i > (int)(d->name[0])) {
    239249#ifdef DEBUG
    240             fprintf(stderr, " OK");
    241 #endif
    242             strcpy((char *)as, d->ip);
     250                fprintf(stderr, " OK");
     251#endif
     252                strcpy((char *)as, d->ip);
    243253#ifdef DEBUG
    244             fprintf(stderr, " %s ", as);
    245 #endif
    246                     return 0;
    247                 }
    248         else if (type == REQ_PTR) { /* search by IP-address */
     254                fprintf(stderr, " as:%s\n", as);
     255#endif
     256                return 0;
     257            }
     258        } else
     259        if (type == REQ_PTR) {          /* search by IP-address */
    249260            if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) {
    250261                strcpy((char *)as, d->name);
     
    282293
    283294    from = (void *)&head[1];    //  start of query string
    284     next = answb = from + strlen((char *)&head[1]) + 1 + sizeof(struct dns_prop);   // where to append answer block
     295    next = answb = from + strlen((char *)from) + 1 + sizeof(struct dns_prop);   // where to append answer block
    285296
    286297    outr.rlen = 0;          // may change later
     
    306317
    307318    // We have a standard query
    308 
    309     log_message(LOG_FILE, (char *)head);
    310     lookup_result = table_lookup(type, answstr, (uint8_t*)(&head[1]));
     319    log_message(LOG_FILE, (char *)from);
     320    lookup_result = table_lookup(type, answstr, (uint8_t*)from);
    311321    if (lookup_result != 0) {
    312322        outr.flags = 3 | 0x0400;    //name do not exist and auth
     
    342352    next += outr.rlen;
    343353
    344       empty_packet:
    345 
     354empty_packet:
    346355    flags = ntohs(head->flags);
    347356    // clear rcode and RA, set responsebit and our new flags
     
    365374}
    366375
    367 #define is_daemon()  (flags&16)
    368 #define is_verbose() (flags&32)
    369 //#define DEBUG 1
    370376
    371377int dnsd_main(int argc, char **argv)
     
    438444                     (void *)&fromlen);
    439445            if(is_verbose())
    440                 fprintf(stderr, "\n--- Got UDP  ");
    441             log_message(LOG_FILE, "\n--- Got UDP  ");
     446                fprintf(stderr, "\n--- Got UDP size=%d ", r);
     447            log_message(LOG_FILE, "\n--- Got UDP ");
    442448
    443449            if (r < 12 || r > 512) {
  • trunk/mindi-busybox/networking/httpd.c

    r821 r904  
    864864  struct sockaddr_in lsocket;
    865865  int fd;
     866  int on = 1;
    866867
    867868  /* create the socket right now */
     
    874875  /* tell the OS it's OK to reuse a previous address even though */
    875876  /* it may still be in a close down state.  Allows bind to succeed. */
    876   int on = 1;
    877877#ifdef SO_REUSEPORT
    878878  setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ;
  • trunk/mindi-busybox/networking/ping6.c

    r821 r904  
    211211    pkt->icmp6_code = 0;
    212212    pkt->icmp6_cksum = 0;
    213     pkt->icmp6_seq = ntransmitted++;
     213    pkt->icmp6_seq = SWAP_BE16(ntransmitted++);
    214214    pkt->icmp6_id = myid;
    215215    CLR(pkt->icmp6_seq % MAX_DUP_CHK);
  • trunk/mindi-busybox/networking/traceroute.c

    r821 r904  
    10041004        port = (u_short)str2val(port_str, "port", 1, (1 << 16) - 1);
    10051005    if(nprobes_str)
    1006         nprobes = str2val(optarg, "nprobes", 1, -1);
     1006        nprobes = str2val(nprobes_str, "nprobes", 1, -1);
    10071007    if(source) {
    10081008        /*
  • trunk/mindi-busybox/networking/zcip.c

    r821 r904  
    1515 */
    1616
    17 // #define      DEBUG
     17//#define DEBUG
    1818
    1919// TODO:
     
    4343struct arp_packet {
    4444    struct ether_header hdr;
    45     // FIXME this part is netinet/if_ether.h "struct ether_arp"
    46     struct arphdr arp;
    47     struct ether_addr source_addr;
    48     struct in_addr source_ip;
    49     struct ether_addr target_addr;
    50     struct in_addr target_ip;
     45    struct ether_arp arp;
    5146} ATTRIBUTE_PACKED;
    5247
     
    6863};
    6964
    70 static const struct in_addr null_ip = { 0 };
    71 static const struct ether_addr null_addr = { {0, 0, 0, 0, 0, 0} };
    72 
    73 static int verbose = 0;
     65/* States during the configuration process. */
     66enum {
     67    PROBE = 0,
     68    RATE_LIMIT_PROBE,
     69    ANNOUNCE,
     70    MONITOR,
     71    DEFEND
     72};
     73
     74/* Implicitly zero-initialized */
     75static const struct in_addr null_ip;
     76static const struct ether_addr null_addr;
     77static int verbose;
    7478
    7579#define DBG(fmt,args...) \
     
    100104{
    101105    struct arp_packet p;
     106    memset(&p, 0, sizeof(p));
    102107
    103108    // ether header
     
    107112
    108113    // arp request
    109     p.arp.ar_hrd = htons(ARPHRD_ETHER);
    110     p.arp.ar_pro = htons(ETHERTYPE_IP);
    111     p.arp.ar_hln = ETH_ALEN;
    112     p.arp.ar_pln = 4;
    113     p.arp.ar_op = htons(op);
    114     memcpy(&p.source_addr, source_addr, ETH_ALEN);
    115     memcpy(&p.source_ip, &source_ip, sizeof (p.source_ip));
    116     memcpy(&p.target_addr, target_addr, ETH_ALEN);
    117     memcpy(&p.target_ip, &target_ip, sizeof (p.target_ip));
     114    p.arp.arp_hrd = htons(ARPHRD_ETHER);
     115    p.arp.arp_pro = htons(ETHERTYPE_IP);
     116    p.arp.arp_hln = ETH_ALEN;
     117    p.arp.arp_pln = 4;
     118    p.arp.arp_op = htons(op);
     119    memcpy(&p.arp.arp_sha, source_addr, ETH_ALEN);
     120    memcpy(&p.arp.arp_spa, &source_ip, sizeof (p.arp.arp_spa));
     121    memcpy(&p.arp.arp_tha, target_addr, ETH_ALEN);
     122    memcpy(&p.arp.arp_tpa, &target_ip, sizeof (p.arp.arp_tpa));
    118123
    119124    // send it
     
    196201    int ready = 0;
    197202    suseconds_t timeout = 0;    // milliseconds
    198     time_t defend = 0;
    199203    unsigned conflicts = 0;
    200204    unsigned nprobes = 0;
    201205    unsigned nclaims = 0;
    202206    int t;
     207    int state = PROBE;
    203208
    204209    // parse commandline: prog [options] ifname script
     
    307312        fds[0].revents = 0;
    308313
     314        int source_ip_conflict = 0;
     315        int target_ip_conflict = 0;
     316
    309317        // poll, being ready to adjust current timeout
    310318        if (!timeout) {
     
    314322            // ones we'd care about.
    315323        }
     324        // set tv1 to the point in time when we timeout
    316325        gettimeofday(&tv1, NULL);
    317326        tv1.tv_usec += (timeout % 1000) * 1000;
     
    326335        switch (poll(fds, 1, timeout)) {
    327336
    328         // timeouts trigger protocol transitions
     337        // timeout
    329338        case 0:
    330             // probes
    331             if (nprobes < PROBE_NUM) {
    332                 nprobes++;
    333                 VDBG("probe/%d %s@%s\n",
    334                         nprobes, intf, inet_ntoa(ip));
    335                 (void)arp(fd, &saddr, ARPOP_REQUEST,
    336                         &addr, null_ip,
    337                         &null_addr, ip);
     339            VDBG("state = %d\n", state);
     340            switch (state) {
     341            case PROBE:
     342                // timeouts in the PROBE state means no conflicting ARP packets
     343                // have been received, so we can progress through the states
    338344                if (nprobes < PROBE_NUM) {
     345                    nprobes++;
     346                    VDBG("probe/%d %s@%s\n",
     347                            nprobes, intf, inet_ntoa(ip));
     348                    (void)arp(fd, &saddr, ARPOP_REQUEST,
     349                            &addr, null_ip,
     350                            &null_addr, ip);
    339351                    timeout = PROBE_MIN * 1000;
    340352                    timeout += ms_rdelay(PROBE_MAX
    341353                            - PROBE_MIN);
    342                 } else
    343                     timeout = ANNOUNCE_WAIT * 1000;
    344             }
    345             // then announcements
    346             else if (nclaims < ANNOUNCE_NUM) {
    347                 nclaims++;
     354                }
     355                else {
     356                    // Switch to announce state.
     357                    state = ANNOUNCE;
     358                    nclaims = 0;
     359                    VDBG("announce/%d %s@%s\n",
     360                            nclaims, intf, inet_ntoa(ip));
     361                    (void)arp(fd, &saddr, ARPOP_REQUEST,
     362                            &addr, ip,
     363                            &addr, ip);
     364                    timeout = ANNOUNCE_INTERVAL * 1000;
     365                }
     366                break;
     367            case RATE_LIMIT_PROBE:
     368                // timeouts in the RATE_LIMIT_PROBE state means no conflicting ARP packets
     369                // have been received, so we can move immediately to the announce state
     370                state = ANNOUNCE;
     371                nclaims = 0;
    348372                VDBG("announce/%d %s@%s\n",
    349373                        nclaims, intf, inet_ntoa(ip));
     
    351375                        &addr, ip,
    352376                        &addr, ip);
     377                timeout = ANNOUNCE_INTERVAL * 1000;
     378                break;
     379            case ANNOUNCE:
     380                // timeouts in the ANNOUNCE state means no conflicting ARP packets
     381                // have been received, so we can progress through the states
    353382                if (nclaims < ANNOUNCE_NUM) {
     383                    nclaims++;
     384                    VDBG("announce/%d %s@%s\n",
     385                            nclaims, intf, inet_ntoa(ip));
     386                    (void)arp(fd, &saddr, ARPOP_REQUEST,
     387                            &addr, ip,
     388                            &addr, ip);
    354389                    timeout = ANNOUNCE_INTERVAL * 1000;
    355                 } else {
     390                }
     391                else {
     392                    // Switch to monitor state.
     393                    state = MONITOR;
    356394                    // link is ok to use earlier
     395                    // FIXME update filters
    357396                    run(script, "config", intf, &ip);
    358397                    ready = 1;
    359398                    conflicts = 0;
    360                     timeout = -1;
     399                    timeout = -1; // Never timeout in the monitor state.
    361400
    362401                    // NOTE:  all other exit paths
     
    364403                    if (quit)
    365404                        return EXIT_SUCCESS;
    366                     // FIXME update filters
    367                 }
    368             }
    369             break;
    370 
     405                }
     406                break;
     407            case DEFEND:
     408                // We won!  No ARP replies, so just go back to monitor.
     409                state = MONITOR;
     410                timeout = -1;
     411                conflicts = 0;
     412                break;
     413            default:
     414                // Invalid, should never happen.  Restart the whole protocol.
     415                state = PROBE;
     416                pick(&ip);
     417                timeout = 0;
     418                nprobes = 0;
     419                nclaims = 0;
     420                break;
     421            } // switch (state)
     422            break; // case 0 (timeout)
    371423        // packets arriving
    372424        case 1:
    373             // maybe adjust timeout
     425            // We need to adjust the timeout in case we didn't receive
     426            // a conflicting packet.
    374427            if (timeout > 0) {
    375428                struct timeval tv2;
     
    377430                gettimeofday(&tv2, NULL);
    378431                if (timercmp(&tv1, &tv2, <)) {
     432                    // Current time is greater than the expected timeout time.
     433                    // Should never happen.
     434                    VDBG("missed an expected timeout\n");
    379435                    timeout = 0;
    380436                } else {
     437                    VDBG("adjusting timeout\n");
    381438                    timersub(&tv1, &tv2, &tv1);
    382439                    timeout = 1000 * tv1.tv_sec
     
    384441                }
    385442            }
     443
    386444            if ((fds[0].revents & POLLIN) == 0) {
    387445                if (fds[0].revents & POLLERR) {
     
    397455                continue;
    398456            }
     457
    399458            // read ARP packet
    400459            if (recv(fd, &p, sizeof (p), 0) < 0) {
     
    405464                continue;
    406465
    407             VDBG("%s recv arp type=%d, op=%d,\n",
     466#ifdef DEBUG
     467            {
     468                struct ether_addr * sha = (struct ether_addr *) p.arp.arp_sha;
     469                struct ether_addr * tha = (struct ether_addr *) p.arp.arp_tha;
     470                struct in_addr * spa = (struct in_addr *) p.arp.arp_spa;
     471                struct in_addr * tpa = (struct in_addr *) p.arp.arp_tpa;
     472                VDBG("%s recv arp type=%d, op=%d,\n",
    408473                    intf, ntohs(p.hdr.ether_type),
    409                     ntohs(p.arp.ar_op));
    410             VDBG("\tsource=%s %s\n",
    411                     ether_ntoa(&p.source_addr),
    412                     inet_ntoa(p.source_ip));
    413             VDBG("\ttarget=%s %s\n",
    414                     ether_ntoa(&p.target_addr),
    415                     inet_ntoa(p.target_ip));
    416             if (p.arp.ar_op != htons(ARPOP_REQUEST)
    417                     && p.arp.ar_op != htons(ARPOP_REPLY))
     474                    ntohs(p.arp.arp_op));
     475                VDBG("\tsource=%s %s\n",
     476                    ether_ntoa(sha),
     477                    inet_ntoa(*spa));
     478                VDBG("\ttarget=%s %s\n",
     479                    ether_ntoa(tha),
     480                    inet_ntoa(*tpa));
     481            }
     482#endif
     483            if (p.arp.arp_op != htons(ARPOP_REQUEST)
     484                    && p.arp.arp_op != htons(ARPOP_REPLY))
    418485                continue;
    419486
    420             // some cases are always conflicts
    421             if ((p.source_ip.s_addr == ip.s_addr)
    422                     && (memcmp(&addr, &p.source_addr,
    423                             ETH_ALEN) != 0)) {
    424 collision:
    425                 VDBG("%s ARP conflict from %s\n", intf,
    426                         ether_ntoa(&p.source_addr));
    427                 if (ready) {
    428                     time_t now = time(0);
    429 
    430                     if ((defend + DEFEND_INTERVAL)
    431                             < now) {
    432                         defend = now;
    433                         (void)arp(fd, &saddr,
    434                                 ARPOP_REQUEST,
    435                                 &addr, ip,
    436                                 &addr, ip);
    437                         VDBG("%s defend\n", intf);
    438                         timeout = -1;
    439                         continue;
     487            if (memcmp(p.arp.arp_spa, &ip.s_addr, sizeof(struct in_addr)) == 0 &&
     488                memcmp(&addr, &p.arp.arp_sha, ETH_ALEN) != 0) {
     489                source_ip_conflict = 1;
     490            }
     491            if (memcmp(p.arp.arp_tpa, &ip.s_addr, sizeof(struct in_addr)) == 0 &&
     492                p.arp.arp_op == htons(ARPOP_REQUEST) &&
     493                memcmp(&addr, &p.arp.arp_tha, ETH_ALEN) != 0) {
     494                target_ip_conflict = 1;
     495            }
     496
     497            VDBG("state = %d, source ip conflict = %d, target ip conflict = %d\n",
     498                state, source_ip_conflict, target_ip_conflict);
     499            switch (state) {
     500            case PROBE:
     501            case ANNOUNCE:
     502                // When probing or announcing, check for source IP conflicts
     503                // and other hosts doing ARP probes (target IP conflicts).
     504                if (source_ip_conflict || target_ip_conflict) {
     505                    conflicts++;
     506                    if (conflicts >= MAX_CONFLICTS) {
     507                        VDBG("%s ratelimit\n", intf);
     508                        timeout = RATE_LIMIT_INTERVAL * 1000;
     509                        state = RATE_LIMIT_PROBE;
    440510                    }
    441                     defend = now;
     511
     512                    // restart the whole protocol
     513                    pick(&ip);
     514                    timeout = 0;
     515                    nprobes = 0;
     516                    nclaims = 0;
     517                }
     518                break;
     519            case MONITOR:
     520                // If a conflict, we try to defend with a single ARP probe.
     521                if (source_ip_conflict) {
     522                    VDBG("monitor conflict -- defending\n");
     523                    state = DEFEND;
     524                    timeout = DEFEND_INTERVAL * 1000;
     525                    (void)arp(fd, &saddr,
     526                            ARPOP_REQUEST,
     527                            &addr, ip,
     528                            &addr, ip);
     529                }
     530                break;
     531            case DEFEND:
     532                // Well, we tried.  Start over (on conflict).
     533                if (source_ip_conflict) {
     534                    state = PROBE;
     535                    VDBG("defend conflict -- starting over\n");
    442536                    ready = 0;
    443537                    run(script, "deconfig", intf, &ip);
    444                     // FIXME rm filters: setsockopt(fd,
    445                     // SO_DETACH_FILTER, ...)
    446                 }
    447                 conflicts++;
    448                 if (conflicts >= MAX_CONFLICTS) {
    449                     VDBG("%s ratelimit\n", intf);
    450                     sleep(RATE_LIMIT_INTERVAL);
    451                 }
    452                 // restart the whole protocol
     538
     539                    // restart the whole protocol
     540                    pick(&ip);
     541                    timeout = 0;
     542                    nprobes = 0;
     543                    nclaims = 0;
     544                }
     545                break;
     546            default:
     547                // Invalid, should never happen.  Restart the whole protocol.
     548                VDBG("invalid state -- starting over\n");
     549                state = PROBE;
    453550                pick(&ip);
    454551                timeout = 0;
    455552                nprobes = 0;
    456553                nclaims = 0;
    457             }
    458             // two hosts probing one address is a collision too
    459             else if (p.target_ip.s_addr == ip.s_addr
    460                     && nclaims == 0
    461                     && p.arp.ar_op == htons(ARPOP_REQUEST)
    462                     && memcmp(&addr, &p.target_addr,
    463                             ETH_ALEN) != 0) {
    464                 goto collision;
    465             }
    466             break;
    467 
     554                break;
     555            } // switch state
     556
     557            break; // case 1 (packets arriving)
    468558        default:
    469559            why = "poll";
    470560            goto bad;
    471         }
     561        } // switch poll
    472562    }
    473563bad:
  • trunk/mindi-busybox/shell/msh.c

    r821 r904  
    32153215    REGISTER char *sp, *tp;
    32163216    int eacces = 0, asis = 0;
    3217 
    3218 #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
    32193217    char *name = c;
    32203218
    3221     optind = 1;
    3222     if (find_applet_by_name(name)) {
    3223         /* We have to exec here since we vforked.  Running
    3224          * run_applet_by_name() won't work and bad things
    3225          * will happen. */
    3226         execve(CONFIG_BUSYBOX_EXEC_PATH, v, envp);
    3227     }
    3228 #endif
     3219    if (ENABLE_FEATURE_SH_STANDALONE_SHELL) {
     3220        optind = 1;
     3221        if (find_applet_by_name(name)) {
     3222            /* We have to exec here since we vforked.  Running
     3223             * run_applet_by_name() won't work and bad things
     3224             * will happen. */
     3225            execve(CONFIG_BUSYBOX_EXEC_PATH, v, envp);
     3226        }
     3227    }
    32293228
    32303229    DBGPRINTF(("REXECVE: c=%p, v=%p, envp=%p\n", c, v, envp));
  • trunk/mindi-busybox/testsuite/README

    r821 r904  
     1Update: doesn't work as described. Try "make check" from parent dir...
     2* * *
     3
    14To run the test suite, change to this directory and run "./runtest".  It will
    25run all of the test cases, and list those with unexpected outcomes.  Adding the
  • trunk/mindi-busybox/testsuite/sed.tests

    r821 r904  
    175175rm ./-     # Clean up
    176176
     177testing "sed s/xxx/[/" "sed -e 's/xxx/[/'" "[\n" "" "xxx\n"
     178
    177179# Ponder this a bit more, why "woo not found" from gnu version?
    178180#testing "sed doesn't substitute in deleted line" \
  • trunk/mindi-busybox/util-linux/mdev.c

    r821 r904  
    4141     * also depend on path having writeable space after it. */
    4242
    43     strcat(path, "/dev");
    44     fd = open(path, O_RDONLY);
    45     len = read(fd, temp + 1, 64);
    46     *temp++ = 0;
    47     close(fd);
    48     if (len < 1) return;
     43    if (!delete) {
     44        strcat(path, "/dev");
     45        fd = open(path, O_RDONLY);
     46        len = read(fd, temp + 1, 64);
     47        *temp++ = 0;
     48        close(fd);
     49        if (len < 1) return;
     50    }
    4951
    5052    /* Determine device name, type, major and minor */
     
    5254    device_name = strrchr(path, '/') + 1;
    5355    type = path[5]=='c' ? S_IFCHR : S_IFBLK;
    54     if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
    5556
    5657    /* If we have a config file, look up permissions for this device */
     
    168169    umask(0);
    169170    if (!delete) {
     171        if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
    170172        if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
    171173            bb_perror_msg_and_die("mknod %s failed", device_name);
  • trunk/mindi-busybox/util-linux/mount.c

    r821 r904  
    292292    // a synthetic filesystem like proc or sysfs.)
    293293
    294     if (lstat(mp->mnt_fsname, &st));
     294    if (stat(mp->mnt_fsname, &st));
    295295    else if (!(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) {
    296296        // Do we need to allocate a loopback device for it?
  • trunk/mindi-busybox/util-linux/readprofile.c

    r821 r904  
    6868    const char *mapFile, *proFile, *mult=0;
    6969    unsigned long len=0, indx=1;
    70     unsigned long long add0=0;
     70    uint64_t add0=0;
    7171    unsigned int step;
    7272    unsigned int *buf, total, fn_len;
     
    244244                    header_printed = 1;
    245245                }
    246                 printf ("\t%llx\t%u\n", (indx - 1)*step + add0, buf[indx]);
     246                printf ("\t%"PRIx64"\t%u\n", (indx - 1)*step + add0, buf[indx]);
    247247            }
    248248            this += buf[indx++];
  • trunk/mindi-busybox/util-linux/umount.c

    r821 r904  
    1515#include <mntent.h>
    1616#include <errno.h>
    17 #include <string.h>
    1817#include <getopt.h>
    1918
    20 #define OPTION_STRING       "flDnrvad"
     19#define OPTION_STRING       "flDnravd"
    2120#define OPT_FORCE           1
    2221#define OPT_LAZY            2
     
    2423#define OPT_NO_MTAB         8
    2524#define OPT_REMOUNT         16
    26 #define OPT_IGNORED         32  // -v is ignored
    27 #define OPT_ALL             (ENABLE_FEATURE_UMOUNT_ALL ? 64 : 0)
     25#define OPT_ALL             (ENABLE_FEATURE_UMOUNT_ALL ? 32 : 0)
    2826
    2927int umount_main(int argc, char **argv)
     
    7876        if (!argc) bb_show_usage();
    7977    }
    80 
    81 
    8278   
    8379    // Loop through everything we're supposed to umount, and do so.
    8480    for (;;) {
    8581        int curstat;
     82        char *zapit = *argv;
    8683
    8784        // Do we already know what to umount this time through the loop?
     
    9289        else if (!argc--) break;
    9390        else {
    94             realpath(*argv++, path);
     91            argv++;
     92            realpath(zapit, path);
    9593            for (m = mtl; m; m = m->next)
    9694                if (!strcmp(path, m->dir) || !strcmp(path, m->device))
    9795                    break;
    9896        }
     97        // If we couldn't find this sucker in /etc/mtab, punt by passing our
     98        // command line argument straight to the umount syscall.  Otherwise,
     99        // umount the directory even if we were given the block device.
     100        if (m) zapit = m->dir;
    99101
    100102        // Let's ask the thing nicely to unmount.
    101         curstat = umount(path);
     103        curstat = umount(zapit);
    102104
    103105        // Force the unmount, if necessary.
    104106        if (curstat && doForce) {
    105             curstat = umount2(path, doForce);
     107            curstat = umount2(zapit, doForce);
    106108            if (curstat)
    107                 bb_error_msg_and_die("forced umount of %s failed!", path);
     109                bb_error_msg_and_die("forced umount of %s failed!", zapit);
    108110        }
    109111
    110112        // If still can't umount, maybe remount read-only?
    111113        if (curstat && (opt & OPT_REMOUNT) && errno == EBUSY && m) {
    112             curstat = mount(m->device, path, NULL, MS_REMOUNT|MS_RDONLY, NULL);
     114            curstat = mount(m->device, zapit, NULL, MS_REMOUNT|MS_RDONLY, NULL);
    113115            bb_error_msg(curstat ? "Cannot remount %s read-only" :
    114116                         "%s busy - remounted read-only", m->device);
    115117        }
    116118
    117         /* De-allocate the loop device.  This ioctl should be ignored on any
    118          * non-loop block devices. */
    119         if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONTFREELOOP) && m)
    120             del_loop(m->device);
     119        if (curstat) {
     120            status = EXIT_FAILURE;
     121            bb_perror_msg("Couldn't umount %s", zapit);
     122        } else {
     123            /* De-allocate the loop device.  This ioctl should be ignored on
     124             * any non-loop block devices. */
     125            if (ENABLE_FEATURE_MOUNT_LOOP && !(opt & OPT_DONTFREELOOP) && m)
     126                del_loop(m->device);
     127            if (ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
     128                erase_mtab(m->dir);
     129        }
    121130
    122         if (curstat) {
    123             /* Yes, the ENABLE is redundant here, but the optimizer for ARM
    124              * can't do simple constant propagation in local variables... */
    125             if(ENABLE_FEATURE_MTAB_SUPPORT && !(opt & OPT_NO_MTAB) && m)
    126                 erase_mtab(m->dir);
    127             status = EXIT_FAILURE;
    128             bb_perror_msg("Couldn't umount %s", path);
    129         }
    130131        // Find next matching mtab entry for -a or umount /dev
     132        // Note this means that "umount /dev/blah" will unmount all instances
     133        // of /dev/blah, not just the most recent.
    131134        while (m && (m = m->next))
    132135            if ((opt & OPT_ALL) || !strcmp(path,m->device))
  • trunk/mindi/install.sh

    r839 r904  
    5555chmod 755 $conf/mindi.conf
    5656
     57# Substirute variables for init
     58perl -pi -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~ ; s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" $locallib/mindi/rootfs/sbin/init
     59
     60# Substirute variables for mindi
    5761if [ "$RPMBUILDMINDI" = "true" ]; then
    5862    sed -e "s~^MINDI_PREFIX=XXX~MINDI_PREFIX=/usr~" -e "s~^MINDI_CONF=YYY~MINDI_CONF=/etc/mindi~" -e "s~^MINDI_VER=VVV~MINDI_VER=$MINDIVER~" -e "s~^MINDI_REV=RRR~MINDI_REV=$MINDIREV~" mindi > $local/sbin/mindi
  • trunk/mindi/rootfs/sbin/init

    r903 r904  
    158158    res=$?
    159159    if [ "$res" -ne "0" ] ; then
    160     LogIt "First call to find-and-mount-cdrom failed." 1
    161     LogIt "Sleeping for 3 seconds and trying again." 1
    162     sleep 3
    163     find-and-mount-cdrom
    164     res=$?
     160        LogIt "First call to find-and-mount-cdrom failed." 1
     161        LogIt "Sleeping for 3 seconds and trying again." 1
     162        sleep 3
     163        find-and-mount-cdrom
     164        res=$?
    165165    fi
    166166    if [ "$res" -eq "0" ] ; then
    167 #        clear
    168     LogIt "OK, I am running on a CD-ROM. Good." 3
     167        LogIt "OK, I am running on a CD-ROM. Good." 3
    169168        CD_MOUNTED_OK=yes
    170169    elif [ "$res" -eq "1" ] ; then
    171 #        clear
    172     LogIt "OK, I am running on floppies. Good." 3
    173     CD_MOUNTED_OK=""
     170        LogIt "OK, I am running on floppies. Good." 3
     171        CD_MOUNTED_OK=""
    174172    else
    175     LogIt "OK, I am falling back to floppy mode." 3
     173        LogIt "OK, I am falling back to floppy mode." 3
    176174        LogIt "That means you'll have to copy the data disk images from" 3
    177175        LogIt "the CD/hard disk/whatever to physical 1.44MB disks and" 3
     
    180178        LogIt "on your hard disk. Your archives are probably fine but" 3
    181179        LogIt "your tape streamer and/or CD-ROM drive are eccentric. :-)" 3
    182     CD_MOUNTED_OK=""
     180        CD_MOUNTED_OK=""
    183181    fi
    184182    return 0
     
    422420# ------------------------ main -----------------------
    423421
     422MINDI_VER=VVV
     423MINDI_REV=RRR
    424424trap CaughtSoftReset SIGTERM
    425425LOGFILE=/tmp/mondo-restore.log
     
    428428USER=root
    429429export PATH GROOVY USER
     430
     431echo "Welcome to init (from mindi ${MINDI_VER}-r${MINDI_REV}"
    430432
    431433mount -o remount rw /
  • trunk/mondo/configure.in

    r788 r904  
    1818AC_ARG_PROGRAM
    1919
    20 AM_INIT_AUTOMAKE([mondo], MONDO_VER)
     20AM_INIT_AUTOMAKE([src], MONDO_VER)
    2121AM_MAINTAINER_MODE
    2222
  • trunk/mondo/distributions/rpm/mondo.spec

    r839 r904  
    1919ExcludeArch:    ppc
    2020OBS
    21 Requires:   mindi >= 1.0.9, bzip2 >= 0.9, afio, mkisofs, binutils, newt >= 0.50, DDD
     21Requires:   mindi >= 1.2.0, bzip2 >= 0.9, afio, mkisofs, binutils, newt >= 0.50, DDD
    2222%ifarch ia64
    2323Requires:   elilo, parted
  • trunk/mondo/src/restore-scripts/Makefile.am

    r426 r904  
    1 SUBDIRS = mondo usr
     1SUBDIRS = src usr
    22
    33restoreetcdir       = $(pkgdatadir)/restore-scripts/etc
  • trunk/mondo/src/restore-scripts/mondo/label-partitions-as-necessary

    r729 r904  
    11#!/bin/sh
    22#
    3 # 09/05
    4 # - replaced 'grep -w' with 'grep " $.. "'
     3# $Id$
    54#
    6 # 06/11
    7 # - added support for 5th column, for labels
    8 #
    9 # 02/02/2003
    10 # - something
    11 #
    12 # mid-2001
    13 # - first written
    145############################################
    156
    167
    17 #LogIt() {
    18 #    echo "$1" >> /dev/stderr
    19 #}
    20 
    21  
    228read_partition_line() {
    239    local tmp label mountpt mountline command format
     
    3420            LogIt "Not labeling $mountpt as anything because $label is not a label"
    3521        else
    36             command="e2label $mountpt $label"
    3722            if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
    38                 LogIt "Running '$command'"
     23                command="e2label $mountpt $label"
     24                LogIt "Running $command"
    3925                $command
     26            elif [ "$format" = "swap" ] ; then
     27                command="mkswap -L $label $mountpt"
     28                LogIt "Running $command"
    4029            else
    41                 LogIt "I am NOT going to run '$command': the partition is format '$format', which doesn't like e2label anyway"
     30                LogIt "I am NOT going to run e2label: the partition is format '$format', which doesn't like e2label anyway"
    4231            fi
    4332    fi
  • trunk/tools/mg

    r788 r904  
    1 egrep -ri -w $* . | egrep -v '\.svn|~:'
     1egrep -ri -w "$*" . | egrep -v '\.svn|~:'
  • trunk/tools/mkqemu

    r618 r904  
    1919fi
    2020
    21 qemu -m 256 $QEMUOPT -redir tcp:${sp}:${ipvm}:22 /users/qemu/$m.qemu
     21ARCH=`/bin/arch`
     22if [ $ARCH == "x86_64" ]; then
     23    qemucmd32=/usr//bin/qemu-system-i386
     24    qemucmd64=/usr//bin/qemu
     25else
     26    qemucmd32=/usr//bin/qemu
     27    qemucmd64=/usr//bin/qemu-system-x86_64
     28fi
     29
     30echo $m | grep -q '_64$'
     31if [ $? -ne 0 ]; then
     32     qemucmd=$qemucmd32
     33else
     34     qemucmd=$qemucmd64
     35fi
     36$qemucmd -m 256 $QEMUOPT -redir tcp:${sp}:${ipvm}:22 /users/qemu/$m.qemu
  • trunk/website/downloads.shtml

    r794 r904  
    2929                <li>HP/Intel Solution Center :
    3030                    <a href="http://www.mondorescue.org">Web site</a>,
    31                     <a href="ftp://ftp.mondorescue.org">Ftp site</a>
     31                    <a href="ftp://ftp.mondorescue.org">Ftp site (ftp)</a>
     32                    <a href="rsync://rsync.mondorescue.org::mondorescue-ftp">Ftp site (rsync)</a>
     33                    <ul>
     34                            <li>Update times: Master site</li>
     35                            <li>Internet Bandwith: 4Mbit</li>
     36                    </ul>
    3237                </li>
    3338            </ul>
     
    3742                    <a href="http://mondorescue.linjection.org">Web site</a>,
    3843                    <a href="http://mondorescue.linjection.org/ftp">Ftp site (http)</a>
     44                </li>
     45            </ul>
     46            <li><i>Italy</i>:</li>
     47            <ul>
     48                    <li>Daniele Carbonetti (<a href="http://www.dcl-arch.it">http://www.dcl-arch.it</a>):
     49                    <a href="http://mondorescue.dcl-arch.it">Web site</a>,
     50                    <a href="http://www.dcl-arch.it/pub/mondorescue">Ftp site (http)</a>
     51                    <a href="ftp://ftp.dcl-arch.it/pub/mondorescue">Ftp site (ftp)</a>
     52                    <a href="rsync://rsync.dcl-arch.it::mondorescue">Ftp site (rsync)</a>
     53                    <ul>
     54                            <li>Update times: 2 times/day</li>
     55                            <li>Internet Bandwith: 100Mbit</li>
     56                    </ul>
    3957                </li>
    4058            </ul>
Note: See TracChangeset for help on using the changeset viewer.