summaryrefslogtreecommitdiff
path: root/src/conn-tools
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2016-11-25 20:16:06 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2016-11-25 20:16:06 +0000
commit8d532683386121e70810b0d7c6642cc2c2b89cb0 (patch)
tree866010763c829a35b18603c5af58896bd14afd18 /src/conn-tools
parent018025f0f36a4847df265c9948dbaf7073ed3245 (diff)
downloads6-networking-8d532683386121e70810b0d7c6642cc2c2b89cb0.tar.xz
Fix build bugs. It builds!
Two things remain to do: - how to pass SNI information to libtls - how to detect cert issuer key type for ECC in bearssl
Diffstat (limited to 'src/conn-tools')
-rw-r--r--src/conn-tools/s6-tlsc.c10
-rw-r--r--src/conn-tools/s6-tlsclient.c27
-rw-r--r--src/conn-tools/s6-tlsd.c2
-rw-r--r--src/conn-tools/s6-tlsserver.c10
4 files changed, 33 insertions, 16 deletions
diff --git a/src/conn-tools/s6-tlsc.c b/src/conn-tools/s6-tlsc.c
index e2b6f7f..4476690 100644
--- a/src/conn-tools/s6-tlsc.c
+++ b/src/conn-tools/s6-tlsc.c
@@ -31,11 +31,12 @@
#endif
-#define USAGE "s6-tlsc [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -6 rfd ] [ -7 wfd ] prog..."
+#define USAGE "s6-tlsc [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -k servername ] [ -6 rfd ] [ -7 wfd ] prog..."
#define dieusage() strerr_dieusage(100, USAGE)
int main (int argc, char const *const *argv, char const *const *envp)
{
+ char const *servername = 0 ;
tain_t tto ;
unsigned int verbosity = 1 ;
uid_t uid = 0 ;
@@ -50,7 +51,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
unsigned int t = 0 ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "SsYyv:K:6:7:", &l) ;
+ register int opt = subgetopt_r(argc, argv, "SsYyv:K:k:6:7:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -60,6 +61,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'y' : preoptions |= 1 ; break ;
case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ;
case 'K' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ;
+ case 'k' : servername = l.arg ; break ;
case '6' :
{
unsigned int fd ;
@@ -84,7 +86,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!getuid())
{
- x = env_get2(envp, "TLS_UID") ;
+ char const *x = env_get2(envp, "TLS_UID") ;
if (x)
{
uint64 u ;
@@ -98,5 +100,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
}
- return s6tlsc(argv, envp, &tto, preoptions, options, uid, gid, verbosity) ;
+ return s6tlsc(argv, envp, &tto, preoptions, options, uid, gid, verbosity, servername, fds) ;
}
diff --git a/src/conn-tools/s6-tlsclient.c b/src/conn-tools/s6-tlsclient.c
index 6d2249a..a1cd75d 100644
--- a/src/conn-tools/s6-tlsclient.c
+++ b/src/conn-tools/s6-tlsclient.c
@@ -9,9 +9,9 @@
#include <skalibs/ip46.h>
#include <s6-networking/config.h>
-#define USAGE "s6-tlsclient [ options ] ip port prog...\n" \
+#define USAGE "s6-tlsclient [ options ] host port prog...\n" \
"s6-tcpclient options: [ -q | -Q | -v ] [ -4 | -6 ] [ -d | -D ] [ -r | -R ] [ -h | -H ] [ -n | -N ] [ -t timeout ] [ -l localname ] [ -T timeoutconn ] [ -i localip ] [ -p localport ]\n" \
-"s6-tlsc options: [ -S | -s ] [ -Y | -y ] [ -K timeout ]"
+"s6-tlsc options: [ -S | -s ] [ -Y | -y ] [ -K timeout ] [ -k servername ]"
#define dieusage() strerr_dieusage(100, USAGE)
@@ -19,6 +19,7 @@ typedef struct options_s options_t, *options_t_ref ;
struct options_s
{
char const *localname ;
+ char const *servername ;
unsigned int timeout ;
unsigned int ximeout ;
unsigned int yimeout ;
@@ -40,6 +41,7 @@ struct options_s
#define OPTIONS_ZERO \
{ \
.localname = 0, \
+ .servername = 0, \
.timeout = 0, \
.ximeout = 2, \
.yimeout = 58, \
@@ -66,7 +68,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "qQv46DdHhRrnNt:l:T:i:p:SsYyK:", &l) ;
+ register int opt = subgetopt_r(argc, argv, "qQv46DdHhRrnNt:l:T:i:p:SsYyK:k:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -78,7 +80,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'D' : o.flagD = 1 ; break ;
case 'd' : o.flagD = 0 ; break ;
case 'H' : o.flagH = 1 ; break ;
- case 'h' : o.flagh = 0 ; break ;
+ case 'h' : o.flagH = 0 ; break ;
case 'R' : o.flagr = 0 ; break ;
case 'r' : o.flagr = 1 ; break ;
case 'n' : o.flagN = 0 ; break ;
@@ -106,6 +108,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'Y' : o.flagy = 0 ; break ;
case 'y' : o.flagy = 1 ; break ;
case 'K' : if (!uint0_scan(l.arg, &o.kimeout)) dieusage() ; break ;
+ case 'k' : o.servername = l.arg ; break ;
default : dieusage() ;
}
}
@@ -113,13 +116,20 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (argc < 3) dieusage() ;
}
+ if (!o.servername && !o.flagH)
+ {
+ ip46full_t ip ;
+ if (!ip46full_scan(argv[0], &ip))
+ o.servername = argv[0] ;
+ }
+
{
unsigned int m = 0 ;
unsigned int pos = 0 ;
char fmt[UINT_FMT * 4 + UINT16_FMT + IP46_FMT] ;
- char const *newargv[26 + argc] ;
+ char const *newargv[28 + argc] ;
newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpclient" ;
- if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" ; "-q" ;
+ if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" : "-q" ;
if (o.flag4) newargv[m++] = "-4" ;
if (o.flag6) newargv[m++] = "-6" ;
if (o.flagD) newargv[m++] = "-D" ;
@@ -172,6 +182,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
pos += uint_fmt(fmt + pos, o.kimeout) ;
fmt[pos++] = 0 ;
}
+ if (o.servername)
+ {
+ newargv[m++] = "-k" ;
+ newargv[m++] = o.servername ;
+ }
newargv[m++] = "--" ;
while (*argv) newargv[m++] = *argv++ ;
newargv[m++] = 0 ;
diff --git a/src/conn-tools/s6-tlsd.c b/src/conn-tools/s6-tlsd.c
index 73758a2..6a6d4ef 100644
--- a/src/conn-tools/s6-tlsd.c
+++ b/src/conn-tools/s6-tlsd.c
@@ -68,7 +68,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!getuid())
{
- x = env_get2(envp, "TLS_UID") ;
+ char const *x = env_get2(envp, "TLS_UID") ;
if (x)
{
uint64 u ;
diff --git a/src/conn-tools/s6-tlsserver.c b/src/conn-tools/s6-tlsserver.c
index 0154e24..5ba5b0c 100644
--- a/src/conn-tools/s6-tlsserver.c
+++ b/src/conn-tools/s6-tlsserver.c
@@ -105,7 +105,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'D' : o.flagD = 1 ; o.doaccess = 1 ; break ;
case 'd' : o.flagD = 0 ; break ;
case 'H' : o.flagH = 1 ; o.doaccess = 1 ; break ;
- case 'h' : o.flagh = 0 ; break ;
+ case 'h' : o.flagH = 0 ; break ;
case 'R' : o.flagr = 0 ; break ;
case 'r' : o.flagr = 1 ; o.doaccess = 1 ; break ;
case 'P' : o.flagp = 0 ; break ;
@@ -133,14 +133,14 @@ int main (int argc, char const *const *argv, char const *const *envp)
char fmt[UINT_FMT * 5 + GID_FMT * (NGROUPS_MAX + 1) + UINT64_FMT] ;
char const *newargv[44 + argc] ;
newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpserver" ;
- if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" ; "-q" ;
+ if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" : "-q" ;
if (o.flag46) newargv[m++] = o.flag46 == 1 ? "-4" : "-6" ;
if (o.flag1) newargv[m++] = "-1" ;
if (o.maxconn)
{
newargv[m++] = "-c" ;
newargv[m++] = fmt + pos ;
- pos += uint_fmt(fmt + pos, maxconn) ;
+ pos += uint_fmt(fmt + pos, o.maxconn) ;
fmt[pos++] = 0 ;
}
if (o.localmaxconn)
@@ -150,11 +150,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
pos += uint_fmt(fmt + pos, o.localmaxconn) ;
fmt[pos++] = 0 ;
}
- if (backlog != (unsigned int)-1)
+ if (o.backlog != (unsigned int)-1)
{
newargv[m++] = "-b" ;
newargv[m++] = fmt + pos ;
- pos += uint_fmt(fmt + pos, backlog) ;
+ pos += uint_fmt(fmt + pos, o.backlog) ;
fmt[pos++] = 0 ;
}
if (o.gidn != (unsigned int)-1)