summaryrefslogtreecommitdiff
path: root/src/conn-tools
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-01-12 23:16:36 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-01-12 23:16:36 +0000
commitbf6d072124a960d3b84ae39cd15c5aeca2e41c88 (patch)
treec082150f61e67d929b1baca2f5c6104fe959ccac /src/conn-tools
parent81c7a02ec870ef3dba9f8b8f8dbecbd119e5ea47 (diff)
downloads6-bf6d072124a960d3b84ae39cd15c5aeca2e41c88.tar.xz
Types fix, first pass
Diffstat (limited to 'src/conn-tools')
-rw-r--r--src/conn-tools/s6-accessrules-cdb-from-fs.c16
-rw-r--r--src/conn-tools/s6-accessrules-fs-from-cdb.c20
-rw-r--r--src/conn-tools/s6-connlimit.c3
-rw-r--r--src/conn-tools/s6-ipcclient.c5
-rw-r--r--src/conn-tools/s6-ipcserver-access.c35
-rw-r--r--src/conn-tools/s6-ipcserver.c2
-rw-r--r--src/conn-tools/s6-ipcserverd.c87
-rw-r--r--src/conn-tools/s6-sudoc.c10
-rw-r--r--src/conn-tools/s6-sudod.c16
9 files changed, 111 insertions, 83 deletions
diff --git a/src/conn-tools/s6-accessrules-cdb-from-fs.c b/src/conn-tools/s6-accessrules-cdb-from-fs.c
index c1aa992..c5b007c 100644
--- a/src/conn-tools/s6-accessrules-cdb-from-fs.c
+++ b/src/conn-tools/s6-accessrules-cdb-from-fs.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h> /* for rename() */
@@ -31,9 +33,9 @@ static void dienomem (void)
strerr_diefu1sys(111, "stralloc_catb") ;
}
-static void doit (struct cdb_make *c, stralloc *sa, unsigned int start)
+static void doit (struct cdb_make *c, stralloc *sa, size_t start)
{
- unsigned int tmpbase = tmp.len ;
+ size_t tmpbase = tmp.len ;
unsigned int k = sa->len ;
if (!stralloc_readyplus(sa, 10)) dienomem() ;
stralloc_catb(sa, "/allow", 7) ;
@@ -62,9 +64,9 @@ static void doit (struct cdb_make *c, stralloc *sa, unsigned int start)
}
else
{
- uint16 envlen = 0 ;
- uint16 execlen = 0 ;
- register int r ;
+ uint16_t envlen = 0 ;
+ uint16_t execlen = 0 ;
+ register ssize_t r ;
tmp.s[tmpbase] = 'A' ;
sa->len = k+1 ;
stralloc_catb(sa, "env", 4) ;
@@ -106,7 +108,7 @@ int main (int argc, char const *const *argv)
stralloc sa = STRALLOC_ZERO ;
struct cdb_make c = CDB_MAKE_ZERO ;
DIR *dir ;
- unsigned int start ;
+ size_t start ;
int fd ;
PROG = "s6-accessrules-cdb-from-fs" ;
if (argc < 3) strerr_dieusage(100, USAGE) ;
@@ -138,7 +140,7 @@ int main (int argc, char const *const *argv)
{
DIR *subdir ;
direntry *d ;
- unsigned int base ;
+ size_t base ;
errno = 0 ;
d = readdir(dir) ;
if (!d) break ;
diff --git a/src/conn-tools/s6-accessrules-fs-from-cdb.c b/src/conn-tools/s6-accessrules-fs-from-cdb.c
index cbe67ef..4bc048f 100644
--- a/src/conn-tools/s6-accessrules-fs-from-cdb.c
+++ b/src/conn-tools/s6-accessrules-fs-from-cdb.c
@@ -1,12 +1,12 @@
/* ISC license. */
#include <sys/types.h>
+#include <stdint.h>
#include <sys/stat.h>
#include <errno.h>
#include <unistd.h>
#include <skalibs/bytestr.h>
#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
#include <skalibs/cdb.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
@@ -14,7 +14,7 @@
#define USAGE "s6-accessrules-fs-from-cdb dir cdbfile"
static char const *basedir ;
-unsigned int basedirlen ;
+size_t basedirlen ;
static void cleanup ()
{
@@ -31,8 +31,8 @@ static int domkdir (char const *s)
static void mkdirp (char *s)
{
mode_t m = umask(0) ;
- unsigned int len = str_len(s) ;
- register unsigned int i = basedirlen + 1 ;
+ size_t len = str_len(s) ;
+ register size_t i = basedirlen + 1 ;
for (; i < len ; i++) if (s[i] == '/')
{
s[i] = 0 ;
@@ -55,10 +55,10 @@ static void touchtrunc (char const *file)
fd_close(fd) ;
}
-static int doenv (char const *dir, unsigned int dirlen, char *env, unsigned int envlen)
+static int doenv (char const *dir, size_t dirlen, char *env, size_t envlen)
{
mode_t m = umask(0) ;
- unsigned int i = 0 ;
+ size_t i = 0 ;
if (!domkdir(dir))
{
cleanup() ;
@@ -67,10 +67,10 @@ static int doenv (char const *dir, unsigned int dirlen, char *env, unsigned int
umask(m) ;
while (i < envlen)
{
- unsigned int n = byte_chr(env + i, envlen - i, 0) ;
+ size_t n = byte_chr(env + i, envlen - i, 0) ;
if (i + n >= envlen) return 0 ;
{
- unsigned int p = byte_chr(env + i, n, '=') ;
+ size_t p = byte_chr(env + i, n, '=') ;
char tmp[dirlen + p + 2] ;
byte_copy(tmp, dirlen, dir) ;
tmp[dirlen] = '/' ;
@@ -97,7 +97,7 @@ static int doit (struct cdb *c)
unsigned int klen = cdb_keylen(c) ;
unsigned int dlen = cdb_datalen(c) ;
{
- uint16 envlen, execlen ;
+ uint16_t envlen, execlen ;
char name[basedirlen + klen + 8] ;
char data[dlen] ;
byte_copy(name, basedirlen, basedir) ;
@@ -145,7 +145,7 @@ static int doit (struct cdb *c)
int main (int argc, char const *const *argv)
{
struct cdb c = CDB_ZERO ;
- uint32 kpos ;
+ uint32_t kpos ;
PROG = "s6-accessrules-fs-from-cdb" ;
if (argc < 3) strerr_dieusage(100, USAGE) ;
if (cdb_mapfile(&c, argv[2]) < 0) strerr_diefu1sys(111, "cdb_mapfile") ;
diff --git a/src/conn-tools/s6-connlimit.c b/src/conn-tools/s6-connlimit.c
index 19f4a2d..903a777 100644
--- a/src/conn-tools/s6-connlimit.c
+++ b/src/conn-tools/s6-connlimit.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
#include <skalibs/strerr2.h>
@@ -9,7 +10,7 @@
int main (int argc, char const *const *argv, char const *const *envp)
{
char const *x ;
- unsigned int protolen ;
+ size_t protolen ;
PROG = "s6-connlimit" ;
x = env_get2(envp, "PROTO") ;
if (!x) strerr_dienotset(100, "PROTO") ;
diff --git a/src/conn-tools/s6-ipcclient.c b/src/conn-tools/s6-ipcclient.c
index c2352ae..384fca0 100644
--- a/src/conn-tools/s6-ipcclient.c
+++ b/src/conn-tools/s6-ipcclient.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/env.h>
@@ -35,7 +36,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (argc < 2) strerr_dieusage(100, USAGE) ;
{
char modif[24 + IPCPATH_MAX] = "PROTO=IPC\0IPCLOCALPATH=" ;
- unsigned int i = 23 ;
+ size_t i = 23 ;
int s = ipc_stream_b() ;
if (s < 0) strerr_diefu1sys(111, "create socket") ;
if (bindpath && (ipc_bind(s, bindpath) == -1))
@@ -45,7 +46,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (verbosity >= 2) strerr_warn3x(PROG, ": connected to ", argv[0]) ;
if (localname)
{
- register unsigned int n = str_len(localname) ;
+ register size_t n = str_len(localname) ;
if (n > IPCPATH_MAX) n = IPCPATH_MAX ;
byte_copy(modif + i, n, localname) ;
i += n ; modif[i++] = 0 ;
diff --git a/src/conn-tools/s6-ipcserver-access.c b/src/conn-tools/s6-ipcserver-access.c
index 629fabb..1a30913 100644
--- a/src/conn-tools/s6-ipcserver-access.c
+++ b/src/conn-tools/s6-ipcserver-access.c
@@ -1,9 +1,12 @@
/* ISC license. */
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <skalibs/gccattributes.h>
+#include <skalibs/uint64.h>
#include <skalibs/uint.h>
+#include <skalibs/gidstuff.h>
#include <skalibs/strerr2.h>
#include <skalibs/sgetopt.h>
#include <skalibs/cdb.h>
@@ -40,24 +43,24 @@ static inline void X ()
/* Logging */
-static void logit (unsigned int pid, unsigned int uid, unsigned int gid, int h)
+static void logit (pid_t pid, uid_t uid, gid_t gid, int h)
{
char fmtpid[UINT_FMT] ;
- char fmtuid[UINT_FMT] ;
- char fmtgid[UINT_FMT] ;
- fmtpid[uint_fmt(fmtpid, pid)] = 0 ;
- fmtuid[uint_fmt(fmtuid, uid)] = 0 ;
- fmtgid[uint_fmt(fmtgid, gid)] = 0 ;
+ char fmtuid[UINT64_FMT] ;
+ char fmtgid[GID_FMT] ;
+ fmtpid[uint_fmt(fmtpid, (unsigned int)pid)] = 0 ;
+ fmtuid[uint64_fmt(fmtuid, (uint64)uid)] = 0 ;
+ fmtgid[gid_fmt(fmtgid, gid)] = 0 ;
if (h) strerr_warni7x("allow", " pid ", fmtpid, " uid ", fmtuid, " gid ", fmtgid) ;
else strerr_warni7sys("deny", " pid ", fmtpid, " uid ", fmtuid, " gid ", fmtgid) ;
}
-static inline void log_accept (unsigned int pid, unsigned int uid, unsigned int gid)
+static inline void log_accept (pid_t pid, uid_t uid, gid_t gid)
{
logit(pid, uid, gid, 1) ;
}
-static inline void log_deny (unsigned int pid, unsigned int uid, unsigned int gid)
+static inline void log_deny (pid_t pid, uid_t uid, gid_t gid)
{
logit(pid, uid, gid, 0) ;
}
@@ -65,7 +68,7 @@ static inline void log_deny (unsigned int pid, unsigned int uid, unsigned int gi
/* Checking */
-static s6_accessrules_result_t check_cdb (unsigned int uid, unsigned int gid, char const *file, s6_accessrules_params_t *params)
+static s6_accessrules_result_t check_cdb (uid_t uid, gid_t gid, char const *file, s6_accessrules_params_t *params)
{
struct cdb c = CDB_ZERO ;
int fd = open_readb(file) ;
@@ -78,7 +81,7 @@ static s6_accessrules_result_t check_cdb (unsigned int uid, unsigned int gid, ch
return r ;
}
-static inline int check (s6_accessrules_params_t *params, char const *rules, unsigned int rulestype, unsigned int uid, unsigned int gid)
+static inline int check (s6_accessrules_params_t *params, char const *rules, unsigned int rulestype, uid_t uid, gid_t gid)
{
char const *x = "" ;
s6_accessrules_result_t r ;
@@ -114,8 +117,9 @@ int main (int argc, char const *const *argv, char const *const *envp)
char const *rules = 0 ;
char const *localname = 0 ;
char const *proto ;
- unsigned int protolen ;
- unsigned int uid = 0, gid = 0 ;
+ size_t protolen ;
+ uid_t uid = 0 ;
+ gid_t gid = 0 ;
unsigned int rulestype = 0 ;
int doenv = 1 ;
PROG = "s6-ipcserver-access" ;
@@ -146,17 +150,20 @@ int main (int argc, char const *const *argv, char const *const *envp)
protolen = str_len(proto) ;
{
+ uint64 u ;
char const *x ;
char tmp[protolen + 11] ;
byte_copy(tmp, protolen, proto) ;
byte_copy(tmp + protolen, 11, "REMOTEEUID") ;
x = env_get2(envp, tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
- if (!uint0_scan(x, &uid)) strerr_dieinvalid(100, tmp) ;
+ if (!uint640_scan(x, &u)) strerr_dieinvalid(100, tmp) ;
+ if (u > (uint64)(uid_t)-1) strerr_dieinvalid(100, tmp) ;
+ uid = (uid_t)u ;
tmp[protolen + 7] = 'G' ;
x = env_get2(envp, tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
- if (!uint0_scan(x, &gid)) strerr_dieinvalid(100, tmp) ;
+ if (!gid0_scan(x, &gid)) strerr_dieinvalid(100, tmp) ;
}
if (!check(&params, rules, rulestype, uid, gid))
diff --git a/src/conn-tools/s6-ipcserver.c b/src/conn-tools/s6-ipcserver.c
index 96f10c7..7b7023f 100644
--- a/src/conn-tools/s6-ipcserver.c
+++ b/src/conn-tools/s6-ipcserver.c
@@ -57,8 +57,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
{
+ size_t pos = 0 ;
unsigned int m = 0 ;
- unsigned int pos = 0 ;
char fmt[UINT_FMT * 5 + GID_FMT * NGROUPS_MAX] ;
char const *newargv[24 + argc] ;
newargv[m++] = S6_BINPREFIX "s6-ipcserver-socketbinder" ;
diff --git a/src/conn-tools/s6-ipcserverd.c b/src/conn-tools/s6-ipcserverd.c
index 4afe5cc..eb8553e 100644
--- a/src/conn-tools/s6-ipcserverd.c
+++ b/src/conn-tools/s6-ipcserverd.c
@@ -7,17 +7,18 @@
#include <fcntl.h>
#include <signal.h>
#include <skalibs/uint.h>
+#include <skalibs/gidstuff.h>
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/bytestr.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/diuint.h>
#include <skalibs/env.h>
#include <skalibs/djbunix.h>
#include <skalibs/sig.h>
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
+#include <skalibs/getpeereid.h>
#include <skalibs/webipc.h>
#define USAGE "s6-ipcserverd [ -v verbosity ] [ -1 ] [ -P | -p ] [ -c maxconn ] [ -C localmaxconn ] prog..."
@@ -32,9 +33,23 @@ static int flaglookup = 1 ;
static unsigned int verbosity = 1 ;
static int cont = 1 ;
-static diuint *piduid ;
+typedef struct piduid_s piduid_t, *piduid_t_ref ;
+struct piduid_s
+{
+ pid_t left ;
+ uid_t right ;
+} ;
+
+typedef struct uidnum_s uidnum_t, *uidnum_t_ref ;
+struct uidnum_s
+{
+ uid_t left ;
+ unsigned int right ;
+} ;
+
+static piduid_t *piduid ;
static unsigned int numconn = 0 ;
-static diuint *uidnum ;
+static uidnum_t *uidnum ;
static unsigned int uidlen = 0 ;
@@ -53,21 +68,18 @@ static inline void X (void)
/* Lookup primitives */
-static unsigned int lookup_diuint (diuint const *tab, unsigned int tablen, unsigned int key)
+static unsigned int lookup_pid (pid_t pid)
{
register unsigned int i = 0 ;
- for (; i < tablen ; i++) if (key == tab[i].left) break ;
+ for (; i < numconn ; i++) if (pid == piduid[i].left) break ;
return i ;
}
-static inline unsigned int lookup_pid (unsigned int pid)
-{
- return lookup_diuint(piduid, numconn, pid) ;
-}
-
-static inline unsigned int lookup_uid (unsigned int uid)
+static inline unsigned int lookup_uid (uid_t uid)
{
- return lookup_diuint(uidnum, uidlen, uid) ;
+ register unsigned int i = 0 ;
+ for (; i < uidlen ; i++) if (uid == uidnum[i].left) break ;
+ return i ;
}
@@ -90,44 +102,44 @@ static void log_status (void)
strerr_warni3x("status: ", fmt, fmtmaxconn) ;
}
-static void log_deny (unsigned int uid, unsigned int gid, unsigned int num)
+static void log_deny (uid_t uid, gid_t gid, unsigned int num)
{
- char fmtuid[UINT_FMT] = "?" ;
- char fmtgid[UINT_FMT] = "?" ;
+ char fmtuid[UINT64_FMT] = "?" ;
+ char fmtgid[GID_FMT] = "?" ;
char fmtnum[UINT_FMT] = "?" ;
if (flaglookup)
{
- fmtuid[uint_fmt(fmtuid, uid)] = 0 ;
- fmtgid[uint_fmt(fmtgid, gid)] = 0 ;
+ fmtuid[uint64_fmt(fmtuid, (uint64)uid)] = 0 ;
+ fmtgid[gid_fmt(fmtgid, gid)] = 0 ;
fmtnum[uint_fmt(fmtnum, num)] = 0 ;
}
strerr_warni7sys("deny ", fmtuid, ":", fmtgid, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_accept (unsigned int pid, unsigned int uid, unsigned int gid, unsigned int num)
+static void log_accept (pid_t pid, uid_t uid, gid_t gid, unsigned int num)
{
- char fmtuidgid[UINT_FMT * 2 + 1] = "?:?" ;
+ char fmtuidgid[UINT64_FMT + GID_FMT + 1] = "?:?" ;
char fmtpid[UINT_FMT] ;
char fmtnum[UINT_FMT] = "?" ;
if (flaglookup)
{
- register unsigned int n = uint_fmt(fmtuidgid, uid) ;
+ register size_t n = uint64_fmt(fmtuidgid, (uint64)uid) ;
fmtuidgid[n++] = ':' ;
- n += uint_fmt(fmtuidgid + n, gid) ;
+ n += gid_fmt(fmtuidgid + n, gid) ;
fmtuidgid[n] = 0 ;
fmtnum[uint_fmt(fmtnum, num)] = 0 ;
}
- fmtpid[uint_fmt(fmtpid, pid)] = 0 ;
+ fmtpid[uint_fmt(fmtpid, (unsigned int)pid)] = 0 ;
strerr_warni7x("allow ", fmtuidgid, " pid ", fmtpid, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_close (unsigned int pid, unsigned int uid, int w)
+static void log_close (pid_t pid, uid_t uid, int w)
{
char fmtpid[UINT_FMT] ;
- char fmtuid[UINT_FMT] = "?" ;
+ char fmtuid[UINT64_FMT] = "?" ;
char fmtw[UINT_FMT] ;
- fmtpid[uint_fmt(fmtpid, pid)] = 0 ;
- if (flaglookup) fmtuid[uint_fmt(fmtuid, uid)] = 0 ;
+ fmtpid[uint_fmt(fmtpid, (unsigned int)pid)] = 0 ;
+ if (flaglookup) fmtuid[uint64_fmt(fmtuid, (uint64)uid)] = 0 ;
fmtw[uint_fmt(fmtw, WIFSIGNALED(w) ? WTERMSIG(w) : WEXITSTATUS(w))] = 0 ;
strerr_warni6x("end pid ", fmtpid, " uid ", fmtuid, WIFSIGNALED(w) ? " signal " : " exitcode ", fmtw) ;
}
@@ -155,7 +167,7 @@ static void wait_children (void)
i = lookup_pid(pid) ;
if (i < numconn)
{
- unsigned int uid = piduid[i].right ;
+ uid_t uid = piduid[i].right ;
register unsigned int j = lookup_uid(uid) ;
if (j >= uidlen) X() ;
if (!--uidnum[j].right) uidnum[j] = uidnum[--uidlen] ;
@@ -218,7 +230,7 @@ static void handle_signals (void)
static void run_child (int, unsigned int, unsigned int, unsigned int, char const *, char const *const *, char const *const *) gccattr_noreturn ;
static void run_child (int s, unsigned int uid, unsigned int gid, unsigned int num, char const *remotepath, char const *const *argv, char const *const *envp)
{
- unsigned int rplen = str_len(remotepath) + 1 ;
+ size_t rplen = str_len(remotepath) + 1 ;
unsigned int n = 0 ;
char fmt[65 + UINT_FMT * 3 + rplen] ;
PROG = "s6-ipcserver (child)" ;
@@ -249,12 +261,13 @@ static void run_child (int s, unsigned int uid, unsigned int gid, unsigned int n
static void new_connection (int s, char const *remotepath, char const *const *argv, char const *const *envp)
{
- unsigned int uid = 0, gid = 0 ;
+ uid_t uid = 0 ;
+ gid_t gid = 0 ;
unsigned int num, i ;
register pid_t pid ;
- if (flaglookup && (ipc_eid(s, &uid, &gid) < 0))
+ if (flaglookup && (getpeereid(s, &uid, &gid) < 0))
{
- if (verbosity) strerr_warnwu1sys("ipc_eid") ;
+ if (verbosity) strerr_warnwu1sys("getpeereid") ;
return ;
}
i = lookup_uid(uid) ;
@@ -282,18 +295,16 @@ static void new_connection (int s, char const *remotepath, char const *const *ar
uidnum[uidlen].left = uid ;
uidnum[uidlen++].right = 1 ;
}
- piduid[numconn].left = (unsigned int)pid ;
+ piduid[numconn].left = pid ;
piduid[numconn++].right = uid ;
if (verbosity >= 2)
{
- log_accept((unsigned int)pid, uid, gid, uidnum[i].right) ;
+ log_accept(pid, uid, gid, uidnum[i].right) ;
log_status() ;
}
}
- /* And the main */
-
int main (int argc, char const *const *argv, char const *const *envp)
{
iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .fd = 0, .events = IOPAUSE_READ | IOPAUSE_EXCEPT } } ;
@@ -363,8 +374,10 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
{
- diuint inyostack[maxconn + (flaglookup ? maxconn : 1)] ;
- piduid = inyostack ; uidnum = inyostack + maxconn ;
+ piduid_t inyostack0[maxconn] ;
+ uidnum_t inyostack1[flaglookup ? maxconn : 1] ;
+ piduid = inyostack0 ;
+ uidnum = inyostack1 ;
while (cont)
{
diff --git a/src/conn-tools/s6-sudoc.c b/src/conn-tools/s6-sudoc.c
index 823d7cb..779380f 100644
--- a/src/conn-tools/s6-sudoc.c
+++ b/src/conn-tools/s6-sudoc.c
@@ -1,9 +1,11 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/wait.h>
+#include <skalibs/uint32.h>
#include <skalibs/uint.h>
#include <skalibs/sgetopt.h>
#include <skalibs/bytestr.h>
@@ -70,12 +72,12 @@ int main (int argc, char const *const *argv, char const *const *envp)
{ .s = 0, .len = 0 } } ;
unixmessage_v_t mv = { .v = v, .vlen = 4, .fds = fds, .nfds = 3 } ;
stralloc sa = STRALLOC_ZERO ;
- unsigned int envlen = doenv ? env_len(envp) : 0 ;
- uint32_pack_big(pack, (uint32)argc) ;
- uint32_pack_big(pack + 4, (uint32)envlen) ;
+ size_t envlen = doenv ? env_len(envp) : 0 ;
+ uint32_pack_big(pack, (uint32_t)argc) ;
+ uint32_pack_big(pack + 4, (uint32_t)envlen) ;
if (!env_string(&sa, argv, argc)) dienomem() ;
v[2].len = sa.len ;
- uint32_pack_big(pack + 8, (uint32)v[2].len) ;
+ uint32_pack_big(pack + 8, (uint32_t)v[2].len) ;
if (doenv)
{
if (!env_string(&sa, envp, envlen)) dienomem() ;
diff --git a/src/conn-tools/s6-sudod.c b/src/conn-tools/s6-sudod.c
index 8c52bb9..c2256a4 100644
--- a/src/conn-tools/s6-sudod.c
+++ b/src/conn-tools/s6-sudod.c
@@ -1,10 +1,12 @@
/* ISC license. */
#include <sys/types.h>
+#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
+#include <skalibs/uint32.h>
#include <skalibs/uint.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/sgetopt.h>
@@ -31,8 +33,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
unixmessage_t m ;
unsigned int nullfds = 0, t = 2000 ;
pid_t pid ;
- uint32 envc = env_len(envp) ;
- uint32 cargc, cenvc, carglen, cenvlen ;
+ size_t envc = env_len(envp) ;
+ uint32_t cargc, cenvc, carglen, cenvlen ;
int spfd ;
tain_t deadline = TAIN_INFINITE_RELATIVE ;
PROG = "s6-sudod" ;
@@ -123,7 +125,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
{
char const *var = tenvp[envc + 1 + i] ;
register unsigned int j = 0 ;
- register unsigned int len = str_chr(var, '=') ;
+ register size_t len = str_chr(var, '=') ;
if (!var[len])
{
char c = EINVAL ;
@@ -165,7 +167,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
fd_close(p[1]) ;
{
char c ;
- register int r = fd_read(p[0], &c, 1) ;
+ register ssize_t r = fd_read(p[0], &c, 1) ;
if (r < 0) strerr_diefu1sys(111, "read from child") ;
if (r)
{
@@ -201,10 +203,10 @@ int main (int argc, char const *const *argv, char const *const *envp)
else if (c == SIGCHLD)
{
int wstat ;
- register int r = wait_pid_nohang(pid, &wstat) ;
- if ((r < 0) && (errno != ECHILD))
+ c = wait_pid_nohang(pid, &wstat) ;
+ if ((c < 0) && (errno != ECHILD))
strerr_diefu1sys(111, "wait_pid_nohang") ;
- else if (r > 0)
+ else if (c > 0)
{
char pack[UINT_PACK] ;
uint_pack_big(pack, (unsigned int)wstat) ;