summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2018-10-06 13:52:26 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2018-10-06 13:52:26 +0000
commite951f27aa82e9155e429782746fd1abc90984d04 (patch)
tree853a9841c91e0c11425ad4617bc367d8236a388f /src
parent29bd7fd3ce371eaad00ffbb367071f1007f216d3 (diff)
downloads6-networking-e951f27aa82e9155e429782746fd1abc90984d04.tar.xz
bugfix: have s6-tcpserver?d write localport to stdout on notif
and not just a newline.
Diffstat (limited to 'src')
-rw-r--r--src/conn-tools/s6-tcpserver4d.c13
-rw-r--r--src/conn-tools/s6-tcpserver6d.c13
2 files changed, 24 insertions, 2 deletions
diff --git a/src/conn-tools/s6-tcpserver4d.c b/src/conn-tools/s6-tcpserver4d.c
index 914e981..3432236 100644
--- a/src/conn-tools/s6-tcpserver4d.c
+++ b/src/conn-tools/s6-tcpserver4d.c
@@ -10,6 +10,7 @@
#include <signal.h>
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
+#include <skalibs/uint16.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -333,7 +334,17 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (flag1)
{
- fd_write(1, "\n", 1) ;
+ uint16_t port ;
+ uint16_t m = 0 ;
+ char ip[4] ;
+ char fmtport[UINT16_FMT] ;
+ if (socket_local4(0, ip, &port) == -1)
+ {
+ if (verbosity) strerr_warnwu1sys("socket_local4") ;
+ }
+ else m = uint16_fmt(fmtport, port) ;
+ fmtport[m++] = '\n' ;
+ allwrite(1, fmtport, m) ;
fd_close(1) ;
}
}
diff --git a/src/conn-tools/s6-tcpserver6d.c b/src/conn-tools/s6-tcpserver6d.c
index 5a763b5..8000531 100644
--- a/src/conn-tools/s6-tcpserver6d.c
+++ b/src/conn-tools/s6-tcpserver6d.c
@@ -10,6 +10,7 @@
#include <signal.h>
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
+#include <skalibs/uint16.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -330,7 +331,17 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (flag1)
{
- fd_write(1, "\n", 1) ;
+ uint16_t port ;
+ uint16_t m = 0 ;
+ char ip[16] ;
+ char fmtport[UINT16_FMT] ;
+ if (socket_local6(0, ip, &port) == -1)
+ {
+ if (verbosity) strerr_warnwu1sys("socket_local6") ;
+ }
+ else m = uint16_fmt(fmtport, port) ;
+ fmtport[m++] = '\n' ;
+ allwrite(1, fmtport, m) ;
fd_close(1) ;
}
fmtlocalmaxconn[1+uint_fmt(fmtlocalmaxconn+1, localmaxconn)] = 0 ;