Apply post 1.13.1 patches, bump to 1.13.2 1_13_2
authorDenis Vlasenko <vda.linux@googlemail.com>
Wed, 31 Dec 2008 03:33:50 +0000 (03:33 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Wed, 31 Dec 2008 03:33:50 +0000 (03:33 -0000)
12 files changed:
Makefile
coreutils/printf.c
include/libbb.h
init/init.c
libbb/xconnect.c
miscutils/crond.c
miscutils/dc.c
networking/arping.c
networking/ip.c
networking/libiproute/iptunnel.c
networking/ping.c
networking/udhcp/socket.c

index a7934c8b26f28ad57bfce39a53eb10649c515e87..a2b2b015b92ecaf2a04191260a0ad6caa99b82bc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 1
 PATCHLEVEL = 13
-SUBLEVEL = 1
+SUBLEVEL = 2
 EXTRAVERSION =
 NAME = Unnamed
 
index 76524f70648e6d1d66ffa47c81d5f97facb8e4a9..b0a48cda4a1738b0baf95456a4e566efd245e579 100644 (file)
@@ -359,8 +359,15 @@ int printf_main(int argc UNUSED_PARAM, char **argv)
         * We will mimic coreutils. */
        if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2])
                argv++;
-       if (!argv[1])
+       if (!argv[1]) {
+               if (ENABLE_ASH_BUILTIN_PRINTF
+                && applet_name[0] != 'p'
+               ) {
+                       bb_error_msg("usage: printf FORMAT [ARGUMENT...]");
+                       return 2; /* bash compat */
+               }
                bb_show_usage();
+       }
 
        format = argv[1];
        argv2 = argv + 2;
index b0f6eaee2d827fbcb3974dead6ef0f5a1c0310ad..9e0399eee56396ca3a2cde88ea0e16ebc1351ef5 100644 (file)
@@ -437,6 +437,7 @@ ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
  * Turn it on before you call bind(). */
 void setsockopt_reuseaddr(int fd) FAST_FUNC; /* On Linux this never fails. */
 int setsockopt_broadcast(int fd) FAST_FUNC;
+int setsockopt_bindtodevice(int fd, const char *iface) FAST_FUNC;
 /* NB: returns port in host byte order */
 unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port) FAST_FUNC;
 typedef struct len_and_sockaddr {
index 1caf45b8d40e51803ec0d92350bd9e7ff1a37874..10f5ba68de69b4e17956631c4d584fc077c30ab5 100644 (file)
@@ -118,18 +118,18 @@ static void message(int where, const char *fmt, ...)
 
        msg[0] = '\r';
        va_start(arguments, fmt);
-       l = vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments);
-       if (l > sizeof(msg) - 2)
-               l = sizeof(msg) - 2;
+       l = 1 + vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments);
+       if (l > sizeof(msg) - 1)
+               l = sizeof(msg) - 1;
        msg[l] = '\0';
        va_end(arguments);
 
        if (ENABLE_FEATURE_INIT_SYSLOG) {
-               /* Log the message to syslogd */
                if (where & L_LOG) {
-                       /* don't print out "\r" */
-                       openlog(applet_name, 0, LOG_DAEMON);
-                       syslog(LOG_INFO, "init: %s", msg + 1);
+                       /* Log the message to syslogd */
+                       openlog("init", 0, LOG_DAEMON);
+                       /* don't print "\r" */
+                       syslog(LOG_INFO, "%s", msg + 1);
                        closelog();
                }
                msg[l++] = '\n';
index d48c50339990ba2079ae83fbf1a558571859022e..27c7424b62f104ed8b8e970e28a7c9db7a18cb42 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <netinet/in.h>
+#include <net/if.h>
 #include "libbb.h"
 
 void FAST_FUNC setsockopt_reuseaddr(int fd)
@@ -17,6 +18,20 @@ int FAST_FUNC setsockopt_broadcast(int fd)
 {
        return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1));
 }
+int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
+{
+       int r;
+       struct ifreq ifr;
+       strncpy(ifr.ifr_name, iface, IFNAMSIZ);
+       /* Actually, ifr_name is at offset 0, and in practice
+        * just giving char[IFNAMSIZ] instead of struct ifreq works too.
+        * But just in case it's not true on some obscure arch... */
+       r = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr));
+       if (r)
+               bb_perror_msg("can't bind to interface %s", iface);
+       return r;
+}
+
 
 void FAST_FUNC xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen)
 {
index bd7a177e0ea411312b5bd4c476fd3bae7fba2d2b..732fbb147cfbcf25ac71bf54d052d6e972bd6f85 100644 (file)
@@ -779,6 +779,8 @@ ForkJob(const char *user, CronLine *line, int mailFd,
                        xmove_fd(mailFd, mail_filename ? 1 : 0);
                        dup2(1, 2);
                }
+               /* crond 3.0pl1-100 puts tasks in separate process groups */
+               bb_setpgrp();
                execlp(prog, prog, cmd, arg, NULL);
                crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg);
                if (mail_filename) {
@@ -914,6 +916,8 @@ static void RunJob(const char *user, CronLine *line)
                if (DebugOpt) {
                        crondlog(LVL5 "child running %s", DEFAULT_SHELL);
                }
+               /* crond 3.0pl1-100 puts tasks in separate process groups */
+               bb_setpgrp();
                execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL);
                crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user,
                                 DEFAULT_SHELL, "-c", line->cl_Shell);
index 6d4efa9432e272ec5391c6b1c64775266d311488..ff2bc3bcef6869eacb8be7799cc97657b65e5d13 100644 (file)
@@ -19,7 +19,9 @@ enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(
 #define pointer   (G.pointer   )
 #define base      (G.base      )
 #define stack     (G.stack     )
-#define INIT_G() do { } while (0)
+#define INIT_G() do { \
+       base = 10; \
+} while (0)
 
 
 static void push(double a)
index aba32b8692c172519b3681cbafe0937303c8a6ad..021dc86ea5119a60bc829223f070e5032c5281cc 100644 (file)
@@ -322,8 +322,7 @@ int arping_main(int argc UNUSED_PARAM, char **argv)
                struct sockaddr_in saddr;
                int probe_fd = xsocket(AF_INET, SOCK_DGRAM, 0);
 
-               if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device) + 1) == -1)
-                       bb_perror_msg("cannot bind to device %s", device);
+               setsockopt_bindtodevice(probe_fd, device);
                memset(&saddr, 0, sizeof(saddr));
                saddr.sin_family = AF_INET;
                if (src.s_addr) {
index 10059c55f23dd4517d108455180a874a1adbefb8..9903c6800cb2bb53d677771a877721533a20c905 100644 (file)
@@ -31,7 +31,7 @@ static int NORETURN ip_print_help(char **argv UNUSED_PARAM)
 
 static int ip_do(int (*ip_func)(char **argv), char **argv)
 {
-       argv = ip_parse_common_args(argv);
+       argv = ip_parse_common_args(argv + 1);
        return ip_func(argv);
 }
 
index 65c27f93667c66f00705754d21b422489eda39f2..14fc6bbcc94b4ea61045cfd1abdeb7c5ad53cb99 100644 (file)
@@ -6,7 +6,6 @@
  *
  * Authors:    Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  *
- *
  * Changes:
  *
  * Rani Assaf <rani@magic.metawire.com> 980929:        resolve addresses
 #include <net/if.h>
 #include <net/if_arp.h>
 #include <asm/types.h>
+
 #ifndef __constant_htons
 #define __constant_htons htons
 #endif
-#include <linux/if_tunnel.h>
+
+// FYI: #define SIOCDEVPRIVATE 0x89F0
+
+/* From linux/if_tunnel.h. #including it proved troublesome
+ * (redefiniton errors due to name collisions in linux/ and net[inet]/) */
+#define SIOCGETTUNNEL   (SIOCDEVPRIVATE + 0)
+#define SIOCADDTUNNEL   (SIOCDEVPRIVATE + 1)
+#define SIOCDELTUNNEL   (SIOCDEVPRIVATE + 2)
+#define SIOCCHGTUNNEL   (SIOCDEVPRIVATE + 3)
+//#define SIOCGETPRL      (SIOCDEVPRIVATE + 4)
+//#define SIOCADDPRL      (SIOCDEVPRIVATE + 5)
+//#define SIOCDELPRL      (SIOCDEVPRIVATE + 6)
+//#define SIOCCHGPRL      (SIOCDEVPRIVATE + 7)
+#define GRE_CSUM        __constant_htons(0x8000)
+//#define GRE_ROUTING     __constant_htons(0x4000)
+#define GRE_KEY         __constant_htons(0x2000)
+#define GRE_SEQ         __constant_htons(0x1000)
+//#define GRE_STRICT      __constant_htons(0x0800)
+//#define GRE_REC         __constant_htons(0x0700)
+//#define GRE_FLAGS       __constant_htons(0x00F8)
+//#define GRE_VERSION     __constant_htons(0x0007)
+struct ip_tunnel_parm {
+       char            name[IFNAMSIZ];
+       int             link;
+       uint16_t        i_flags;
+       uint16_t        o_flags;
+       uint32_t        i_key;
+       uint32_t        o_key;
+       struct iphdr    iph;
+};
+/* SIT-mode i_flags */
+//#define SIT_ISATAP 0x0001
+//struct ip_tunnel_prl {
+//     uint32_t          addr;
+//     uint16_t          flags;
+//     uint16_t          __reserved;
+//     uint32_t          datalen;
+//     uint32_t          __reserved2;
+//     /* data follows */
+//};
+///* PRL flags */
+//#define PRL_DEFAULT 0x0001
 
 #include "ip_common.h"  /* #include "libbb.h" is inside */
 #include "rt_names.h"
index 01a9f9ac55317ba3cd8befe5b1c12370e7a9b8ff..f2a612fde43c5e8a8a673d731e906a12209a5a71 100644 (file)
@@ -572,7 +572,7 @@ static void ping4(len_and_sockaddr *lsa)
                xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
        }
        if (str_I)
-               setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, str_I, strlen(str_I) + 1);
+               setsockopt_bindtodevice(pingsock, str_I);
 
        /* enable broadcast pings */
        setsockopt_broadcast(pingsock);
@@ -622,7 +622,7 @@ static void ping6(len_and_sockaddr *lsa)
        if (source_lsa)
                xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
        if (str_I)
-               setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, str_I, strlen(str_I) + 1);
+               setsockopt_bindtodevice(pingsock, str_I);
 
 #ifdef ICMP6_FILTER
        {
index ea0a2c3a8d4b131339403e20823b2e97553c049d..385d5c3c0a06bc3590aea74821dab1c25f5ac90d 100644 (file)
@@ -98,8 +98,8 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf)
                bb_perror_msg_and_die("SO_BROADCAST");
 
        /* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */
-       if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &inf, strlen(inf) + 1) == -1)
-               bb_perror_msg_and_die("SO_BINDTODEVICE");
+       if (setsockopt_bindtodevice(fd, inf))
+               xfunc_die(); /* warning is already printed */
 
        memset(&addr, 0, sizeof(addr));
        addr.sin_family = AF_INET;