diff options
Diffstat (limited to 'src/conn-tools')
-rw-r--r-- | src/conn-tools/s6-accessrules-cdb-from-fs.c | 11 | ||||
-rw-r--r-- | src/conn-tools/s6-accessrules-fs-from-cdb.c | 28 | ||||
-rw-r--r-- | src/conn-tools/s6-connlimit.c | 13 | ||||
-rw-r--r-- | src/conn-tools/s6-ioconnect.c | 6 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcclient.c | 10 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserver-access.c | 37 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserver-socketbinder.c | 5 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserver.c | 13 | ||||
-rw-r--r-- | src/conn-tools/s6-ipcserverd.c | 67 | ||||
-rw-r--r-- | src/conn-tools/s6-sudo.c | 4 | ||||
-rw-r--r-- | src/conn-tools/s6-sudoc.c | 35 | ||||
-rw-r--r-- | src/conn-tools/s6-sudod.c | 19 |
12 files changed, 117 insertions, 131 deletions
diff --git a/src/conn-tools/s6-accessrules-cdb-from-fs.c b/src/conn-tools/s6-accessrules-cdb-from-fs.c index c5b007c..ccd1204 100644 --- a/src/conn-tools/s6-accessrules-cdb-from-fs.c +++ b/src/conn-tools/s6-accessrules-cdb-from-fs.c @@ -1,13 +1,10 @@ /* ISC license. */ -#include <sys/types.h> #include <stdint.h> #include <unistd.h> #include <errno.h> -#include <stdio.h> /* for rename() */ -#include <skalibs/bytestr.h> -#include <skalibs/uint16.h> -#include <skalibs/fmtscan.h> +#include <stdio.h> +#include <skalibs/types.h> #include <skalibs/cdb_make.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> @@ -22,7 +19,7 @@ static stralloc tmp = STRALLOC_ZERO ; static void cleanup (void) { - register int e = errno ; + int e = errno ; unlink(tmp.s) ; errno = e ; } @@ -66,7 +63,7 @@ static void doit (struct cdb_make *c, stralloc *sa, size_t start) { uint16_t envlen = 0 ; uint16_t execlen = 0 ; - register ssize_t r ; + ssize_t r ; tmp.s[tmpbase] = 'A' ; sa->len = k+1 ; stralloc_catb(sa, "env", 4) ; diff --git a/src/conn-tools/s6-accessrules-fs-from-cdb.c b/src/conn-tools/s6-accessrules-fs-from-cdb.c index 4bc048f..3db1c77 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 <string.h> #include <stdint.h> #include <sys/stat.h> #include <errno.h> #include <unistd.h> #include <skalibs/bytestr.h> -#include <skalibs/uint16.h> +#include <skalibs/types.h> #include <skalibs/cdb.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -31,8 +31,8 @@ static int domkdir (char const *s) static void mkdirp (char *s) { mode_t m = umask(0) ; - size_t len = str_len(s) ; - register size_t i = basedirlen + 1 ; + size_t len = strlen(s) ; + size_t i = basedirlen + 1 ; for (; i < len ; i++) if (s[i] == '/') { s[i] = 0 ; @@ -50,7 +50,7 @@ static void mkdirp (char *s) static void touchtrunc (char const *file) { - register int fd = open_trunc(file) ; + int fd = open_trunc(file) ; if (fd < 0) strerr_diefu2sys(111, "open_trunc ", file) ; fd_close(fd) ; } @@ -72,9 +72,9 @@ static int doenv (char const *dir, size_t dirlen, char *env, size_t envlen) { size_t p = byte_chr(env + i, n, '=') ; char tmp[dirlen + p + 2] ; - byte_copy(tmp, dirlen, dir) ; + memcpy(tmp, dir, dirlen) ; tmp[dirlen] = '/' ; - byte_copy(tmp + dirlen + 1, p, env + i) ; + memcpy(tmp + dirlen + 1, env + i, p) ; tmp[dirlen + p + 1] = 0 ; if (p < n) { @@ -100,7 +100,7 @@ static int doit (struct cdb *c) uint16_t envlen, execlen ; char name[basedirlen + klen + 8] ; char data[dlen] ; - byte_copy(name, basedirlen, basedir) ; + memcpy(name, basedir, basedirlen) ; name[basedirlen] = '/' ; if (!dlen || (dlen > 8201)) return (errno = EINVAL, 0) ; if ((cdb_read(c, name+basedirlen+1, klen, cdb_keypos(c)) < 0) @@ -114,12 +114,12 @@ static int doit (struct cdb *c) name[basedirlen + klen + 1] = '/' ; if (data[0] == 'A') { - byte_copy(name + basedirlen + klen + 2, 6, "allow") ; + memcpy(name + basedirlen + klen + 2, "allow", 6) ; touchtrunc(name) ; } else if (data[0] == 'D') { - byte_copy(name + basedirlen + klen + 2, 5, "deny") ; + memcpy(name + basedirlen + klen + 2, "deny", 5) ; touchtrunc(name) ; } if (dlen < 3) return 1 ; @@ -129,10 +129,10 @@ static int doit (struct cdb *c) if ((execlen > 4096U) || (5U + envlen + execlen != dlen)) return (errno = EINVAL, 0) ; if (envlen) { - byte_copy(name + basedirlen + klen + 2, 4, "env") ; + memcpy(name + basedirlen + klen + 2, "env", 4) ; if (!doenv(name, basedirlen + klen + 5, data + 3, envlen)) return (errno = EINVAL, 0) ; } - byte_copy(name + basedirlen + klen + 2, 5, "exec") ; + memcpy(name + basedirlen + klen + 2, "exec", 5) ; if (execlen && !openwritenclose_unsafe(name, data + 5 + envlen, execlen)) { cleanup() ; @@ -150,7 +150,7 @@ int main (int argc, char const *const *argv) if (argc < 3) strerr_dieusage(100, USAGE) ; if (cdb_mapfile(&c, argv[2]) < 0) strerr_diefu1sys(111, "cdb_mapfile") ; basedir = argv[1] ; - basedirlen = str_len(argv[1]) ; + basedirlen = strlen(argv[1]) ; { mode_t m = umask(0) ; if (mkdir(basedir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH | S_ISGID) < 0) @@ -160,7 +160,7 @@ int main (int argc, char const *const *argv) cdb_traverse_init(&c, &kpos) ; for (;;) { - register int r = cdb_nextkey(&c, &kpos) ; + int r = cdb_nextkey(&c, &kpos) ; if (r < 0) { cleanup() ; diff --git a/src/conn-tools/s6-connlimit.c b/src/conn-tools/s6-connlimit.c index 903a777..d7d48c9 100644 --- a/src/conn-tools/s6-connlimit.c +++ b/src/conn-tools/s6-connlimit.c @@ -1,8 +1,7 @@ /* ISC license. */ -#include <sys/types.h> -#include <skalibs/uint.h> -#include <skalibs/bytestr.h> +#include <string.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> @@ -14,17 +13,17 @@ int main (int argc, char const *const *argv, char const *const *envp) PROG = "s6-connlimit" ; x = env_get2(envp, "PROTO") ; if (!x) strerr_dienotset(100, "PROTO") ; - protolen = str_len(x) ; + protolen = strlen(x) ; if (!protolen) strerr_dief1x(100, "empty PROTO") ; { unsigned int num ; char s[protolen + 8] ; - byte_copy(s, protolen, x) ; - byte_copy(s + protolen, 8, "CONNNUM") ; + memcpy(s, x, protolen) ; + memcpy(s + protolen, "CONNNUM", 8) ; x = env_get2(envp, s) ; if (!x) strerr_dienotset(100, s) ; if (!uint0_scan(x, &num)) strerr_dief2x(100, "invalid ", s) ; - byte_copy(s + protolen + 4, 4, "MAX") ; + memcpy(s + protolen + 4, "MAX", 4) ; x = env_get2(envp, s) ; if (x) { diff --git a/src/conn-tools/s6-ioconnect.c b/src/conn-tools/s6-ioconnect.c index abd309b..05a3fdf 100644 --- a/src/conn-tools/s6-ioconnect.c +++ b/src/conn-tools/s6-ioconnect.c @@ -4,7 +4,7 @@ #include <sys/socket.h> #include <errno.h> #include <signal.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> #include <skalibs/error.h> @@ -74,14 +74,14 @@ static void handle_signals (void) int main (int argc, char const *const *argv) { tain_t tto ; - register unsigned int i, j ; + unsigned int i, j ; PROG = "s6-ioconnect" ; { subgetopt_t l = SUBGETOPT_ZERO ; unsigned int t = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "0167t:r:w:", &l) ; + int opt = subgetopt_r(argc, argv, "0167t:r:w:", &l) ; if (opt < 0) break ; switch (opt) { diff --git a/src/conn-tools/s6-ipcclient.c b/src/conn-tools/s6-ipcclient.c index 384fca0..a8c6075 100644 --- a/src/conn-tools/s6-ipcclient.c +++ b/src/conn-tools/s6-ipcclient.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> @@ -19,7 +19,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, "qQvp:l:", &l) ; + int opt = subgetopt_r(argc, argv, "qQvp:l:", &l) ; if (opt == -1) break ; switch (opt) { @@ -46,16 +46,16 @@ 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 size_t n = str_len(localname) ; + size_t n = strlen(localname) ; if (n > IPCPATH_MAX) n = IPCPATH_MAX ; - byte_copy(modif + i, n, localname) ; + memcpy(modif + i, localname, n) ; i += n ; modif[i++] = 0 ; } else { int dummy ; if (ipc_local(s, modif + i, IPCPATH_MAX, &dummy) < 0) modif[--i] = 0 ; - else i += str_len(modif + i) + 1 ; + else i += strlen(modif + i) + 1 ; } if (fd_move(6, s) < 0) strerr_diefu2sys(111, "set up fd ", "6") ; diff --git a/src/conn-tools/s6-ipcserver-access.c b/src/conn-tools/s6-ipcserver-access.c index 1a30913..c5e20c2 100644 --- a/src/conn-tools/s6-ipcserver-access.c +++ b/src/conn-tools/s6-ipcserver-access.c @@ -1,12 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.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/types.h> #include <skalibs/strerr2.h> #include <skalibs/sgetopt.h> #include <skalibs/cdb.h> @@ -45,11 +43,11 @@ static inline void X () static void logit (pid_t pid, uid_t uid, gid_t gid, int h) { - char fmtpid[UINT_FMT] ; - char fmtuid[UINT64_FMT] ; + char fmtpid[PID_FMT] ; + char fmtuid[UID_FMT] ; char fmtgid[GID_FMT] ; - fmtpid[uint_fmt(fmtpid, (unsigned int)pid)] = 0 ; - fmtuid[uint64_fmt(fmtuid, (uint64)uid)] = 0 ; + fmtpid[pid_fmt(fmtpid, pid)] = 0 ; + fmtuid[uid_fmt(fmtuid, 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) ; @@ -72,7 +70,7 @@ static s6_accessrules_result_t check_cdb (uid_t uid, gid_t gid, char const *file { struct cdb c = CDB_ZERO ; int fd = open_readb(file) ; - register s6_accessrules_result_t r ; + s6_accessrules_result_t r ; if (fd < 0) return -1 ; if (cdb_init(&c, fd) < 0) strerr_diefu2sys(111, "cdb_init ", file) ; r = s6_accessrules_uidgid_cdb(uid, gid, &c, params) ; @@ -127,7 +125,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, "v:Eel:i:x:", &l) ; + int opt = subgetopt_r(argc, argv, "v:Eel:i:x:", &l) ; if (opt == -1) break ; switch (opt) { @@ -147,19 +145,16 @@ int main (int argc, char const *const *argv, char const *const *envp) proto = env_get2(envp, "PROTO") ; if (!proto) strerr_dienotset(100, "PROTO") ; - protolen = str_len(proto) ; + protolen = strlen(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 (!uint640_scan(x, &u)) strerr_dieinvalid(100, tmp) ; - if (u > (uint64)(uid_t)-1) strerr_dieinvalid(100, tmp) ; - uid = (uid_t)u ; + if (!uid0_scan(x, &uid)) strerr_dieinvalid(100, tmp) ; tmp[protolen + 7] = 'G' ; x = env_get2(envp, tmp) ; if (!x) strerr_dienotset(100, tmp) ; @@ -176,8 +171,8 @@ int main (int argc, char const *const *argv, char const *const *envp) if (doenv) { char tmp[protolen + 10] ; - byte_copy(tmp, protolen, proto) ; - byte_copy(tmp + protolen, 10, "LOCALPATH") ; + memcpy(tmp, proto, protolen) ; + memcpy(tmp + protolen, "LOCALPATH", 10) ; if (localname) { if (!env_addmodif(¶ms.env, tmp, localname)) dienomem() ; @@ -194,15 +189,15 @@ int main (int argc, char const *const *argv, char const *const *envp) else { char tmp[protolen + 11] ; - byte_copy(tmp, protolen, proto) ; - byte_copy(tmp + protolen, 11, "REMOTEEUID") ; + memcpy(tmp, proto, protolen) ; + memcpy(tmp + protolen, "REMOTEEUID", 11) ; if (!env_addmodif(¶ms.env, "PROTO", 0)) dienomem() ; if (!env_addmodif(¶ms.env, tmp, 0)) dienomem() ; tmp[protolen + 7] = 'G' ; if (!env_addmodif(¶ms.env, tmp, 0)) dienomem() ; - byte_copy(tmp + protolen + 6, 5, "PATH") ; + memcpy(tmp + protolen + 6, "PATH", 5) ; if (!env_addmodif(¶ms.env, tmp, 0)) dienomem() ; - byte_copy(tmp + protolen, 10, "LOCALPATH") ; + memcpy(tmp + protolen, "LOCALPATH", 10) ; if (!env_addmodif(¶ms.env, tmp, 0)) dienomem() ; } diff --git a/src/conn-tools/s6-ipcserver-socketbinder.c b/src/conn-tools/s6-ipcserver-socketbinder.c index 523b118..5d74096 100644 --- a/src/conn-tools/s6-ipcserver-socketbinder.c +++ b/src/conn-tools/s6-ipcserver-socketbinder.c @@ -1,10 +1,9 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/stat.h> #include <sys/socket.h> #include <unistd.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -23,7 +22,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, "DdMmb:", &l) ; + int opt = subgetopt_r(argc, argv, "DdMmb:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/conn-tools/s6-ipcserver.c b/src/conn-tools/s6-ipcserver.c index 7b7023f..9e85699 100644 --- a/src/conn-tools/s6-ipcserver.c +++ b/src/conn-tools/s6-ipcserver.c @@ -2,8 +2,7 @@ #include <sys/types.h> #include <limits.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,7 +20,7 @@ int main (int argc, char const *const *argv, char const *const *envp) int flagreuse = 1 ; unsigned int uid = 0, 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 ; @@ -30,7 +29,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, "qQvDd1UPpc:C:b:u:g:G:", &l) ; + int opt = subgetopt_r(argc, argv, "qQvDd1UPpc:C:b:u:g:G:", &l) ; if (opt == -1) break ; switch (opt) { @@ -48,7 +47,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'g' : if (!uint0_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() ; } } @@ -73,7 +72,7 @@ int main (int argc, char const *const *argv, char const *const *envp) } newargv[m++] = "--" ; newargv[m++] = *argv++ ; - if (flagU || uid || gid || gidn != (unsigned int)-1) + if (flagU || uid || gid || gidn != (size_t)-1) { newargv[m++] = S6_BINPREFIX "s6-applyuidgid" ; if (flagU) newargv[m++] = "-Uz" ; @@ -91,7 +90,7 @@ int main (int argc, char const *const *argv, char const *const *envp) pos += uint_fmt(fmt + pos, gid) ; fmt[pos++] = 0 ; } - if (gidn != (unsigned int)-1) + if (gidn != (size_t)-1) { newargv[m++] = "-G" ; newargv[m++] = fmt + pos ; diff --git a/src/conn-tools/s6-ipcserverd.c b/src/conn-tools/s6-ipcserverd.c index eb8553e..036de7b 100644 --- a/src/conn-tools/s6-ipcserverd.c +++ b/src/conn-tools/s6-ipcserverd.c @@ -3,14 +3,13 @@ #include <sys/types.h> #include <sys/wait.h> #include <errno.h> +#include <string.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> -#include <skalibs/uint.h> -#include <skalibs/gidstuff.h> +#include <skalibs/types.h> #include <skalibs/gccattributes.h> #include <skalibs/allreadwrite.h> -#include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> @@ -70,14 +69,14 @@ static inline void X (void) static unsigned int lookup_pid (pid_t pid) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < numconn ; i++) if (pid == piduid[i].left) break ; return i ; } static inline unsigned int lookup_uid (uid_t uid) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < uidlen ; i++) if (uid == uidnum[i].left) break ; return i ; } @@ -104,12 +103,12 @@ static void log_status (void) static void log_deny (uid_t uid, gid_t gid, unsigned int num) { - char fmtuid[UINT64_FMT] = "?" ; + char fmtuid[UID_FMT] = "?" ; char fmtgid[GID_FMT] = "?" ; char fmtnum[UINT_FMT] = "?" ; if (flaglookup) { - fmtuid[uint64_fmt(fmtuid, (uint64)uid)] = 0 ; + fmtuid[uid_fmt(fmtuid, uid)] = 0 ; fmtgid[gid_fmt(fmtgid, gid)] = 0 ; fmtnum[uint_fmt(fmtnum, num)] = 0 ; } @@ -118,28 +117,28 @@ static void log_deny (uid_t uid, gid_t gid, unsigned int num) static void log_accept (pid_t pid, uid_t uid, gid_t gid, unsigned int num) { - char fmtuidgid[UINT64_FMT + GID_FMT + 1] = "?:?" ; + char fmtuidgid[UID_FMT + GID_FMT + 1] = "?:?" ; char fmtpid[UINT_FMT] ; char fmtnum[UINT_FMT] = "?" ; if (flaglookup) { - register size_t n = uint64_fmt(fmtuidgid, (uint64)uid) ; + size_t n = uid_fmt(fmtuidgid, uid) ; fmtuidgid[n++] = ':' ; n += gid_fmt(fmtuidgid + n, gid) ; fmtuidgid[n] = 0 ; fmtnum[uint_fmt(fmtnum, num)] = 0 ; } - fmtpid[uint_fmt(fmtpid, (unsigned int)pid)] = 0 ; + fmtpid[pid_fmt(fmtpid, pid)] = 0 ; strerr_warni7x("allow ", fmtuidgid, " pid ", fmtpid, " count ", fmtnum, fmtlocalmaxconn) ; } static void log_close (pid_t pid, uid_t uid, int w) { - char fmtpid[UINT_FMT] ; - char fmtuid[UINT64_FMT] = "?" ; + char fmtpid[PID_FMT] ; + char fmtuid[UID_FMT] = "?" ; char fmtw[UINT_FMT] ; - fmtpid[uint_fmt(fmtpid, (unsigned int)pid)] = 0 ; - if (flaglookup) fmtuid[uint64_fmt(fmtuid, (uint64)uid)] = 0 ; + fmtpid[pid_fmt(fmtpid, pid)] = 0 ; + if (flaglookup) fmtuid[uid_fmt(fmtuid, 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) ; } @@ -149,7 +148,7 @@ static void log_close (pid_t pid, uid_t uid, int w) static void killthem (int sig) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < numconn ; i++) kill(piduid[i].left, sig) ; } @@ -159,7 +158,7 @@ static void wait_children (void) { unsigned int i ; int w ; - register pid_t pid = wait_nohang(&w) ; + pid_t pid = wait_nohang(&w) ; if (pid < 0) if (errno != ECHILD) strerr_diefu1sys(111, "wait_nohang") ; else break ; @@ -168,7 +167,7 @@ static void wait_children (void) if (i < numconn) { uid_t uid = piduid[i].right ; - register unsigned int j = lookup_uid(uid) ; + unsigned int j = lookup_uid(uid) ; if (j >= uidlen) X() ; if (!--uidnum[j].right) uidnum[j] = uidnum[--uidlen] ; piduid[i] = piduid[--numconn] ; @@ -227,34 +226,34 @@ static void handle_signals (void) /* New connection handling */ -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) +static void run_child (int, uid_t, gid_t, unsigned int, char const *, char const *const *, char const *const *) gccattr_noreturn ; +static void run_child (int s, uid_t uid, gid_t gid, unsigned int num, char const *remotepath, char const *const *argv, char const *const *envp) { - size_t rplen = str_len(remotepath) + 1 ; + size_t rplen = strlen(remotepath) + 1 ; unsigned int n = 0 ; - char fmt[65 + UINT_FMT * 3 + rplen] ; + char fmt[65 + UID_FMT + GID_FMT + UINT_FMT + rplen] ; PROG = "s6-ipcserver (child)" ; if ((fd_move(0, s) < 0) || (fd_copy(1, 0) < 0)) strerr_diefu1sys(111, "move fds") ; - byte_copy(fmt+n, 23, "PROTO=IPC\0IPCREMOTEEUID") ; n += 23 ; + memcpy(fmt+n, "PROTO=IPC\0IPCREMOTEEUID", 23) ; n += 23 ; if (flaglookup) { fmt[n++] = '=' ; - n += uint_fmt(fmt+n, uid) ; + n += uid_fmt(fmt+n, uid) ; } fmt[n++] = 0 ; - byte_copy(fmt+n, 13, "IPCREMOTEEGID") ; n += 13 ; + memcpy(fmt+n, "IPCREMOTEEGID", 13) ; n += 13 ; if (flaglookup) { fmt[n++] = '=' ; - n += uint_fmt(fmt+n, gid) ; + n += gid_fmt(fmt+n, gid) ; } fmt[n++] = 0 ; - byte_copy(fmt+n, 11, "IPCCONNNUM=") ; n += 11 ; + memcpy(fmt+n, "IPCCONNNUM=", 11) ; n += 11 ; if (flaglookup) n += uint_fmt(fmt+n, num) ; fmt[n++] = 0 ; - byte_copy(fmt+n, 14, "IPCREMOTEPATH=") ; n += 14 ; - byte_copy(fmt+n, rplen, remotepath) ; n += rplen ; + memcpy(fmt+n, "IPCREMOTEPATH=", 14) ; n += 14 ; + memcpy(fmt+n, remotepath, rplen) ; n += rplen ; pathexec_r(argv, envp, env_len(envp), fmt, n) ; strerr_dieexec(111, argv[0]) ; } @@ -263,8 +262,8 @@ static void new_connection (int s, char const *remotepath, char const *const *ar { uid_t uid = 0 ; gid_t gid = 0 ; + pid_t pid ; unsigned int num, i ; - register pid_t pid ; if (flaglookup && (getpeereid(s, &uid, &gid) < 0)) { if (verbosity) strerr_warnwu1sys("getpeereid") ; @@ -314,7 +313,7 @@ int main (int argc, char const *const *argv, char const *const *envp) int flag1 = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "Pp1c:C:v:", &l) ; + int opt = subgetopt_r(argc, argv, "Pp1c:C:v:", &l) ; if (opt == -1) break ; switch (opt) { @@ -393,15 +392,15 @@ int main (int argc, char const *const *argv, char const *const *envp) { int dummy ; char remotepath[IPCPATH_MAX+1] ; - register int s = ipc_accept(x[1].fd, remotepath, IPCPATH_MAX+1, &dummy) ; - if (s < 0) + int sock = ipc_accept(x[1].fd, remotepath, IPCPATH_MAX+1, &dummy) ; + if (sock < 0) { if (verbosity) strerr_warnwu1sys("accept") ; } else { - new_connection(s, remotepath, argv, envp) ; - fd_close(s) ; + new_connection(sock, remotepath, argv, envp) ; + fd_close(sock) ; } } } diff --git a/src/conn-tools/s6-sudo.c b/src/conn-tools/s6-sudo.c index 12880b2..c422a1d 100644 --- a/src/conn-tools/s6-sudo.c +++ b/src/conn-tools/s6-sudo.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -20,7 +20,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, "qQvp:l:et:T:", &l) ; + int opt = subgetopt_r(argc, argv, "qQvp:l:et:T:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/conn-tools/s6-sudoc.c b/src/conn-tools/s6-sudoc.c index 779380f..eb8f138 100644 --- a/src/conn-tools/s6-sudoc.c +++ b/src/conn-tools/s6-sudoc.c @@ -1,14 +1,14 @@ /* ISC license. */ +#include <string.h> #include <stdint.h> #include <errno.h> #include <fcntl.h> #include <signal.h> +#include <sys/uio.h> #include <sys/wait.h> -#include <skalibs/uint32.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> #include <skalibs/strerr2.h> @@ -36,7 +36,7 @@ int main (int argc, char const *const *argv, char const *const *envp) PROG = "s6-sudoc" ; for (;;) { - register int opt = subgetopt_r(argc, argv, "et:T:", &l) ; + int opt = subgetopt_r(argc, argv, "et:T:", &l) ; if (opt < 0) break ; switch (opt) { @@ -59,33 +59,33 @@ int main (int argc, char const *const *argv, char const *const *envp) char tmp[S6_SUDO_BANNERB_LEN] ; if (buffer_timed_get_g(&b6, tmp, S6_SUDO_BANNERB_LEN, &deadline) < S6_SUDO_BANNERB_LEN) strerr_diefu1sys(111, "read banner from s6-sudod") ; - if (str_diffn(tmp, S6_SUDO_BANNERB, S6_SUDO_BANNERB_LEN)) + if (strncmp(tmp, S6_SUDO_BANNERB, S6_SUDO_BANNERB_LEN)) strerr_dief1x(100, "wrong server banner") ; } { int fds[3] = { 0, 1, 2 } ; char pack[16] ; - siovec_t v[4] = { - { .s = S6_SUDO_BANNERA, .len = S6_SUDO_BANNERA_LEN }, - { .s = pack, .len = 16 }, - { .s = 0, .len = 0 }, - { .s = 0, .len = 0 } } ; + struct iovec v[4] = { + { .iov_base = S6_SUDO_BANNERA, .iov_len = S6_SUDO_BANNERA_LEN }, + { .iov_base = pack, .iov_len = 16 }, + { .iov_base = 0, .iov_len = 0 }, + { .iov_base = 0, .iov_len = 0 } } ; unixmessage_v_t mv = { .v = v, .vlen = 4, .fds = fds, .nfds = 3 } ; stralloc sa = STRALLOC_ZERO ; 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_t)v[2].len) ; + v[2].iov_len = sa.len ; + uint32_pack_big(pack + 8, (uint32_t)v[2].iov_len) ; if (doenv) { if (!env_string(&sa, envp, envlen)) dienomem() ; - v[3].len = sa.len - v[2].len ; + v[3].iov_len = sa.len - v[2].iov_len ; } - uint32_pack_big(pack + 12, (uint32)v[3].len) ; - v[2].s = sa.s ; - v[3].s = sa.s + v[2].len ; + uint32_pack_big(pack + 12, (uint32_t)v[3].iov_len) ; + v[2].iov_base = sa.s ; + v[3].iov_base = sa.s + v[2].iov_len ; if (!unixmessage_putv_and_close(&b7, &mv, (unsigned char const *)"\003")) strerr_diefu1sys(111, "unixmessage_putv") ; stralloc_free(&sa) ; @@ -112,6 +112,5 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_diefu1sys(111, "get exit status from server") ; uint_unpack_big(pack, &t) ; } - if (WIFSIGNALED(t)) raise(WTERMSIG(t)) ; - return WEXITSTATUS(t) ; + return wait_estatus(t) ; } diff --git a/src/conn-tools/s6-sudod.c b/src/conn-tools/s6-sudod.c index c2256a4..bb56d84 100644 --- a/src/conn-tools/s6-sudod.c +++ b/src/conn-tools/s6-sudod.c @@ -1,13 +1,12 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.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/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> @@ -40,7 +39,7 @@ int main (int argc, char const *const *argv, char const *const *envp) PROG = "s6-sudod" ; for (;;) { - register int opt = subgetopt_r(argc, argv, "012t:", &l) ; + int opt = subgetopt_r(argc, argv, "012t:", &l) ; if (opt < 0) break ; switch (opt) { @@ -67,7 +66,7 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_dief1x(100, "client did not send 3 fds") ; if (m.len < 16 + S6_SUDO_BANNERA_LEN) strerr_dief1x(100, "wrong client message") ; - if (str_diffn(m.s, S6_SUDO_BANNERA, S6_SUDO_BANNERA_LEN)) + if (strncmp(m.s, S6_SUDO_BANNERA, S6_SUDO_BANNERA_LEN)) strerr_dief1x(100, "wrong client banner") ; uint32_unpack_big(m.s + S6_SUDO_BANNERA_LEN, &cargc) ; uint32_unpack_big(m.s + S6_SUDO_BANNERA_LEN + 4, &cenvc) ; @@ -100,7 +99,7 @@ int main (int argc, char const *const *argv, char const *const *envp) char const *targv[argc + 1 + cargc] ; char const *tenvp[envc + 1 + cenvc] ; int p[2] ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < (unsigned int)argc ; i++) targv[i] = argv[i] ; for (i = 0 ; i <= envc ; i++) tenvp[i] = envp[i] ; if (!env_make(targv + argc, cargc, m.s + S6_SUDO_BANNERA_LEN + 16, carglen)) @@ -124,8 +123,8 @@ int main (int argc, char const *const *argv, char const *const *envp) for (i = 0 ; i < cenvc ; i++) { char const *var = tenvp[envc + 1 + i] ; - register unsigned int j = 0 ; - register size_t len = str_chr(var, '=') ; + unsigned int j = 0 ; + size_t len = str_chr(var, '=') ; if (!var[len]) { char c = EINVAL ; @@ -133,7 +132,7 @@ int main (int argc, char const *const *argv, char const *const *envp) buffer_timed_flush_g(buffer_1small, &deadline) ; strerr_dief1x(100, "bad environment from client") ; } - for (; j < envc ; j++) if (!str_diffn(var, tenvp[j], len+1)) break ; + for (; j < envc ; j++) if (!strncmp(var, tenvp[j], len+1)) break ; if ((j < envc) && !tenvp[j][len+1]) tenvp[j] = var ; } @@ -167,7 +166,7 @@ int main (int argc, char const *const *argv, char const *const *envp) fd_close(p[1]) ; { char c ; - register ssize_t r = fd_read(p[0], &c, 1) ; + ssize_t r = fd_read(p[0], &c, 1) ; if (r < 0) strerr_diefu1sys(111, "read from child") ; if (r) { |