aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-01 09:39:03 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-01 09:39:03 +0000
commitba2fb719b92034e745b59d2c3b5b05209ce45352 (patch)
tree811452c3e50482b9f4063de1121dd630c44dbf0e
parent2856dab4770e521a87c18b04ae8ebc209a9b95f9 (diff)
downloadbusybox-w32-ba2fb719b92034e745b59d2c3b5b05209ce45352.tar.gz
busybox-w32-ba2fb719b92034e745b59d2c3b5b05209ce45352.tar.bz2
busybox-w32-ba2fb719b92034e745b59d2c3b5b05209ce45352.zip
Copyright, help text, whitespace cleanups
-rw-r--r--editors/vi.c2
-rw-r--r--include/usage.h22
-rw-r--r--ipsvd/tcpsvd.c84
-rw-r--r--networking/udhcp/dumpleases.c4
4 files changed, 71 insertions, 41 deletions
diff --git a/editors/vi.c b/editors/vi.c
index c7582bfe0..5bce4272f 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -976,7 +976,7 @@ static void colon(char * buf)
976 } 976 }
977#if ENABLE_FEATURE_VI_SETOPTS 977#if ENABLE_FEATURE_VI_SETOPTS
978 argp = args; 978 argp = args;
979 while (*argp) { 979 while (*argp) {
980 if (strncasecmp(argp, "no", 2) == 0) 980 if (strncasecmp(argp, "no", 2) == 0)
981 i = 2; // ":set noautoindent" 981 i = 2; // ":set noautoindent"
982 setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT); 982 setops(argp, "autoindent ", i, "ai", VI_AUTOINDENT);
diff --git a/include/usage.h b/include/usage.h
index 09b6908f9..e1fbf7599 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -3326,9 +3326,27 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3326 "1\n" 3326 "1\n"
3327 3327
3328#define tcpsvd_trivial_usage \ 3328#define tcpsvd_trivial_usage \
3329 "TODO" 3329 "[-hpEvv] [-c n] [-C n:msg] [-b n] [-u user] [-l name] ip port prog..."
3330/* with not-implemented options: */
3331/* "[-hpEvv] [-c n] [-C n:msg] [-b n] [-u user] [-l name] [-i dir|-x cdb] [ -t sec] ip port prog..." */
3330#define tcpsvd_full_usage \ 3332#define tcpsvd_full_usage \
3331 "TODO" 3333 "tcpsvd creates TCP/IP socket, binds it to host:port\n" \
3334 "and listens on in for incoming connections. For each connection\n" \
3335 "it runs prog" \
3336 "\n" \
3337 "\nip IP to listen on. '0' = 'all'" \
3338 "\nport Port to listen on" \
3339 "\nprog [arg] Program to run for each connection" \
3340 "\n-l name Local hostname (else looks up local hostname in DNS)" \
3341 "\n-u user[:group] Change to user/group after bind" \
3342 "\n-c n Handle up to n connections simultaneously" \
3343 "\n-C n[:msg] Allow only up to n connections from the same IP" \
3344 "\n New connections from this IP address are closed" \
3345 "\n immediately. 'msg' is written to the peer before close" \
3346 "\n-h Look up peer's hostname in DNS" \
3347 "\n-b n Allow a backlog of approximately n TCP SYNs" \
3348 "\n-E Do not set up TCP-related environment variables" \
3349 "\n-v Verbose"
3332 3350
3333#define tftp_trivial_usage \ 3351#define tftp_trivial_usage \
3334 "[OPTION]... HOST [PORT]" 3352 "[OPTION]... HOST [PORT]"
diff --git a/ipsvd/tcpsvd.c b/ipsvd/tcpsvd.c
index 9a0a348de..df9821652 100644
--- a/ipsvd/tcpsvd.c
+++ b/ipsvd/tcpsvd.c
@@ -1,15 +1,20 @@
1/* 1/* Based on ipsvd utilities written by Gerrit Pape <pape@smarden.org>
2# /usr/bin/tcpsvd -v 0 1234 true 2 * which are released into public domain by the author.
3tcpsvd: info: pid 24916 from 127.0.0.1 3 * Homepage: http://smarden.sunsite.dk/ipsvd/
4tcpsvd: info: start 24916 localhost:127.0.0.1 ::127.0.0.1:47905 4 *
5tcpsvd: info: pid 24918 from 127.0.0.1 5 * Copyright (C) 2007 by Denis Vlasenko.
6tcpsvd: info: start 24918 localhost:127.0.0.1 ::127.0.0.1:47906 6 *
7# ./busybox tcpsvd -v 0 1234 true 7 * Licensed under GPLv2, see file LICENSE in this tarball for details.
8tcpsvd: info: pid 24924 from 127.0.0.1 8 */
9tcpsvd: info: start 24924 localhost:1234:127.0.0.1:1234 ::127.0.0.1:47908 9
10tcpsvd: info: pid 24926 from 127.0.0.1 10/* Based on ipsvd ipsvd-0.12.1. This tcpsvd accepts all options
11tcpsvd: info: start 24926 localhost:1234:127.0.0.1:1234 ::127.0.0.1:47909 11 * which are supported by one from ipsvd-0.12.1, but not all are
12*/ 12 * functional. See help text at the end of this file for details.
13 *
14 * Code inside "#ifdef SSLSVD" is for sslsvd and is currently unused.
15 * Code inside #if 0" is parts of original tcpsvd which are not implemented
16 * for busyboxed version.
17 */
13 18
14#include "busybox.h" 19#include "busybox.h"
15#include "ipsvd_perhost.h" 20#include "ipsvd_perhost.h"
@@ -297,15 +302,15 @@ int tcpsvd_main(int argc, char **argv)
297 if (!max_per_host) 302 if (!max_per_host)
298 remote_ip = xmalloc_sockaddr2dotted_noport(&sock_adr.sa, sizeof(sock_adr)); 303 remote_ip = xmalloc_sockaddr2dotted_noport(&sock_adr.sa, sizeof(sock_adr));
299 /* else it is already done */ 304 /* else it is already done */
300 305
301 remote_port = get_nport(&sock_adr.sa); 306 remote_port = get_nport(&sock_adr.sa);
302 remote_port = ntohs(remote_port); 307 remote_port = ntohs(remote_port);
303 308
304 if (verbose) { 309 if (verbose) {
305 pid = getpid(); 310 pid = getpid();
306 printf("%s: info: pid %d from %s\n", applet_name, pid, remote_ip); 311 printf("%s: info: pid %d from %s\n", applet_name, pid, remote_ip);
307 } 312 }
308 313
309 if (need_addresses && (option_mask32 & OPT_h)) { 314 if (need_addresses && (option_mask32 & OPT_h)) {
310 remote_hostname = xmalloc_sockaddr2host(&sock_adr.sa, sizeof(sock_adr)); 315 remote_hostname = xmalloc_sockaddr2host(&sock_adr.sa, sizeof(sock_adr));
311 if (!remote_hostname) { 316 if (!remote_hostname) {
@@ -313,7 +318,7 @@ int tcpsvd_main(int argc, char **argv)
313 remote_hostname = (char*)""; 318 remote_hostname = (char*)"";
314 } 319 }
315 } 320 }
316 321
317 sockadr_size = sizeof(sock_adr); 322 sockadr_size = sizeof(sock_adr);
318 /* Errors ignored (I'm not paranoid enough to imagine kernel 323 /* Errors ignored (I'm not paranoid enough to imagine kernel
319 * which doesn't know local ip) */ 324 * which doesn't know local ip) */
@@ -329,7 +334,7 @@ int tcpsvd_main(int argc, char **argv)
329 bb_error_msg_and_die("cannot look up local hostname for %s", local_ip); 334 bb_error_msg_and_die("cannot look up local hostname for %s", local_ip);
330 } 335 }
331 } 336 }
332 337
333 if (!(option_mask32 & OPT_E)) { 338 if (!(option_mask32 & OPT_E)) {
334 /* setup ucspi env */ 339 /* setup ucspi env */
335 xsetenv("PROTO", "TCP"); 340 xsetenv("PROTO", "TCP");
@@ -346,7 +351,7 @@ int tcpsvd_main(int argc, char **argv)
346 if (cur_per_host > 0) 351 if (cur_per_host > 0)
347 xsetenv("TCPCONCURRENCY", utoa(cur_per_host)); 352 xsetenv("TCPCONCURRENCY", utoa(cur_per_host));
348 } 353 }
349 354
350#if 0 355#if 0
351 if (instructs) { 356 if (instructs) {
352 ac = ipsvd_check(iscdb, &inst, &match, (char*)instructs, 357 ac = ipsvd_check(iscdb, &inst, &match, (char*)instructs,
@@ -356,11 +361,11 @@ int tcpsvd_main(int argc, char **argv)
356 } else 361 } else
357 ac = IPSVD_DEFAULT; 362 ac = IPSVD_DEFAULT;
358#endif 363#endif
359 364
360 if (max_per_host && verbose) 365 if (max_per_host && verbose)
361 printf("%s: info: concurrency %u %s %u/%u\n", 366 printf("%s: info: concurrency %u %s %u/%u\n",
362 applet_name, pid, remote_ip, cur_per_host, max_per_host); 367 applet_name, pid, remote_ip, cur_per_host, max_per_host);
363 368
364 if (verbose) { 369 if (verbose) {
365 printf("%s: info: start %u %s:%s :%s:%s:%u\n", 370 printf("%s: info: start %u %s:%s :%s:%s:%u\n",
366 applet_name, pid, 371 applet_name, pid,
@@ -445,6 +450,8 @@ host
445 host either is a hostname, or a dotted-decimal IP address, 450 host either is a hostname, or a dotted-decimal IP address,
446 or 0. If host is 0, tcpsvd accepts connections to any local 451 or 0. If host is 0, tcpsvd accepts connections to any local
447 IP address. 452 IP address.
453 * busybox accepts IPv6 addresses and host:port pairs too
454 In this case second parameter is ignored
448port 455port
449 tcpsvd accepts connections to host:port. port may be a name 456 tcpsvd accepts connections to host:port. port may be a name
450 from /etc/services or a number. 457 from /etc/services or a number.
@@ -453,14 +460,16 @@ prog
453 tcpsvd normally runs prog, with file descriptor 0 reading from 460 tcpsvd normally runs prog, with file descriptor 0 reading from
454 the network, and file descriptor 1 writing to the network. 461 the network, and file descriptor 1 writing to the network.
455 By default it also sets up TCP-related environment variables, 462 By default it also sets up TCP-related environment variables,
456 see tcp-environ(5) 463 see tcp-environ(5)
457-i dir 464-i dir
458 read instructions for handling new connections from the instructions 465 read instructions for handling new connections from the instructions
459 directory dir. See ipsvd-instruct(5) for details. 466 directory dir. See ipsvd-instruct(5) for details.
467 * ignored by busyboxed version
460-x cdb 468-x cdb
461 read instructions for handling new connections from the constant database 469 read instructions for handling new connections from the constant database
462 cdb. The constant database normally is created from an instructions 470 cdb. The constant database normally is created from an instructions
463 directory by running ipsvd-cdb(8). 471 directory by running ipsvd-cdb(8).
472 * ignored by busyboxed version
464-t sec 473-t sec
465 timeout. This option only takes effect if the -i option is given. 474 timeout. This option only takes effect if the -i option is given.
466 While checking the instructions directory, check the time of last access 475 While checking the instructions directory, check the time of last access
@@ -468,47 +477,50 @@ prog
468 and remove the file if it wasn't accessed within the last sec seconds; 477 and remove the file if it wasn't accessed within the last sec seconds;
469 tcpsvd does not discard or remove a file if the user's write permission 478 tcpsvd does not discard or remove a file if the user's write permission
470 is not set, for those files the timeout is disabled. Default is 0, 479 is not set, for those files the timeout is disabled. Default is 0,
471 which means that the timeout is disabled. 480 which means that the timeout is disabled.
481 * ignored by busyboxed version
472-l name 482-l name
473 local hostname. Do not look up the local hostname in DNS, but use name 483 local hostname. Do not look up the local hostname in DNS, but use name
474 as hostname. This option must be set if tcpsvd listens on port 53 484 as hostname. This option must be set if tcpsvd listens on port 53
475 to avoid loops. 485 to avoid loops.
476-u user[:group] 486-u user[:group]
477 drop permissions. Switch user ID to user's UID, and group ID to user's 487 drop permissions. Switch user ID to user's UID, and group ID to user's
478 primary GID after creating and binding to the socket. If user is followed 488 primary GID after creating and binding to the socket. If user is followed
479 by a colon and a group name, the group ID is switched to the GID of group 489 by a colon and a group name, the group ID is switched to the GID of group
480 instead. All supplementary groups are removed. 490 instead. All supplementary groups are removed.
481-c n 491-c n
482 concurrency. Handle up to n connections simultaneously. Default is 30. 492 concurrency. Handle up to n connections simultaneously. Default is 30.
483 If there are n connections active, tcpsvd defers acceptance of a new 493 If there are n connections active, tcpsvd defers acceptance of a new
484 connection until an active connection is closed. 494 connection until an active connection is closed.
485-C n[:msg] 495-C n[:msg]
486 per host concurrency. Allow only up to n connections from the same IP 496 per host concurrency. Allow only up to n connections from the same IP
487 address simultaneously. If there are n active connections from one IP 497 address simultaneously. If there are n active connections from one IP
488 address, new incoming connections from this IP address are closed 498 address, new incoming connections from this IP address are closed
489 immediately. If n is followed by :msg, the message msg is written 499 immediately. If n is followed by :msg, the message msg is written
490 to the client if possible, before closing the connection. By default 500 to the client if possible, before closing the connection. By default
491 msg is empty. See ipsvd-instruct(5) for supported escape sequences in msg. 501 msg is empty. See ipsvd-instruct(5) for supported escape sequences in msg.
492 502
493 For each accepted connection, the current per host concurrency is 503 For each accepted connection, the current per host concurrency is
494 available through the environment variable TCPCONCURRENCY. n and msg 504 available through the environment variable TCPCONCURRENCY. n and msg
495 can be overwritten by ipsvd(7) instructions, see ipsvd-instruct(5). 505 can be overwritten by ipsvd(7) instructions, see ipsvd-instruct(5).
496 By default tcpsvd doesn't keep track of connections. 506 By default tcpsvd doesn't keep track of connections.
497-h 507-h
498 Look up the client's hostname in DNS. 508 Look up the client's hostname in DNS.
499-p 509-p
500 paranoid. After looking up the client's hostname in DNS, look up the IP 510 paranoid. After looking up the client's hostname in DNS, look up the IP
501 addresses in DNS for that hostname, and forget about the hostname 511 addresses in DNS for that hostname, and forget about the hostname
502 if none of the addresses match the client's IP address. You should 512 if none of the addresses match the client's IP address. You should
503 set this option if you use hostname based instructions. The -p option 513 set this option if you use hostname based instructions. The -p option
504 implies the -h option. 514 implies the -h option.
515 * ignored by busyboxed version
505-b n 516-b n
506 backlog. Allow a backlog of approximately n TCP SYNs. On some systems n 517 backlog. Allow a backlog of approximately n TCP SYNs. On some systems n
507 is silently limited. Default is 20. 518 is silently limited. Default is 20.
508-E 519-E
509 no special environment. Do not set up TCP-related environment variables. 520 no special environment. Do not set up TCP-related environment variables.
510-v 521-v
511 verbose. Print verbose messsages to standard output. 522 verbose. Print verbose messsages to standard output.
512-vv 523-vv
513 more verbose. Print more verbose messages to standard output. 524 more verbose. Print more verbose messages to standard output.
525 * no difference between -v and -vv in busyboxed version
514*/ 526*/
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c
index 80cf5b8f5..507663fd9 100644
--- a/networking/udhcp/dumpleases.c
+++ b/networking/udhcp/dumpleases.c
@@ -23,14 +23,14 @@ int dumpleases_main(int argc, char *argv[])
23 OPT_r = 0x2, // -r 23 OPT_r = 0x2, // -r
24 OPT_f = 0x4, // -f 24 OPT_f = 0x4, // -f
25 }; 25 };
26#if ENABLE_GETOPT_LONG 26#if ENABLE_GETOPT_LONG
27 static const struct option options[] = { 27 static const struct option options[] = {
28 { "absolute", no_argument, 0, 'a' }, 28 { "absolute", no_argument, 0, 'a' },
29 { "remaining", no_argument, 0, 'r' }, 29 { "remaining", no_argument, 0, 'r' },
30 { "file", required_argument, 0, 'f' }, 30 { "file", required_argument, 0, 'f' },
31 { NULL, 0, 0, 0 } 31 { NULL, 0, 0, 0 }
32 }; 32 };
33 33
34 applet_long_options = options; 34 applet_long_options = options;
35#endif 35#endif
36 opt_complementary = "=0:?:a--r:r--a"; 36 opt_complementary = "=0:?:a--r:r--a";