1.0 backports of:
authorRob Landley <rob@landley.net>
Sat, 13 Aug 2005 00:26:01 +0000 (00:26 -0000)
committerRob Landley <rob@landley.net>
Sat, 13 Aug 2005 00:26:01 +0000 (00:26 -0000)
10861, 10875, 10881, 10888 ash fix
10865 suid thing?  (look at this)
10886 telnet bugfix
10866 ftp fix for RFC 959 compliance.
10867 Remove spurious newline from cp -i prompt.
10874 ksyslogd fix
10876 msh fix
10877 httpd fix
10880, 10889, 11005 dhcp fixes

busybox/include/applets.h
busybox/include/usage.h
busybox/libbb/copy_file.c
busybox/networking/ftpgetput.c
busybox/networking/httpd.c
busybox/networking/telnet.c
busybox/networking/udhcp/dhcpc.c
busybox/shell/ash.c
busybox/shell/cmdedit.c
busybox/shell/msh.c
busybox/sysklogd/syslogd.c

index 21f82f57d507fcf92be0bee2828341e86629e10a..d89500e7774f44834f991afe47329442411322c6 100644 (file)
 #endif
 
 #if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
-       { 0,NULL,0 }
+       { 0,NULL,0,0 }
 };
 
 #endif
index ad4410196b9c88e0dae5b317d72e6f40215c3278..b58c572751f6fc070154bd6021d5b63259dc8c66 100644 (file)
        "/dev/tty2\n"
 
 #define udhcpc_trivial_usage \
-       "[-fbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
+       "[-Cfbnqv] [-c CLIENTID] [-H HOSTNAME] [-i INTERFACE]\n[-p pidfile] [-r IP] [-s script]"
 #define udhcpc_full_usage \
-       "\t-c,\t--clientid=CLIENTID\tClient identifier\n" \
+       "\t-c,\t--clientid=CLIENTID\tSet client identifier\n" \
+       "\t-C,\t--clientid-none\tSuppress default client identifier\n" \
        "\t-H,\t--hostname=HOSTNAME\tClient hostname\n" \
        "\t-h,\t                   \tAlias for -H\n" \
        "\t-f,\t--foreground\tDo not fork after getting lease\n" \
index 4b349b7fcf9c4b1f107f4fb773ab2c0b46388e50..f5fecaf73353bb53fb442fe98ab8d92cad2f8eab 100644 (file)
@@ -146,7 +146,7 @@ int copy_file(const char *source, const char *dest, int flags)
 
                if (dest_exists) {
                        if (flags & FILEUTILS_INTERACTIVE) {
-                               bb_error_msg("overwrite `%s'? ", dest);
+                               fprintf(stderr, "%s: overwrite `%s'? ", bb_applet_name, dest);
                                if (!bb_ask_confirmation()) {
                                        close (src_fd);
                                        return 0;
index f6bd82bc85ea68e38742c40e394a977993045efb..02c21d9e11e6717b3b8851bd030900a9e152af1b 100644 (file)
@@ -65,9 +65,9 @@ static int ftpcmd(const char *s1, const char *s2, FILE *stream, char *buf)
 
        if (s1) {
                if (s2) {
-                       fprintf(stream, "%s%s\n", s1, s2);
+                       fprintf(stream, "%s%s\r\n", s1, s2);
                } else {
-                       fprintf(stream, "%s\n", s1);
+                       fprintf(stream, "%s\r\n", s1);
                }
        }
        do {
index 94fcfc8c18bcd21512f17787659321bb70623e6c..e3f4027dcad130f3ad0ce68f5f2c2ee92de3fab0 100644 (file)
@@ -1259,6 +1259,8 @@ static int sendCgi(const char *url,
                        post_readed_idx += count;
                        if(post_readed_size == 0)
                                post_readed_idx = 0;
+               } else {
+                       post_readed_size = post_readed_idx = bodyLen = 0; /* broken pipe to CGI */
                }
       } else if(bodyLen > 0 && post_readed_size == 0 && FD_ISSET(a_c_r, &readSet)) {
                count = bodyLen > sizeof(wbuf) ? sizeof(wbuf) : bodyLen;
@@ -1266,7 +1268,7 @@ static int sendCgi(const char *url,
                if(count > 0) {
                        post_readed_size += count;
                        bodyLen -= count;
-      } else {
+               } else {
                        bodyLen = 0;    /* closed */
                }
       }
index 6ad7712ab87b900731bd1a88259040034e93a0c5..24160057bbd9df946fafbe466381c41eca35eabf 100644 (file)
@@ -96,6 +96,7 @@ static struct Globalvars {
        byte    charmode;
        byte    telflags;
        byte    gotsig;
+       byte    do_termios;
        /* buffer to handle telnet negotiations */
        char    iacbuf[IACBUFSIZE];
        short   iaclen; /* could even use byte */
@@ -616,12 +617,12 @@ static void fgotsig(int sig)
 
 static void rawmode(void)
 {
-       tcsetattr(0, TCSADRAIN, &G.termios_raw);
+       if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_raw);
 }
 
 static void cookmode(void)
 {
-       tcsetattr(0, TCSADRAIN, &G.termios_def);
+       if (G.do_termios) tcsetattr(0, TCSADRAIN, &G.termios_def);
 }
 
 extern int telnet_main(int argc, char** argv)
@@ -649,11 +650,12 @@ extern int telnet_main(int argc, char** argv)
 
        memset(&G, 0, sizeof G);
 
-       if (tcgetattr(0, &G.termios_def) < 0)
-               exit(1);
+       if (tcgetattr(0, &G.termios_def) >= 0) {
+               G.do_termios = 1;
 
-       G.termios_raw = G.termios_def;
-       cfmakeraw(&G.termios_raw);
+               G.termios_raw = G.termios_def;
+               cfmakeraw(&G.termios_raw);
+       }
 
        if (argc < 2)
                bb_show_usage();
index 91af9153b3a2c3dc503daabaf7eca9337f3a23f4..e89affe1fff54d20e39d1ea85328313089e98e5f 100644 (file)
@@ -76,7 +76,8 @@ static void __attribute__ ((noreturn)) show_usage(void)
 {
        printf(
 "Usage: udhcpc [OPTIONS]\n\n"
-"  -c, --clientid=CLIENTID         Client identifier\n"
+"  -c, --clientid=CLIENTID         Set client identifier\n"
+"  -C, --clientid-none             Suppress default client identifier\n"
 "  -H, --hostname=HOSTNAME         Client hostname\n"
 "  -h                              Alias for -H\n"
 "  -f, --foreground                Do not fork after getting lease\n"
@@ -191,9 +192,11 @@ int main(int argc, char *argv[])
        long now;
        int max_fd;
        int sig;
+       int no_clientid = 0;
 
        static const struct option arg_options[] = {
                {"clientid",    required_argument,      0, 'c'},
+               {"clientid-none", no_argument,          0, 'C'},
                {"foreground",  no_argument,            0, 'f'},
                {"background",  no_argument,            0, 'b'},
                {"hostname",    required_argument,      0, 'H'},
@@ -211,11 +214,12 @@ int main(int argc, char *argv[])
        /* get options */
        while (1) {
                int option_index = 0;
-               c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
+               c = getopt_long(argc, argv, "c:CfbH:h:i:np:qr:s:v", arg_options, &option_index);
                if (c == -1) break;
 
                switch (c) {
                case 'c':
+                       if (no_clientid) show_usage();
                        len = strlen(optarg) > 255 ? 255 : strlen(optarg);
                        if (client_config.clientid) free(client_config.clientid);
                        client_config.clientid = xmalloc(len + 2);
@@ -224,6 +228,10 @@ int main(int argc, char *argv[])
                        client_config.clientid[OPT_DATA] = '\0';
                        strncpy(client_config.clientid + OPT_DATA, optarg, len);
                        break;
+               case 'C':
+                       if (client_config.clientid) show_usage();
+                       no_clientid = 1;
+                       break;
                case 'f':
                        client_config.foreground = 1;
                        break;
@@ -273,7 +281,8 @@ int main(int argc, char *argv[])
                           NULL, client_config.arp) < 0)
                return 1;
 
-       if (!client_config.clientid) {
+       /* if not set, and not suppressed, setup the default client ID */
+       if (!client_config.clientid && !no_clientid) {
                client_config.clientid = xmalloc(6 + 3);
                client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
                client_config.clientid[OPT_LEN] = 7;
@@ -420,8 +429,10 @@ int main(int argc, char *argv[])
                                continue;
                        }
                        /* Ignore packets that aren't for us */
-                       if (memcmp(client_config.arp,packet.chaddr,6))
+                       if (memcmp(packet.chaddr, client_config.arp, 6)) {
+                               DEBUG(LOG_INFO, "packet does not have our chaddr -- ignoring");
                                continue;
+                       }
 
                        if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) {
                                DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring");
index d9ea2b0f3731e6ce4bb21ec665579eb565ba422f..f16edbc38166abfe64f5760f62fd5192b02e85a9 100644 (file)
@@ -1353,6 +1353,7 @@ struct builtincmd {
 
 #define IS_BUILTIN_SPECIAL(builtincmd) ((builtincmd)->name[0] & 1)
 #define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
+#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
 
 static const struct builtincmd builtincmd[] = {
        { BUILTIN_SPEC_REG      ".", dotcmd },
@@ -3208,7 +3209,14 @@ parse_command_args(char **argv, const char **path)
 }
 #endif
 
-
+static inline int
+isassignment(const char *p)
+{
+       const char *q = endofname(p);
+       if (p == q)
+               return 0;
+       return *q == '=';
+}
 
 /*
  * Execute a simple command.
@@ -3232,6 +3240,8 @@ evalcommand(union node *cmd, int flags)
        int cmd_is_exec;
        int status;
        char **nargv;
+       struct builtincmd *bcmd;
+       int pseudovarflag = 0;
 
        /* First expand the arguments. */
        TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags));
@@ -3246,11 +3256,21 @@ evalcommand(union node *cmd, int flags)
        *arglist.lastp = NULL;
 
        argc = 0;
+       if (cmd->ncmd.args)
+       {
+               bcmd = find_builtin(cmd->ncmd.args->narg.text);
+               pseudovarflag = bcmd && IS_BUILTIN_ASSIGN(bcmd);
+       }
+
        for (argp = cmd->ncmd.args; argp; argp = argp->narg.next) {
                struct strlist **spp;
 
                spp = arglist.lastp;
-               expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+               if (pseudovarflag && isassignment(argp->narg.text)) 
+                       expandarg(argp, &arglist, EXP_VARTILDE);
+               else
+                       expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
+
                for (sp = *spp; sp; sp = sp->next)
                        argc++;
        }
@@ -9370,15 +9390,6 @@ static void setprompt(int);
 
 
 
-static inline int
-isassignment(const char *p)
-{
-       const char *q = endofname(p);
-       if (p == q)
-               return 0;
-       return *q == '=';
-}
-
 
 /*
  * Read and parse a command.  Returns NEOF on end of file.  (NULL is a
@@ -12005,7 +12016,7 @@ setvar(const char *name, const char *val, int flags)
        INTOFF;
        p = mempcpy(nameeq = ckmalloc(namelen + vallen + 2), name, namelen);
        *p++ = '\0';
-       if (vallen) {
+       if (val) {
                p[-1] = '=';
                p = mempcpy(p, val, vallen);
        }
index 56b789ab6c93adc15cf6948e830738353cc91863..3380dffe9404c0dccff8019da71c3a19b6427629 100644 (file)
@@ -782,8 +782,8 @@ static int match_compare(const void *a, const void *b)
 #define QUOT    (UCHAR_MAX+1)
 
 #define collapse_pos(is, in) { \
-       memcpy(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
-       memcpy(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
+       memmove(int_buf+(is), int_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); \
+       memmove(pos_buf+(is), pos_buf+(in), (BUFSIZ+1-(is)-(in))*sizeof(int)); }
 
 static int find_match(char *matchBuf, int *len_with_quotes)
 {
index 2fb0df739fd5cb3b3c918d8c076bff07f8894b23..14e875854d7559f7f30336e7bd3064fecc7a5728 100644 (file)
@@ -4290,7 +4290,7 @@ int quoted;
                        }
 
                        var_name[var_index++] = *src++;
-                       while (isalnum(*src))
+                       while (isalnum(*src) || *src=='_')
                                var_name[var_index++] = *src++;
                        var_name[var_index] = 0;
 
index 8c6c44ee0a5c918c00d8c649257a12aaceeea98d..aecd35d588e050375e5be76ab3ef1debfd501815 100644 (file)
@@ -441,7 +441,7 @@ static void logMessage(int pri, char *msg)
                /* if we have a valid socket, send the message */
                if (-1 != remotefd) {
                        now = 1;
-                       snprintf(line, sizeof(line), "<%d> %s", pri, msg);
+                       snprintf(line, sizeof(line), "<%d>%s", pri, msg);
 
                retry:
                        /* send message to remote logger */