summaryrefslogtreecommitdiff
path: root/src/minidentd
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 19:39:01 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 19:39:01 +0000
commit53091e3bce487ee82e2805a0231e780551561717 (patch)
treef0fa36ff8eadaf1f01d4510597b5e3a310764dc7 /src/minidentd
parentf85b8a70f3b44510a5cf3895bf7357ae90655f65 (diff)
downloads6-networking-53091e3bce487ee82e2805a0231e780551561717.tar.xz
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/minidentd')
-rw-r--r--src/minidentd/mgetuid-linux.c20
-rw-r--r--src/minidentd/minidentd.c31
2 files changed, 23 insertions, 28 deletions
diff --git a/src/minidentd/mgetuid-linux.c b/src/minidentd/mgetuid-linux.c
index 18caba7..f374adf 100644
--- a/src/minidentd/mgetuid-linux.c
+++ b/src/minidentd/mgetuid-linux.c
@@ -1,12 +1,10 @@
/* ISC license. */
#include <sys/types.h>
+#include <string.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/types.h>
#include <skalibs/fmtscan.h>
#include <skalibs/buffer.h>
#include <skalibs/stralloc.h>
@@ -33,10 +31,10 @@ static int skipspace (char **s)
static void reverse_address (char *s, size_t n)
{
- register size_t i = n >> 1 ;
+ size_t i = n >> 1 ;
while (i--)
{
- register char tmp = s[i] ;
+ char tmp = s[i] ;
s[i] = s[n-1-i] ;
s[n-1-i] = tmp ;
}
@@ -46,9 +44,9 @@ static int parseline (char *s, size_t len, uid_t *u, char *la, uint16_t *lp, cha
{
char *cur = s ;
size_t pos ;
- uint64 uu ;
+ uint64_t uu ;
uint32_t junk ;
- register unsigned int iplen = is6 ? 16 : 4 ;
+ unsigned int iplen = is6 ? 16 : 4 ;
if (!skipspace(&cur)) bug("initial whitespace") ;
pos = uint32_scan(cur, &junk) ; /* sl */
@@ -149,7 +147,7 @@ uid_t mgetuid (ip46_t const *localaddr, uint16_t localport, ip46_t const *remote
stralloc line = STRALLOC_ZERO ;
buffer b ;
char y[BUFFER_INSIZE] ;
- register int is6 = ip46_is6(localaddr) ;
+ int is6 = ip46_is6(localaddr) ;
int fd = open_readb(is6 ? "/proc/net/tcp6" : "/proc/net/tcp") ;
if (fd == -1) return -2 ;
buffer_init(&b, &buffer_read, fd, y, BUFFER_INSIZE_SMALL) ;
@@ -173,8 +171,8 @@ uid_t mgetuid (ip46_t const *localaddr, uint16_t localport, ip46_t const *remote
debuglog(lp, rp, nu, la, ra, is6) ;
#endif
if ((lp == localport) && (rp == remoteport)
- && !byte_diff(la, is6 ? 16 : 4, localaddr->ip)
- && !byte_diff(ra, is6 ? 16 : 4, remoteaddr->ip))
+ && !memcmp(la, localaddr->ip, is6 ? 16 : 4)
+ && !memcmp(ra, remoteaddr->ip, is6 ? 16 : 4))
{
u = nu ; break ;
}
diff --git a/src/minidentd/minidentd.c b/src/minidentd/minidentd.c
index 4a73021..6d0f6a0 100644
--- a/src/minidentd/minidentd.c
+++ b/src/minidentd/minidentd.c
@@ -1,13 +1,11 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <pwd.h>
-#include <skalibs/uint16.h>
-#include <skalibs/uint32.h>
-#include <skalibs/uint.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/bytestr.h>
#include <skalibs/fmtscan.h>
@@ -33,8 +31,7 @@ static tain_t deadline ;
static unsigned int nquery = 0 ;
static char logfmt[UINT_FMT] ;
-#define DECIMAL "0123456789"
-#define godecimal(s) while (*(s) && !DECIMAL[str_chr(DECIMAL, *(s))]) (s)++
+#define godecimal(s) while (*(s) && !strchr("0123456789", *(s))) (s)++
static int parseline (char const *s, uint16_t *localport, uint16_t *remoteport)
{
@@ -106,12 +103,12 @@ static int userident (char *s, char const *home)
int fd ;
size_t r = 1 ;
{
- size_t homelen = str_len(home) ;
- size_t userlen = str_len(userfile) ;
+ size_t homelen = strlen(home) ;
+ size_t userlen = strlen(userfile) ;
char tmp[homelen + userlen + 2] ;
- byte_copy(tmp, homelen, home) ;
+ memcpy(tmp, home, homelen) ;
tmp[homelen] = '/' ;
- byte_copy(tmp + homelen + 1, userlen + 1, userfile) ;
+ memcpy(tmp + homelen + 1, userfile, userlen + 1) ;
fd = open_readb(tmp) ;
}
if (fd == -1) return (errno != ENOENT) ? -1 : 0 ;
@@ -181,7 +178,7 @@ static void doit (char const *s, ip46_t const *localaddr, ip46_t const *remotead
if (how)
{
char s[15] ;
- register int r = userident(s, pw->pw_dir) ;
+ int r = userident(s, pw->pw_dir) ;
if ((how == 1) || (r == 1))
{
reply(lr, "ERROR", "HIDDEN-USER") ;
@@ -213,7 +210,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
unsigned int t = 0 ;
for (;;)
{
- register int opt = subgetopt_r(argc, argv, "vniry:t:", &l) ;
+ int opt = subgetopt_r(argc, argv, "vniry:t:", &l) ;
if (opt == -1) break ;
switch (opt)
{
@@ -235,14 +232,14 @@ int main (int argc, char const *const *argv, char const *const *envp)
if (!proto) strerr_dienotset(100, "PROTO") ;
{
char const *x ;
- size_t protolen = str_len(proto) ;
+ size_t protolen = strlen(proto) ;
char tmp[protolen + 9] ;
- byte_copy(tmp, protolen, proto) ;
- byte_copy(tmp + protolen, 8, "LOCALIP") ;
+ memcpy(tmp, proto, protolen) ;
+ memcpy(tmp + protolen, "LOCALIP", 8) ;
x = env_get2(envp, tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
if (!ip46_scan(x, &localaddr)) strerr_dieinvalid(100, tmp) ;
- byte_copy(tmp + protolen, 9, "REMOTEIP") ;
+ memcpy(tmp + protolen, "REMOTEIP", 9) ;
x = env_get2(envp, tmp) ;
if (!x) strerr_dienotset(100, tmp) ;
if (!ip46_scan(x, &remoteaddr)) strerr_dieinvalid(100, tmp) ;
@@ -258,7 +255,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
for (;;)
{
- register int r ;
+ int r ;
line.len = 0 ;
tain_add_g(&deadline, &tto) ;
r = timed_getln_g(buffer_0small, &line, '\n', &deadline) ;