diff options
author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-03 15:41:12 +0000 |
---|---|---|
committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-08-03 15:41:12 +0000 |
commit | 5e2a5391f9142bca773aab4c829615895b69a6b7 (patch) | |
tree | e4a2769349867c441cf2983d83097bb66701a733 /networking | |
parent | e883e03918a0e26e390ea23996abdb8fc1925f88 (diff) | |
download | busybox-w32-5e2a5391f9142bca773aab4c829615895b69a6b7.tar.gz busybox-w32-5e2a5391f9142bca773aab4c829615895b69a6b7.tar.bz2 busybox-w32-5e2a5391f9142bca773aab4c829615895b69a6b7.zip |
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes... General cleanup pass. What I've
been doing for the last couple days.
And it conflicts! I've removed httpd.c from this checkin due to somebody else
touching that file. It builds for me. I have to catch a bus. (Now you know
why I'm looking forward to Mercurial.)
git-svn-id: svn://busybox.net/trunk/busybox@15767 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ether-wake.c | 19 | ||||
-rw-r--r-- | networking/fakeidentd.c | 18 | ||||
-rw-r--r-- | networking/ftpgetput.c | 19 | ||||
-rw-r--r-- | networking/hostname.c | 11 | ||||
-rw-r--r-- | networking/ifconfig.c | 10 | ||||
-rw-r--r-- | networking/ifupdown.c | 48 | ||||
-rw-r--r-- | networking/inetd.c | 27 | ||||
-rw-r--r-- | networking/nameif.c | 14 | ||||
-rw-r--r-- | networking/nc.c | 8 | ||||
-rw-r--r-- | networking/route.c | 30 | ||||
-rw-r--r-- | networking/tftp.c | 16 | ||||
-rw-r--r-- | networking/traceroute.c | 16 | ||||
-rw-r--r-- | networking/udhcp/libbb_udhcp.h | 2 | ||||
-rw-r--r-- | networking/udhcp/script.c | 12 | ||||
-rw-r--r-- | networking/vconfig.c | 12 | ||||
-rw-r--r-- | networking/wget.c | 15 |
16 files changed, 73 insertions, 204 deletions
diff --git a/networking/ether-wake.c b/networking/ether-wake.c index 1803d2265..75f065cdc 100644 --- a/networking/ether-wake.c +++ b/networking/ether-wake.c | |||
@@ -65,25 +65,10 @@ | |||
65 | */ | 65 | */ |
66 | 66 | ||
67 | 67 | ||
68 | #include <unistd.h> | ||
69 | #include <stdlib.h> | ||
70 | #include <stdio.h> | ||
71 | #include <errno.h> | ||
72 | #include <ctype.h> | ||
73 | #include <string.h> | ||
74 | |||
75 | #include <sys/socket.h> | ||
76 | #include <sys/types.h> | ||
77 | #include <sys/ioctl.h> | ||
78 | #include <features.h> | ||
79 | #include <netpacket/packet.h> | 68 | #include <netpacket/packet.h> |
80 | #include <net/ethernet.h> | 69 | #include <net/ethernet.h> |
81 | #include <netdb.h> | ||
82 | #include <netinet/ether.h> | 70 | #include <netinet/ether.h> |
83 | |||
84 | #ifdef __linux__ | ||
85 | #include <linux/if.h> | 71 | #include <linux/if.h> |
86 | #endif | ||
87 | 72 | ||
88 | #include "busybox.h" | 73 | #include "busybox.h" |
89 | 74 | ||
@@ -93,10 +78,10 @@ | |||
93 | */ | 78 | */ |
94 | #ifdef PF_PACKET | 79 | #ifdef PF_PACKET |
95 | # define whereto_t sockaddr_ll | 80 | # define whereto_t sockaddr_ll |
96 | # define make_socket() bb_xsocket(PF_PACKET, SOCK_RAW, 0) | 81 | # define make_socket() xsocket(PF_PACKET, SOCK_RAW, 0) |
97 | #else | 82 | #else |
98 | # define whereto_t sockaddr | 83 | # define whereto_t sockaddr |
99 | # define make_socket() bb_xsocket(AF_INET, SOCK_PACKET, SOCK_PACKET) | 84 | # define make_socket() xsocket(AF_INET, SOCK_PACKET, SOCK_PACKET) |
100 | #endif | 85 | #endif |
101 | 86 | ||
102 | #ifdef DEBUG | 87 | #ifdef DEBUG |
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c index 9cdbc5725..6ee7c328e 100644 --- a/networking/fakeidentd.c +++ b/networking/fakeidentd.c | |||
@@ -10,19 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "busybox.h" | 12 | #include "busybox.h" |
13 | |||
14 | #include <unistd.h> | ||
15 | #include <string.h> | ||
16 | #include <fcntl.h> | ||
17 | #include <signal.h> | ||
18 | #include <sys/syslog.h> | ||
19 | |||
20 | #include <pwd.h> | ||
21 | |||
22 | #include <sys/syslog.h> | 13 | #include <sys/syslog.h> |
23 | #include <time.h> | ||
24 | #include <sys/socket.h> | ||
25 | #include <errno.h> | ||
26 | #include <sys/uio.h> | 14 | #include <sys/uio.h> |
27 | 15 | ||
28 | 16 | ||
@@ -97,7 +85,7 @@ static void inetbind(void) | |||
97 | else | 85 | else |
98 | port = se->s_port; | 86 | port = se->s_port; |
99 | 87 | ||
100 | s = bb_xsocket(AF_INET, SOCK_STREAM, 0); | 88 | s = xsocket(AF_INET, SOCK_STREAM, 0); |
101 | 89 | ||
102 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); | 90 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); |
103 | 91 | ||
@@ -106,8 +94,8 @@ static void inetbind(void) | |||
106 | addr.sin_family = AF_INET; | 94 | addr.sin_family = AF_INET; |
107 | addr.sin_port = htons(port); | 95 | addr.sin_port = htons(port); |
108 | 96 | ||
109 | bb_xbind(s, (struct sockaddr *)&addr, len); | 97 | xbind(s, (struct sockaddr *)&addr, len); |
110 | bb_xlisten(s, 5); | 98 | xlisten(s, 5); |
111 | 99 | ||
112 | movefd(s, 0); | 100 | movefd(s, 0); |
113 | } | 101 | } |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 9f3c78976..767ace9fb 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -13,19 +13,8 @@ | |||
13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <sys/ioctl.h> | ||
17 | |||
18 | #include <ctype.h> | ||
19 | #include <errno.h> | ||
20 | #include <fcntl.h> | ||
21 | #include <getopt.h> | ||
22 | #include <signal.h> | ||
23 | #include <string.h> | ||
24 | #include <unistd.h> | ||
25 | |||
26 | #include <sys/socket.h> | ||
27 | |||
28 | #include "busybox.h" | 16 | #include "busybox.h" |
17 | #include <getopt.h> | ||
29 | 18 | ||
30 | typedef struct ftp_host_info_s { | 19 | typedef struct ftp_host_info_s { |
31 | char *user; | 20 | char *user; |
@@ -175,9 +164,9 @@ static int ftp_receive(ftp_host_info_t *server, FILE *control_stream, | |||
175 | /* only make a local file if we know that one exists on the remote server */ | 164 | /* only make a local file if we know that one exists on the remote server */ |
176 | if (fd_local == -1) { | 165 | if (fd_local == -1) { |
177 | if (do_continue) { | 166 | if (do_continue) { |
178 | fd_local = bb_xopen(local_path, O_APPEND | O_WRONLY); | 167 | fd_local = xopen(local_path, O_APPEND | O_WRONLY); |
179 | } else { | 168 | } else { |
180 | fd_local = bb_xopen(local_path, O_CREAT | O_TRUNC | O_WRONLY); | 169 | fd_local = xopen(local_path, O_CREAT | O_TRUNC | O_WRONLY); |
181 | } | 170 | } |
182 | } | 171 | } |
183 | 172 | ||
@@ -223,7 +212,7 @@ static int ftp_send(ftp_host_info_t *server, FILE *control_stream, | |||
223 | if ((local_path[0] == '-') && (local_path[1] == '\0')) { | 212 | if ((local_path[0] == '-') && (local_path[1] == '\0')) { |
224 | fd_local = STDIN_FILENO; | 213 | fd_local = STDIN_FILENO; |
225 | } else { | 214 | } else { |
226 | fd_local = bb_xopen(local_path, O_RDONLY); | 215 | fd_local = xopen(local_path, O_RDONLY); |
227 | fstat(fd_local, &sbuf); | 216 | fstat(fd_local, &sbuf); |
228 | 217 | ||
229 | sprintf(buf, "ALLO %lu", (unsigned long)sbuf.st_size); | 218 | sprintf(buf, "ALLO %lu", (unsigned long)sbuf.st_size); |
diff --git a/networking/hostname.c b/networking/hostname.c index ec4a0e8d8..03fd88edb 100644 --- a/networking/hostname.c +++ b/networking/hostname.c | |||
@@ -13,15 +13,8 @@ | |||
13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <errno.h> | ||
17 | #include <arpa/inet.h> | ||
18 | #include <netdb.h> | ||
19 | #include <unistd.h> | ||
20 | #include <string.h> | ||
21 | #include <stdio.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <getopt.h> | ||
24 | #include "busybox.h" | 16 | #include "busybox.h" |
17 | #include <getopt.h> | ||
25 | 18 | ||
26 | extern char *optarg; /* in unistd.h */ | 19 | extern char *optarg; /* in unistd.h */ |
27 | extern int optind, opterr, optopt; /* in unistd.h */ | 20 | extern int optind, opterr, optopt; /* in unistd.h */ |
@@ -41,7 +34,7 @@ static void do_sethostname(char *s, int isfile) | |||
41 | bb_perror_msg_and_die("sethostname"); | 34 | bb_perror_msg_and_die("sethostname"); |
42 | } | 35 | } |
43 | } else { | 36 | } else { |
44 | f = bb_xfopen(s, "r"); | 37 | f = xfopen(s, "r"); |
45 | while (fgets(buf, 255, f) != NULL) { | 38 | while (fgets(buf, 255, f) != NULL) { |
46 | if (buf[0] =='#') { | 39 | if (buf[0] =='#') { |
47 | continue; | 40 | continue; |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 7b358c43f..4d346c47f 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -26,14 +26,6 @@ | |||
26 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> | 26 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <stdio.h> | ||
30 | #include <stdlib.h> | ||
31 | #include <string.h> /* strcmp and friends */ | ||
32 | #include <ctype.h> /* isdigit and friends */ | ||
33 | #include <stddef.h> /* offsetof */ | ||
34 | #include <unistd.h> | ||
35 | #include <netdb.h> | ||
36 | #include <sys/ioctl.h> | ||
37 | #include <net/if.h> | 29 | #include <net/if.h> |
38 | #include <net/if_arp.h> | 30 | #include <net/if_arp.h> |
39 | #include <netinet/in.h> | 31 | #include <netinet/in.h> |
@@ -329,7 +321,7 @@ int ifconfig_main(int argc, char **argv) | |||
329 | } | 321 | } |
330 | 322 | ||
331 | /* Create a channel to the NET kernel. */ | 323 | /* Create a channel to the NET kernel. */ |
332 | sockfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0); | 324 | sockfd = xsocket(AF_INET, SOCK_DGRAM, 0); |
333 | 325 | ||
334 | /* get interface name */ | 326 | /* get interface name */ |
335 | safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ); | 327 | safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ); |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 8ee488364..6429c07e5 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -17,22 +17,10 @@ | |||
17 | 17 | ||
18 | /* TODO: standardise execute() return codes to return 0 for success and 1 for failure */ | 18 | /* TODO: standardise execute() return codes to return 0 for success and 1 for failure */ |
19 | 19 | ||
20 | #include <sys/stat.h> | 20 | #include "busybox.h" |
21 | #include <sys/utsname.h> | 21 | #include <sys/utsname.h> |
22 | #include <sys/wait.h> | ||
23 | |||
24 | #include <ctype.h> | ||
25 | #include <errno.h> | ||
26 | #include <fcntl.h> | ||
27 | #include <fnmatch.h> | 22 | #include <fnmatch.h> |
28 | #include <getopt.h> | 23 | #include <getopt.h> |
29 | #include <stdarg.h> | ||
30 | #include <stdio.h> | ||
31 | #include <stdlib.h> | ||
32 | #include <string.h> | ||
33 | #include <unistd.h> | ||
34 | |||
35 | #include "busybox.h" | ||
36 | 24 | ||
37 | #define MAX_OPT_DEPTH 10 | 25 | #define MAX_OPT_DEPTH 10 |
38 | #define EUNBALBRACK 10001 | 26 | #define EUNBALBRACK 10001 |
@@ -628,7 +616,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
628 | 616 | ||
629 | defn = xzalloc(sizeof(struct interfaces_file_t)); | 617 | defn = xzalloc(sizeof(struct interfaces_file_t)); |
630 | 618 | ||
631 | f = bb_xfopen(filename, "r"); | 619 | f = xfopen(filename, "r"); |
632 | 620 | ||
633 | while ((buf = bb_get_chomped_line_from_file(f)) != NULL) { | 621 | while ((buf = bb_get_chomped_line_from_file(f)) != NULL) { |
634 | char *buf_ptr = buf; | 622 | char *buf_ptr = buf; |
@@ -649,7 +637,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
649 | currmap->match = xrealloc(currmap->match, sizeof(currmap->match) * currmap->max_matches); | 637 | currmap->match = xrealloc(currmap->match, sizeof(currmap->match) * currmap->max_matches); |
650 | } | 638 | } |
651 | 639 | ||
652 | currmap->match[currmap->n_matches++] = bb_xstrdup(firstword); | 640 | currmap->match[currmap->n_matches++] = xstrdup(firstword); |
653 | } | 641 | } |
654 | currmap->max_mappings = 0; | 642 | currmap->max_mappings = 0; |
655 | currmap->n_mappings = 0; | 643 | currmap->n_mappings = 0; |
@@ -701,7 +689,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
701 | return NULL; | 689 | return NULL; |
702 | } | 690 | } |
703 | 691 | ||
704 | currif->iface = bb_xstrdup(iface_name); | 692 | currif->iface = xstrdup(iface_name); |
705 | 693 | ||
706 | currif->address_family = get_address_family(addr_fams, address_family_name); | 694 | currif->address_family = get_address_family(addr_fams, address_family_name); |
707 | if (!currif->address_family) { | 695 | if (!currif->address_family) { |
@@ -741,7 +729,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
741 | } | 729 | } |
742 | 730 | ||
743 | /* Add the interface to the list */ | 731 | /* Add the interface to the list */ |
744 | llist_add_to_end(&(defn->autointerfaces), bb_xstrdup(firstword)); | 732 | llist_add_to_end(&(defn->autointerfaces), xstrdup(firstword)); |
745 | debug_noise("\nauto %s\n", firstword); | 733 | debug_noise("\nauto %s\n", firstword); |
746 | } | 734 | } |
747 | currently_processing = NONE; | 735 | currently_processing = NONE; |
@@ -775,8 +763,8 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
775 | opt = xrealloc(currif->option, sizeof(*opt) * currif->max_options); | 763 | opt = xrealloc(currif->option, sizeof(*opt) * currif->max_options); |
776 | currif->option = opt; | 764 | currif->option = opt; |
777 | } | 765 | } |
778 | currif->option[currif->n_options].name = bb_xstrdup(firstword); | 766 | currif->option[currif->n_options].name = xstrdup(firstword); |
779 | currif->option[currif->n_options].value = bb_xstrdup(buf_ptr); | 767 | currif->option[currif->n_options].value = xstrdup(buf_ptr); |
780 | if (!currif->option[currif->n_options].name) { | 768 | if (!currif->option[currif->n_options].name) { |
781 | perror(filename); | 769 | perror(filename); |
782 | return NULL; | 770 | return NULL; |
@@ -796,14 +784,14 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |||
796 | bb_error_msg("duplicate script in mapping \"%s\"", buf); | 784 | bb_error_msg("duplicate script in mapping \"%s\"", buf); |
797 | return NULL; | 785 | return NULL; |
798 | } else { | 786 | } else { |
799 | currmap->script = bb_xstrdup(next_word(&buf_ptr)); | 787 | currmap->script = xstrdup(next_word(&buf_ptr)); |
800 | } | 788 | } |
801 | } else if (strcmp(firstword, "map") == 0) { | 789 | } else if (strcmp(firstword, "map") == 0) { |
802 | if (currmap->max_mappings == currmap->n_mappings) { | 790 | if (currmap->max_mappings == currmap->n_mappings) { |
803 | currmap->max_mappings = currmap->max_mappings * 2 + 1; | 791 | currmap->max_mappings = currmap->max_mappings * 2 + 1; |
804 | currmap->mapping = xrealloc(currmap->mapping, sizeof(char *) * currmap->max_mappings); | 792 | currmap->mapping = xrealloc(currmap->mapping, sizeof(char *) * currmap->max_mappings); |
805 | } | 793 | } |
806 | currmap->mapping[currmap->n_mappings] = bb_xstrdup(next_word(&buf_ptr)); | 794 | currmap->mapping[currmap->n_mappings] = xstrdup(next_word(&buf_ptr)); |
807 | currmap->n_mappings++; | 795 | currmap->n_mappings++; |
808 | } else { | 796 | } else { |
809 | bb_error_msg("misplaced option \"%s\"", buf); | 797 | bb_error_msg("misplaced option \"%s\"", buf); |
@@ -833,7 +821,7 @@ static char *setlocalenv(char *format, const char *name, const char *value) | |||
833 | char *here; | 821 | char *here; |
834 | char *there; | 822 | char *there; |
835 | 823 | ||
836 | result = bb_xasprintf(format, name, value); | 824 | result = xasprintf(format, name, value); |
837 | 825 | ||
838 | for (here = there = result; *there != '=' && *there; there++) { | 826 | for (here = there = result; *there != '=' && *there; there++) { |
839 | if (*there == '-') | 827 | if (*there == '-') |
@@ -922,7 +910,7 @@ static int execute_all(struct interface_defn_t *ifd, const char *opt) | |||
922 | } | 910 | } |
923 | } | 911 | } |
924 | 912 | ||
925 | buf = bb_xasprintf("run-parts /etc/network/if-%s.d", opt); | 913 | buf = xasprintf("run-parts /etc/network/if-%s.d", opt); |
926 | if (doit(buf) != 1) { | 914 | if (doit(buf) != 1) { |
927 | return 0; | 915 | return 0; |
928 | } | 916 | } |
@@ -1013,7 +1001,7 @@ static char *run_mapping(char *physical, struct mapping_defn_t * map) | |||
1013 | int i, status; | 1001 | int i, status; |
1014 | pid_t pid; | 1002 | pid_t pid; |
1015 | 1003 | ||
1016 | char *logical = bb_xstrdup(physical); | 1004 | char *logical = xstrdup(physical); |
1017 | 1005 | ||
1018 | /* Run the mapping script. */ | 1006 | /* Run the mapping script. */ |
1019 | pid = popen2(&in, &out, map->script, physical, NULL); | 1007 | pid = popen2(&in, &out, map->script, physical, NULL); |
@@ -1158,7 +1146,7 @@ int ifupdown_main(int argc, char **argv) | |||
1158 | /* iface_down */ | 1146 | /* iface_down */ |
1159 | const llist_t *list = state_list; | 1147 | const llist_t *list = state_list; |
1160 | while (list) { | 1148 | while (list) { |
1161 | llist_add_to_end(&target_list, bb_xstrdup(list->data)); | 1149 | llist_add_to_end(&target_list, xstrdup(list->data)); |
1162 | list = list->link; | 1150 | list = list->link; |
1163 | } | 1151 | } |
1164 | target_list = defn->autointerfaces; | 1152 | target_list = defn->autointerfaces; |
@@ -1178,15 +1166,15 @@ int ifupdown_main(int argc, char **argv) | |||
1178 | int okay = 0; | 1166 | int okay = 0; |
1179 | int cmds_ret; | 1167 | int cmds_ret; |
1180 | 1168 | ||
1181 | iface = bb_xstrdup(target_list->data); | 1169 | iface = xstrdup(target_list->data); |
1182 | target_list = target_list->link; | 1170 | target_list = target_list->link; |
1183 | 1171 | ||
1184 | pch = strchr(iface, '='); | 1172 | pch = strchr(iface, '='); |
1185 | if (pch) { | 1173 | if (pch) { |
1186 | *pch = '\0'; | 1174 | *pch = '\0'; |
1187 | liface = bb_xstrdup(pch + 1); | 1175 | liface = xstrdup(pch + 1); |
1188 | } else { | 1176 | } else { |
1189 | liface = bb_xstrdup(iface); | 1177 | liface = xstrdup(iface); |
1190 | } | 1178 | } |
1191 | 1179 | ||
1192 | if (!force) { | 1180 | if (!force) { |
@@ -1263,7 +1251,7 @@ int ifupdown_main(int argc, char **argv) | |||
1263 | llist_t *iface_state = find_iface_state(state_list, iface); | 1251 | llist_t *iface_state = find_iface_state(state_list, iface); |
1264 | 1252 | ||
1265 | if (cmds == iface_up) { | 1253 | if (cmds == iface_up) { |
1266 | char *newiface = bb_xasprintf("%s=%s", iface, liface); | 1254 | char *newiface = xasprintf("%s=%s", iface, liface); |
1267 | if (iface_state == NULL) { | 1255 | if (iface_state == NULL) { |
1268 | llist_add_to_end(&state_list, newiface); | 1256 | llist_add_to_end(&state_list, newiface); |
1269 | } else { | 1257 | } else { |
@@ -1281,7 +1269,7 @@ int ifupdown_main(int argc, char **argv) | |||
1281 | if (!no_act) { | 1269 | if (!no_act) { |
1282 | FILE *state_fp = NULL; | 1270 | FILE *state_fp = NULL; |
1283 | 1271 | ||
1284 | state_fp = bb_xfopen(statefile, "w"); | 1272 | state_fp = xfopen(statefile, "w"); |
1285 | while (state_list) { | 1273 | while (state_list) { |
1286 | if (state_list->data) { | 1274 | if (state_list->data) { |
1287 | fputs(state_list->data, state_fp); | 1275 | fputs(state_list->data, state_fp); |
diff --git a/networking/inetd.c b/networking/inetd.c index 54294b635..49ca7a36e 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -128,31 +128,8 @@ | |||
128 | * | 128 | * |
129 | */ | 129 | */ |
130 | 130 | ||
131 | #include <sys/param.h> | ||
132 | #include <sys/stat.h> | ||
133 | #include <sys/ioctl.h> | ||
134 | #include <sys/socket.h> | ||
135 | #include <sys/un.h> | ||
136 | #include <sys/file.h> | ||
137 | #include <sys/wait.h> | ||
138 | #include <sys/resource.h> | ||
139 | |||
140 | |||
141 | #include <netinet/in.h> | ||
142 | #include <arpa/inet.h> | ||
143 | |||
144 | #include <errno.h> | ||
145 | #include <signal.h> | ||
146 | #include <netdb.h> | ||
147 | #include <syslog.h> | ||
148 | #include <stdio.h> | ||
149 | #include <stdlib.h> | ||
150 | #include <unistd.h> | ||
151 | #include <string.h> | ||
152 | #include <ctype.h> | ||
153 | #include <time.h> | ||
154 | |||
155 | #include "busybox.h" | 131 | #include "busybox.h" |
132 | #include <syslog.h> | ||
156 | 133 | ||
157 | //#define CONFIG_FEATURE_INETD_RPC | 134 | //#define CONFIG_FEATURE_INETD_RPC |
158 | //#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO | 135 | //#define CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO |
@@ -1314,7 +1291,7 @@ inetd_main (int argc, char *argv[]) | |||
1314 | /* reexec for vfork() do continue parent */ | 1291 | /* reexec for vfork() do continue parent */ |
1315 | vfork_daemon_rexec (0, 0, argc, argv, "-f"); | 1292 | vfork_daemon_rexec (0, 0, argc, argv, "-f"); |
1316 | #else | 1293 | #else |
1317 | bb_xdaemon (0, 0); | 1294 | xdaemon (0, 0); |
1318 | #endif | 1295 | #endif |
1319 | } else { | 1296 | } else { |
1320 | setsid (); | 1297 | setsid (); |
diff --git a/networking/nameif.c b/networking/nameif.c index f13ef1b8b..501e244b1 100644 --- a/networking/nameif.c +++ b/networking/nameif.c | |||
@@ -10,13 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include "busybox.h" | 12 | #include "busybox.h" |
13 | 13 | #include <syslog.h> | |
14 | #include <sys/syslog.h> | ||
15 | #include <sys/socket.h> | ||
16 | #include <sys/ioctl.h> | ||
17 | #include <errno.h> | ||
18 | #include <string.h> | ||
19 | #include <unistd.h> | ||
20 | #include <net/if.h> | 14 | #include <net/if.h> |
21 | #include <netinet/ether.h> | 15 | #include <netinet/ether.h> |
22 | 16 | ||
@@ -107,7 +101,7 @@ int nameif_main(int argc, char **argv) | |||
107 | if (strlen(*a) > IF_NAMESIZE) | 101 | if (strlen(*a) > IF_NAMESIZE) |
108 | serror("interface name `%s' too long", *a); | 102 | serror("interface name `%s' too long", *a); |
109 | ch = xzalloc(sizeof(mactable_t)); | 103 | ch = xzalloc(sizeof(mactable_t)); |
110 | ch->ifname = bb_xstrdup(*a++); | 104 | ch->ifname = xstrdup(*a++); |
111 | ch->mac = cc_macaddr(*a++); | 105 | ch->mac = cc_macaddr(*a++); |
112 | if (clist) | 106 | if (clist) |
113 | clist->prev = ch; | 107 | clist->prev = ch; |
@@ -115,7 +109,7 @@ int nameif_main(int argc, char **argv) | |||
115 | clist = ch; | 109 | clist = ch; |
116 | } | 110 | } |
117 | } else { | 111 | } else { |
118 | ifh = bb_xfopen(fname, "r"); | 112 | ifh = xfopen(fname, "r"); |
119 | 113 | ||
120 | while ((line = bb_get_line_from_file(ifh)) != NULL) { | 114 | while ((line = bb_get_line_from_file(ifh)) != NULL) { |
121 | char *line_ptr; | 115 | char *line_ptr; |
@@ -128,7 +122,7 @@ int nameif_main(int argc, char **argv) | |||
128 | } | 122 | } |
129 | name_length = strcspn(line_ptr, " \t"); | 123 | name_length = strcspn(line_ptr, " \t"); |
130 | ch = xzalloc(sizeof(mactable_t)); | 124 | ch = xzalloc(sizeof(mactable_t)); |
131 | ch->ifname = bb_xstrndup(line_ptr, name_length); | 125 | ch->ifname = xstrndup(line_ptr, name_length); |
132 | if (name_length > IF_NAMESIZE) | 126 | if (name_length > IF_NAMESIZE) |
133 | serror("interface name `%s' too long", ch->ifname); | 127 | serror("interface name `%s' too long", ch->ifname); |
134 | line_ptr += name_length; | 128 | line_ptr += name_length; |
diff --git a/networking/nc.c b/networking/nc.c index 117bbe20e..3f4149e14 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -54,10 +54,10 @@ int nc_main(int argc, char **argv) | |||
54 | alarm(wsecs); | 54 | alarm(wsecs); |
55 | } | 55 | } |
56 | 56 | ||
57 | if (infile) cfd = bb_xopen(infile, O_RDWR); | 57 | if (infile) cfd = xopen(infile, O_RDWR); |
58 | else { | 58 | else { |
59 | opt = 1; | 59 | opt = 1; |
60 | sfd = bb_xsocket(AF_INET, SOCK_STREAM, 0); | 60 | sfd = xsocket(AF_INET, SOCK_STREAM, 0); |
61 | fcntl(sfd, F_SETFD, FD_CLOEXEC); | 61 | fcntl(sfd, F_SETFD, FD_CLOEXEC); |
62 | setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)); | 62 | setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt)); |
63 | address.sin_family = AF_INET; | 63 | address.sin_family = AF_INET; |
@@ -67,13 +67,13 @@ int nc_main(int argc, char **argv) | |||
67 | if (lport != 0) { | 67 | if (lport != 0) { |
68 | address.sin_port = lport; | 68 | address.sin_port = lport; |
69 | 69 | ||
70 | bb_xbind(sfd, (struct sockaddr *) &address, sizeof(address)); | 70 | xbind(sfd, (struct sockaddr *) &address, sizeof(address)); |
71 | } | 71 | } |
72 | 72 | ||
73 | if (do_listen) { | 73 | if (do_listen) { |
74 | socklen_t addrlen = sizeof(address); | 74 | socklen_t addrlen = sizeof(address); |
75 | 75 | ||
76 | bb_xlisten(sfd, do_listen); | 76 | xlisten(sfd, do_listen); |
77 | 77 | ||
78 | // If we didn't specify a port number, query and print it to stderr. | 78 | // If we didn't specify a port number, query and print it to stderr. |
79 | 79 | ||
diff --git a/networking/route.c b/networking/route.c index d90578615..5fd888617 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -26,20 +26,12 @@ | |||
26 | * remove ridiculous amounts of bloat. | 26 | * remove ridiculous amounts of bloat. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <stdio.h> | 29 | #include "busybox.h" |
30 | #include <stdlib.h> | 30 | #include "inet_common.h" |
31 | #include <string.h> | ||
32 | #include <errno.h> | ||
33 | #include <assert.h> | ||
34 | #include <unistd.h> | ||
35 | #include <fcntl.h> | ||
36 | #include <getopt.h> | 31 | #include <getopt.h> |
37 | #include <sys/types.h> | ||
38 | #include <sys/ioctl.h> | ||
39 | #include <net/route.h> | 32 | #include <net/route.h> |
40 | #include <net/if.h> | 33 | #include <net/if.h> |
41 | #include "busybox.h" | 34 | |
42 | #include "inet_common.h" | ||
43 | 35 | ||
44 | #ifndef RTF_UP | 36 | #ifndef RTF_UP |
45 | /* Keep this in sync with /usr/src/linux/include/linux/route.h */ | 37 | /* Keep this in sync with /usr/src/linux/include/linux/route.h */ |
@@ -166,8 +158,6 @@ static void INET_setroute(int action, char **args) | |||
166 | const char *netmask = NULL; | 158 | const char *netmask = NULL; |
167 | int skfd, isnet, xflag; | 159 | int skfd, isnet, xflag; |
168 | 160 | ||
169 | assert((action == RTACTION_ADD) || (action == RTACTION_DEL)); | ||
170 | |||
171 | /* Grab the -net or -host options. Remember they were transformed. */ | 161 | /* Grab the -net or -host options. Remember they were transformed. */ |
172 | xflag = kw_lookup(tbl_hash_net_host, &args); | 162 | xflag = kw_lookup(tbl_hash_net_host, &args); |
173 | 163 | ||
@@ -335,7 +325,7 @@ static void INET_setroute(int action, char **args) | |||
335 | } | 325 | } |
336 | 326 | ||
337 | /* Create a socket to the INET kernel. */ | 327 | /* Create a socket to the INET kernel. */ |
338 | skfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0); | 328 | skfd = xsocket(AF_INET, SOCK_DGRAM, 0); |
339 | 329 | ||
340 | if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) { | 330 | if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) { |
341 | bb_perror_msg_and_die("SIOC[ADD|DEL]RT"); | 331 | bb_perror_msg_and_die("SIOC[ADD|DEL]RT"); |
@@ -353,9 +343,6 @@ static void INET6_setroute(int action, char **args) | |||
353 | int prefix_len, skfd; | 343 | int prefix_len, skfd; |
354 | const char *devname; | 344 | const char *devname; |
355 | 345 | ||
356 | assert((action == RTACTION_ADD) || (action == RTACTION_DEL)); | ||
357 | |||
358 | { | ||
359 | /* We know args isn't NULL from the check in route_main. */ | 346 | /* We know args isn't NULL from the check in route_main. */ |
360 | const char *target = *args++; | 347 | const char *target = *args++; |
361 | 348 | ||
@@ -374,7 +361,6 @@ static void INET6_setroute(int action, char **args) | |||
374 | bb_error_msg_and_die("resolving %s", target); | 361 | bb_error_msg_and_die("resolving %s", target); |
375 | } | 362 | } |
376 | } | 363 | } |
377 | } | ||
378 | 364 | ||
379 | /* Clean out the RTREQ structure. */ | 365 | /* Clean out the RTREQ structure. */ |
380 | memset((char *) &rt, 0, sizeof(struct in6_rtmsg)); | 366 | memset((char *) &rt, 0, sizeof(struct in6_rtmsg)); |
@@ -429,7 +415,7 @@ static void INET6_setroute(int action, char **args) | |||
429 | } | 415 | } |
430 | 416 | ||
431 | /* Create a socket to the INET6 kernel. */ | 417 | /* Create a socket to the INET6 kernel. */ |
432 | skfd = bb_xsocket(AF_INET6, SOCK_DGRAM, 0); | 418 | skfd = xsocket(AF_INET6, SOCK_DGRAM, 0); |
433 | 419 | ||
434 | rt.rtmsg_ifindex = 0; | 420 | rt.rtmsg_ifindex = 0; |
435 | 421 | ||
@@ -503,7 +489,7 @@ void displayroutes(int noresolve, int netstatfmt) | |||
503 | struct sockaddr_in s_addr; | 489 | struct sockaddr_in s_addr; |
504 | struct in_addr mask; | 490 | struct in_addr mask; |
505 | 491 | ||
506 | FILE *fp = bb_xfopen("/proc/net/route", "r"); | 492 | FILE *fp = xfopen("/proc/net/route", "r"); |
507 | 493 | ||
508 | bb_printf("Kernel IP routing table\n" | 494 | bb_printf("Kernel IP routing table\n" |
509 | "Destination Gateway Genmask" | 495 | "Destination Gateway Genmask" |
@@ -573,7 +559,7 @@ static void INET6_displayroutes(int noresolve) | |||
573 | int iflags, metric, refcnt, use, prefix_len, slen; | 559 | int iflags, metric, refcnt, use, prefix_len, slen; |
574 | struct sockaddr_in6 snaddr6; | 560 | struct sockaddr_in6 snaddr6; |
575 | 561 | ||
576 | FILE *fp = bb_xfopen("/proc/net/ipv6_route", "r"); | 562 | FILE *fp = xfopen("/proc/net/ipv6_route", "r"); |
577 | 563 | ||
578 | bb_printf("Kernel IPv6 routing table\n%-44s%-40s" | 564 | bb_printf("Kernel IPv6 routing table\n%-44s%-40s" |
579 | "Flags Metric Ref Use Iface\n", | 565 | "Flags Metric Ref Use Iface\n", |
@@ -699,7 +685,7 @@ int route_main(int argc, char **argv) | |||
699 | #endif | 685 | #endif |
700 | displayroutes(noresolve, opt & ROUTE_OPT_e); | 686 | displayroutes(noresolve, opt & ROUTE_OPT_e); |
701 | 687 | ||
702 | bb_xferror_stdout(); | 688 | xferror_stdout(); |
703 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 689 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); |
704 | } | 690 | } |
705 | 691 | ||
diff --git a/networking/tftp.c b/networking/tftp.c index dfa599ab5..42fd9d2ca 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -19,18 +19,6 @@ | |||
19 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 19 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
20 | * ------------------------------------------------------------------------- */ | 20 | * ------------------------------------------------------------------------- */ |
21 | 21 | ||
22 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <string.h> | ||
25 | #include <sys/types.h> | ||
26 | #include <sys/socket.h> | ||
27 | #include <sys/stat.h> | ||
28 | #include <netdb.h> | ||
29 | #include <netinet/in.h> | ||
30 | #include <arpa/inet.h> | ||
31 | #include <unistd.h> | ||
32 | #include <fcntl.h> | ||
33 | |||
34 | #include "busybox.h" | 22 | #include "busybox.h" |
35 | 23 | ||
36 | 24 | ||
@@ -159,7 +147,7 @@ static int tftp(const int cmd, const struct hostent *host, | |||
159 | char *buf=xmalloc(tftp_bufsize += 4); | 147 | char *buf=xmalloc(tftp_bufsize += 4); |
160 | 148 | ||
161 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { | 149 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { |
162 | /* need to unlink the localfile, so don't use bb_xsocket here. */ | 150 | /* need to unlink the localfile, so don't use xsocket here. */ |
163 | bb_perror_msg("socket"); | 151 | bb_perror_msg("socket"); |
164 | return EXIT_FAILURE; | 152 | return EXIT_FAILURE; |
165 | } | 153 | } |
@@ -167,7 +155,7 @@ static int tftp(const int cmd, const struct hostent *host, | |||
167 | len = sizeof(sa); | 155 | len = sizeof(sa); |
168 | 156 | ||
169 | memset(&sa, 0, len); | 157 | memset(&sa, 0, len); |
170 | bb_xbind(socketfd, (struct sockaddr *)&sa, len); | 158 | xbind(socketfd, (struct sockaddr *)&sa, len); |
171 | 159 | ||
172 | sa.sin_family = host->h_addrtype; | 160 | sa.sin_family = host->h_addrtype; |
173 | sa.sin_port = port; | 161 | sa.sin_port = port; |
diff --git a/networking/traceroute.c b/networking/traceroute.c index c2084fc1e..446490303 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -357,7 +357,7 @@ ifaddrlist(struct IFADDRLIST **ipaddrp) | |||
357 | struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr; | 357 | struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr; |
358 | struct IFADDRLIST *st_ifaddrlist; | 358 | struct IFADDRLIST *st_ifaddrlist; |
359 | 359 | ||
360 | fd = bb_xsocket(AF_INET, SOCK_DGRAM, 0); | 360 | fd = xsocket(AF_INET, SOCK_DGRAM, 0); |
361 | 361 | ||
362 | ifc.ifc_len = sizeof(ibuf); | 362 | ifc.ifc_len = sizeof(ibuf); |
363 | ifc.ifc_buf = (caddr_t)ibuf; | 363 | ifc.ifc_buf = (caddr_t)ibuf; |
@@ -457,7 +457,7 @@ findsaddr(const struct sockaddr_in *to, struct sockaddr_in *from) | |||
457 | struct IFADDRLIST *al; | 457 | struct IFADDRLIST *al; |
458 | char buf[256], tdevice[256], device[256]; | 458 | char buf[256], tdevice[256], device[256]; |
459 | 459 | ||
460 | f = bb_xfopen(route, "r"); | 460 | f = xfopen(route, "r"); |
461 | 461 | ||
462 | /* Find the appropriate interface */ | 462 | /* Find the appropriate interface */ |
463 | n = 0; | 463 | n = 0; |
@@ -875,7 +875,7 @@ gethostinfo(const char *host) | |||
875 | hi = xcalloc(1, sizeof(*hi)); | 875 | hi = xcalloc(1, sizeof(*hi)); |
876 | addr = inet_addr(host); | 876 | addr = inet_addr(host); |
877 | if ((int32_t)addr != -1) { | 877 | if ((int32_t)addr != -1) { |
878 | hi->name = bb_xstrdup(host); | 878 | hi->name = xstrdup(host); |
879 | hi->n = 1; | 879 | hi->n = 1; |
880 | hi->addrs = xcalloc(1, sizeof(hi->addrs[0])); | 880 | hi->addrs = xcalloc(1, sizeof(hi->addrs[0])); |
881 | hi->addrs[0] = addr; | 881 | hi->addrs[0] = addr; |
@@ -885,7 +885,7 @@ gethostinfo(const char *host) | |||
885 | hp = xgethostbyname(host); | 885 | hp = xgethostbyname(host); |
886 | if (hp->h_addrtype != AF_INET || hp->h_length != 4) | 886 | if (hp->h_addrtype != AF_INET || hp->h_length != 4) |
887 | bb_perror_msg_and_die("bad host %s", host); | 887 | bb_perror_msg_and_die("bad host %s", host); |
888 | hi->name = bb_xstrdup(hp->h_name); | 888 | hi->name = xstrdup(hp->h_name); |
889 | for (n = 0, p = hp->h_addr_list; *p != NULL; ++n, ++p) | 889 | for (n = 0, p = hp->h_addr_list; *p != NULL; ++n, ++p) |
890 | continue; | 890 | continue; |
891 | hi->n = n; | 891 | hi->n = n; |
@@ -1081,11 +1081,11 @@ traceroute_main(int argc, char *argv[]) | |||
1081 | bb_perror_msg_and_die("unknown protocol %s", cp); | 1081 | bb_perror_msg_and_die("unknown protocol %s", cp); |
1082 | 1082 | ||
1083 | /* Insure the socket fds won't be 0, 1 or 2 */ | 1083 | /* Insure the socket fds won't be 0, 1 or 2 */ |
1084 | do n = bb_xopen(bb_dev_null, O_RDONLY); while (n < 2); | 1084 | do n = xopen(bb_dev_null, O_RDONLY); while (n < 2); |
1085 | if (n > 2) | 1085 | if (n > 2) |
1086 | close(n); | 1086 | close(n); |
1087 | 1087 | ||
1088 | s = bb_xsocket(AF_INET, SOCK_RAW, pe->p_proto); | 1088 | s = xsocket(AF_INET, SOCK_RAW, pe->p_proto); |
1089 | 1089 | ||
1090 | #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG | 1090 | #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG |
1091 | if (op & USAGE_OP_DEBUG) | 1091 | if (op & USAGE_OP_DEBUG) |
@@ -1096,7 +1096,7 @@ traceroute_main(int argc, char *argv[]) | |||
1096 | (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on, | 1096 | (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on, |
1097 | sizeof(on)); | 1097 | sizeof(on)); |
1098 | 1098 | ||
1099 | sndsock = bb_xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); | 1099 | sndsock = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); |
1100 | 1100 | ||
1101 | #ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE | 1101 | #ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE |
1102 | #if defined(IP_OPTIONS) | 1102 | #if defined(IP_OPTIONS) |
@@ -1248,7 +1248,7 @@ traceroute_main(int argc, char *argv[]) | |||
1248 | 1248 | ||
1249 | outip->ip_src = from->sin_addr; | 1249 | outip->ip_src = from->sin_addr; |
1250 | #ifndef IP_HDRINCL | 1250 | #ifndef IP_HDRINCL |
1251 | bb_xbind(sndsock, (struct sockaddr *)from, sizeof(*from)); | 1251 | xbind(sndsock, (struct sockaddr *)from, sizeof(*from)); |
1252 | #endif | 1252 | #endif |
1253 | 1253 | ||
1254 | fprintf(stderr, "traceroute to %s (%s)", hostname, inet_ntoa(to->sin_addr)); | 1254 | fprintf(stderr, "traceroute to %s (%s)", hostname, inet_ntoa(to->sin_addr)); |
diff --git a/networking/udhcp/libbb_udhcp.h b/networking/udhcp/libbb_udhcp.h index 3cf2d1401..c21d3baab 100644 --- a/networking/udhcp/libbb_udhcp.h +++ b/networking/udhcp/libbb_udhcp.h | |||
@@ -20,8 +20,6 @@ | |||
20 | 20 | ||
21 | #define COMBINED_BINARY | 21 | #define COMBINED_BINARY |
22 | 22 | ||
23 | #define xfopen bb_xfopen | ||
24 | |||
25 | void udhcp_background(const char *pidfile); | 23 | void udhcp_background(const char *pidfile); |
26 | void udhcp_start_log_and_pid(const char *client_server, const char *pidfile); | 24 | void udhcp_start_log_and_pid(const char *client_server, const char *pidfile); |
27 | void udhcp_logging(int level, const char *fmt, ...); | 25 | void udhcp_logging(int level, const char *fmt, ...); |
diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c index 8c4933455..5a4b33a53 100644 --- a/networking/udhcp/script.c +++ b/networking/udhcp/script.c | |||
@@ -149,10 +149,10 @@ static char **fill_envp(struct dhcpMessage *packet) | |||
149 | 149 | ||
150 | envp = xzalloc(sizeof(char *) * (num_options + 5)); | 150 | envp = xzalloc(sizeof(char *) * (num_options + 5)); |
151 | j = 0; | 151 | j = 0; |
152 | envp[j++] = bb_xasprintf("interface=%s", client_config.interface); | 152 | envp[j++] = xasprintf("interface=%s", client_config.interface); |
153 | envp[j++] = bb_xasprintf("PATH=%s", | 153 | envp[j++] = xasprintf("PATH=%s", |
154 | getenv("PATH") ? : "/bin:/usr/bin:/sbin:/usr/sbin"); | 154 | getenv("PATH") ? : "/bin:/usr/bin:/sbin:/usr/sbin"); |
155 | envp[j++] = bb_xasprintf("HOME=%s", getenv("HOME") ? : "/"); | 155 | envp[j++] = xasprintf("HOME=%s", getenv("HOME") ? : "/"); |
156 | 156 | ||
157 | if (packet == NULL) return envp; | 157 | if (packet == NULL) return envp; |
158 | 158 | ||
@@ -170,7 +170,7 @@ static char **fill_envp(struct dhcpMessage *packet) | |||
170 | /* Fill in a subnet bits option for things like /24 */ | 170 | /* Fill in a subnet bits option for things like /24 */ |
171 | if (dhcp_options[i].code == DHCP_SUBNET) { | 171 | if (dhcp_options[i].code == DHCP_SUBNET) { |
172 | memcpy(&subnet, temp, 4); | 172 | memcpy(&subnet, temp, 4); |
173 | envp[j++] = bb_xasprintf("mask=%d", mton(&subnet)); | 173 | envp[j++] = xasprintf("mask=%d", mton(&subnet)); |
174 | } | 174 | } |
175 | } | 175 | } |
176 | if (packet->siaddr) { | 176 | if (packet->siaddr) { |
@@ -180,12 +180,12 @@ static char **fill_envp(struct dhcpMessage *packet) | |||
180 | if (!(over & FILE_FIELD) && packet->file[0]) { | 180 | if (!(over & FILE_FIELD) && packet->file[0]) { |
181 | /* watch out for invalid packets */ | 181 | /* watch out for invalid packets */ |
182 | packet->file[sizeof(packet->file) - 1] = '\0'; | 182 | packet->file[sizeof(packet->file) - 1] = '\0'; |
183 | envp[j++] = bb_xasprintf("boot_file=%s", packet->file); | 183 | envp[j++] = xasprintf("boot_file=%s", packet->file); |
184 | } | 184 | } |
185 | if (!(over & SNAME_FIELD) && packet->sname[0]) { | 185 | if (!(over & SNAME_FIELD) && packet->sname[0]) { |
186 | /* watch out for invalid packets */ | 186 | /* watch out for invalid packets */ |
187 | packet->sname[sizeof(packet->sname) - 1] = '\0'; | 187 | packet->sname[sizeof(packet->sname) - 1] = '\0'; |
188 | envp[j++] = bb_xasprintf("sname=%s", packet->sname); | 188 | envp[j++] = xasprintf("sname=%s", packet->sname); |
189 | } | 189 | } |
190 | return envp; | 190 | return envp; |
191 | } | 191 | } |
diff --git a/networking/vconfig.c b/networking/vconfig.c index 6cbbb54ca..b90f41085 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c | |||
@@ -9,14 +9,8 @@ | |||
9 | 9 | ||
10 | /* BB_AUDIT SUSv3 N/A */ | 10 | /* BB_AUDIT SUSv3 N/A */ |
11 | 11 | ||
12 | #include <stdlib.h> | ||
13 | #include <unistd.h> | ||
14 | #include <fcntl.h> | ||
15 | #include <sys/ioctl.h> | ||
16 | #include <net/if.h> | ||
17 | #include <string.h> | ||
18 | #include <limits.h> | ||
19 | #include "busybox.h" | 12 | #include "busybox.h" |
13 | #include <net/if.h> | ||
20 | 14 | ||
21 | /* Stuff from linux/if_vlan.h, kernel version 2.4.23 */ | 15 | /* Stuff from linux/if_vlan.h, kernel version 2.4.23 */ |
22 | enum vlan_ioctl_cmds { | 16 | enum vlan_ioctl_cmds { |
@@ -124,7 +118,7 @@ int vconfig_main(int argc, char **argv) | |||
124 | 118 | ||
125 | /* Don't bother closing the filedes. It will be closed on cleanup. */ | 119 | /* Don't bother closing the filedes. It will be closed on cleanup. */ |
126 | /* Will die if 802.1q is not present */ | 120 | /* Will die if 802.1q is not present */ |
127 | bb_xopen3(conf_file_name, O_RDONLY, 0); | 121 | xopen3(conf_file_name, O_RDONLY, 0); |
128 | 122 | ||
129 | memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); | 123 | memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); |
130 | 124 | ||
@@ -159,7 +153,7 @@ int vconfig_main(int argc, char **argv) | |||
159 | } | 153 | } |
160 | } | 154 | } |
161 | 155 | ||
162 | fd = bb_xsocket(AF_INET, SOCK_STREAM, 0); | 156 | fd = xsocket(AF_INET, SOCK_STREAM, 0); |
163 | if (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) { | 157 | if (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) { |
164 | bb_perror_msg_and_die("ioctl error for %s", *argv); | 158 | bb_perror_msg_and_die("ioctl error for %s", *argv); |
165 | } | 159 | } |
diff --git a/networking/wget.c b/networking/wget.c index 6565bb1f3..1b7555abc 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -7,9 +7,6 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "busybox.h" | 9 | #include "busybox.h" |
10 | #include <errno.h> | ||
11 | #include <signal.h> | ||
12 | #include <sys/ioctl.h> | ||
13 | #include <getopt.h> | 10 | #include <getopt.h> |
14 | 11 | ||
15 | 12 | ||
@@ -221,7 +218,7 @@ int wget_main(int argc, char **argv) | |||
221 | if (use_proxy) { | 218 | if (use_proxy) { |
222 | proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); | 219 | proxy = getenv(target.is_ftp ? "ftp_proxy" : "http_proxy"); |
223 | if (proxy && *proxy) { | 220 | if (proxy && *proxy) { |
224 | parse_url(bb_xstrdup(proxy), &server); | 221 | parse_url(xstrdup(proxy), &server); |
225 | } else { | 222 | } else { |
226 | use_proxy = 0; | 223 | use_proxy = 0; |
227 | } | 224 | } |
@@ -263,7 +260,7 @@ int wget_main(int argc, char **argv) | |||
263 | output = stdout; | 260 | output = stdout; |
264 | quiet_flag = TRUE; | 261 | quiet_flag = TRUE; |
265 | } else { | 262 | } else { |
266 | output = bb_xfopen(fname_out, (do_continue ? "a" : "w")); | 263 | output = xfopen(fname_out, (do_continue ? "a" : "w")); |
267 | } | 264 | } |
268 | 265 | ||
269 | /* | 266 | /* |
@@ -396,9 +393,9 @@ read_response: | |||
396 | } | 393 | } |
397 | if (strcasecmp(buf, "location") == 0) { | 394 | if (strcasecmp(buf, "location") == 0) { |
398 | if (s[0] == '/') | 395 | if (s[0] == '/') |
399 | target.path = bb_xstrdup(s+1); | 396 | target.path = xstrdup(s+1); |
400 | else { | 397 | else { |
401 | parse_url(bb_xstrdup(s), &target); | 398 | parse_url(xstrdup(s), &target); |
402 | if (use_proxy == 0) { | 399 | if (use_proxy == 0) { |
403 | server.host = target.host; | 400 | server.host = target.host; |
404 | server.port = target.port; | 401 | server.port = target.port; |
@@ -419,7 +416,7 @@ read_response: | |||
419 | * FTP session | 416 | * FTP session |
420 | */ | 417 | */ |
421 | if (! target.user) | 418 | if (! target.user) |
422 | target.user = bb_xstrdup("anonymous:busybox@"); | 419 | target.user = xstrdup("anonymous:busybox@"); |
423 | 420 | ||
424 | sfp = open_socket(&s_in); | 421 | sfp = open_socket(&s_in); |
425 | if (ftpcmd(NULL, NULL, sfp, buf) != 220) | 422 | if (ftpcmd(NULL, NULL, sfp, buf) != 220) |
@@ -556,7 +553,7 @@ void parse_url(char *url, struct host_info *h) | |||
556 | *sp++ = '\0'; | 553 | *sp++ = '\0'; |
557 | h->path = sp; | 554 | h->path = sp; |
558 | } else | 555 | } else |
559 | h->path = bb_xstrdup(""); | 556 | h->path = xstrdup(""); |
560 | 557 | ||
561 | up = strrchr(h->host, '@'); | 558 | up = strrchr(h->host, '@'); |
562 | if (up != NULL) { | 559 | if (up != NULL) { |