Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/nc - Disable crypto for now, and functionality that ...
details: https://anonhg.NetBSD.org/src/rev/3aaac9b4a163
branches: trunk
changeset: 351197:3aaac9b4a163
user: christos <christos%NetBSD.org@localhost>
date: Mon Feb 06 16:03:40 2017 +0000
description:
- Disable crypto for now, and functionality that we don't provide.
- Fix warnings
diffstat:
usr.bin/nc/Makefile | 10 +-
usr.bin/nc/atomicio.c | 2 +
usr.bin/nc/nc.1 | 9 +-
usr.bin/nc/netcat.c | 288 ++++++++++++++++++++++++++++++++-----------------
usr.bin/nc/socks.c | 42 ++++--
5 files changed, 229 insertions(+), 122 deletions(-)
diffs (truncated from 861 to 300 lines):
diff -r 426a051305aa -r 3aaac9b4a163 usr.bin/nc/Makefile
--- a/usr.bin/nc/Makefile Mon Feb 06 16:02:17 2017 +0000
+++ b/usr.bin/nc/Makefile Mon Feb 06 16:03:40 2017 +0000
@@ -1,8 +1,14 @@
# $OpenBSD: Makefile,v 1.7 2015/09/11 21:07:01 beck Exp $
+.include <bsd.own.mk>
+
PROG= nc
SRCS= netcat.c atomicio.c socks.c
-LDADD+= -ltls -lssl -lcrypto
-DPADD+= ${LIBTLS} ${LIBSSL} ${LIBCRYPTO}
+
+#.if ${MKCRYPTO} == "yes"
+#CPPFLAGS+=-DCRYPTO
+#LDADD+= -ltls -lssl -lcrypto
+#DPADD+= ${LIBTLS} ${LIBSSL} ${LIBCRYPTO}
+#.endif
.include <bsd.prog.mk>
diff -r 426a051305aa -r 3aaac9b4a163 usr.bin/nc/atomicio.c
--- a/usr.bin/nc/atomicio.c Mon Feb 06 16:02:17 2017 +0000
+++ b/usr.bin/nc/atomicio.c Mon Feb 06 16:03:40 2017 +0000
@@ -25,6 +25,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: atomicio.c,v 1.2 2017/02/06 16:03:40 christos Exp $");
#include <errno.h>
#include <poll.h>
diff -r 426a051305aa -r 3aaac9b4a163 usr.bin/nc/nc.1
--- a/usr.bin/nc/nc.1 Mon Feb 06 16:02:17 2017 +0000
+++ b/usr.bin/nc/nc.1 Mon Feb 06 16:03:40 2017 +0000
@@ -1,3 +1,4 @@
+.\" $NetBSD: nc.1,v 1.2 2017/02/06 16:03:40 christos Exp $
.\" $OpenBSD: nc.1,v 1.81 2017/01/26 22:59:55 jmc Exp $
.\"
.\" Copyright (c) 1996 David Sacerdote
@@ -25,7 +26,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: January 26 2017 $
+.Dd Feb 2, 2017
.Dt NC 1
.Os
.Sh NAME
@@ -49,7 +50,7 @@
.Op Fl R Ar CAfile
.Op Fl s Ar source
.Op Fl T Ar keyword
-.Op Fl V Ar rtable
+.\" .Op Fl V Ar rtable
.Op Fl w Ar timeout
.Op Fl X Ar proxy_protocol
.Op Fl x Ar proxy_address Ns Op : Ns Ar port
@@ -281,8 +282,8 @@
unless the
.Fl s
flag is given.
-.It Fl V Ar rtable
-Set the routing table to be used.
+.\" .It Fl V Ar rtable
+.\" Set the routing table to be used.
.It Fl v
Have
.Nm
diff -r 426a051305aa -r 3aaac9b4a163 usr.bin/nc/netcat.c
--- a/usr.bin/nc/netcat.c Mon Feb 06 16:02:17 2017 +0000
+++ b/usr.bin/nc/netcat.c Mon Feb 06 16:03:40 2017 +0000
@@ -26,6 +26,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: netcat.c,v 1.2 2017/02/06 16:03:40 christos Exp $");
/*
* Re-written nc(1) for OpenBSD. Original implementation by
@@ -54,9 +56,18 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#ifdef CRYPTO
#include <tls.h>
+#else
+#define TLS_WANT_POLLIN -2
+#define TLS_WANT_POLLOUT -2
+#endif
#include "atomicio.h"
+#ifdef __NetBSD__
+#define accept4(a, b, c, d) paccept((a), (b), (c), NULL, (d))
+#endif
+
#define PORT_MAX 65535
#define UNIX_DG_TMP_SOCKET_SIZE 19
@@ -95,13 +106,15 @@
int Oflag; /* TCP send buffer size */
int Sflag; /* TCP MD5 signature option */
int Tflag = -1; /* IP Type of Service */
+#ifdef __OpenBSD__
int rtableid = -1;
+#endif
int usetls; /* use TLS */
char *Cflag; /* Public cert file */
char *Kflag; /* Private key file */
char *oflag; /* OCSP stapling file */
-char *Rflag = DEFAULT_CA_FILE; /* Root CA file */
+const char *Rflag = DEFAULT_CA_FILE; /* Root CA file */
int tls_cachanged; /* Using non-default CA file */
int TLSopt; /* TLS options */
char *tls_expectname; /* required name in peer cert */
@@ -118,6 +131,7 @@
void build_ports(char *);
void help(void);
int local_listen(char *, char *, struct addrinfo);
+struct tls;
void readwrite(int, struct tls *);
void fdpass(int nfd) __attribute__((noreturn));
int remote_connect(const char *, const char *, struct addrinfo);
@@ -132,7 +146,7 @@
int map_tos(char *, int *);
int map_tls(char *, int *);
void report_connect(const struct sockaddr *, socklen_t, char *);
-void report_tls(struct tls *tls_ctx, char * host, char *tls_expectname);
+void report_tls(struct tls *tls_ctx, char * host, char *tlsexpectname);
void usage(int);
ssize_t drainbuf(int, unsigned char *, size_t *, struct tls *);
ssize_t fillbuf(int, unsigned char *, size_t *, struct tls *);
@@ -148,12 +162,14 @@
struct servent *sv;
socklen_t len;
struct sockaddr_storage cliaddr;
- char *proxy, *proxyport = NULL;
- const char *errstr;
+ char *proxy = NULL, *proxyport = NULL;
+ int errnum;
struct addrinfo proxyhints;
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
+#ifdef CRYPTO
struct tls_config *tls_cfg = NULL;
struct tls *tls_ctx = NULL;
+#endif
ret = 1;
socksv = 5;
@@ -185,12 +201,14 @@
else
errx(1, "unsupported proxy protocol");
break;
+#ifdef CRYPTO
case 'C':
Cflag = optarg;
break;
case 'c':
usetls = 1;
break;
+#endif
case 'd':
dflag = 1;
break;
@@ -200,20 +218,24 @@
case 'F':
Fflag = 1;
break;
+#ifdef CRYPTO
case 'H':
tls_expecthash = optarg;
break;
+#endif
case 'h':
help();
break;
case 'i':
- iflag = strtonum(optarg, 0, UINT_MAX, &errstr);
- if (errstr)
- errx(1, "interval %s: %s", errstr, optarg);
+ iflag = strtoi(optarg, NULL, 0, 0, UINT_MAX, &errnum);
+ if (errnum)
+ errc(1, errnum, "bad interval `%s'", optarg);
break;
+#ifdef CRYPTO
case 'K':
Kflag = optarg;
break;
+#endif
case 'k':
kflag = 1;
break;
@@ -221,14 +243,14 @@
lflag = 1;
break;
case 'M':
- ttl = strtonum(optarg, 0, 255, &errstr);
- if (errstr)
- errx(1, "ttl is %s", errstr);
+ ttl = strtoi(optarg, NULL, 0, 0, 255, &errnum);
+ if (errnum)
+ errc(1, errnum, "bad ttl `%s'", optarg);
break;
case 'm':
- minttl = strtonum(optarg, 0, 255, &errstr);
- if (errstr)
- errx(1, "minttl is %s", errstr);
+ minttl = strtoi(optarg, NULL, 0, 0, 255, &errnum);
+ if (errnum)
+ errc(1, errnum, "bad minttl `%s'", optarg);
break;
case 'N':
Nflag = 1;
@@ -242,10 +264,12 @@
case 'p':
pflag = optarg;
break;
+#ifdef CRYPTO
case 'R':
tls_cachanged = 1;
Rflag = optarg;
break;
+#endif
case 'r':
rflag = 1;
break;
@@ -258,19 +282,20 @@
case 'u':
uflag = 1;
break;
+#ifdef __OpenBSD__
case 'V':
- rtableid = (int)strtonum(optarg, 0,
- RT_TABLEID_MAX, &errstr);
- if (errstr)
- errx(1, "rtable %s: %s", errstr, optarg);
+ rtableid = (int)strtoi(optarg, NULL, 0, 0, 255, &errnum);
+ if (errnum)
+ errc(1, errnum, "bad rtable `%s'", optarg);
break;
+#endif
case 'v':
vflag = 1;
break;
case 'w':
- timeout = strtonum(optarg, 0, INT_MAX / 1000, &errstr);
- if (errstr)
- errx(1, "timeout %s: %s", errstr, optarg);
+ timeout = strtoi(optarg, NULL, 0, 0, INT_MAX / 1000, &errnum);
+ if (errnum)
+ errc(1, errnum, "bad timeout `%s'", optarg);
timeout *= 1000;
break;
case 'x':
@@ -285,39 +310,37 @@
Dflag = 1;
break;
case 'I':
- Iflag = strtonum(optarg, 1, 65536 << 14, &errstr);
- if (errstr != NULL)
- errx(1, "TCP receive window %s: %s",
- errstr, optarg);
+ Iflag = strtoi(optarg, NULL, 0, 1, 65536 << 14, &errnum);
+ if (errnum)
+ errc(1, errnum, "bad TCP receive window `%s'",
+ optarg);
break;
case 'O':
- Oflag = strtonum(optarg, 1, 65536 << 14, &errstr);
- if (errstr != NULL)
- errx(1, "TCP send window %s: %s",
- errstr, optarg);
+ Oflag = strtoi(optarg, NULL, 0, 1, 65536 << 14, &errnum);
+ if (errnum)
+ errc(1, errnum, "bad TCP send window `%s'",
+ optarg);
break;
+#ifdef CRYPTO
case 'o':
oflag = optarg;
break;
+#endif
case 'S':
Sflag = 1;
break;
+#ifdef CRYPTO
case 'T':
- errstr = NULL;
- errno = 0;
if (map_tos(optarg, &Tflag))
break;
if (map_tls(optarg, &TLSopt))
break;
- if (strlen(optarg) > 1 && optarg[0] == '0' &&
- optarg[1] == 'x')
- Tflag = (int)strtol(optarg, NULL, 16);
- else
- Tflag = (int)strtonum(optarg, 0, 255,
Home |
Main Index |
Thread Index |
Old Index