summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--coreutils/printf.c9
-rw-r--r--include/libbb.h1
-rw-r--r--init/init.c14
-rw-r--r--libbb/xconnect.c15
-rw-r--r--miscutils/crond.c4
-rw-r--r--miscutils/dc.c4
-rw-r--r--networking/arping.c3
-rw-r--r--networking/ip.c2
-rw-r--r--networking/libiproute/iptunnel.c45
-rw-r--r--networking/ping.c4
-rw-r--r--networking/udhcp/socket.c4
12 files changed, 88 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index a7934c8b2..a2b2b015b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 1 1VERSION = 1
2PATCHLEVEL = 13 2PATCHLEVEL = 13
3SUBLEVEL = 1 3SUBLEVEL = 2
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Unnamed 5NAME = Unnamed
6 6
diff --git a/coreutils/printf.c b/coreutils/printf.c
index 76524f706..b0a48cda4 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -359,8 +359,15 @@ int printf_main(int argc UNUSED_PARAM, char **argv)
359 * We will mimic coreutils. */ 359 * We will mimic coreutils. */
360 if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2]) 360 if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2])
361 argv++; 361 argv++;
362 if (!argv[1]) 362 if (!argv[1]) {
363 if (ENABLE_ASH_BUILTIN_PRINTF
364 && applet_name[0] != 'p'
365 ) {
366 bb_error_msg("usage: printf FORMAT [ARGUMENT...]");
367 return 2; /* bash compat */
368 }
363 bb_show_usage(); 369 bb_show_usage();
370 }
364 371
365 format = argv[1]; 372 format = argv[1];
366 argv2 = argv + 2; 373 argv2 = argv + 2;
diff --git a/include/libbb.h b/include/libbb.h
index b0f6eaee2..9e0399eee 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -437,6 +437,7 @@ ssize_t xsendto(int s, const void *buf, size_t len, const struct sockaddr *to,
437 * Turn it on before you call bind(). */ 437 * Turn it on before you call bind(). */
438void setsockopt_reuseaddr(int fd) FAST_FUNC; /* On Linux this never fails. */ 438void setsockopt_reuseaddr(int fd) FAST_FUNC; /* On Linux this never fails. */
439int setsockopt_broadcast(int fd) FAST_FUNC; 439int setsockopt_broadcast(int fd) FAST_FUNC;
440int setsockopt_bindtodevice(int fd, const char *iface) FAST_FUNC;
440/* NB: returns port in host byte order */ 441/* NB: returns port in host byte order */
441unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port) FAST_FUNC; 442unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port) FAST_FUNC;
442typedef struct len_and_sockaddr { 443typedef struct len_and_sockaddr {
diff --git a/init/init.c b/init/init.c
index 1caf45b8d..10f5ba68d 100644
--- a/init/init.c
+++ b/init/init.c
@@ -118,18 +118,18 @@ static void message(int where, const char *fmt, ...)
118 118
119 msg[0] = '\r'; 119 msg[0] = '\r';
120 va_start(arguments, fmt); 120 va_start(arguments, fmt);
121 l = vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments); 121 l = 1 + vsnprintf(msg + 1, sizeof(msg) - 2, fmt, arguments);
122 if (l > sizeof(msg) - 2) 122 if (l > sizeof(msg) - 1)
123 l = sizeof(msg) - 2; 123 l = sizeof(msg) - 1;
124 msg[l] = '\0'; 124 msg[l] = '\0';
125 va_end(arguments); 125 va_end(arguments);
126 126
127 if (ENABLE_FEATURE_INIT_SYSLOG) { 127 if (ENABLE_FEATURE_INIT_SYSLOG) {
128 /* Log the message to syslogd */
129 if (where & L_LOG) { 128 if (where & L_LOG) {
130 /* don't print out "\r" */ 129 /* Log the message to syslogd */
131 openlog(applet_name, 0, LOG_DAEMON); 130 openlog("init", 0, LOG_DAEMON);
132 syslog(LOG_INFO, "init: %s", msg + 1); 131 /* don't print "\r" */
132 syslog(LOG_INFO, "%s", msg + 1);
133 closelog(); 133 closelog();
134 } 134 }
135 msg[l++] = '\n'; 135 msg[l++] = '\n';
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index d48c50339..27c7424b6 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <netinet/in.h> 9#include <netinet/in.h>
10#include <net/if.h>
10#include "libbb.h" 11#include "libbb.h"
11 12
12void FAST_FUNC setsockopt_reuseaddr(int fd) 13void FAST_FUNC setsockopt_reuseaddr(int fd)
@@ -17,6 +18,20 @@ int FAST_FUNC setsockopt_broadcast(int fd)
17{ 18{
18 return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1)); 19 return setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_1, sizeof(const_int_1));
19} 20}
21int FAST_FUNC setsockopt_bindtodevice(int fd, const char *iface)
22{
23 int r;
24 struct ifreq ifr;
25 strncpy(ifr.ifr_name, iface, IFNAMSIZ);
26 /* Actually, ifr_name is at offset 0, and in practice
27 * just giving char[IFNAMSIZ] instead of struct ifreq works too.
28 * But just in case it's not true on some obscure arch... */
29 r = setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr));
30 if (r)
31 bb_perror_msg("can't bind to interface %s", iface);
32 return r;
33}
34
20 35
21void FAST_FUNC xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen) 36void FAST_FUNC xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen)
22{ 37{
diff --git a/miscutils/crond.c b/miscutils/crond.c
index bd7a177e0..732fbb147 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -779,6 +779,8 @@ ForkJob(const char *user, CronLine *line, int mailFd,
779 xmove_fd(mailFd, mail_filename ? 1 : 0); 779 xmove_fd(mailFd, mail_filename ? 1 : 0);
780 dup2(1, 2); 780 dup2(1, 2);
781 } 781 }
782 /* crond 3.0pl1-100 puts tasks in separate process groups */
783 bb_setpgrp();
782 execlp(prog, prog, cmd, arg, NULL); 784 execlp(prog, prog, cmd, arg, NULL);
783 crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg); 785 crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, prog, cmd, arg);
784 if (mail_filename) { 786 if (mail_filename) {
@@ -914,6 +916,8 @@ static void RunJob(const char *user, CronLine *line)
914 if (DebugOpt) { 916 if (DebugOpt) {
915 crondlog(LVL5 "child running %s", DEFAULT_SHELL); 917 crondlog(LVL5 "child running %s", DEFAULT_SHELL);
916 } 918 }
919 /* crond 3.0pl1-100 puts tasks in separate process groups */
920 bb_setpgrp();
917 execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL); 921 execl(DEFAULT_SHELL, DEFAULT_SHELL, "-c", line->cl_Shell, NULL);
918 crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user, 922 crondlog(ERR20 "can't exec, user %s cmd %s %s %s", user,
919 DEFAULT_SHELL, "-c", line->cl_Shell); 923 DEFAULT_SHELL, "-c", line->cl_Shell);
diff --git a/miscutils/dc.c b/miscutils/dc.c
index 6d4efa943..ff2bc3bce 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -19,7 +19,9 @@ enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(
19#define pointer (G.pointer ) 19#define pointer (G.pointer )
20#define base (G.base ) 20#define base (G.base )
21#define stack (G.stack ) 21#define stack (G.stack )
22#define INIT_G() do { } while (0) 22#define INIT_G() do { \
23 base = 10; \
24} while (0)
23 25
24 26
25static void push(double a) 27static void push(double a)
diff --git a/networking/arping.c b/networking/arping.c
index aba32b869..021dc86ea 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -322,8 +322,7 @@ int arping_main(int argc UNUSED_PARAM, char **argv)
322 struct sockaddr_in saddr; 322 struct sockaddr_in saddr;
323 int probe_fd = xsocket(AF_INET, SOCK_DGRAM, 0); 323 int probe_fd = xsocket(AF_INET, SOCK_DGRAM, 0);
324 324
325 if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device) + 1) == -1) 325 setsockopt_bindtodevice(probe_fd, device);
326 bb_perror_msg("cannot bind to device %s", device);
327 memset(&saddr, 0, sizeof(saddr)); 326 memset(&saddr, 0, sizeof(saddr));
328 saddr.sin_family = AF_INET; 327 saddr.sin_family = AF_INET;
329 if (src.s_addr) { 328 if (src.s_addr) {
diff --git a/networking/ip.c b/networking/ip.c
index 10059c55f..9903c6800 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -31,7 +31,7 @@ static int NORETURN ip_print_help(char **argv UNUSED_PARAM)
31 31
32static int ip_do(int (*ip_func)(char **argv), char **argv) 32static int ip_do(int (*ip_func)(char **argv), char **argv)
33{ 33{
34 argv = ip_parse_common_args(argv); 34 argv = ip_parse_common_args(argv + 1);
35 return ip_func(argv); 35 return ip_func(argv);
36} 36}
37 37
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index 65c27f936..14fc6bbcc 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 7 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
8 * 8 *
9 *
10 * Changes: 9 * Changes:
11 * 10 *
12 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses 11 * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
@@ -18,10 +17,52 @@
18#include <net/if.h> 17#include <net/if.h>
19#include <net/if_arp.h> 18#include <net/if_arp.h>
20#include <asm/types.h> 19#include <asm/types.h>
20
21#ifndef __constant_htons 21#ifndef __constant_htons
22#define __constant_htons htons 22#define __constant_htons htons
23#endif 23#endif
24#include <linux/if_tunnel.h> 24
25// FYI: #define SIOCDEVPRIVATE 0x89F0
26
27/* From linux/if_tunnel.h. #including it proved troublesome
28 * (redefiniton errors due to name collisions in linux/ and net[inet]/) */
29#define SIOCGETTUNNEL (SIOCDEVPRIVATE + 0)
30#define SIOCADDTUNNEL (SIOCDEVPRIVATE + 1)
31#define SIOCDELTUNNEL (SIOCDEVPRIVATE + 2)
32#define SIOCCHGTUNNEL (SIOCDEVPRIVATE + 3)
33//#define SIOCGETPRL (SIOCDEVPRIVATE + 4)
34//#define SIOCADDPRL (SIOCDEVPRIVATE + 5)
35//#define SIOCDELPRL (SIOCDEVPRIVATE + 6)
36//#define SIOCCHGPRL (SIOCDEVPRIVATE + 7)
37#define GRE_CSUM __constant_htons(0x8000)
38//#define GRE_ROUTING __constant_htons(0x4000)
39#define GRE_KEY __constant_htons(0x2000)
40#define GRE_SEQ __constant_htons(0x1000)
41//#define GRE_STRICT __constant_htons(0x0800)
42//#define GRE_REC __constant_htons(0x0700)
43//#define GRE_FLAGS __constant_htons(0x00F8)
44//#define GRE_VERSION __constant_htons(0x0007)
45struct ip_tunnel_parm {
46 char name[IFNAMSIZ];
47 int link;
48 uint16_t i_flags;
49 uint16_t o_flags;
50 uint32_t i_key;
51 uint32_t o_key;
52 struct iphdr iph;
53};
54/* SIT-mode i_flags */
55//#define SIT_ISATAP 0x0001
56//struct ip_tunnel_prl {
57// uint32_t addr;
58// uint16_t flags;
59// uint16_t __reserved;
60// uint32_t datalen;
61// uint32_t __reserved2;
62// /* data follows */
63//};
64///* PRL flags */
65//#define PRL_DEFAULT 0x0001
25 66
26#include "ip_common.h" /* #include "libbb.h" is inside */ 67#include "ip_common.h" /* #include "libbb.h" is inside */
27#include "rt_names.h" 68#include "rt_names.h"
diff --git a/networking/ping.c b/networking/ping.c
index 01a9f9ac5..f2a612fde 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -572,7 +572,7 @@ static void ping4(len_and_sockaddr *lsa)
572 xbind(pingsock, &source_lsa->u.sa, source_lsa->len); 572 xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
573 } 573 }
574 if (str_I) 574 if (str_I)
575 setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, str_I, strlen(str_I) + 1); 575 setsockopt_bindtodevice(pingsock, str_I);
576 576
577 /* enable broadcast pings */ 577 /* enable broadcast pings */
578 setsockopt_broadcast(pingsock); 578 setsockopt_broadcast(pingsock);
@@ -622,7 +622,7 @@ static void ping6(len_and_sockaddr *lsa)
622 if (source_lsa) 622 if (source_lsa)
623 xbind(pingsock, &source_lsa->u.sa, source_lsa->len); 623 xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
624 if (str_I) 624 if (str_I)
625 setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, str_I, strlen(str_I) + 1); 625 setsockopt_bindtodevice(pingsock, str_I);
626 626
627#ifdef ICMP6_FILTER 627#ifdef ICMP6_FILTER
628 { 628 {
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index ea0a2c3a8..385d5c3c0 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -98,8 +98,8 @@ int FAST_FUNC udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf)
98 bb_perror_msg_and_die("SO_BROADCAST"); 98 bb_perror_msg_and_die("SO_BROADCAST");
99 99
100 /* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */ 100 /* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */
101 if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &inf, strlen(inf) + 1) == -1) 101 if (setsockopt_bindtodevice(fd, inf))
102 bb_perror_msg_and_die("SO_BINDTODEVICE"); 102 xfunc_die(); /* warning is already printed */
103 103
104 memset(&addr, 0, sizeof(addr)); 104 memset(&addr, 0, sizeof(addr));
105 addr.sin_family = AF_INET; 105 addr.sin_family = AF_INET;