Apply post-1.10.2 fixes, bump version to 1.10.3 1_10_3
authorDenis Vlasenko <vda.linux@googlemail.com>
Thu, 5 Jun 2008 01:10:03 +0000 (01:10 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Thu, 5 Jun 2008 01:10:03 +0000 (01:10 -0000)
Makefile
libbb/udp_io.c
networking/dnsd.c
networking/interface.c
networking/isrv_identd.c
networking/libiproute/ip_parse_common_args.c
procps/fuser.c
shell/hush.c
sysklogd/syslogd.c
util-linux/mdev.c

index 4feab0e6cb0e804ef769c2e76f9a1f82952accd6..be843fc94de6b6cfa2e21440b84bf52570671e9c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 1
 PATCHLEVEL = 10
-SUBLEVEL = 2
+SUBLEVEL = 3
 EXTRAVERSION =
 NAME = Unnamed
 
index e968ecb6600b177be9c78cec2b63aeaf51ba7a72..bde4d779f3c2977aad414674d23d62f4f5ff449e 100644 (file)
@@ -36,11 +36,12 @@ send_to_from(int fd, void *buf, size_t len, int flags,
 #else
        struct iovec iov[1];
        struct msghdr msg;
-       char cbuf[sizeof(struct in_pktinfo)
+       union {
+               char cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))];
 #if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
-               | sizeof(struct in6_pktinfo) /* (a|b) is poor man's max(a,b) */
+               char cmsg6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
 #endif
-       ];
+       } u;
        struct cmsghdr* cmsgptr;
 
        if (from->sa_family != AF_INET
@@ -57,15 +58,15 @@ send_to_from(int fd, void *buf, size_t len, int flags,
        iov[0].iov_base = buf;
        iov[0].iov_len = len;
 
-       memset(cbuf, 0, sizeof(cbuf));
+       memset(&u, 0, sizeof(u));
 
        memset(&msg, 0, sizeof(msg));
        msg.msg_name = (void *)(struct sockaddr *)to; /* or compiler will annoy us */
        msg.msg_namelen = tolen;
        msg.msg_iov = iov;
        msg.msg_iovlen = 1;
-       msg.msg_control = cbuf;
-       msg.msg_controllen = sizeof(cbuf);
+       msg.msg_control = &u;
+       msg.msg_controllen = sizeof(u);
        msg.msg_flags = flags;
 
        cmsgptr = CMSG_FIRSTHDR(&msg);
@@ -89,6 +90,8 @@ send_to_from(int fd, void *buf, size_t len, int flags,
                pktptr->ipi6_addr = ((struct sockaddr_in6*)from)->sin6_addr;
        }
 #endif
+       msg.msg_controllen = cmsgptr->cmsg_len;
+
        return sendmsg(fd, &msg, flags);
 #endif
 }
@@ -109,7 +112,9 @@ recv_from_to(int fd, void *buf, size_t len, int flags,
        struct iovec iov[1];
        union {
                char cmsg[CMSG_SPACE(sizeof(struct in_pktinfo))];
+#if ENABLE_FEATURE_IPV6 && defined(IPV6_PKTINFO)
                char cmsg6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+#endif
        } u;
        struct cmsghdr *cmsgptr;
        struct msghdr msg;
index cb62d2081ed5268af4770911e6cf0f8b4bde72b0..97ba2dc6afb2c07d9fca80710709c6d624e603f5 100644 (file)
@@ -194,7 +194,8 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
                        for (i = 1; i <= (int)(d->name[0]); i++)
                                if (tolower(qs[i]) != d->name[i])
                                        break;
-                       if (i > (int)(d->name[0])) {
+                       if (i > (int)(d->name[0]) ||
+                           (d->name[0] == 1 && d->name[1] == '*')) {
                                strcpy((char *)as, d->ip);
 #if DEBUG
                                fprintf(stderr, " OK as:%s\n", as);
@@ -202,7 +203,8 @@ static int table_lookup(uint16_t type, uint8_t * as, uint8_t * qs)
                                return 0;
                        }
                } else if (type == REQ_PTR) { /* search by IP-address */
-                       if (!strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) {
+                       if ((d->name[0] != 1 || d->name[1] != '*') &&
+                           !strncmp((char*)&d->rip[1], (char*)&qs[1], strlen(d->rip)-1)) {
                                strcpy((char *)as, d->name);
                                return 0;
                        }
@@ -401,7 +403,7 @@ int dnsd_main(int argc ATTRIBUTE_UNUSED, char **argv)
                r = process_packet(buf);
                if (r <= 0)
                        continue;
-               send_to_from(udps, buf, r, 0, &to->u.sa, &from->u.sa, lsa->len);
+               send_to_from(udps, buf, r, 0, &from->u.sa, &to->u.sa, lsa->len);
        }
        return 0;
 }
index 44bd8d3d9fda3016df1bf30af41a34b3803d0660..cdd31da646d27c22866efbab8486f3752b70a790 100644 (file)
@@ -223,7 +223,7 @@ static char *UNSPEC_print(unsigned char *ptr)
        char *pos;
        unsigned int i;
 
-       if (!buff);
+       if (!buff)
                buff = xmalloc(sizeof(struct sockaddr) * 3 + 1);
        pos = buff;
        for (i = 0; i < sizeof(struct sockaddr); i++) {
index d60c9fbafb09f5156e683aecf6fcfc5adb1dd2d9..a96ac6041f1979e4f3d76e79a411def3f6fc96fb 100644 (file)
@@ -113,7 +113,7 @@ int fakeidentd_main(int argc ATTRIBUTE_UNUSED, char **argv)
                strncpy(bogouser, argv[optind], sizeof(bogouser));
 
        /* Daemonize if no -f and no -i and no -w */
-       if (!(opt & OPT_fiw));
+       if (!(opt & OPT_fiw))
                bb_daemonize_or_rexec(0, argv);
 
        /* Where to log in inetd modes? "Classic" inetd
index 294bde5401bfc377e01345114ce7e76ddb7b5364..5e4012b81e9999a70cb89c70b9c8c13c4522bc5a 100644 (file)
@@ -54,7 +54,7 @@ char **ip_parse_common_args(char **argv)
                                break;
                        }
                }
-               arg = index_in_strings(ip_common_commands, opt);
+               arg = index_in_substrings(ip_common_commands, opt);
                if (arg < 0)
                        bb_show_usage();
                if (arg == ARG_oneline) {
index fd876d5599408b87b84b3489de19bbe52fa61d46..55f7917a08ba459baf3ed2588487466f27afbd81 100644 (file)
@@ -208,6 +208,7 @@ static pid_list *scan_dir_links(const char *dname, pid_t pid,
        return plist;
 }
 
+/* NB: does chdir internally */
 static pid_list *scan_proc_pids(inode_list *ilist)
 {
        DIR *d;
@@ -215,7 +216,8 @@ static pid_list *scan_proc_pids(inode_list *ilist)
        pid_t pid;
        pid_list *plist;
 
-       d = opendir(".");
+       xchdir("/proc");
+       d = opendir("/proc");
        if (!d)
                return NULL;
 
@@ -329,7 +331,7 @@ Find processes which use FILEs or PORTs
                pp++;
        }
 
-       plist = scan_proc_pids(ilist);
+       plist = scan_proc_pids(ilist); /* changes dir to "/proc" */
 
        if (!plist)
                return EXIT_FAILURE;
index 4e6d5009428b77f70e84bbcf7f6cc49bc39d25e9..dcaeed0d72979de8091fd23466d9e51ae03fa1c5 100644 (file)
@@ -699,9 +699,18 @@ static const struct built_in_command bltins[] = {
        BLTIN(NULL, NULL, NULL)
 };
 
+/* Signals are grouped, we handle them in batches */
+static void set_misc_sighandler(void (*handler)(int))
+{
+       bb_signals(0
+               + (1 << SIGINT)
+               + (1 << SIGQUIT)
+               + (1 << SIGTERM)
+               , handler);
+}
+
 #if ENABLE_HUSH_JOB
 
-/* Signals are grouped, we handle them in batches */
 static void set_fatal_sighandler(void (*handler)(int))
 {
        bb_signals(0
@@ -725,14 +734,6 @@ static void set_jobctrl_sighandler(void (*handler)(int))
                + (1 << SIGTTOU)
                , handler);
 }
-static void set_misc_sighandler(void (*handler)(int))
-{
-       bb_signals(0
-               + (1 << SIGINT)
-               + (1 << SIGQUIT)
-               + (1 << SIGTERM)
-               , handler);
-}
 /* SIGCHLD is special and handled separately */
 
 static void set_every_sighandler(void (*handler)(int))
@@ -815,7 +816,6 @@ static void hush_exit(int exitcode)
 
 #define set_fatal_sighandler(handler)   ((void)0)
 #define set_jobctrl_sighandler(handler) ((void)0)
-#define set_misc_sighandler(handler)    ((void)0)
 #define hush_exit(e)                    exit(e)
 
 #endif /* JOB */
@@ -3907,8 +3907,10 @@ int hush_main(int argc, char **argv)
                                /* give up */
                                interactive_fd = 0;
                }
-               if (interactive_fd)
+               if (interactive_fd) {
                        fcntl(interactive_fd, F_SETFD, FD_CLOEXEC);
+                       set_misc_sighandler(SIG_IGN);
+               }
        }
 #endif
 
index 371b5588fa1de09906ae48c8348cbc3732b0e9c3..5f3ac2c2fd109ebb70c9c3d261e004426e308ab4 100644 (file)
@@ -347,10 +347,11 @@ static void log_locally(time_t now, char *msg)
                                sprintf(newFile, "%s.%d", G.logFilePath, i);
                                if (i == 0) break;
                                sprintf(oldFile, "%s.%d", G.logFilePath, --i);
-                               xrename(oldFile, newFile);
+                               /* ignore errors - file might be missing */
+                               rename(oldFile, newFile);
                        }
                        /* newFile == "f.0" now */
-                       xrename(G.logFilePath, newFile);
+                       rename(G.logFilePath, newFile);
                        fl.l_type = F_UNLCK;
                        fcntl(G.logFD, F_SETLKW, &fl);
                        close(G.logFD);
index f0a8854822d4bd7a96afc3381145ac7b2fe456c7..2341a5a67c7805513cc2d3f731b7e2797de3c7af 100644 (file)
@@ -72,8 +72,14 @@ static void make_device(char *path, int delete)
        /* Determine device name, type, major and minor */
        device_name = bb_basename(path);
        /* http://kernel.org/doc/pending/hotplug.txt says that only
-        * "/sys/block/..." is for block devices. "sys/bus" etc is not! */
-       type = (strncmp(&path[5], "block/", 6) == 0 ? S_IFBLK : S_IFCHR);
+        * "/sys/block/..." is for block devices. "/sys/bus" etc is not!
+        * Since kernel 2.6.25 block devices are also in /sys/class/block. */
+       /* TODO: would it be acceptable to just use strstr(path, "/block/")? */
+       if (strncmp(&path[5], "class/block/"+6, 6) != 0
+        && strncmp(&path[5], "class/block/", 12) != 0)
+               type = S_IFCHR;
+       else
+               type = S_IFBLK;
 
        if (ENABLE_FEATURE_MDEV_CONF) {
                FILE *fp;
@@ -172,8 +178,9 @@ static void make_device(char *path, int delete)
                                        /* substitute %1..9 with off[1..9], if any */
                                        n = 0;
                                        s = val;
-                                       while (*s && *s++ == '%')
-                                               n++;
+                                       while (*s)
+                                               if (*s++ == '%')
+                                                       n++;
 
                                        p = alias = xzalloc(strlen(val) + n * strlen(device_name));
                                        s = val + 1;