summaryrefslogtreecommitdiff
path: root/src/fdholder
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/fdholder
parent81c7a02ec870ef3dba9f8b8f8dbecbd119e5ea47 (diff)
downloads6-bf6d072124a960d3b84ae39cd15c5aeca2e41c88.tar.xz
Types fix, first pass
Diffstat (limited to 'src/fdholder')
-rw-r--r--src/fdholder/s6-fdholder-daemon.c3
-rw-r--r--src/fdholder/s6-fdholder-getdumpc.c10
-rw-r--r--src/fdholder/s6-fdholder-listc.c5
-rw-r--r--src/fdholder/s6-fdholder-setdumpc.c4
-rw-r--r--src/fdholder/s6-fdholder-transferdump.c3
-rw-r--r--src/fdholder/s6-fdholderd.c20
6 files changed, 28 insertions, 17 deletions
diff --git a/src/fdholder/s6-fdholder-daemon.c b/src/fdholder/s6-fdholder-daemon.c
index 46c4923..0a706da 100644
--- a/src/fdholder/s6-fdholder-daemon.c
+++ b/src/fdholder/s6-fdholder-daemon.c
@@ -61,7 +61,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!rulesdir && !rulesfile) strerr_dief1x(100, "no access rights specified!") ;
{
- unsigned int m = 0, pos = 0 ;
+ size_t pos = 0 ;
+ unsigned int m = 0 ;
char const *newargv[30] ;
char fmt[UINT_FMT * 8 + GID_FMT * NGROUPS_MAX] ;
newargv[m++] = S6_BINPREFIX "s6-ipcserver-socketbinder" ;
diff --git a/src/fdholder/s6-fdholder-getdumpc.c b/src/fdholder/s6-fdholder-getdumpc.c
index 85c288c..41ad5c5 100644
--- a/src/fdholder/s6-fdholder-getdumpc.c
+++ b/src/fdholder/s6-fdholder-getdumpc.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <limits.h>
#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
#include <skalibs/strerr2.h>
@@ -46,16 +48,18 @@ int main (int argc, char const *const *argv, char const *const *envp)
tain_half(&halfinfinite, &tain_infinite_relative) ;
tain_add_g(&halfinfinite, &halfinfinite) ;
{
- unsigned int n = genalloc_len(s6_fdholder_fd_t, &dump) ;
- unsigned int pos = 0, i = 0 ;
+ size_t n = genalloc_len(s6_fdholder_fd_t, &dump) ;
+ size_t pos = 0 ;
+ 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 ;
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 ;
- unsigned int len = str_len(p->id) + 1 ;
+ size_t len = str_len(p->id) + 1 ;
if (uncoe(p->fd) < 0) strerr_diefu1sys(111, "uncoe") ;
byte_copy(modifs + pos, 6, "S6_FD_") ; pos += 6 ;
pos += uint_fmt(modifs + pos, i) ;
diff --git a/src/fdholder/s6-fdholder-listc.c b/src/fdholder/s6-fdholder-listc.c
index 6bd2104..7bc2d1d 100644
--- a/src/fdholder/s6-fdholder-listc.c
+++ b/src/fdholder/s6-fdholder-listc.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
#include <skalibs/buffer.h>
@@ -17,7 +18,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
{
s6_fdholder_t a = S6_FDHOLDER_ZERO ;
stralloc sa = STRALLOC_ZERO, sb = STRALLOC_ZERO ;
- unsigned int pos = 0 ;
+ size_t pos = 0 ;
int n ;
tain_t deadline ;
PROG = "s6-fdholder-listc" ;
@@ -46,7 +47,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (n < 0) strerr_diefu1sys(1, "get fd list") ;
while (n--)
{
- register unsigned int len = str_len(sa.s + pos) ;
+ register size_t len = str_len(sa.s + pos) ;
sb.len = 0 ;
if (!string_quote_nodelim_mustquote(&sb, sa.s + pos, len, 0, 0))
strerr_diefu1sys(111, "quote string") ;
diff --git a/src/fdholder/s6-fdholder-setdumpc.c b/src/fdholder/s6-fdholder-setdumpc.c
index 9e253d9..5c80fd7 100644
--- a/src/fdholder/s6-fdholder-setdumpc.c
+++ b/src/fdholder/s6-fdholder-setdumpc.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint.h>
#include <skalibs/bytestr.h>
#include <skalibs/env.h>
@@ -49,7 +50,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
tain_add_g(&deadline, &deadline) ;
for (; i < dumplen ; i++)
{
- unsigned int fd, len ;
+ size_t len ;
+ unsigned int fd ;
byte_copy(s, 6, "S6_FD_") ;
s[6 + uint_fmt(s+6, i)] = 0 ;
x = env_get2(envp, s) ;
diff --git a/src/fdholder/s6-fdholder-transferdump.c b/src/fdholder/s6-fdholder-transferdump.c
index 3f86d69..5d6ccd0 100644
--- a/src/fdholder/s6-fdholder-transferdump.c
+++ b/src/fdholder/s6-fdholder-transferdump.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/types.h>
#include <skalibs/uint.h>
#include <skalibs/sgetopt.h>
#include <skalibs/env.h>
@@ -29,7 +30,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
{
case 't' :
{
- unsigned int pos = uint_scan(l.arg, &timeoutfrom) ;
+ size_t pos = uint_scan(l.arg, &timeoutfrom) ;
if (!pos)
{
if (l.arg[pos] != ':') dieusage() ;
diff --git a/src/fdholder/s6-fdholderd.c b/src/fdholder/s6-fdholderd.c
index cb041f3..001108a 100644
--- a/src/fdholder/s6-fdholderd.c
+++ b/src/fdholder/s6-fdholderd.c
@@ -23,6 +23,7 @@
#include <skalibs/selfpipe.h>
#include <skalibs/siovec.h>
#include <skalibs/cdb.h>
+#include <skalibs/getpeereid.h>
#include <skalibs/webipc.h>
#include <skalibs/genset.h>
#include <skalibs/avltreen.h>
@@ -323,7 +324,7 @@ static int do_list (unsigned int cc, unixmessage_t const *m)
char pack[5] = "" ;
if (c->dumping || m->len || m->nfds) return (errno = EPROTO, 0) ;
if (!(c->flags & 4)) return answer(c, EPERM) ;
- uint32_pack_big(pack + 1, (uint32)numfds) ;
+ uint32_pack_big(pack + 1, (uint32_t)numfds) ;
v[0].s = pack ; v[0].len = 5 ;
genset_iter(fdstore, &fill_siovec_with_ids_iter, &vp) ;
if (!unixmessage_putv(&c->connection.out, &ans)) return answer(c, errno) ;
@@ -363,8 +364,8 @@ static int do_getdump (unsigned int cc, unixmessage_t const *m)
{
char pack[9] = "" ;
unixmessage_t ans = { .s = pack, .len = 9, .fds = 0, .nfds = 0 } ;
- uint32_pack_big(pack+1, (uint32)n) ;
- uint32_pack_big(pack+5, (uint32)numfds) ;
+ uint32_pack_big(pack+1, (uint32_t)n) ;
+ uint32_pack_big(pack+5, (uint32_t)numfds) ;
if (!unixmessage_put(&c->connection.out, &ans)) return answer(c, errno) ;
}
if (n)
@@ -412,7 +413,7 @@ static int do_getdump (unsigned int cc, unixmessage_t const *m)
static int do_setdump (unsigned int cc, unixmessage_t const *m)
{
char pack[5] = "" ;
- uint32 n ;
+ uint32_t n ;
unixmessage_t ans = { .s = pack, .len = 5, .fds = 0, .nfds = 0 } ;
client_t *c = CLIENT(cc) ;
if (c->dumping || m->len != 4 || m->nfds) return (errno = EPROTO, 0) ;
@@ -443,7 +444,7 @@ static int do_setdump_data (unsigned int cc, unixmessage_t const *m)
}
{
char const *s = m->s ;
- unsigned int len = m->len ;
+ size_t len = m->len ;
unsigned int i = 0 ;
unsigned int indices[m->nfds] ;
for (; i < m->nfds ; i++)
@@ -523,7 +524,7 @@ static inline int client_read (unsigned int cc, iopause_fd const *x)
static int makere (regex_t *re, char const *s, char const *var)
{
- register unsigned int varlen = str_len(var) ;
+ register size_t varlen = str_len(var) ;
if (str_start(s, var) && (s[varlen] == '='))
{
int r = regcomp(re, s + varlen + 1, REG_EXTENDED | REG_NOSUB) ;
@@ -591,9 +592,10 @@ static inline int new_connection (int fd, regex_t *rre, regex_t *wre, unsigned i
{
s6_accessrules_params_t params = S6_ACCESSRULES_PARAMS_ZERO ;
s6_accessrules_result_t result = S6_ACCESSRULES_ERROR ;
- unsigned int uid, gid ;
+ uid_t uid ;
+ gid_t gid ;
- if (ipc_eid(fd, &uid, &gid) < 0)
+ if (getpeereid(fd, &uid, &gid) < 0)
{
if (verbosity) strerr_warnwu1sys("getpeereid") ;
return 0 ;
@@ -623,7 +625,7 @@ static inline int new_connection (int fd, regex_t *rre, regex_t *wre, unsigned i
}
if (params.env.s)
{
- unsigned int n = byte_count(params.env.s, params.env.len, '\0') ;
+ size_t n = byte_count(params.env.s, params.env.len, '\0') ;
char const *envp[n+1] ;
if (!env_make(envp, n, params.env.s, params.env.len))
{