diff options
Diffstat (limited to 'src/minidentd')
-rw-r--r-- | src/minidentd/mgetuid-default.c | 7 | ||||
-rw-r--r-- | src/minidentd/mgetuid-linux.c | 28 | ||||
-rw-r--r-- | src/minidentd/mgetuid.h | 5 | ||||
-rw-r--r-- | src/minidentd/minidentd.c | 28 |
4 files changed, 38 insertions, 30 deletions
diff --git a/src/minidentd/mgetuid-default.c b/src/minidentd/mgetuid-default.c index 6c9ae9b..5c9f1d2 100644 --- a/src/minidentd/mgetuid-default.c +++ b/src/minidentd/mgetuid-default.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <errno.h> -#include <skalibs/uint16.h> -#include <skalibs/uint32.h> +#include <skalibs/ip46.h> #include "mgetuid.h" -int mgetuid (ip46_t const *localaddr, uint16 localport, ip46_t const *remoteaddr, uint16 remoteport) +uid_t mgetuid (ip46_t const *localaddr, uint16_t localport, ip46_t const *remoteaddr, uint16_t remoteport) { (void)localaddr ; (void)localport ; diff --git a/src/minidentd/mgetuid-linux.c b/src/minidentd/mgetuid-linux.c index 209318b..18caba7 100644 --- a/src/minidentd/mgetuid-linux.c +++ b/src/minidentd/mgetuid-linux.c @@ -1,7 +1,10 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <skalibs/uint16.h> #include <skalibs/uint32.h> +#include <skalibs/uint64.h> #include <skalibs/uint.h> #include <skalibs/bytestr.h> #include <skalibs/fmtscan.h> @@ -28,9 +31,9 @@ static int skipspace (char **s) return (int)**s ; } -static void reverse_address (char *s, unsigned int n) +static void reverse_address (char *s, size_t n) { - register unsigned int i = n >> 1 ; + register size_t i = n >> 1 ; while (i--) { register char tmp = s[i] ; @@ -39,11 +42,12 @@ static void reverse_address (char *s, unsigned int n) } } -static int parseline (char *s, unsigned int len, unsigned int *u, char *la, uint16 *lp, char *ra, uint16 *rp, int is6) +static int parseline (char *s, size_t len, uid_t *u, char *la, uint16_t *lp, char *ra, uint16_t *rp, int is6) { char *cur = s ; - unsigned int pos ; - uint32 junk ; + size_t pos ; + uint64 uu ; + uint32_t junk ; register unsigned int iplen = is6 ? 16 : 4 ; if (!skipspace(&cur)) bug("initial whitespace") ; @@ -102,15 +106,15 @@ static int parseline (char *s, unsigned int len, unsigned int *u, char *la, uint cur += pos ; if (!skipspace(&cur)) bug("retrnsmt SPACE") ; - pos = uint_scan(cur, u) ; /* uid */ + pos = uint64_scan(cur, &uu) ; /* uid */ if (!pos || (cur-s+1+pos) > len) bug("uid") ; - + *u = uu ; return 1 ; } #ifdef DEBUG -static void debuglog (uint16 a, uint16 b, unsigned int c, char const *d, char const *e, int is6) +static void debuglog (uint16_t a, uint16_t b, unsigned int c, char const *d, char const *e, int is6) { char sa[UINT16_FMT] ; char sb[UINT16_FMT] ; @@ -138,10 +142,10 @@ static void debuglog (uint16 a, uint16 b, unsigned int c, char const *d, char co #endif -int mgetuid (ip46_t const *localaddr, uint16 localport, ip46_t const *remoteaddr, uint16 remoteport) +uid_t mgetuid (ip46_t const *localaddr, uint16_t localport, ip46_t const *remoteaddr, uint16_t remoteport) { int r ; - int u = -2 ; + uid_t u = -2 ; stralloc line = STRALLOC_ZERO ; buffer b ; char y[BUFFER_INSIZE] ; @@ -158,8 +162,8 @@ int mgetuid (ip46_t const *localaddr, uint16 localport, ip46_t const *remoteaddr { char la[16] ; char ra[16] ; - unsigned int nu ; - uint16 lp, rp ; + uid_t nu ; + uint16_t lp, rp ; line.len = 0 ; r = skagetln(&b, &line, '\n') ; if (r <= 0) { u = -1 ; break ; } diff --git a/src/minidentd/mgetuid.h b/src/minidentd/mgetuid.h index 0572385..4b882e4 100644 --- a/src/minidentd/mgetuid.h +++ b/src/minidentd/mgetuid.h @@ -3,9 +3,10 @@ #ifndef MGETUID_H #define MGETUID_H -#include <skalibs/uint16.h> +#include <sys/types.h> +#include <stdint.h> #include <skalibs/ip46.h> -extern int mgetuid (ip46_t const *, uint16, ip46_t const *, uint16) ; +extern uid_t mgetuid (ip46_t const *, uint16_t, ip46_t const *, uint16_t) ; #endif diff --git a/src/minidentd/minidentd.c b/src/minidentd/minidentd.c index 287a492..4a73021 100644 --- a/src/minidentd/minidentd.c +++ b/src/minidentd/minidentd.c @@ -1,5 +1,7 @@ /* ISC license. */ +#include <sys/types.h> +#include <stdint.h> #include <unistd.h> #include <errno.h> #include <pwd.h> @@ -34,15 +36,16 @@ static char logfmt[UINT_FMT] ; #define DECIMAL "0123456789" #define godecimal(s) while (*(s) && !DECIMAL[str_chr(DECIMAL, *(s))]) (s)++ -static int parseline (char const *s, uint16 *localport, uint16 *remoteport) +static int parseline (char const *s, uint16_t *localport, uint16_t *remoteport) { - unsigned int pos = 0 ; - + size_t pos ; godecimal(s) ; if (!*s) return 0 ; - s += uint16_scan(s, localport) ; + pos = uint16_scan(s, localport) ; + if (!pos) return 0 ; + s += pos ; if (!*s) return 0 ; - s += str_chr(s+pos, ',') ; + s += str_chr(s, ',') ; if (*s) s++ ; godecimal(s) ; if (!*s) return 0 ; @@ -50,7 +53,7 @@ static int parseline (char const *s, uint16 *localport, uint16 *remoteport) return 1 ; } -static void formatlr (char *s, uint16 lp, uint16 rp) +static void formatlr (char *s, uint16_t lp, uint16_t rp) { s += uint16_fmt(s, lp) ; *s++ = ',' ; @@ -101,10 +104,10 @@ static void logreply (char const *type, char const *reply1, char const *reply2) static int userident (char *s, char const *home) { int fd ; - int r = 1 ; + size_t r = 1 ; { - unsigned int homelen = str_len(home) ; - unsigned int userlen = str_len(userfile) ; + size_t homelen = str_len(home) ; + size_t userlen = str_len(userfile) ; char tmp[homelen + userlen + 2] ; byte_copy(tmp, homelen, home) ; tmp[homelen] = '/' ; @@ -119,7 +122,6 @@ static int userident (char *s, char const *home) } r = allread(fd, s, 14) ; fd_close(fd) ; - if (r == -1) return -1 ; if (!r) return 1 ; s[r] = 0 ; s[byte_chr(s, r, '\n')] = 0 ; @@ -130,9 +132,9 @@ static int userident (char *s, char const *home) static void doit (char const *s, ip46_t const *localaddr, ip46_t const *remoteaddr) { char lr[15] ; - uint16 localport, remoteport ; + uint16_t localport, remoteport ; struct passwd *pw ; - int uid ; + uid_t uid ; if (!parseline(s, &localport, &remoteport)) { reply("0, 0", "ERROR", "INVALID-PORT") ; @@ -233,7 +235,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (!proto) strerr_dienotset(100, "PROTO") ; { char const *x ; - unsigned int protolen = str_len(proto) ; + size_t protolen = str_len(proto) ; char tmp[protolen + 9] ; byte_copy(tmp, protolen, proto) ; byte_copy(tmp + protolen, 8, "LOCALIP") ; |