diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-12 19:39:01 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-12 19:39:01 +0000 |
commit | 53091e3bce487ee82e2805a0231e780551561717 (patch) | |
tree | f0fa36ff8eadaf1f01d4510597b5e3a310764dc7 /src/conn-tools/s6-tcpserver.c | |
parent | f85b8a70f3b44510a5cf3895bf7357ae90655f65 (diff) | |
download | s6-networking-53091e3bce487ee82e2805a0231e780551561717.tar.xz |
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/conn-tools/s6-tcpserver.c')
-rw-r--r-- | src/conn-tools/s6-tcpserver.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/conn-tools/s6-tcpserver.c b/src/conn-tools/s6-tcpserver.c index 3036ce7..3866b75 100644 --- a/src/conn-tools/s6-tcpserver.c +++ b/src/conn-tools/s6-tcpserver.c @@ -2,9 +2,7 @@ #include <sys/types.h> #include <limits.h> -#include <skalibs/uint64.h> -#include <skalibs/uint.h> -#include <skalibs/gidstuff.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -21,10 +19,10 @@ int main (int argc, char const *const *argv, char const *const *envp) int flag1 = 0 ; int flagU = 0 ; int flagreuse = 1 ; - uint64 uid = 0 ; + uid_t uid = 0 ; gid_t gid = 0 ; gid_t gids[NGROUPS_MAX] ; - unsigned int gidn = (unsigned int)-1 ; + size_t gidn = (size_t)-1 ; unsigned int maxconn = 0 ; unsigned int localmaxconn = 0 ; unsigned int backlog = (unsigned int)-1 ; @@ -34,7 +32,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, "qQvDd1U46c:C:b:u:g:G:", &l) ; + int opt = subgetopt_r(argc, argv, "qQvDd1U46c:C:b:u:g:G:", &l) ; if (opt == -1) break ; switch (opt) { @@ -48,11 +46,11 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'c' : if (!uint0_scan(l.arg, &maxconn)) dieusage() ; if (!maxconn) maxconn = 1 ; break ; case 'C' : if (!uint0_scan(l.arg, &localmaxconn)) dieusage() ; if (!localmaxconn) localmaxconn = 1 ; break ; case 'b' : if (!uint0_scan(l.arg, &backlog)) dieusage() ; break ; - case 'u' : if (!uint640_scan(l.arg, &uid)) dieusage() ; break ; + case 'u' : if (!uid0_scan(l.arg, &uid)) dieusage() ; break ; case 'g' : if (!gid0_scan(l.arg, &gid)) dieusage() ; break ; case 'G' : if (!gid_scanlist(gids, NGROUPS_MAX, l.arg, &gidn) && *l.arg) dieusage() ; break ; case '1' : flag1 = 1 ; break ; - case 'U' : flagU = 1 ; uid = 0 ; gid = 0 ; gidn = (unsigned int)-1 ; break ; + case 'U' : flagU = 1 ; uid = 0 ; gid = 0 ; gidn = (size_t)-1 ; break ; default : dieusage() ; } } @@ -70,7 +68,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { size_t pos = 0 ; unsigned int m = 0 ; - char fmt[UINT_FMT * 3 + UINT64_FMT + GID_FMT * (NGROUPS_MAX + 1)] ; + char fmt[UINT_FMT * 3 + UID_FMT + GID_FMT * (NGROUPS_MAX + 1)] ; char const *newargv[23 + argc] ; newargv[m++] = what == 6 ? S6_NETWORKING_BINPREFIX "s6-tcpserver6-socketbinder" : S6_NETWORKING_BINPREFIX "s6-tcpserver4-socketbinder" ; if (!flagreuse) newargv[m++] = "-D" ; @@ -84,7 +82,7 @@ int main (int argc, char const *const *argv, char const *const *envp) newargv[m++] = "--" ; newargv[m++] = *argv++ ; newargv[m++] = *argv++ ; - if (flagU || uid || gid || gidn != (unsigned int)-1) + if (flagU || uid || gid || gidn != (size_t)-1) { newargv[m++] = S6_EXTBINPREFIX "s6-applyuidgid" ; if (flagU) newargv[m++] = "-Uz" ; @@ -92,7 +90,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { newargv[m++] = "-u" ; newargv[m++] = fmt + pos ; - pos += uint64_fmt(fmt + pos, uid) ; + pos += uid_fmt(fmt + pos, uid) ; fmt[pos++] = 0 ; } if (gid) @@ -102,7 +100,7 @@ int main (int argc, char const *const *argv, char const *const *envp) pos += gid_fmt(fmt + pos, gid) ; fmt[pos++] = 0 ; } - if (gidn != (unsigned int)-1) + if (gidn != (size_t)-1) { newargv[m++] = "-G" ; newargv[m++] = fmt + pos ; |