summaryrefslogtreecommitdiff
path: root/src/tls/s6-ucspitlsc.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-09-24 00:18:17 +0000
committerLaurent Bercot <ska@appnovation.com>2021-09-24 00:18:17 +0000
commitead934a879028ab68c14f645c06d90fa8ced175d (patch)
tree36de9537c32c708db8b27e0a5d83bb4b79c961d0 /src/tls/s6-ucspitlsc.c
parentaa2def27d55cdaf25edbf6e1d390d4743ad03549 (diff)
downloads6-networking-ead934a879028ab68c14f645c06d90fa8ced175d.tar.xz
Log client decision on s6-ucspitls[cd] -v2
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tls/s6-ucspitlsc.c')
-rw-r--r--src/tls/s6-ucspitlsc.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/tls/s6-ucspitlsc.c b/src/tls/s6-ucspitlsc.c
index d2bad3d..877ffa6 100644
--- a/src/tls/s6-ucspitlsc.c
+++ b/src/tls/s6-ucspitlsc.c
@@ -17,8 +17,8 @@
#define USAGE "s6-ucspitlsc [ -S | -s ] [ -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 [4][2], uint32_t, unsigned int, unsigned int, char const *) gccattr_noreturn ;
-static inline void child (int p[4][2], uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername)
+static inline void child (int [4][2], uint32_t, unsigned int, unsigned int, char const *, pid_t) gccattr_noreturn ;
+static inline void child (int p[4][2], uint32_t options, unsigned int verbosity, unsigned int kimeout, char const *servername, pid_t pid)
{
int fds[3] = { p[0][0], p[1][1], p[2][1] } ;
ssize_t r ;
@@ -31,7 +31,16 @@ static inline void child (int p[4][2], uint32_t options, unsigned int verbosity,
strerr_diefu1sys(111, "move network fds to stdin/stdout") ;
r = read(p[2][1], &c, 1) ;
if (r < 0) strerr_diefu1sys(111, "read from control socket") ;
- if (!r) _exit(0) ;
+ if (!r)
+ {
+ if (verbosity >= 2)
+ {
+ char fmt[PID_FMT] ;
+ fmt[pid_fmt(fmt, pid)] = 0 ;
+ strerr_warni4x("pid ", fmt, " declined", " opportunistic TLS") ;
+ }
+ _exit(0) ;
+ }
switch (c)
{
case 'y' :
@@ -44,6 +53,12 @@ static inline void child (int p[4][2], uint32_t options, unsigned int verbosity,
default :
strerr_dief1x(100, "unrecognized command on control socket") ;
}
+ if (verbosity >= 2)
+ {
+ char fmt[PID_FMT] ;
+ fmt[pid_fmt(fmt, pid)] = 0 ;
+ strerr_warni4x("pid ", fmt, " accepted", " opportunistic TLS") ;
+ }
s6tls_exec_tlscio(fds, options, verbosity, kimeout, servername) ;
}
@@ -55,6 +70,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
uint32_t coptions = 0 ;
uint32_t poptions = 1 ;
char const *servername = 0 ;
+ pid_t pid ;
PROG = "s6-ucspitlsc (parent)" ;
{
@@ -100,10 +116,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (ipc_pair_b(p[2]) < 0) strerr_diefu1sys(111, "ipc_pair") ;
if (pipe(p[0]) < 0 || pipe(p[1]) < 0) strerr_diefu1sys(111, "pipe") ;
+ pid = getpid() ;
switch (fork())
{
case -1 : strerr_diefu1sys(111, "fork") ;
- case 0 : child(p, coptions, verbosity, kimeout, servername) ;
+ case 0 : child(p, coptions, verbosity, kimeout, servername, pid) ;
default : break ;
}
s6tls_ucspi_exec_app(argv, p, poptions) ;