Apply post 1.13.1 patches, bump to 1.13.2

1_13_stable 1_13_2
Denis Vlasenko 2008-12-31 03:33:50 +00:00
parent ccdc13d306
commit 15c0b72584
12 changed files with 88 additions and 19 deletions

View File

@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 13
SUBLEVEL = 1
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed

View 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;

View 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 {

View 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';

View 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)
{

View 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);

View 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)

View 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) {

View 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);
}

View File

@ -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"

View 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
{

View 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;