From c60ebd422171808ad58b936914055397bb205bef Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Sun, 12 Mar 2017 11:59:43 +0000
Subject: Adapt to skalibs-2.5.0.0
---
doc/libs6/accessrules.html | 7 +-
doc/libs6/ftrigr.html | 10 +-
doc/libs6/ftrigw.html | 2 +-
doc/libs6/s6lock.html | 6 +-
doc/libs6/s6lockd-helper.html | 3 +-
src/conn-tools/s6-accessrules-cdb-from-fs.c | 11 +-
src/conn-tools/s6-accessrules-fs-from-cdb.c | 28 ++---
src/conn-tools/s6-connlimit.c | 13 ++-
src/conn-tools/s6-ioconnect.c | 6 +-
src/conn-tools/s6-ipcclient.c | 10 +-
src/conn-tools/s6-ipcserver-access.c | 37 +++----
src/conn-tools/s6-ipcserver-socketbinder.c | 5 +-
src/conn-tools/s6-ipcserver.c | 13 ++-
src/conn-tools/s6-ipcserverd.c | 67 ++++++------
src/conn-tools/s6-sudo.c | 4 +-
src/conn-tools/s6-sudoc.c | 35 +++----
src/conn-tools/s6-sudod.c | 19 ++--
src/daemontools-extras/s6-applyuidgid.c | 19 ++--
src/daemontools-extras/s6-envdir.c | 2 +-
src/daemontools-extras/s6-envuidgid.c | 39 ++++---
src/daemontools-extras/s6-fghack.c | 1 -
src/daemontools-extras/s6-log.c | 140 ++++++++++++-------------
src/daemontools-extras/s6-setlock.c | 7 +-
src/daemontools-extras/s6-setsid.c | 4 +-
src/daemontools-extras/s6-setuidgid.c | 13 ++-
src/daemontools-extras/s6-softlimit.c | 2 +-
src/daemontools-extras/s6-tai64n.c | 7 +-
src/daemontools-extras/s6-tai64nlocal.c | 6 +-
src/daemontools-extras/ucspilogd.c | 8 +-
src/fdholder/s6-fdholder-daemon.c | 13 ++-
src/fdholder/s6-fdholder-delete.c | 4 +-
src/fdholder/s6-fdholder-deletec.c | 4 +-
src/fdholder/s6-fdholder-getdump.c | 4 +-
src/fdholder/s6-fdholder-getdumpc.c | 19 ++--
src/fdholder/s6-fdholder-list.c | 4 +-
src/fdholder/s6-fdholder-listc.c | 9 +-
src/fdholder/s6-fdholder-retrieve.c | 4 +-
src/fdholder/s6-fdholder-retrievec.c | 4 +-
src/fdholder/s6-fdholder-setdump.c | 4 +-
src/fdholder/s6-fdholder-setdumpc.c | 17 ++-
src/fdholder/s6-fdholder-store.c | 4 +-
src/fdholder/s6-fdholder-storec.c | 4 +-
src/fdholder/s6-fdholder-transferdump.c | 4 +-
src/fdholder/s6-fdholder-transferdumpc.c | 4 +-
src/fdholder/s6-fdholderd.c | 65 ++++++------
src/include/s6/ftrigr.h | 19 ++--
src/include/s6/ftrigw.h | 8 +-
src/include/s6/s6lock.h | 14 +--
src/libs6/ftrig1_make.c | 11 +-
src/libs6/ftrigr_check.c | 2 +-
src/libs6/ftrigr_subscribe.c | 24 +++--
src/libs6/ftrigr_unsubscribe.c | 2 +-
src/libs6/ftrigr_update.c | 2 +-
src/libs6/ftrigr_wait_and.c | 2 +-
src/libs6/ftrigr_wait_or.c | 4 +-
src/libs6/ftrigw_clean.c | 13 ++-
src/libs6/ftrigw_fifodir_make.c | 3 +-
src/libs6/ftrigw_notifyb_nosig.c | 15 ++-
src/libs6/s6-ftrigrd.c | 14 ++-
src/libs6/s6_accessrules_backend_cdb.c | 9 +-
src/libs6/s6_accessrules_backend_fs.c | 20 ++--
src/libs6/s6_accessrules_keycheck_ip4.c | 7 +-
src/libs6/s6_accessrules_keycheck_ip6.c | 9 +-
src/libs6/s6_accessrules_keycheck_reversedns.c | 10 +-
src/libs6/s6_accessrules_keycheck_uidgid.c | 4 +-
src/libs6/s6_fdholder_delete.c | 2 +-
src/libs6/s6_fdholder_delete_async.c | 11 +-
src/libs6/s6_fdholder_getdump.c | 13 ++-
src/libs6/s6_fdholder_list.c | 2 +-
src/libs6/s6_fdholder_list_async.c | 3 +-
src/libs6/s6_fdholder_list_cb.c | 6 +-
src/libs6/s6_fdholder_retrieve.c | 2 +-
src/libs6/s6_fdholder_retrieve_async.c | 12 +--
src/libs6/s6_fdholder_retrieve_cb.c | 4 +-
src/libs6/s6_fdholder_setdump.c | 22 ++--
src/libs6/s6_fdholder_store.c | 2 +-
src/libs6/s6_fdholder_store_async.c | 11 +-
src/libs6/s6_supervise_lock.c | 1 -
src/libs6/s6_supervise_lock_mode.c | 13 ++-
src/libs6/s6_svc_ok.c | 11 +-
src/libs6/s6_svc_write.c | 2 +-
src/libs6/s6_svc_writectl.c | 13 ++-
src/libs6/s6_svstatus_pack.c | 4 +-
src/libs6/s6_svstatus_read.c | 9 +-
src/libs6/s6_svstatus_unpack.c | 8 +-
src/libs6/s6_svstatus_write.c | 9 +-
src/libs6/s6lock_acquire.c | 17 +--
src/libs6/s6lock_release.c | 2 +-
src/libs6/s6lock_update.c | 2 +-
src/libs6/s6lock_wait_and.c | 2 +-
src/libs6/s6lock_wait_or.c | 4 +-
src/libs6/s6lockd.c | 22 ++--
src/pipe-tools/s6-ftrig-listen.c | 7 +-
src/pipe-tools/s6-ftrig-listen1.c | 7 +-
src/pipe-tools/s6-ftrig-wait.c | 4 +-
src/pipe-tools/s6-mkfifodir.c | 4 +-
src/supervision/s6-supervise.c | 24 ++---
src/supervision/s6-svc.c | 17 ++-
src/supervision/s6-svlisten.c | 5 +-
src/supervision/s6-svlisten1.c | 7 +-
src/supervision/s6-svscan.c | 31 +++---
src/supervision/s6-svscanctl.c | 3 +-
src/supervision/s6-svstat.c | 17 ++-
src/supervision/s6-svwait.c | 4 +-
src/supervision/s6_svlisten_loop.c | 24 ++---
src/supervision/s6_svlisten_signal_handler.c | 2 +-
106 files changed, 596 insertions(+), 652 deletions(-)
diff --git a/doc/libs6/accessrules.html b/doc/libs6/accessrules.html
index 20d3f2c..4cdca6c 100644
--- a/doc/libs6/accessrules.html
+++ b/doc/libs6/accessrules.html
@@ -66,7 +66,7 @@ Namely:
-s6_accessrules_result_t f (char const *key, unsigned int keylen, void *handle, s6_accessrules_params_t *params)
+s6_accessrules_result_t f (char const *key, size_t keylen, void *handle, s6_accessrules_params_t *params)
@@ -123,9 +123,8 @@ is not S6_ACCESSRULES_NOTFOUND. If no match can be found in the whole list,
s6_accessrules_keycheck_uidgid interprets key as a
-diuint, i.e. a
-structure containing two unsigned ints. The first one is interpreted as an
-uid u, the second one as a gid g. The function first looks
+pointer to a structure containing an uid u and a gid g.
+The function first looks
for a uid/u match; if it cannot find one, it looks for a
gid/g match. If it cannot find one either, it checks
uid/default and returns the result.
diff --git a/doc/libs6/ftrigr.html b/doc/libs6/ftrigr.html
index b16081f..889e389 100644
--- a/doc/libs6/ftrigr.html
+++ b/doc/libs6/ftrigr.html
@@ -44,8 +44,8 @@ simply ignoring pids you don't know.
- If your (badly programmed) application has trouble handling unknown
-children, consider using a ftrigrd service.
+ If your application has trouble handling unknown
+children, consider using a ftrigrd service. (And fix your application!)
A programming example
@@ -240,14 +240,14 @@ which something happened.
When ftrigr_update returns,
-genalloc_s(uint16, &a->list) points to an array of
-genalloc_len(uint16, &a->list) 16-bit unsigned
+genalloc_s(uint16_t, &a->list) points to an array of
+genalloc_len(uint16_t, &a->list) 16-bit unsigned
integers. Those integers are ids waiting to be passed to
ftrigr_check.
-int ftrigr_check (ftrigr_t *a, uint16 id, char *what)
+int ftrigr_check (ftrigr_t *a, uint16_t id, char *what)
diff --git a/doc/libs6/ftrigw.html b/doc/libs6/ftrigw.html
index d494d72..1089ed7 100644
--- a/doc/libs6/ftrigw.html
+++ b/doc/libs6/ftrigw.html
@@ -41,7 +41,7 @@ exact function prototypes.
char const *path = "/var/lib/myservice/fifodir" ;
-int gid = -1 ;
+gid_t gid = -1 ;
int forceperms = 0 ;
int r = ftrigw_fifodir_make(path, gid, forceperms) ;
diff --git a/doc/libs6/s6lock.html b/doc/libs6/s6lock.html
index cffe3f8..268b4c0 100644
--- a/doc/libs6/s6lock.html
+++ b/doc/libs6/s6lock.html
@@ -193,14 +193,14 @@ which something happened.
When s6lock_update returns,
-genalloc_s(uint16, &a->list) points to an array of
-genalloc_len(uint16, &a->list) 16-bit unsigned
+genalloc_s(uint16_t, &a->list) points to an array of
+genalloc_len(uint16_t, &a->list) 16-bit unsigned
integers. Those integers are ids waiting to be passed to
s6lock_check.
-int s6lock_check (s6lock_t *a, uint16 id, char *what)
+int s6lock_check (s6lock_t *a, uint16_t id, char *what)
diff --git a/doc/libs6/s6lockd-helper.html b/doc/libs6/s6lockd-helper.html
index 281c7e8..7a7d80a 100644
--- a/doc/libs6/s6lockd-helper.html
+++ b/doc/libs6/s6lockd-helper.html
@@ -43,7 +43,8 @@ threads) to implement timed lock acquisition. This can lead to a lot of
s6lockd-helper processes, but this is not a problem:
- Processes are not a scarce resource. Today's schedulers work in O(1),
-i.e. a sleeping process takes no scheduling time at all.
+or in O(a function of the number of runnable processes), which means that a
+sleeping process takes no scheduling time at all
- s6lockd-helper is extremely tiny. Every instance should use up at
most one or two pages of non-sharable memory.
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
#include
#include
#include
-#include /* for rename() */
-#include
-#include
-#include
+#include
+#include
#include
#include
#include
@@ -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
+#include
#include
#include
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -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
-#include
-#include
+#include
+#include
#include
#include
#include
@@ -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
#include
#include
-#include
+#include
#include
#include
#include
@@ -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
+#include
#include
#include
#include
@@ -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
+#include
#include
#include
#include
-#include
-#include
-#include
+#include
#include
#include
#include
@@ -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
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -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
#include
-#include
-#include
+#include
#include
#include
#include
@@ -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
#include
#include
+#include
#include
#include
#include
-#include
-#include
+#include
#include
#include
-#include
#include
#include
#include
@@ -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
+#include
#include
#include
#include
@@ -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
#include
#include
#include
#include
+#include
#include
-#include
-#include
+#include
#include
-#include
#include
#include
#include
@@ -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
+#include
#include
#include
#include
#include
#include
-#include
-#include
+#include
#include
#include
#include
@@ -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)
{
diff --git a/src/daemontools-extras/s6-applyuidgid.c b/src/daemontools-extras/s6-applyuidgid.c
index b80564f..a770b2a 100644
--- a/src/daemontools-extras/s6-applyuidgid.c
+++ b/src/daemontools-extras/s6-applyuidgid.c
@@ -1,12 +1,10 @@
/* ISC license. */
#include
-#include
#include
#include
#include
-#include
-#include
+#include
#include
#include
#include
@@ -18,29 +16,29 @@
int main (int argc, char const *const *argv, char const *const *envp)
{
- 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 ;
int unexport = 0 ;
PROG = "s6-applyuidgid" ;
{
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "zUu:g:G:", &l) ;
+ int opt = subgetopt_r(argc, argv, "zUu:g:G:", &l) ;
if (opt == -1) break ;
switch (opt)
{
case 'z' : unexport = 1 ; 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 'U' :
{
char const *x = env_get2(envp, "UID") ;
if (!x) strerr_dienotset(100, "UID") ;
- if (!uint640_scan(x, &uid)) strerr_dieinvalid(100, "UID") ;
+ if (!uid0_scan(x, &uid)) strerr_dieinvalid(100, "UID") ;
x = env_get2(envp, "GID") ;
if (!x) strerr_dienotset(100, "GID") ;
if (!gid0_scan(x, &gid)) strerr_dieinvalid(100, "GID") ;
@@ -57,12 +55,11 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
if (!argc) dieusage() ;
- if (uid > (uint64)(uid_t)-1) strerr_dief1x(100, "uid value too big") ;
- if (gidn != (unsigned int)-1 && setgroups(gidn, gids) < 0)
+ if (gidn != (size_t)-1 && setgroups(gidn, gids) < 0)
strerr_diefu1sys(111, "set supplementary group list") ;
if (gid && setgid(gid) < 0)
strerr_diefu1sys(111, "setgid") ;
- if (uid && setuid((uid_t)uid) < 0)
+ if (uid && setuid(uid) < 0)
strerr_diefu1sys(111, "setuid") ;
if (unexport) pathexec_r(argv, envp, env_len(envp), "UID\0GID\0GIDLIST", 16) ;
diff --git a/src/daemontools-extras/s6-envdir.c b/src/daemontools-extras/s6-envdir.c
index 394253e..431389b 100644
--- a/src/daemontools-extras/s6-envdir.c
+++ b/src/daemontools-extras/s6-envdir.c
@@ -19,7 +19,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
PROG = "s6-envdir" ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "Iinfc:", &l) ;
+ int opt = subgetopt_r(argc, argv, "Iinfc:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/daemontools-extras/s6-envuidgid.c b/src/daemontools-extras/s6-envuidgid.c
index 365a862..d808219 100644
--- a/src/daemontools-extras/s6-envuidgid.c
+++ b/src/daemontools-extras/s6-envuidgid.c
@@ -1,24 +1,21 @@
/* ISC license. */
-#include
+#include
#include
#include
#include
-#include
-#include
-#include
+#include
#include
#include
#include
-#include
#include
#define USAGE "s6-envuidgid [ -i | -D defaultuid:defaultgid ] [ -u | -g | -B ] [ -n ] account prog..."
#define dieusage() strerr_dieusage(100, USAGE)
-static inline size_t scan_defaults (char const *s, uint64 *uid, gid_t *gid, unsigned int *n, gid_t *tab)
+static inline size_t scan_defaults (char const *s, uid_t *uid, gid_t *gid, size_t *n, gid_t *tab)
{
- size_t pos = uint64_scan(s, uid) ;
+ size_t pos = uid_scan(s, uid) ;
if (!pos)
{
if (*s != ':') return 0 ;
@@ -54,16 +51,16 @@ int main (int argc, char *const *argv, char const *const *envp)
unsigned int what = 7 ;
int numfallback = 0 ;
int insist = 1 ;
- uint64 uid ;
+ uid_t uid ;
gid_t gid ;
- unsigned int n ;
+ size_t n ;
gid_t tab[NGROUPS_MAX] ;
PROG = "s6-envuidgid" ;
{
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, (char const *const *)argv, "ugBniD:", &l) ;
+ int opt = subgetopt_r(argc, (char const *const *)argv, "ugBniD:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -94,13 +91,13 @@ int main (int argc, char *const *argv, char const *const *envp)
break ;
case 3 : /* both */
{
- size_t pos = str_chr(argv[0], ':') ;
+ char *colon = strchr(argv[0], ':') ;
user = argv[0] ;
- if (argv[0][pos])
+ if (colon)
{
- argv[0][pos] = 0 ;
- group = argv[0] + pos + 1 ;
- if (!pos) user = 0 ;
+ *colon = 0 ;
+ group = colon + 1 ;
+ if (colon == argv[0]) user = 0 ;
if (!group[0]) group = 0 ;
}
break ;
@@ -131,28 +128,28 @@ int main (int argc, char *const *argv, char const *const *envp)
gid = pw->pw_gid ;
}
}
- else if (numfallback && uint64_scan(user, &uid)) ;
+ else if (numfallback && uid_scan(user, &uid)) ;
else if (insist) strerr_dief2x(1, "unknown user: ", user) ;
}
{
size_t pos = 0 ;
- char fmt[19 + UINT64_FMT + (NGROUPS_MAX+1) * GID_FMT] ;
+ char fmt[19 + UID_FMT + (NGROUPS_MAX+1) * GID_FMT] ;
if (what & 1)
{
- byte_copy(fmt + pos, 4, "UID=") ; pos += 4 ;
- pos += uint64_fmt(fmt + pos, uid) ;
+ memcpy(fmt + pos, "UID=", 4) ; pos += 4 ;
+ pos += uid_fmt(fmt + pos, uid) ;
fmt[pos++] = 0 ;
}
if (what & 2)
{
- byte_copy(fmt + pos, 4, "GID=") ; pos += 4 ;
+ memcpy(fmt + pos, "GID=", 4) ; pos += 4 ;
pos += gid_fmt(fmt + pos, gid) ;
fmt[pos++] = 0 ;
}
if (what & 4)
{
- byte_copy(fmt + pos, 8, "GIDLIST=") ; pos += 8 ;
+ memcpy(fmt + pos, "GIDLIST=", 8) ; pos += 8 ;
pos += gid_fmtlist(fmt + pos, tab, n) ;
fmt[pos++] = 0 ;
}
diff --git a/src/daemontools-extras/s6-fghack.c b/src/daemontools-extras/s6-fghack.c
index 1415706..5981b96 100644
--- a/src/daemontools-extras/s6-fghack.c
+++ b/src/daemontools-extras/s6-fghack.c
@@ -1,6 +1,5 @@
/* ISC license. */
-#include
#include
#include
#include
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index 0fdbf68..bdc0a82 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -1,17 +1,17 @@
/* ISC license. */
-#include
#include
#include
+#include
+#include
#include
#include
#include
#include
#include
#include
-#include
#include
-#include
+#include
#include
#include
#include
@@ -141,11 +141,11 @@ struct logdir_s
unsigned int xindex ;
tain_t retrytto ;
tain_t deadline ;
- uint64 maxdirsize ;
- uint32 b ;
- uint32 n ;
- uint32 s ;
- uint32 tolerance ;
+ uint64_t maxdirsize ;
+ uint32_t b ;
+ uint32_t n ;
+ uint32_t s ;
+ uint32_t tolerance ;
pid_t pid ;
char const *dir ;
char const *processor ;
@@ -188,13 +188,13 @@ static unsigned int llen = 0 ;
static int filesize_cmp (filesize_t const *a, filesize_t const *b)
{
- return byte_diff(a->name+1, 26, b->name+1) ;
+ return memcmp(a->name+1, b->name+1, 26) ;
}
static int name_is_relevant (char const *name)
{
tain_t dummy ;
- if (str_len(name) != 27) return 0 ;
+ if (strlen(name) != 27) return 0 ;
if (!timestamp_scan(name, &dummy)) return 0 ;
if (name[25] != '.') return 0 ;
if ((name[26] != 's') && (name[26] != 'u')) return 0 ;
@@ -216,7 +216,7 @@ static inline int logdir_trim (logdir_t *ldp)
}
if (errno)
{
- register int e = errno ;
+ int e = errno ;
dir_close(dir) ;
errno = e ;
return -1 ;
@@ -224,12 +224,12 @@ static inline int logdir_trim (logdir_t *ldp)
rewinddir(dir) ;
if (n)
{
- uint64 totalsize = 0 ;
- size_t dirlen = str_len(ldp->dir) ;
+ uint64_t totalsize = 0 ;
+ size_t dirlen = strlen(ldp->dir) ;
unsigned int i = 0 ;
filesize_t blurgh[n] ;
char fullname[dirlen + 29] ;
- byte_copy(fullname, dirlen, ldp->dir) ;
+ memcpy(fullname, ldp->dir, dirlen) ;
fullname[dirlen] = '/' ;
for (;;)
{
@@ -240,20 +240,20 @@ static inline int logdir_trim (logdir_t *ldp)
if (!d) break ;
if (!name_is_relevant(d->d_name)) continue ;
if (i >= n) { errno = EBUSY ; break ; }
- byte_copy(fullname + dirlen + 1, 28, d->d_name) ;
+ memcpy(fullname + dirlen + 1, d->d_name, 28) ;
if (stat(fullname, &st) < 0)
{
if (verbosity) strerr_warnwu2sys("stat ", fullname) ;
continue ;
}
- byte_copy(blurgh[i].name, 28, d->d_name) ;
+ memcpy(blurgh[i].name, d->d_name, 28) ;
blurgh[i].size = st.st_size ;
totalsize += st.st_size ;
i++ ;
}
if (errno)
{
- register int e = errno ;
+ int e = errno ;
dir_close(dir) ;
errno = e ;
return -1 ;
@@ -265,7 +265,7 @@ static inline int logdir_trim (logdir_t *ldp)
n = 0 ;
while ((i > ldp->n + n) || (ldp->maxdirsize && (totalsize > ldp->maxdirsize)))
{
- byte_copy(fullname + dirlen + 1, 28, blurgh[n].name) ;
+ memcpy(fullname + dirlen + 1, blurgh[n].name, 28) ;
if (unlink(fullname) < 0)
{
if (errno == ENOENT) totalsize -= blurgh[n].size ;
@@ -281,17 +281,17 @@ static inline int logdir_trim (logdir_t *ldp)
static int finish (logdir_t *ldp, char const *name, char suffix)
{
struct stat st ;
- size_t dirlen = str_len(ldp->dir) ;
- size_t namelen = str_len(name) ;
+ size_t dirlen = strlen(ldp->dir) ;
+ size_t namelen = strlen(name) ;
char x[dirlen + namelen + 2] ;
- byte_copy(x, dirlen, ldp->dir) ;
+ memcpy(x, ldp->dir, dirlen) ;
x[dirlen] = '/' ;
- byte_copy(x + dirlen + 1, namelen + 1, name) ;
+ memcpy(x + dirlen + 1, name, namelen + 1) ;
if (stat(x, &st) < 0) return errno == ENOENT ? 0 : -1 ;
if (st.st_nlink == 1)
{
char y[dirlen + 29] ;
- byte_copy(y, dirlen, ldp->dir) ;
+ memcpy(y, ldp->dir, dirlen) ;
y[dirlen] = '/' ;
timestamp_g(y + dirlen + 1) ;
y[dirlen + 26] = '.' ;
@@ -329,7 +329,7 @@ static inline void exec_processor (logdir_t *ldp)
static int rotator (logdir_t *ldp)
{
- size_t dirlen = str_len(ldp->dir) ;
+ size_t dirlen = strlen(ldp->dir) ;
switch (ldp->rstate)
{
case ROTSTATE_START :
@@ -344,10 +344,10 @@ static int rotator (logdir_t *ldp)
{
char current[dirlen + 9] ;
char previous[dirlen + 10] ;
- byte_copy(current, dirlen, ldp->dir) ;
- byte_copy(current + dirlen, 9, "/current") ;
- byte_copy(previous, dirlen, ldp->dir) ;
- byte_copy(previous + dirlen, 10, "/previous") ;
+ memcpy(current, ldp->dir, dirlen) ;
+ memcpy(current + dirlen, "/current", 9) ;
+ memcpy(previous, ldp->dir, dirlen) ;
+ memcpy(previous + dirlen, "/previous", 10) ;
if (rename(current, previous) < 0)
{
if (verbosity) strerr_warnwu4sys("rename ", current, " to ", previous) ;
@@ -359,8 +359,8 @@ static int rotator (logdir_t *ldp)
{
int fd ;
char x[dirlen + 9] ;
- byte_copy(x, dirlen, ldp->dir) ;
- byte_copy(x + dirlen, 9, "/current") ;
+ memcpy(x, ldp->dir, dirlen) ;
+ memcpy(x + dirlen, "/current", 9) ;
fd = open_append(x) ;
if (fd < 0)
{
@@ -369,7 +369,7 @@ static int rotator (logdir_t *ldp)
}
if (coe(fd) < 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
if (verbosity) strerr_warnwu2sys("coe ", x) ;
@@ -377,7 +377,7 @@ static int rotator (logdir_t *ldp)
}
if (fd_chmod(fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
if (verbosity) strerr_warnwu3sys("fchmod ", x, " to 0644") ;
@@ -391,8 +391,8 @@ static int rotator (logdir_t *ldp)
case ROTSTATE_CHMODPREVIOUS :
{
char x[dirlen + 10] ;
- byte_copy(x, dirlen, ldp->dir) ;
- byte_copy(x + dirlen, 10, "/previous") ;
+ memcpy(x, ldp->dir, dirlen) ;
+ memcpy(x + dirlen, "/previous", 10) ;
if (chmod(x, S_IRWXU | S_IRGRP | S_IROTH) < 0)
{
if (verbosity) strerr_warnwu3sys("chmod ", x, " to 0744") ;
@@ -431,8 +431,8 @@ static int rotator (logdir_t *ldp)
{
int fd ;
char x[dirlen + 11] ;
- byte_copy(x, dirlen, ldp->dir) ;
- byte_copy(x + dirlen, 11, "/processed") ;
+ memcpy(x, ldp->dir, dirlen) ;
+ memcpy(x + dirlen, "/processed", 11) ;
fd = open_append(x) ;
if (fd < 0)
{
@@ -441,7 +441,7 @@ static int rotator (logdir_t *ldp)
}
if (fd_sync(fd) < 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
if (verbosity) strerr_warnwu2sys("fd_sync ", x) ;
@@ -450,7 +450,7 @@ static int rotator (logdir_t *ldp)
tain_now_g() ;
if (fd_chmod(fd, S_IRWXU | S_IRGRP | S_IROTH) < 0)
{
- register int e = errno ;
+ int e = errno ;
fd_close(fd) ;
errno = e ;
if (verbosity) strerr_warnwu3sys("fd_chmod ", x, " to 0744") ;
@@ -463,8 +463,8 @@ static int rotator (logdir_t *ldp)
{
int fd ;
char x[dirlen + 10] ;
- byte_copy(x, dirlen, ldp->dir) ;
- byte_copy(x + dirlen, 10, "/newstate") ;
+ memcpy(x, ldp->dir, dirlen) ;
+ memcpy(x + dirlen, "/newstate", 10) ;
fd = open_append(x) ;
if (fd < 0)
{
@@ -483,8 +483,8 @@ static int rotator (logdir_t *ldp)
case ROTSTATE_UNLINKPREVIOUS :
{
char x[dirlen + 10] ;
- byte_copy(x, dirlen, ldp->dir) ;
- byte_copy(x + dirlen, 10, "/previous") ;
+ memcpy(x, ldp->dir, dirlen) ;
+ memcpy(x + dirlen, "/previous", 10) ;
if ((unlink(x) < 0) && (errno != ENOENT))
{
if (verbosity) strerr_warnwu2sys("open_append ", x) ;
@@ -496,10 +496,10 @@ static int rotator (logdir_t *ldp)
{
char newstate[dirlen + 10] ;
char state[dirlen + 7] ;
- byte_copy(newstate, dirlen, ldp->dir) ;
- byte_copy(state, dirlen, ldp->dir) ;
- byte_copy(newstate + dirlen, 10, "/newstate") ;
- byte_copy(state + dirlen, 7, "/state") ;
+ memcpy(newstate, ldp->dir, dirlen) ;
+ memcpy(state, ldp->dir, dirlen) ;
+ memcpy(newstate + dirlen, "/newstate", 10) ;
+ memcpy(state + dirlen, "/state", 7) ;
if (rename(newstate, state) < 0)
{
if (verbosity) strerr_warnwu4sys("rename ", newstate, " to ", state) ;
@@ -524,7 +524,7 @@ static int rotator (logdir_t *ldp)
return 0 ;
}
-static int logdir_write (int i, char const *s, size_t len)
+static ssize_t logdir_write (int i, char const *s, size_t len)
{
logdir_t *ldp = logdirs + i ;
ssize_t r ;
@@ -563,7 +563,7 @@ static inline void rotate_or_flush (logdir_t *ldp)
bufalloc_flush(&ldp->out) ;
}
-static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint32_t tolerance, uint64 maxdirsize, tain_t const *retrytto, char const *processor, char const *name, unsigned int flags)
+static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint32_t tolerance, uint64_t maxdirsize, tain_t const *retrytto, char const *processor, char const *name, unsigned int flags)
{
logdir_t *ldp = logdirs + index ;
struct stat st ;
@@ -583,25 +583,25 @@ static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint
ldp->rstate = ROTSTATE_WRITABLE ;
r = mkdir(ldp->dir, S_IRWXU | S_ISGID) ;
if ((r < 0) && (errno != EEXIST)) strerr_diefu2sys(111, "mkdir ", name) ;
- byte_copy(x, dirlen, name) ;
- byte_copy(x + dirlen, 6, "/lock") ;
+ memcpy(x, name, dirlen) ;
+ memcpy(x + dirlen, "/lock", 6) ;
ldp->fdlock = open_append(x) ;
if ((ldp->fdlock) < 0) strerr_diefu2sys(111, "open_append ", x) ;
if (lock_exnb(ldp->fdlock) < 0) strerr_diefu2sys(111, "lock_exnb ", x) ;
if (coe(ldp->fdlock) < 0) strerr_diefu2sys(111, "coe ", x) ;
- byte_copy(x + dirlen + 1, 8, "current") ;
+ memcpy(x + dirlen + 1, "current", 8) ;
if (stat(x, &st) < 0)
{
if (errno != ENOENT) strerr_diefu2sys(111, "stat ", x) ;
}
else if (st.st_mode & S_IXUSR) goto opencurrent ;
- byte_copy(x + dirlen + 1, 6, "state") ;
+ memcpy(x + dirlen + 1, "state", 6) ;
unlink(x) ;
- byte_copy(x + dirlen + 1, 9, "newstate") ;
+ memcpy(x + dirlen + 1, "newstate", 9) ;
unlink(x) ;
{
int flagprocessed = 0 ;
- byte_copy(x + dirlen + 1, 10, "processed") ;
+ memcpy(x + dirlen + 1, "processed", 10) ;
if (stat(x, &st) < 0)
{
if (errno != ENOENT) strerr_diefu2sys(111, "stat ", x) ;
@@ -609,7 +609,7 @@ static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint
else if (st.st_mode & S_IXUSR) flagprocessed = 1 ;
if (flagprocessed)
{
- byte_copy(x + dirlen + 1, 9, "previous") ;
+ memcpy(x + dirlen + 1, "previous", 9) ;
unlink(x) ;
if (finish(ldp, "processed", 's') < 0)
strerr_diefu2sys(111, "finish processed .s for logdir ", ldp->dir) ;
@@ -623,12 +623,12 @@ static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint
}
if (finish(ldp, "current", 'u') < 0)
strerr_diefu2sys(111, "finish current .u for logdir ", ldp->dir) ;
- byte_copy(x + dirlen + 1, 6, "state") ;
+ memcpy(x + dirlen + 1, "state", 6) ;
ldp->fd = open_trunc(x) ;
if (ldp->fd < 0) strerr_diefu2sys(111, "open_trunc ", x) ;
fd_close(ldp->fd) ;
st.st_size = 0 ;
- byte_copy(x + dirlen + 1, 8, "current") ;
+ memcpy(x + dirlen + 1, "current", 8) ;
opencurrent:
ldp->fd = open_append(x) ;
if (ldp->fd < 0) strerr_diefu2sys(111, "open_append ", x) ;
@@ -779,7 +779,7 @@ static inline void script_secondpass (char const *const *argv, scriptelem_t *scr
uint32_t s = 99999 ;
uint32_t n = 10 ;
uint32_t tolerance = 2000 ;
- uint64 maxdirsize = 0 ;
+ uint64_t maxdirsize = 0 ;
char const *processor = 0 ;
unsigned int sel = 0, act = 0, lidx = 0, flags = 0 ;
int flagacted = 0 ;
@@ -948,7 +948,7 @@ static void script_run (scriptelem_t const *script, unsigned int scriptlen, char
for (j = 0 ; j < script[i].actlen ; j++)
{
act_t const *act = script[i].acts + j ;
- siovec_t v[4] = { { .s = tstamp, .len = act->flags & 1 ? TIMESTAMP+1 : 0 }, { .s = hstamp, .len = act->flags & 2 ? hlen : 0 }, { .s = (char *)s, .len = len }, { .s = "\n", .len = 1 } } ;
+ struct iovec v[4] = { { .iov_base = tstamp, .iov_len = act->flags & 1 ? TIMESTAMP+1 : 0 }, { .iov_base = hstamp, .iov_len = act->flags & 2 ? hlen : 0 }, { .iov_base = (char *)s, .iov_len = len }, { .iov_base = "\n", .iov_len = 1 } } ;
switch (act->type)
{
case ACTTYPE_FD1 :
@@ -961,9 +961,9 @@ static void script_run (scriptelem_t const *script, unsigned int scriptlen, char
buffer_puts(buffer_2, ": alert: ") ;
if (act->data.fd2_size && act->data.fd2_size + 3 < len)
{
- v[2].len = act->data.fd2_size ;
- v[3].s = "...\n" ;
- v[3].len = 4 ;
+ v[2].iov_len = act->data.fd2_size ;
+ v[3].iov_base = "...\n" ;
+ v[3].iov_len = 4 ;
}
buffer_putv(buffer_2, v, 4) ;
buffer_flush(buffer_2) ; /* if it blocks, too bad */
@@ -977,10 +977,10 @@ static void script_run (scriptelem_t const *script, unsigned int scriptlen, char
siovec_trunc(v, 4, act->data.status.filelen) ;
else
{
- register size_t k = act->data.status.filelen - reallen + 1 ;
+ size_t k = act->data.status.filelen - reallen + 1 ;
char pad[k] ;
- v[3].s = pad ;
- v[3].len = k ;
+ v[3].iov_base = pad ;
+ v[3].iov_len = k ;
while (k--) pad[k] = '\n' ;
if (!openwritevnclose_suffix(act->data.status.file, v, 4, ".new") && verbosity)
strerr_warnwu2sys("write status file ", act->data.status.file) ;
@@ -1115,8 +1115,8 @@ static inline void handle_signals (void)
case 0 : return ;
case SIGALRM :
{
- register unsigned int i = 0 ;
- for (i = 0 ; i < llen ; i++)
+ unsigned int i = 0 ;
+ for (; i < llen ; i++)
if ((logdirs[i].rstate == ROTSTATE_WRITABLE) && logdirs[i].b)
{
logdirs[i].rstate = ROTSTATE_START ;
@@ -1135,8 +1135,8 @@ static inline void handle_signals (void)
for (;;)
{
int wstat ;
- register unsigned int i = 0 ;
- register pid_t r = wait_nohang(&wstat) ;
+ unsigned int i = 0 ;
+ pid_t r = wait_nohang(&wstat) ;
if (r <= 0) break ;
for (; i < llen ; i++) if (r == logdirs[i].pid) break ;
if (i < llen) processor_died(logdirs + i, wstat) ;
@@ -1161,7 +1161,7 @@ int main (int argc, char const *const *argv)
subgetopt_t l = SUBGETOPT_ZERO ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "qvbptel:", &l) ;
+ int opt = subgetopt_r(argc, argv, "qvbptel:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/daemontools-extras/s6-setlock.c b/src/daemontools-extras/s6-setlock.c
index 27b6b23..a90bb13 100644
--- a/src/daemontools-extras/s6-setlock.c
+++ b/src/daemontools-extras/s6-setlock.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include
#include
#include
#include
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -28,7 +27,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
PROG = "s6-setlock" ;
for (;;)
{
- register int opt = subgetopt(argc, argv, "nNrwt:") ;
+ int opt = subgetopt(argc, argv, "nNrwt:") ;
if (opt == -1) break ;
switch (opt)
{
@@ -68,7 +67,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
for (;;)
{
ssize_t rr ;
- register int r = iopause_g(&x, 1, &deadline) ;
+ int r = iopause_g(&x, 1, &deadline) ;
if (r < 0) strerr_diefu1sys(111, "iopause") ;
if (!r)
{
diff --git a/src/daemontools-extras/s6-setsid.c b/src/daemontools-extras/s6-setsid.c
index 609b041..0e30559 100644
--- a/src/daemontools-extras/s6-setsid.c
+++ b/src/daemontools-extras/s6-setsid.c
@@ -2,7 +2,7 @@
#include
#include
-#include
+#include
#include
#include
#include
@@ -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, "sbfgiIqd:", &l) ;
+ int opt = subgetopt_r(argc, argv, "sbfgiIqd:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/daemontools-extras/s6-setuidgid.c b/src/daemontools-extras/s6-setuidgid.c
index 727696a..1893883 100644
--- a/src/daemontools-extras/s6-setuidgid.c
+++ b/src/daemontools-extras/s6-setuidgid.c
@@ -1,7 +1,6 @@
/* ISC license. */
-#include
-#include
+#include
#include
#include
#include
@@ -12,20 +11,20 @@
int main (int argc, char *const *argv, char const *const *envp)
{
char const *newargv[argc + 7] ;
- size_t pos ;
+ char *colon ;
unsigned int m = 0 ;
PROG = "s6-setuidgid" ;
if (argc < 3) dieusage() ;
argv++ ;
- pos = str_chr(argv[0], ':') ;
- if (argv[0][pos])
+ colon = strchr(argv[0], ':') ;
+ if (colon)
{
- argv[0][pos] = 0 ;
+ *colon = 0 ;
newargv[m++] = S6_BINPREFIX "s6-applyuidgid" ;
newargv[m++] = "-u" ;
newargv[m++] = argv[0] ;
newargv[m++] = "-g" ;
- newargv[m++] = argv[0] + pos + 1 ;
+ newargv[m++] = colon + 1 ;
newargv[m++] = "-G" ;
newargv[m++] = "" ;
argv++ ;
diff --git a/src/daemontools-extras/s6-softlimit.c b/src/daemontools-extras/s6-softlimit.c
index 6ddd779..7de9f3d 100644
--- a/src/daemontools-extras/s6-softlimit.c
+++ b/src/daemontools-extras/s6-softlimit.c
@@ -30,7 +30,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
PROG = "s6-softlimit" ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:", &l) ;
+ int opt = subgetopt_r(argc, argv, "a:c:d:f:l:m:o:p:r:s:t:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/daemontools-extras/s6-tai64n.c b/src/daemontools-extras/s6-tai64n.c
index 085c053..c6b2859 100644
--- a/src/daemontools-extras/s6-tai64n.c
+++ b/src/daemontools-extras/s6-tai64n.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include
#include
#include
#include
@@ -14,7 +15,7 @@ int main (void)
stamp[TIMESTAMP] = ' ' ;
for (;;)
{
- register int r = skagetln(buffer_0f1, &satmp, '\n') ;
+ int r = skagetln(buffer_0f1, &satmp, '\n') ;
if (r < 0)
if (errno != EPIPE)
strerr_diefu1sys(111, "read from stdin") ;
@@ -26,8 +27,8 @@ int main (void)
}
else if (!r) break ;
timestamp(stamp) ;
- if ((buffer_put(buffer_1, stamp, TIMESTAMP+1) < 0)
- || (buffer_put(buffer_1, satmp.s, satmp.len) < 0))
+ if ((buffer_put(buffer_1, stamp, TIMESTAMP+1) < TIMESTAMP+1)
+ || (buffer_put(buffer_1, satmp.s, satmp.len) < (ssize_t)satmp.len))
strerr_diefu1sys(111, "write to stdout") ;
satmp.len = 0 ;
}
diff --git a/src/daemontools-extras/s6-tai64nlocal.c b/src/daemontools-extras/s6-tai64nlocal.c
index 84e717a..ce97470 100644
--- a/src/daemontools-extras/s6-tai64nlocal.c
+++ b/src/daemontools-extras/s6-tai64nlocal.c
@@ -2,8 +2,6 @@
#include
#include
-#include
-#include
#include
#include
#include
@@ -34,11 +32,11 @@ int main (void)
size_t len ;
localtmn_from_tain(&local, &a, 1) ;
len = localtmn_fmt(fmt, &local) ;
- if (buffer_put(buffer_1, fmt, len) < 0)
+ if (buffer_put(buffer_1, fmt, len) < (ssize_t)len)
strerr_diefu1sys(111, "write to stdout") ;
}
}
- if (buffer_put(buffer_1, satmp.s + p, satmp.len - p) < 0)
+ if (buffer_put(buffer_1, satmp.s + p, satmp.len - p) < (ssize_t)(satmp.len - p))
strerr_diefu1sys(111, "write to stdout") ;
satmp.len = 0 ;
}
diff --git a/src/daemontools-extras/ucspilogd.c b/src/daemontools-extras/ucspilogd.c
index 1f338bd..25e8371 100644
--- a/src/daemontools-extras/ucspilogd.c
+++ b/src/daemontools-extras/ucspilogd.c
@@ -10,7 +10,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -138,7 +138,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, "D:", &l) ;
+ int opt = subgetopt_r(argc, argv, "D:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -162,7 +162,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
size_t pos = 0 ;
satmp.len = 0 ;
{
- register int r = skagetlnsep(buffer_0f1, &satmp, "\n", 2) ;
+ int r = skagetlnsep(buffer_0f1, &satmp, "\n", 2) ;
if (r < 0)
{
if (errno != EPIPE || !stralloc_0(&satmp))
@@ -181,7 +181,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if ((buffer_puts(buffer_1, envs[i]) < 0)
|| (buffer_put(buffer_1, ": ", 2) < 2)) die() ;
pos += syslog_names(satmp.s + pos) ;
- if (buffer_put(buffer_1, satmp.s + pos, satmp.len - pos) < (int)(satmp.len - pos)) die() ;
+ if (buffer_put(buffer_1, satmp.s + pos, satmp.len - pos) < (ssize_t)(satmp.len - pos)) die() ;
}
}
return 0 ;
diff --git a/src/fdholder/s6-fdholder-daemon.c b/src/fdholder/s6-fdholder-daemon.c
index 0a706da..0a0f019 100644
--- a/src/fdholder/s6-fdholder-daemon.c
+++ b/src/fdholder/s6-fdholder-daemon.c
@@ -2,8 +2,7 @@
#include
#include
-#include
-#include
+#include
#include
#include
#include
@@ -20,7 +19,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 maxfds = 0 ;
unsigned int backlog = (unsigned int)-1 ;
@@ -33,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, "Dd1Uv:c:n:b:u:g:G:t:T:i:x:", &l) ;
+ int opt = subgetopt_r(argc, argv, "Dd1Uv:c:n:b:u:g:G:t:T:i:x:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -47,7 +46,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
case 'u' : if (!uint0_scan(l.arg, &uid)) dieusage() ; break ;
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 '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 ;
case 't' : if (!uint0_scan(l.arg, &timeout)) dieusage() ; break ;
case 'T' : if (!uint0_scan(l.arg, <imeout)) dieusage() ; break ;
case 'i' : rulesdir = l.arg ; rulesfile = 0 ; break ;
@@ -76,7 +75,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" ;
@@ -94,7 +93,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/fdholder/s6-fdholder-delete.c b/src/fdholder/s6-fdholder-delete.c
index 7742148..94e658b 100644
--- a/src/fdholder/s6-fdholder-delete.c
+++ b/src/fdholder/s6-fdholder-delete.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include
+#include
#include
#include
#include
@@ -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, "t:", &l) ;
+ int opt = subgetopt_r(argc, argv, "t:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/fdholder/s6-fdholder-deletec.c b/src/fdholder/s6-fdholder-deletec.c
index 5f7dfa4..2b9820e 100644
--- a/src/fdholder/s6-fdholder-deletec.c
+++ b/src/fdholder/s6-fdholder-deletec.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include
+#include
#include
#include
#include
@@ -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, "t:", &l) ;
+ int opt = subgetopt_r(argc, argv, "t:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/fdholder/s6-fdholder-getdump.c b/src/fdholder/s6-fdholder-getdump.c
index 7ac88a2..bb359dc 100644
--- a/src/fdholder/s6-fdholder-getdump.c
+++ b/src/fdholder/s6-fdholder-getdump.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include
+#include
#include
#include
#include
@@ -18,7 +18,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, "t:", &l) ;
+ int opt = subgetopt_r(argc, argv, "t:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/fdholder/s6-fdholder-getdumpc.c b/src/fdholder/s6-fdholder-getdumpc.c
index 41ad5c5..73be61b 100644
--- a/src/fdholder/s6-fdholder-getdumpc.c
+++ b/src/fdholder/s6-fdholder-getdumpc.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include
+#include
#include
-#include
-#include
+#include
#include
#include
#include
@@ -25,7 +24,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, "t:", &l) ;
+ int opt = subgetopt_r(argc, argv, "t:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -53,25 +52,25 @@ int main (int argc, char const *const *argv, char const *const *envp)
unsigned int i = 0 ;
char modifs[7 + UINT_FMT + (25 + TIMESTAMP + 4 * UINT_FMT) * n] ;
if (n > UINT_MAX) strerr_dief1x(100, "dump exceeds maximum size") ;
- byte_copy(modifs + pos, 7, "S6_FD#=") ; pos += 7 ;
+ memcpy(modifs + pos, "S6_FD#=", 7) ; pos += 7 ;
pos += uint_fmt(modifs + pos, n) ;
modifs[pos++] = 0 ;
for (; i < n ; i++)
{
s6_fdholder_fd_t *p = genalloc_s(s6_fdholder_fd_t, &dump) + i ;
- size_t len = str_len(p->id) + 1 ;
+ size_t len = strlen(p->id) + 1 ;
if (uncoe(p->fd) < 0) strerr_diefu1sys(111, "uncoe") ;
- byte_copy(modifs + pos, 6, "S6_FD_") ; pos += 6 ;
+ memcpy(modifs + pos, "S6_FD_", 6) ; pos += 6 ;
pos += uint_fmt(modifs + pos, i) ;
modifs[pos++] = '=' ;
pos += uint_fmt(modifs + pos, p->fd) ;
modifs[pos++] = 0 ;
- byte_copy(modifs + pos, 8, "S6_FDID_") ; pos += 8 ;
+ memcpy(modifs + pos, "S6_FDID_", 8) ; pos += 8 ;
pos += uint_fmt(modifs + pos, i) ;
modifs[pos++] = '=' ;
- byte_copy(modifs + pos, len, p->id) ;
+ memcpy(modifs + pos, p->id, len) ;
pos += len ;
- byte_copy(modifs + pos, 11, "S6_FDLIMIT_") ; pos += 11 ;
+ memcpy(modifs + pos, "S6_FDLIMIT_", 11) ; pos += 11 ;
pos += uint_fmt(modifs + pos, i) ;
if (tain_less(&p->limit, &halfinfinite))
{
diff --git a/src/fdholder/s6-fdholder-list.c b/src/fdholder/s6-fdholder-list.c
index 2c6f73e..43f9ec8 100644
--- a/src/fdholder/s6-fdholder-list.c
+++ b/src/fdholder/s6-fdholder-list.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include
+#include
#include
#include
#include
@@ -21,7 +21,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, "d:t:T:", &l) ;
+ int opt = subgetopt_r(argc, argv, "d:t:T:", &l) ;
if (opt == -1) break ;
switch (opt)
{
diff --git a/src/fdholder/s6-fdholder-listc.c b/src/fdholder/s6-fdholder-listc.c
index 7bc2d1d..8c746c3 100644
--- a/src/fdholder/s6-fdholder-listc.c
+++ b/src/fdholder/s6-fdholder-listc.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include
-#include