Apply post 1.13.1 patches, bump to 1.13.2

diff --git a/Makefile b/Makefile
index a7934c8..a2b2b01 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 1
 PATCHLEVEL = 13
-SUBLEVEL = 1
+SUBLEVEL = 2
 EXTRAVERSION =
 NAME = Unnamed
 
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 76524f7..b0a48cd 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -359,8 +359,15 @@
 	 * 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;
diff --git a/include/libbb.h b/include/libbb.h
index b0f6eae..9e0399e 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -437,6 +437,7 @@
  * 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 {
diff --git a/init/init.c b/init/init.c
index 1caf45b..10f5ba6 100644
--- a/init/init.c
+++ b/init/init.c
@@ -118,18 +118,18 @@
 
 	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';
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index d48c503..27c7424 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -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 @@
 {
 	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)
 {
diff --git a/miscutils/crond.c b/miscutils/crond.c
index bd7a177..732fbb1 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -779,6 +779,8 @@
 			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 @@
 		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);
diff --git a/miscutils/dc.c b/miscutils/dc.c
index 6d4efa9..ff2bc3b 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -19,7 +19,9 @@
 #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)
diff --git a/networking/arping.c b/networking/arping.c
index aba32b8..021dc86 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -322,8 +322,7 @@
 		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) {
diff --git a/networking/ip.c b/networking/ip.c
index 10059c5..9903c68 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -31,7 +31,7 @@
 
 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);
 }
 
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index 65c27f9..14fc6bb 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -6,7 +6,6 @@
  *
  * Authors:	Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  *
- *
  * Changes:
  *
  * Rani Assaf <rani@magic.metawire.com> 980929:	resolve addresses
@@ -18,10 +17,52 @@
 #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"
diff --git a/networking/ping.c b/networking/ping.c
index 01a9f9a..f2a612f 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -572,7 +572,7 @@
 		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 @@
 	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
 	{
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index ea0a2c3..385d5c3 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -98,8 +98,8 @@
 		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;