diff options
author | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-05-06 05:00:34 +0000 |
---|---|---|
committer | vapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-05-06 05:00:34 +0000 |
commit | 236198e87cb515d78232f3fa0179db805b3d1fc1 (patch) | |
tree | 527c4d23922e3ad159e06623de1b2afcf04a4b0f | |
parent | 47353430391435241f22ccbb15a9dbe4d48ea186 (diff) | |
download | busybox-w32-236198e87cb515d78232f3fa0179db805b3d1fc1.tar.gz busybox-w32-236198e87cb515d78232f3fa0179db805b3d1fc1.tar.bz2 busybox-w32-236198e87cb515d78232f3fa0179db805b3d1fc1.zip |
make the exec (-e) an optional feature of netcat
git-svn-id: svn://busybox.net/trunk/busybox@10254 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | include/usage.h | 11 | ||||
-rw-r--r-- | networking/Config.in | 8 | ||||
-rw-r--r-- | networking/nc.c | 27 |
3 files changed, 28 insertions, 18 deletions
diff --git a/include/usage.h b/include/usage.h index d731957f1..1ef79df61 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -1824,6 +1824,11 @@ | |||
1824 | " or\n" \ | 1824 | " or\n" \ |
1825 | "$ nameif -c /etc/my_mactab_file\n" \ | 1825 | "$ nameif -c /etc/my_mactab_file\n" \ |
1826 | 1826 | ||
1827 | #ifdef CONFIG_NC_GAPING_SECURITY_HOLE | ||
1828 | # define USAGE_NC_EXEC(a) a | ||
1829 | #else | ||
1830 | # define USAGE_NC_EXEC(a) | ||
1831 | #endif | ||
1827 | #define nc_trivial_usage \ | 1832 | #define nc_trivial_usage \ |
1828 | "[OPTIONS] [IP] [port]" | 1833 | "[OPTIONS] [IP] [port]" |
1829 | #define nc_full_usage \ | 1834 | #define nc_full_usage \ |
@@ -1832,8 +1837,10 @@ | |||
1832 | "\t-l\t\tlisten mode, for inbound connects\n" \ | 1837 | "\t-l\t\tlisten mode, for inbound connects\n" \ |
1833 | "\t-p PORT\t\tlocal port number\n" \ | 1838 | "\t-p PORT\t\tlocal port number\n" \ |
1834 | "\t-i SECS\t\tdelay interval for lines sent\n" \ | 1839 | "\t-i SECS\t\tdelay interval for lines sent\n" \ |
1835 | "\t-w SECS\t\ttimeout for connects and final net reads\n" \ | 1840 | USAGE_NC_EXEC( \ |
1836 | "\t-e PROG\t\tprogram to exec after connect (dangerous!)" | 1841 | "\t-e PROG\t\tprogram to exec after connect (dangerous!)\n" \ |
1842 | ) \ | ||
1843 | "\t-w SECS\t\ttimeout for connects and final net reads" | ||
1837 | #define nc_example_usage \ | 1844 | #define nc_example_usage \ |
1838 | "$ nc foobar.somedomain.com 25\n" \ | 1845 | "$ nc foobar.somedomain.com 25\n" \ |
1839 | "220 foobar ESMTP Exim 3.12 #1 Sat, 15 Apr 2000 00:03:02 -0600\n" \ | 1846 | "220 foobar ESMTP Exim 3.12 #1 Sat, 15 Apr 2000 00:03:02 -0600\n" \ |
diff --git a/networking/Config.in b/networking/Config.in index 418ef4bc4..a84427981 100644 --- a/networking/Config.in +++ b/networking/Config.in | |||
@@ -422,6 +422,14 @@ config CONFIG_NC | |||
422 | A simple Unix utility which reads and writes data across network | 422 | A simple Unix utility which reads and writes data across network |
423 | connections. | 423 | connections. |
424 | 424 | ||
425 | config CONFIG_NC_GAPING_SECURITY_HOLE | ||
426 | bool "gaping security hole" | ||
427 | default n | ||
428 | depends on CONFIG_NC | ||
429 | help | ||
430 | Add support for executing a program after making or receiving a | ||
431 | successful connection (-e option). | ||
432 | |||
425 | config CONFIG_NETSTAT | 433 | config CONFIG_NETSTAT |
426 | bool "netstat" | 434 | bool "netstat" |
427 | default n | 435 | default n |
diff --git a/networking/nc.c b/networking/nc.c index bbcbc0d13..bb6373fd3 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | 0.0.1 6K It works. | 5 | 0.0.1 6K It works. |
6 | 0.0.2 5K Smaller and you can also check the exit condition if you wish. | 6 | 0.0.2 5K Smaller and you can also check the exit condition if you wish. |
7 | 0.0.3 Uses select() | 7 | 0.0.3 Uses select() |
8 | 8 | ||
9 | 19980918 Busy Boxed! Dave Cinege | 9 | 19980918 Busy Boxed! Dave Cinege |
10 | 19990512 Uses Select. Charles P. Wright | 10 | 19990512 Uses Select. Charles P. Wright |
@@ -23,7 +23,6 @@ | |||
23 | You should have received a copy of the GNU General Public License | 23 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software | 24 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 25 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
26 | |||
27 | */ | 26 | */ |
28 | 27 | ||
29 | #include <stdio.h> | 28 | #include <stdio.h> |
@@ -41,8 +40,6 @@ | |||
41 | #include <sys/ioctl.h> | 40 | #include <sys/ioctl.h> |
42 | #include "busybox.h" | 41 | #include "busybox.h" |
43 | 42 | ||
44 | #define GAPING_SECURITY_HOLE | ||
45 | |||
46 | static void timeout(int signum) | 43 | static void timeout(int signum) |
47 | { | 44 | { |
48 | bb_error_msg_and_die("Timed out"); | 45 | bb_error_msg_and_die("Timed out"); |
@@ -52,8 +49,8 @@ int nc_main(int argc, char **argv) | |||
52 | { | 49 | { |
53 | int do_listen = 0, lport = 0, delay = 0, wsecs = 0, tmpfd, opt, sfd, x; | 50 | int do_listen = 0, lport = 0, delay = 0, wsecs = 0, tmpfd, opt, sfd, x; |
54 | char buf[BUFSIZ]; | 51 | char buf[BUFSIZ]; |
55 | #ifdef GAPING_SECURITY_HOLE | 52 | #ifdef CONFIG_NC_GAPING_SECURITY_HOLE |
56 | char * pr00gie = NULL; | 53 | char *pr00gie = NULL; |
57 | #endif | 54 | #endif |
58 | 55 | ||
59 | struct sockaddr_in address; | 56 | struct sockaddr_in address; |
@@ -72,7 +69,7 @@ int nc_main(int argc, char **argv) | |||
72 | case 'i': | 69 | case 'i': |
73 | delay = atoi(optarg); | 70 | delay = atoi(optarg); |
74 | break; | 71 | break; |
75 | #ifdef GAPING_SECURITY_HOLE | 72 | #ifdef CONFIG_NC_GAPING_SECURITY_HOLE |
76 | case 'e': | 73 | case 'e': |
77 | pr00gie = optarg; | 74 | pr00gie = optarg; |
78 | break; | 75 | break; |
@@ -85,13 +82,12 @@ int nc_main(int argc, char **argv) | |||
85 | } | 82 | } |
86 | } | 83 | } |
87 | 84 | ||
88 | #ifdef GAPING_SECURITY_HOLE | 85 | #ifdef CONFIG_NC_GAPING_SECURITY_HOLE |
89 | if (pr00gie) { | 86 | if (pr00gie) { |
90 | /* won't need stdin */ | 87 | /* won't need stdin */ |
91 | close (STDIN_FILENO); | 88 | close (STDIN_FILENO); |
92 | } | 89 | } |
93 | #endif /* GAPING_SECURITY_HOLE */ | 90 | #endif /* CONFIG_NC_GAPING_SECURITY_HOLE */ |
94 | |||
95 | 91 | ||
96 | if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) | 92 | if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) |
97 | bb_show_usage(); | 93 | bb_show_usage(); |
@@ -142,19 +138,18 @@ int nc_main(int argc, char **argv) | |||
142 | signal(SIGALRM, SIG_DFL); | 138 | signal(SIGALRM, SIG_DFL); |
143 | } | 139 | } |
144 | 140 | ||
145 | #ifdef GAPING_SECURITY_HOLE | 141 | #ifdef CONFIG_NC_GAPING_SECURITY_HOLE |
146 | /* -e given? */ | 142 | /* -e given? */ |
147 | if (pr00gie) { | 143 | if (pr00gie) { |
148 | dup2(sfd, 0); | 144 | dup2(sfd, 0); |
149 | close(sfd); | 145 | close(sfd); |
150 | dup2 (0, 1); | 146 | dup2(0, 1); |
151 | dup2 (0, 2); | 147 | dup2(0, 2); |
152 | execl (pr00gie, pr00gie, NULL); | 148 | execl(pr00gie, pr00gie, NULL); |
153 | /* Don't print stuff or it will go over the wire.... */ | 149 | /* Don't print stuff or it will go over the wire.... */ |
154 | _exit(-1); | 150 | _exit(-1); |
155 | } | 151 | } |
156 | #endif /* GAPING_SECURITY_HOLE */ | 152 | #endif /* CONFIG_NC_GAPING_SECURITY_HOLE */ |
157 | |||
158 | 153 | ||
159 | FD_ZERO(&readfds); | 154 | FD_ZERO(&readfds); |
160 | FD_SET(sfd, &readfds); | 155 | FD_SET(sfd, &readfds); |