summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-08-09 00:37:19 +0000
committerLaurent Bercot <ska@appnovation.com>2023-08-09 00:37:19 +0000
commit589d0d4040c7d13afd779f734fe91f8e372a9c07 (patch)
treea1bb09adcb51e92733db4441f9613f2e9c039622
parenteb54ce73503085fca8af147c166b3755a567d930 (diff)
downloads6-networking-589d0d4040c7d13afd779f734fe91f8e372a9c07.tar.xz
Fix s6-tlsserver tcpaccess invocation condition
Also fix s6-tlsclient storage reservation Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--.gitignore9
-rw-r--r--src/tls/s6-tlsclient.c2
-rw-r--r--src/tls/s6-tlsserver.c59
3 files changed, 37 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore
index 00c244e..c2177b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,13 +2,8 @@
/src/include/s6-networking/config.h
*.o
*.lo
-/libs6net.a.xyzzy
-/libs6net.so.xyzzy
-/libsbearssl.a.xyzzy
-/libsbearssl.so.xyzzy
-/libstls.a.xyzzy
-/libstls.so.xyzzy
-/libs6tls.a.xyzzy
+*.a.xyzzy
+*.so.xyzzy
/s6-clockadd
/s6-clockview
/s6-getservbyname
diff --git a/src/tls/s6-tlsclient.c b/src/tls/s6-tlsclient.c
index 987e713..261c8be 100644
--- a/src/tls/s6-tlsclient.c
+++ b/src/tls/s6-tlsclient.c
@@ -133,7 +133,7 @@ int main (int argc, char const *const *argv)
size_t pos = 0 ;
unsigned int m = 0 ;
char fmt[UINT_FMT * 4 + UINT16_FMT + IP46_FMT] ;
- char const *newargv[29 + argc] ;
+ char const *newargv[31 + argc] ;
newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpclient" ;
if (o.verbosity != 1) newargv[m++] = o.verbosity ? "-v" : "-q" ;
if (o.flag4) newargv[m++] = "-4" ;
diff --git a/src/tls/s6-tlsserver.c b/src/tls/s6-tlsserver.c
index 533e856..f72ab60 100644
--- a/src/tls/s6-tlsserver.c
+++ b/src/tls/s6-tlsserver.c
@@ -44,12 +44,12 @@ struct options_s
unsigned int flagH : 1 ;
unsigned int flagr : 1 ;
unsigned int flagp : 1 ;
- unsigned int ruleswhat : 2 ;
+ unsigned int rulesx : 1 ;
unsigned int flagS : 1 ;
unsigned int flagy : 1 ;
unsigned int flagY : 1 ;
unsigned int flagZ : 1 ;
- unsigned int onlyvars : 1 ;
+ unsigned int forceaccess : 1 ;
unsigned int doaccess : 1 ;
unsigned int doapply : 1 ;
} ;
@@ -77,13 +77,13 @@ struct options_s
.flagH = 0, \
.flagr = 0, \
.flagp = 0, \
- .ruleswhat = 0, \
+ .rulesx = 0, \
.flagS = 0, \
.flagy = 0, \
.flagY = 0, \
.flagZ = 0, \
- .onlyvars = 0, \
- .doaccess = 0, \
+ .forceaccess = 0, \
+ .doaccess = 1, \
.doapply = 0 \
}
@@ -114,20 +114,20 @@ int main (int argc, char const *const *argv)
case 'U' : o.flagU = 1 ; o.uid = 0 ; o.gid = 0 ; o.gidn = (size_t)-1 ; o.doapply = 1 ; break ;
case 'W' : o.flagw = 0 ; break ;
case 'w' : o.flagw = 1 ; break ;
- case 'D' : o.flagD = 1 ; o.doaccess = 1 ; break ;
+ case 'D' : o.flagD = 1 ; break ;
case 'd' : o.flagD = 0 ; break ;
- case 'H' : o.flagH = 1 ; o.doaccess = 1 ; break ;
+ case 'H' : o.flagH = 1 ; break ;
case 'h' : o.flagH = 0 ; break ;
case 'R' : o.flagr = 0 ; break ;
- case 'r' : o.flagr = 1 ; o.doaccess = 1 ; break ;
+ case 'r' : o.flagr = 1 ; break ;
case 'P' : o.flagp = 0 ; break ;
- case 'p' : o.flagp = 1 ; o.doaccess = 1 ; break ;
- case 'l' : o.localname = l.arg ; o.doaccess = 1 ; break ;
- case 'e' : o.onlyvars = 1 ; o.doaccess = 1 ; break ;
- case 'B' : o.banner = l.arg ; o.doaccess = 1 ; break ;
+ case 'p' : o.flagp = 1 ; break ;
+ case 'l' : o.localname = l.arg ; break ;
+ case 'e' : o.forceaccess = 1 ; break ;
+ case 'B' : o.banner = l.arg ; break ;
case 't' : if (!uint0_scan(l.arg, &o.timeout)) dieusage() ; break ;
- case 'i' : o.rules = l.arg ; o.ruleswhat = 1 ; o.doaccess = 1 ; break ;
- case 'x' : o.rules = l.arg ; o.ruleswhat = 2 ; o.doaccess = 1 ; break ;
+ case 'i' : o.rules = l.arg ; o.rulesx = 0 ; break ;
+ case 'x' : o.rules = l.arg ; o.rulesx = 1 ; break ;
case 'S' : o.flagS = 1 ; break ;
case 's' : o.flagS = 0 ; break ;
case 'Y' : o.flagY = 1 ; o.flagy = 0 ; break ;
@@ -143,13 +143,21 @@ int main (int argc, char const *const *argv)
if (argc < 3) dieusage() ;
}
+ o.doaccess = o.forceaccess || (o.verbosity >= 2) || o.flagw || o.flagD || !o.flagH || o.flagr || o.flagp || o.localname || o.banner || o.timeout || o.rules ;
+
{
size_t pos = 0 ;
unsigned int m = 0 ;
- char fmt[UINT_FMT * 5 + UID_FMT + GID_FMT * (NGROUPS_MAX + 1)] ;
- char const *newargv[46 + argc] ;
+ char fmt[UINT_FMT * 6 + UID_FMT + GID_FMT * (NGROUPS_MAX + 1)] ;
+ char const *newargv[50 + 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" ;
+ newargv[m++] = fmt ;
+ pos = uint_fmt(fmt, o.verbosity) ;
+ fmt[pos++] = 0 ;
+ }
if (o.flag46) newargv[m++] = o.flag46 == 1 ? "-4" : "-6" ;
if (o.flag1) newargv[m++] = "-1" ;
if (o.maxconn)
@@ -179,13 +187,11 @@ int main (int argc, char const *const *argv)
if (o.doaccess)
{
newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tcpserver-access" ;
- if (o.verbosity)
+ if (o.verbosity != 1)
{
- if (o.verbosity > 1 && (!o.onlyvars || o.ruleswhat))
- newargv[m++] = "-v2" ;
+ newargv[m++] = "-v" ;
+ newargv[m++] = fmt ;
}
- else newargv[m++] = "-v0" ;
-
if (o.flagw) newargv[m++] = "-w" ;
if (o.flagD) newargv[m++] = "-D" ;
if (o.flagH) newargv[m++] = "-H" ;
@@ -208,16 +214,19 @@ int main (int argc, char const *const *argv)
pos += uint_fmt(fmt + pos, o.timeout) ;
fmt[pos++] = 0 ;
}
- if (o.ruleswhat)
+ if (o.rules)
{
- newargv[m++] = o.ruleswhat == 1 ? "-i" : "-x" ;
+ newargv[m++] = o.rulesx ? "-x" : "-i" ;
newargv[m++] = o.rules ;
}
newargv[m++] = "--" ;
}
newargv[m++] = S6_NETWORKING_BINPREFIX "s6-tlsd" ;
if (o.verbosity != 1)
- newargv[m++] = o.verbosity ? "-v2" : "-v0" ;
+ {
+ newargv[m++] = "-v" ;
+ newargv[m++] = fmt ;
+ }
if (o.flagS) newargv[m++] = "-S" ;
if (o.flagy) newargv[m++] = "-y" ;
else if (o.flagY) newargv[m++] = "-Y" ;