diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-14 02:23:43 +0000 |
commit | ea62077b850076c4d7dc3cf78ebd1888928c6ddf (patch) | |
tree | 37b7584ae40b99edb5583fbc4392b62ffdadf278 /networking | |
parent | 88ca06769028e442bf873b270c176ca0e9f021f8 (diff) | |
download | busybox-w32-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.tar.gz busybox-w32-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.tar.bz2 busybox-w32-ea62077b850076c4d7dc3cf78ebd1888928c6ddf.zip |
add open_read_close() and similar stuff
Diffstat (limited to 'networking')
-rw-r--r-- | networking/fakeidentd.c | 2 | ||||
-rw-r--r-- | networking/ftpgetput.c | 2 | ||||
-rw-r--r-- | networking/inetd.c | 2 | ||||
-rw-r--r-- | networking/libiproute/libnetlink.c | 2 | ||||
-rw-r--r-- | networking/netstat.c | 8 | ||||
-rw-r--r-- | networking/traceroute.c | 8 | ||||
-rw-r--r-- | networking/udhcp/arpping.c | 2 | ||||
-rw-r--r-- | networking/udhcp/clientpacket.c | 7 | ||||
-rw-r--r-- | networking/udhcp/options.c | 2 | ||||
-rw-r--r-- | networking/udhcp/signalpipe.c | 2 | ||||
-rw-r--r-- | networking/wget.c | 4 |
11 files changed, 19 insertions, 22 deletions
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c index c8d32765a..18e86c50b 100644 --- a/networking/fakeidentd.c +++ b/networking/fakeidentd.c | |||
@@ -140,7 +140,7 @@ static int godaemon(void) | |||
140 | case 0: | 140 | case 0: |
141 | pw = getpwnam(nobodystr); | 141 | pw = getpwnam(nobodystr); |
142 | if (pw == NULL) | 142 | if (pw == NULL) |
143 | bb_error_msg_and_die("Cannot find uid/gid of user '%s'", nobodystr); | 143 | bb_error_msg_and_die("cannot find uid/gid of user '%s'", nobodystr); |
144 | nobody = pw->pw_uid; | 144 | nobody = pw->pw_uid; |
145 | nogrp = pw->pw_gid; | 145 | nogrp = pw->pw_gid; |
146 | writepid(nobody, nogrp); | 146 | writepid(nobody, nogrp); |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 47126ee83..aafeaf6e9 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -166,7 +166,7 @@ int ftp_receive(ftp_host_info_t *server, FILE *control_stream, | |||
166 | if (do_continue) { | 166 | if (do_continue) { |
167 | fd_local = xopen(local_path, O_APPEND | O_WRONLY); | 167 | fd_local = xopen(local_path, O_APPEND | O_WRONLY); |
168 | } else { | 168 | } else { |
169 | fd_local = xopen3(local_path, O_CREAT | O_TRUNC | O_WRONLY, 0777); | 169 | fd_local = xopen3(local_path, O_CREAT | O_TRUNC | O_WRONLY, 0666); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
diff --git a/networking/inetd.c b/networking/inetd.c index 966425385..75b2b14a7 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -1371,7 +1371,7 @@ inetd_main(int argc, char *argv[]) | |||
1371 | socklen_t plen = sizeof(peer); | 1371 | socklen_t plen = sizeof(peer); |
1372 | 1372 | ||
1373 | if (getpeername(ctrl, (struct sockaddr *) &peer, &plen) < 0) { | 1373 | if (getpeername(ctrl, (struct sockaddr *) &peer, &plen) < 0) { |
1374 | bb_error_msg("could not getpeername"); | 1374 | bb_error_msg("cannot getpeername"); |
1375 | close(ctrl); | 1375 | close(ctrl); |
1376 | continue; | 1376 | continue; |
1377 | } | 1377 | } |
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index de11d9dac..a595e967f 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c | |||
@@ -126,7 +126,7 @@ int rtnl_dump_filter(struct rtnl_handle *rth, | |||
126 | int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), | 126 | int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), |
127 | void *arg2) | 127 | void *arg2) |
128 | { | 128 | { |
129 | char buf[8192]; | 129 | char buf[8192]; |
130 | struct sockaddr_nl nladdr; | 130 | struct sockaddr_nl nladdr; |
131 | struct iovec iov = { buf, sizeof(buf) }; | 131 | struct iovec iov = { buf, sizeof(buf) }; |
132 | 132 | ||
diff --git a/networking/netstat.c b/networking/netstat.c index bc5c61974..8e481f67b 100644 --- a/networking/netstat.c +++ b/networking/netstat.c | |||
@@ -496,7 +496,6 @@ static void unix_do_one(int nr, const char *line) | |||
496 | 496 | ||
497 | static void do_info(const char *file, const char *name, void (*proc)(int, const char *)) | 497 | static void do_info(const char *file, const char *name, void (*proc)(int, const char *)) |
498 | { | 498 | { |
499 | char buffer[8192]; | ||
500 | int lnr = 0; | 499 | int lnr = 0; |
501 | FILE *procinfo; | 500 | FILE *procinfo; |
502 | 501 | ||
@@ -505,12 +504,15 @@ static void do_info(const char *file, const char *name, void (*proc)(int, const | |||
505 | if (errno != ENOENT) { | 504 | if (errno != ENOENT) { |
506 | perror(file); | 505 | perror(file); |
507 | } else { | 506 | } else { |
508 | bb_error_msg("no support for `%s' on this system", name); | 507 | bb_error_msg("no support for '%s' on this system", name); |
509 | } | 508 | } |
510 | } else { | 509 | } else { |
511 | do { | 510 | do { |
512 | if (fgets(buffer, sizeof(buffer), procinfo)) | 511 | char *buffer = xmalloc_fgets(procinfo); |
512 | if (buffer) { | ||
513 | (proc)(lnr++, buffer); | 513 | (proc)(lnr++, buffer); |
514 | free(buffer); | ||
515 | } | ||
514 | } while (!feof(procinfo)); | 516 | } while (!feof(procinfo)); |
515 | fclose(procinfo); | 517 | fclose(procinfo); |
516 | } | 518 | } |
diff --git a/networking/traceroute.c b/networking/traceroute.c index 84ce8ae69..3b590630c 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -417,7 +417,7 @@ ifaddrlist(struct IFADDRLIST **ipaddrp) | |||
417 | ++nipaddr; | 417 | ++nipaddr; |
418 | } | 418 | } |
419 | if (nipaddr == 0) | 419 | if (nipaddr == 0) |
420 | bb_error_msg_and_die ("Can't find any network interfaces"); | 420 | bb_error_msg_and_die ("can't find any network interfaces"); |
421 | (void)close(fd); | 421 | (void)close(fd); |
422 | 422 | ||
423 | *ipaddrp = st_ifaddrlist; | 423 | *ipaddrp = st_ifaddrlist; |
@@ -472,7 +472,7 @@ findsaddr(const struct sockaddr_in *to, struct sockaddr_in *from) | |||
472 | fclose(f); | 472 | fclose(f); |
473 | 473 | ||
474 | if (device[0] == '\0') | 474 | if (device[0] == '\0') |
475 | bb_error_msg_and_die ("Can't find interface"); | 475 | bb_error_msg_and_die ("can't find interface"); |
476 | 476 | ||
477 | /* Get the interface address list */ | 477 | /* Get the interface address list */ |
478 | n = ifaddrlist(&al); | 478 | n = ifaddrlist(&al); |
@@ -482,7 +482,7 @@ findsaddr(const struct sockaddr_in *to, struct sockaddr_in *from) | |||
482 | if (strcmp(device, al->device) == 0) | 482 | if (strcmp(device, al->device) == 0) |
483 | break; | 483 | break; |
484 | if (i <= 0) | 484 | if (i <= 0) |
485 | bb_error_msg_and_die("Can't find interface %s", device); | 485 | bb_error_msg_and_die("can't find interface %s", device); |
486 | 486 | ||
487 | setsin(from, al->addr); | 487 | setsin(from, al->addr); |
488 | } | 488 | } |
@@ -1156,7 +1156,7 @@ traceroute_main(int argc, char *argv[]) | |||
1156 | if (strcmp(device, al->device) == 0) | 1156 | if (strcmp(device, al->device) == 0) |
1157 | break; | 1157 | break; |
1158 | if (i <= 0) { | 1158 | if (i <= 0) { |
1159 | bb_error_msg_and_die("Can't find interface %s", device); | 1159 | bb_error_msg_and_die("can't find interface %s", device); |
1160 | } | 1160 | } |
1161 | } | 1161 | } |
1162 | 1162 | ||
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index 587339f9b..086692082 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c | |||
@@ -49,7 +49,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) | |||
49 | } | 49 | } |
50 | 50 | ||
51 | if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { | 51 | if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { |
52 | bb_perror_msg("Could not setsocketopt on raw socket"); | 52 | bb_perror_msg("cannot setsocketopt on raw socket"); |
53 | close(s); | 53 | close(s); |
54 | return -1; | 54 | return -1; |
55 | } | 55 | } |
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c index f9f5a3b8c..439aa0250 100644 --- a/networking/udhcp/clientpacket.c +++ b/networking/udhcp/clientpacket.c | |||
@@ -39,16 +39,13 @@ unsigned long random_xid(void) | |||
39 | { | 39 | { |
40 | static int initialized; | 40 | static int initialized; |
41 | if (!initialized) { | 41 | if (!initialized) { |
42 | int fd; | ||
43 | unsigned long seed; | 42 | unsigned long seed; |
44 | 43 | ||
45 | fd = open("/dev/urandom", 0); | 44 | if (open_read_close("/dev/urandom", &seed, sizeof(seed)) < 0) { |
46 | if (fd < 0 || read(fd, &seed, sizeof(seed)) < 0) { | 45 | bb_info_msg("Cannot load seed " |
47 | bb_info_msg("Could not load seed " | ||
48 | "from /dev/urandom: %s", strerror(errno)); | 46 | "from /dev/urandom: %s", strerror(errno)); |
49 | seed = time(0); | 47 | seed = time(0); |
50 | } | 48 | } |
51 | if (fd >= 0) close(fd); | ||
52 | srand(seed); | 49 | srand(seed); |
53 | initialized++; | 50 | initialized++; |
54 | } | 51 | } |
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index ded0f7b9b..8dba2ef69 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -171,6 +171,6 @@ int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) | |||
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | bb_error_msg("Could not add option 0x%02x", code); | 174 | bb_error_msg("cannot add option 0x%02x", code); |
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
diff --git a/networking/udhcp/signalpipe.c b/networking/udhcp/signalpipe.c index 6c4a9f1f2..bece4193a 100644 --- a/networking/udhcp/signalpipe.c +++ b/networking/udhcp/signalpipe.c | |||
@@ -36,7 +36,7 @@ static int signal_pipe[2]; | |||
36 | static void signal_handler(int sig) | 36 | static void signal_handler(int sig) |
37 | { | 37 | { |
38 | if (send(signal_pipe[1], &sig, sizeof(sig), MSG_DONTWAIT) < 0) | 38 | if (send(signal_pipe[1], &sig, sizeof(sig), MSG_DONTWAIT) < 0) |
39 | bb_perror_msg("Could not send signal"); | 39 | bb_perror_msg("cannot send signal"); |
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
diff --git a/networking/wget.c b/networking/wget.c index 264ae4483..7a931f363 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -219,9 +219,7 @@ int wget_main(int argc, char **argv) | |||
219 | } else if (opt & WGET_OPT_CONTINUE) { | 219 | } else if (opt & WGET_OPT_CONTINUE) { |
220 | output_fd = open(fname_out, O_WRONLY); | 220 | output_fd = open(fname_out, O_WRONLY); |
221 | if (output_fd >= 0) { | 221 | if (output_fd >= 0) { |
222 | beg_range = lseek(output_fd, 0, SEEK_END); | 222 | beg_range = xlseek(output_fd, 0, SEEK_END); |
223 | if (beg_range == (off_t)-1) | ||
224 | bb_perror_msg_and_die("lseek"); | ||
225 | } | 223 | } |
226 | /* File doesn't exist. We do not create file here yet. | 224 | /* File doesn't exist. We do not create file here yet. |
227 | We are not sure it exists on remove side */ | 225 | We are not sure it exists on remove side */ |