summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--libbb/udp_io.c17
-rw-r--r--networking/dnsd.c8
-rw-r--r--networking/interface.c2
-rw-r--r--networking/isrv_identd.c2
-rw-r--r--networking/libiproute/ip_parse_common_args.c2
-rw-r--r--procps/fuser.c6
-rw-r--r--shell/hush.c24
-rw-r--r--sysklogd/syslogd.c5
-rw-r--r--util-linux/mdev.c15
10 files changed, 51 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index 4feab0e6c..be843fc94 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 1 1VERSION = 1
2PATCHLEVEL = 10 2PATCHLEVEL = 10
3SUBLEVEL = 2 3SUBLEVEL = 3
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Unnamed 5NAME = Unnamed
6 6
diff --git a/libbb/udp_io.c b/libbb/udp_io.c
index e968ecb66..bde4d779f 100644
--- a/libbb/udp_io.c
+++ b/libbb/udp_io.c
@@ -36,11 +36,12 @@ send_to_from(int fd, void *buf, size_t len, int flags,
36#else 36#else
37 struct iovec iov[1]; 37 struct iovec iov[1];
38 struct msghdr msg; 38 struct msghdr msg;
39 char cbuf[sizeof(struct in_pktinfo) 39 union {
40 char cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))];
40#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO) 41#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
41 | sizeof(struct in6_pktinfo) /* (a|b) is poor man's max(a,b) */ 42 char cmsg6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
42#endif 43#endif
43 ]; 44 } u;
44 struct cmsghdr* cmsgptr; 45 struct cmsghdr* cmsgptr;
45 46
46 if (from->sa_family != AF_INET 47 if (from->sa_family != AF_INET
@@ -57,15 +58,15 @@ send_to_from(int fd, void *buf, size_t len, int flags,
57 iov[0].iov_base = buf; 58 iov[0].iov_base = buf;
58 iov[0].iov_len = len; 59 iov[0].iov_len = len;
59 60
60 memset(cbuf, 0, sizeof(cbuf)); 61 memset(&u, 0, sizeof(u));
61 62
62 memset(&msg, 0, sizeof(msg)); 63 memset(&msg, 0, sizeof(msg));
63 msg.msg_name = (void *)(struct sockaddr *)to; /* or compiler will annoy us */ 64 msg.msg_name = (void *)(struct sockaddr *)to; /* or compiler will annoy us */
64 msg.msg_namelen = tolen; 65 msg.msg_namelen = tolen;
65 msg.msg_iov = iov; 66 msg.msg_iov = iov;
66 msg.msg_iovlen = 1; 67 msg.msg_iovlen = 1;
67 msg.msg_control = cbuf; 68 msg.msg_control = &u;
68 msg.msg_controllen = sizeof(cbuf); 69 msg.msg_controllen = sizeof(u);
69 msg.msg_flags = flags; 70 msg.msg_flags = flags;
70 71
71 cmsgptr = CMSG_FIRSTHDR(&msg); 72 cmsgptr = CMSG_FIRSTHDR(&msg);
@@ -89,6 +90,8 @@ send_to_from(int fd, void *buf, size_t len, int flags,
89 pktptr->ipi6_addr = ((struct sockaddr_in6*)from)->sin6_addr; 90 pktptr->ipi6_addr = ((struct sockaddr_in6*)from)->sin6_addr;
90 } 91 }
91#endif 92#endif
93 msg.msg_controllen = cmsgptr->cmsg_len;
94
92 return sendmsg(fd, &msg, flags); 95 return sendmsg(fd, &msg, flags);
93#endif 96#endif
94} 97}
@@ -109,7 +112,9 @@ recv_from_to(int fd, void *buf, size_t len, int flags,
109 struct iovec iov[1]; 112 struct iovec iov[1];
110 union { 113 union {
111 char cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))]; 114 char cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))];
115#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
112 char cmsg6[CMSG_SPACE(sizeof(struct in6_pktinfo))]; 116 char cmsg6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
117#endif
113 } u; 118 } u;
114 struct cmsghdr *cmsgptr; 119 struct cmsghdr *cmsgptr;
115 struct msghdr msg; 120 struct msghdr msg;
diff --git a/networking/dnsd.c b/networking/dnsd.c
index cb62d2081..97ba2dc6a 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -194,7 +194,8 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
194 for (i = 1; i <= (int)(d->name[0]); i++) 194 for (i = 1; i <= (int)(d->name[0]); i++)
195 if (tolower(qs[i]) != d->name[i]) 195 if (tolower(qs[i]) != d->name[i])
196 break; 196 break;
197 if (i > (int)(d->name[0])) { 197 if (i > (int)(d->name[0]) ||
198 (d->name[0] == 1 && d->name[1] == '*')) {
198 strcpy((char *)as, d->ip); 199 strcpy((char *)as, d->ip);
199#if DEBUG 200#if DEBUG
200 fprintf(stderr, " OK as:%s\n", as); 201 fprintf(stderr, " OK as:%s\n", as);
@@ -202,7 +203,8 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
202 return 0; 203 return 0;
203 } 204 }
204 } else if (type == REQ_PTR) { /* search by IP-address */ 205 } else if (type == REQ_PTR) { /* search by IP-address */
205 if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) { 206 if ((d->name[0] != 1 || d->name[1] != '*') &&
207 !strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) {
206 strcpy((char *)as, d->name); 208 strcpy((char *)as, d->name);
207 return 0; 209 return 0;
208 } 210 }
@@ -401,7 +403,7 @@ int dnsd_main(int argc ATTRIBUTE_UNUSED, char **argv)
401 r = process_packet(buf); 403 r = process_packet(buf);
402 if (r <= 0) 404 if (r <= 0)
403 continue; 405 continue;
404 send_to_from(udps, buf, r, 0, &to->u.sa, &from->u.sa, lsa->len); 406 send_to_from(udps, buf, r, 0, &from->u.sa, &to->u.sa, lsa->len);
405 } 407 }
406 return 0; 408 return 0;
407} 409}
diff --git a/networking/interface.c b/networking/interface.c
index 44bd8d3d9..cdd31da64 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -223,7 +223,7 @@ static char *UNSPEC_print(unsigned char *ptr)
223 char *pos; 223 char *pos;
224 unsigned int i; 224 unsigned int i;
225 225
226 if (!buff); 226 if (!buff)
227 buff = xmalloc(sizeof(struct sockaddr) * 3 + 1); 227 buff = xmalloc(sizeof(struct sockaddr) * 3 + 1);
228 pos = buff; 228 pos = buff;
229 for (i = 0; i < sizeof(struct sockaddr); i++) { 229 for (i = 0; i < sizeof(struct sockaddr); i++) {
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index d60c9fbaf..a96ac6041 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -113,7 +113,7 @@ int fakeidentd_main(int argc ATTRIBUTE_UNUSED, char **argv)
113 strncpy(bogouser, argv[optind], sizeof(bogouser)); 113 strncpy(bogouser, argv[optind], sizeof(bogouser));
114 114
115 /* Daemonize if no -f and no -i and no -w */ 115 /* Daemonize if no -f and no -i and no -w */
116 if (!(opt & OPT_fiw)); 116 if (!(opt & OPT_fiw))
117 bb_daemonize_or_rexec(0, argv); 117 bb_daemonize_or_rexec(0, argv);
118 118
119 /* Where to log in inetd modes? "Classic" inetd 119 /* Where to log in inetd modes? "Classic" inetd
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c
index 294bde540..5e4012b81 100644
--- a/networking/libiproute/ip_parse_common_args.c
+++ b/networking/libiproute/ip_parse_common_args.c
@@ -54,7 +54,7 @@ char **ip_parse_common_args(char **argv)
54 break; 54 break;
55 } 55 }
56 } 56 }
57 arg = index_in_strings(ip_common_commands, opt); 57 arg = index_in_substrings(ip_common_commands, opt);
58 if (arg < 0) 58 if (arg < 0)
59 bb_show_usage(); 59 bb_show_usage();
60 if (arg == ARG_oneline) { 60 if (arg == ARG_oneline) {
diff --git a/procps/fuser.c b/procps/fuser.c
index fd876d559..55f7917a0 100644
--- a/procps/fuser.c
+++ b/procps/fuser.c
@@ -208,6 +208,7 @@ static pid_list *scan_dir_links(const char *dname, pid_t pid,
208 return plist; 208 return plist;
209} 209}
210 210
211/* NB: does chdir internally */
211static pid_list *scan_proc_pids(inode_list *ilist) 212static pid_list *scan_proc_pids(inode_list *ilist)
212{ 213{
213 DIR *d; 214 DIR *d;
@@ -215,7 +216,8 @@ static pid_list *scan_proc_pids(inode_list *ilist)
215 pid_t pid; 216 pid_t pid;
216 pid_list *plist; 217 pid_list *plist;
217 218
218 d = opendir("."); 219 xchdir("/proc");
220 d = opendir("/proc");
219 if (!d) 221 if (!d)
220 return NULL; 222 return NULL;
221 223
@@ -329,7 +331,7 @@ Find processes which use FILEs or PORTs
329 pp++; 331 pp++;
330 } 332 }
331 333
332 plist = scan_proc_pids(ilist); 334 plist = scan_proc_pids(ilist); /* changes dir to "/proc" */
333 335
334 if (!plist) 336 if (!plist)
335 return EXIT_FAILURE; 337 return EXIT_FAILURE;
diff --git a/shell/hush.c b/shell/hush.c
index 4e6d50094..dcaeed0d7 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -699,9 +699,18 @@ static const struct built_in_command bltins[] = {
699 BLTIN(NULL, NULL, NULL) 699 BLTIN(NULL, NULL, NULL)
700}; 700};
701 701
702/* Signals are grouped, we handle them in batches */
703static void set_misc_sighandler(void (*handler)(int))
704{
705 bb_signals(0
706 + (1 << SIGINT)
707 + (1 << SIGQUIT)
708 + (1 << SIGTERM)
709 , handler);
710}
711
702#if ENABLE_HUSH_JOB 712#if ENABLE_HUSH_JOB
703 713
704/* Signals are grouped, we handle them in batches */
705static void set_fatal_sighandler(void (*handler)(int)) 714static void set_fatal_sighandler(void (*handler)(int))
706{ 715{
707 bb_signals(0 716 bb_signals(0
@@ -725,14 +734,6 @@ static void set_jobctrl_sighandler(void (*handler)(int))
725 + (1 << SIGTTOU) 734 + (1 << SIGTTOU)
726 , handler); 735 , handler);
727} 736}
728static void set_misc_sighandler(void (*handler)(int))
729{
730 bb_signals(0
731 + (1 << SIGINT)
732 + (1 << SIGQUIT)
733 + (1 << SIGTERM)
734 , handler);
735}
736/* SIGCHLD is special and handled separately */ 737/* SIGCHLD is special and handled separately */
737 738
738static void set_every_sighandler(void (*handler)(int)) 739static void set_every_sighandler(void (*handler)(int))
@@ -815,7 +816,6 @@ static void hush_exit(int exitcode)
815 816
816#define set_fatal_sighandler(handler) ((void)0) 817#define set_fatal_sighandler(handler) ((void)0)
817#define set_jobctrl_sighandler(handler) ((void)0) 818#define set_jobctrl_sighandler(handler) ((void)0)
818#define set_misc_sighandler(handler) ((void)0)
819#define hush_exit(e) exit(e) 819#define hush_exit(e) exit(e)
820 820
821#endif /* JOB */ 821#endif /* JOB */
@@ -3907,8 +3907,10 @@ int hush_main(int argc, char **argv)
3907 /* give up */ 3907 /* give up */
3908 interactive_fd = 0; 3908 interactive_fd = 0;
3909 } 3909 }
3910 if (interactive_fd) 3910 if (interactive_fd) {
3911 fcntl(interactive_fd, F_SETFD, FD_CLOEXEC); 3911 fcntl(interactive_fd, F_SETFD, FD_CLOEXEC);
3912 set_misc_sighandler(SIG_IGN);
3913 }
3912 } 3914 }
3913#endif 3915#endif
3914 3916
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 371b5588f..5f3ac2c2f 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -347,10 +347,11 @@ static void log_locally(time_t now, char *msg)
347 sprintf(newFile, "%s.%d", G.logFilePath, i); 347 sprintf(newFile, "%s.%d", G.logFilePath, i);
348 if (i == 0) break; 348 if (i == 0) break;
349 sprintf(oldFile, "%s.%d", G.logFilePath, --i); 349 sprintf(oldFile, "%s.%d", G.logFilePath, --i);
350 xrename(oldFile, newFile); 350 /* ignore errors - file might be missing */
351 rename(oldFile, newFile);
351 } 352 }
352 /* newFile == "f.0" now */ 353 /* newFile == "f.0" now */
353 xrename(G.logFilePath, newFile); 354 rename(G.logFilePath, newFile);
354 fl.l_type = F_UNLCK; 355 fl.l_type = F_UNLCK;
355 fcntl(G.logFD, F_SETLKW, &fl); 356 fcntl(G.logFD, F_SETLKW, &fl);
356 close(G.logFD); 357 close(G.logFD);
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index f0a885482..2341a5a67 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -72,8 +72,14 @@ static void make_device(char *path, int delete)
72 /* Determine device name, type, major and minor */ 72 /* Determine device name, type, major and minor */
73 device_name = bb_basename(path); 73 device_name = bb_basename(path);
74 /* http://kernel.org/doc/pending/hotplug.txt says that only 74 /* http://kernel.org/doc/pending/hotplug.txt says that only
75 * "/sys/block/..." is for block devices. "sys/bus" etc is not! */ 75 * "/sys/block/..." is for block devices. "/sys/bus" etc is not!
76 type = (strncmp(&path[5], "block/", 6) == 0 ? S_IFBLK : S_IFCHR); 76 * Since kernel 2.6.25 block devices are also in /sys/class/block. */
77 /* TODO: would it be acceptable to just use strstr(path, "/block/")? */
78 if (strncmp(&path[5], "class/block/"+6, 6) != 0
79 && strncmp(&path[5], "class/block/", 12) != 0)
80 type = S_IFCHR;
81 else
82 type = S_IFBLK;
77 83
78 if (ENABLE_FEATURE_MDEV_CONF) { 84 if (ENABLE_FEATURE_MDEV_CONF) {
79 FILE *fp; 85 FILE *fp;
@@ -172,8 +178,9 @@ static void make_device(char *path, int delete)
172 /* substitute %1..9 with off[1..9], if any */ 178 /* substitute %1..9 with off[1..9], if any */
173 n = 0; 179 n = 0;
174 s = val; 180 s = val;
175 while (*s && *s++ == '%') 181 while (*s)
176 n++; 182 if (*s++ == '%')
183 n++;
177 184
178 p = alias = xzalloc(strlen(val) + n * strlen(device_name)); 185 p = alias = xzalloc(strlen(val) + n * strlen(device_name));
179 s = val + 1; 186 s = val + 1;