diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-11-16 05:13:06 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-11-16 05:13:06 +0000 |
commit | 26597a785ec2dd4e9ec9fb7d9765d2ee8779ee16 (patch) | |
tree | c2c5602397e9381b1cb04472ed057edd4a00e520 /src/tls | |
parent | d8ca717da164c3e76ebb56c954d0a08544955601 (diff) | |
download | s6-networking-26597a785ec2dd4e9ec9fb7d9765d2ee8779ee16.tar.xz |
Add -J and -j to the TLS tools to check for peer close_notify.
Also, and more importantly, significantly rewrite stls_run()
for better full-duplex support. This implementation isn't fully
tested yet.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tls')
-rw-r--r-- | src/tls/s6-tlsc-io.c | 8 | ||||
-rw-r--r-- | src/tls/s6-tlsc.c | 12 | ||||
-rw-r--r-- | src/tls/s6-tlsd-io.c | 6 | ||||
-rw-r--r-- | src/tls/s6-tlsd.c | 8 | ||||
-rw-r--r-- | src/tls/s6-ucspitlsc.c | 10 | ||||
-rw-r--r-- | src/tls/s6-ucspitlsd.c | 8 | ||||
-rw-r--r-- | src/tls/s6tls-internal.h | 2 | ||||
-rw-r--r-- | src/tls/s6tls_prep_tlscio.c | 1 | ||||
-rw-r--r-- | src/tls/s6tls_prep_tlsdio.c | 1 |
9 files changed, 35 insertions, 21 deletions
diff --git a/src/tls/s6-tlsc-io.c b/src/tls/s6-tlsc-io.c index e64c014..25347b7 100644 --- a/src/tls/s6-tlsc-io.c +++ b/src/tls/s6-tlsc-io.c @@ -13,7 +13,7 @@ #include <s6-networking/config.h> -#define USAGE "s6-tlsc-io [ -v verbosity ] [ -d notif ] [ -S | -s ] [ -Y | -y ] [ -K timeout ] [ -k servername ] fdr fdw" +#define USAGE "s6-tlsc-io [ -v verbosity ] [ -d notif ] [ -S | -s ] [ -J | -j ] [ -Y | -y ] [ -K timeout ] [ -k servername ] fdr fdw" #define dieusage() strerr_dieusage(100, USAGE) static inline void doit (int *, tain const *tto, uint32_t, uint32_t, unsigned int, char const *, unsigned int) gccattr_noreturn ; @@ -81,7 +81,7 @@ int main (int argc, char const *const *argv, char const *const *envp) unsigned int t = 0 ; for (;;) { - int opt = subgetopt_r(argc, argv, "d:SsYyv:K:k:", &l) ; + int opt = subgetopt_r(argc, argv, "d:SsJjYyv:K:k:", &l) ; if (opt == -1) break ; switch (opt) { @@ -89,8 +89,10 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'd' : if (!uint0_scan(l.arg, ¬if)) dieusage() ; break ; case 'S' : options |= 1 ; break ; case 's' : options &= ~1 ; break ; - case 'Y' : preoptions &= ~1 ; break ; + case 'J' : options |= 2 ; break ; + case 'j' : options &= ~2 ; break ; case 'y' : preoptions |= 1 ; break ; + case 'Y' : preoptions &= ~1 ; break ; case 'K' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; case 'k' : servername = l.arg ; break ; default : dieusage() ; diff --git a/src/tls/s6-tlsc.c b/src/tls/s6-tlsc.c index d348599..ebea264 100644 --- a/src/tls/s6-tlsc.c +++ b/src/tls/s6-tlsc.c @@ -11,7 +11,7 @@ #include "s6tls-internal.h" -#define USAGE "s6-tlsc [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -k servername ] [ -Z | -z ] [ -6 fdr ] [ -7 fdw ] prog..." +#define USAGE "s6-tlsc [ -S | -s ] [ -J | -j ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -k servername ] [ -Z | -z ] [ -6 fdr ] [ -7 fdw ] prog..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) @@ -30,14 +30,16 @@ int main (int argc, char const *const *argv) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "SsYyv:K:k:Zz6:7:", &l) ; + int opt = subgetopt_r(argc, argv, "SsJjyYv:K:k:Zz6:7:", &l) ; if (opt == -1) break ; switch (opt) { - case 'S' : coptions &= ~4 ; break ; - case 's' : coptions |= 4 ; break ; - case 'Y' : coptions &= ~1 ; break ; + case 'S' : coptions |= 4 ; break ; + case 's' : coptions &= ~4 ; break ; + case 'J' : coptions |= 2 ; break ; + case 'j' : coptions &= ~2 ; break ; case 'y' : coptions |= 1 ; break ; + case 'Y' : coptions &= ~1 ; break ; case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; case 'k' : servername = l.arg ; break ; diff --git a/src/tls/s6-tlsd-io.c b/src/tls/s6-tlsd-io.c index fac2164..08eee77 100644 --- a/src/tls/s6-tlsd-io.c +++ b/src/tls/s6-tlsd-io.c @@ -13,7 +13,7 @@ #include <s6-networking/config.h> -#define USAGE "s6-tlsd-io [ -v verbosity ] [ -d notif ] [ -S | -s ] [ -Y | -y ] [ -K timeout ] [ -k snilevel ] fdr fdw" +#define USAGE "s6-tlsd-io [ -v verbosity ] [ -d notif ] [ -S | -s ] [ -J | -j ] [ -Y | -y ] [ -K timeout ] [ -k snilevel ] fdr fdw" #define dieusage() strerr_dieusage(100, USAGE) static inline void doit (int *, tain const *tto, uint32_t, uint32_t, unsigned int, unsigned int) gccattr_noreturn ; @@ -78,7 +78,7 @@ int main (int argc, char const *const *argv) unsigned int t = 0 ; for (;;) { - int opt = subgetopt_r(argc, argv, "d:SsYyv:K:k:", &l) ; + int opt = subgetopt_r(argc, argv, "d:SsJjYyv:K:k:", &l) ; if (opt == -1) break ; switch (opt) { @@ -86,6 +86,8 @@ int main (int argc, char const *const *argv) case 'd' : if (!uint0_scan(l.arg, ¬if)) dieusage() ; break ; case 'S' : options |= 1 ; break ; case 's' : options &= ~1 ; break ; + case 'J' : options |= 2 ; break ; + case 'j' : options &= ~2 ; break ; case 'Y' : preoptions |= 1 ; preoptions &= ~2 ; break ; case 'y' : preoptions |= 3 ; break ; case 'K' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; diff --git a/src/tls/s6-tlsd.c b/src/tls/s6-tlsd.c index 85c0d9f..acd2945 100644 --- a/src/tls/s6-tlsd.c +++ b/src/tls/s6-tlsd.c @@ -9,7 +9,7 @@ #include "s6tls-internal.h" -#define USAGE "s6-tlsd [ -S | -s ] [ -Y | -y ] [ -k snilevel ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] prog..." +#define USAGE "s6-tlsd [ -S | -s ] [ -J | -j ] [ -Y | -y ] [ -k snilevel ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] prog..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) @@ -28,14 +28,16 @@ int main (int argc, char const *const *argv) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "SsYyv:K:Zzk:", &l) ; + int opt = subgetopt_r(argc, argv, "SsJjyYv:K:Zzk:", &l) ; if (opt == -1) break ; switch (opt) { case 'S' : coptions |= 4 ; break ; case 's' : coptions &= ~4 ; break ; - case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; + case 'J' : coptions |= 8 ; break ; + case 'j' : coptions &= ~8 ; break ; case 'y' : coptions |= 3 ; break ; + case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; case 'Z' : poptions &= ~1 ; break ; diff --git a/src/tls/s6-ucspitlsc.c b/src/tls/s6-ucspitlsc.c index bb1a2dc..cd29324 100644 --- a/src/tls/s6-ucspitlsc.c +++ b/src/tls/s6-ucspitlsc.c @@ -15,7 +15,7 @@ #include <s6-networking/config.h> #include "s6tls-internal.h" -#define USAGE "s6-ucspitlsc [ -S | -s ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] [ -k servername ] [ -6 fdr ] [ -7 fdw ] prog..." +#define USAGE "s6-ucspitlsc [ -S | -s ] [ -J | -j ] [ -Y | -y ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] [ -k servername ] [ -6 fdr ] [ -7 fdw ] prog..." #define dieusage() strerr_dieusage(100, USAGE) static inline void child (int *, uint32_t, unsigned int, unsigned int, char const *, pid_t) gccattr_noreturn ; @@ -80,14 +80,16 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "SsYyv:K:Zzk:6:7:", &l) ; + int opt = subgetopt_r(argc, argv, "SsJjyYv:K:Zzk:6:7:", &l) ; if (opt == -1) break ; switch (opt) { case 'S' : coptions |= 4 ; break ; case 's' : coptions &= ~4 ; break ; - case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; - case 'y' : coptions |= 3 ; break ; + case 'J' : coptions |= 2 ; break ; + case 'j' : coptions &= ~2 ; break ; + case 'y' : coptions |= 1 ; break ; + case 'Y' : coptions &= ~1 ; break ; case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; case 'Z' : poptions &= ~1 ; break ; diff --git a/src/tls/s6-ucspitlsd.c b/src/tls/s6-ucspitlsd.c index fc0868a..d2b9580 100644 --- a/src/tls/s6-ucspitlsd.c +++ b/src/tls/s6-ucspitlsd.c @@ -14,7 +14,7 @@ #include <s6-networking/config.h> #include "s6tls-internal.h" -#define USAGE "s6-ucspitlsd [ -S | -s ] [ -Y | -y ] [ -k snilevel ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] prog..." +#define USAGE "s6-ucspitlsd [ -S | -s ] [ -J | -j ] [ -Y | -y ] [ -k snilevel ] [ -v verbosity ] [ -K timeout ] [ -Z | -z ] prog..." #define dieusage() strerr_dieusage(100, USAGE) static inline void child (int *, uint32_t, unsigned int, unsigned int, unsigned int, pid_t) gccattr_noreturn ; @@ -77,14 +77,16 @@ int main (int argc, char const *const *argv) subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "SsYyv:K:Zzk:", &l) ; + int opt = subgetopt_r(argc, argv, "SsJjyYv:K:Zzk:", &l) ; if (opt == -1) break ; switch (opt) { case 'S' : coptions |= 4 ; break ; case 's' : coptions &= ~4 ; break ; - case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; + case 'J' : coptions |= 8 ; break ; + case 'j' : coptions &= ~8 ; break ; case 'y' : coptions |= 3 ; break ; + case 'Y' : coptions |= 1 ; coptions &= ~2 ; break ; case 'v' : if (!uint0_scan(l.arg, &verbosity)) dieusage() ; break ; case 'K' : if (!uint0_scan(l.arg, &kimeout)) dieusage() ; break ; case 'Z' : poptions &= ~1 ; break ; diff --git a/src/tls/s6tls-internal.h b/src/tls/s6tls-internal.h index fdd247f..1ab77f6 100644 --- a/src/tls/s6tls-internal.h +++ b/src/tls/s6tls-internal.h @@ -9,7 +9,7 @@ #include <skalibs/gccattributes.h> #include <skalibs/types.h> -#define S6TLS_PREP_IO_ARGC 15 +#define S6TLS_PREP_IO_ARGC 16 #define S6TLS_PREP_IO_BUFLEN (5 * UINT_FMT) extern pid_t s6tls_io_spawn (char const *const *argv, int const *, int) ; diff --git a/src/tls/s6tls_prep_tlscio.c b/src/tls/s6tls_prep_tlscio.c index a3f33b0..0b7ff1f 100644 --- a/src/tls/s6tls_prep_tlscio.c +++ b/src/tls/s6tls_prep_tlscio.c @@ -26,6 +26,7 @@ void s6tls_prep_tlscio (char const **argv, char *buf, int const *p, uint32_t opt buf[n++] = 0 ; } argv[m++] = options & 4 ? "-S" : "-s" ; + argv[m++] = options & 2 ? "-J" : "-j" ; argv[m++] = options & 1 ? "-y" : "-Y" ; if (kimeout) { diff --git a/src/tls/s6tls_prep_tlsdio.c b/src/tls/s6tls_prep_tlsdio.c index 73099bf..59cc536 100644 --- a/src/tls/s6tls_prep_tlsdio.c +++ b/src/tls/s6tls_prep_tlsdio.c @@ -26,6 +26,7 @@ void s6tls_prep_tlsdio (char const **argv, char *buf, int const *p, uint32_t opt buf[n++] = 0 ; } argv[m++] = options & 4 ? "-S" : "-s" ; + argv[m++] = options & 8 ? "-J" : "-j" ; if (options & 1) argv[m++] = options & 2 ? "-y" : "-Y" ; if (kimeout) |