Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.2:ARM
pidentd
pidentd-3.1a25-ipv6.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pidentd-3.1a25-ipv6.diff of Package pidentd
--- src/k_linux.c +++ src/k_linux.c @@ -51,37 +51,36 @@ { #ifdef HAVE_IPV6 static FILE *fp[2]; -#else - FILE *fp; -#endif + int e6, e; - -#ifdef HAVE_IPV6 while ((fp[FP_INET6] = fopen("/proc/net/tcp6", "r")) == NULL && errno == EINTR) ; - - /* We just ignore this - IPv6 is not in use on this machine */ -#if 0 - if (fp[FP_INET6] == NULL) - syslog(LOG_ERR, "fopen(\"/proc/net/tcp6\", \"r\"): %m"); -#endif + e6 = errno; while ((fp[FP_INET] = fopen("/proc/net/tcp", "r")) == NULL && errno == EINTR) ; + e = errno; - if (fp[FP_INET] == NULL) + if (fp[FP_INET] == NULL && fp[FP_INET6] == NULL) + { + syslog(LOG_ERR, "fopen(\"/proc/net/tcp6\", \"r\"): %s", strerror(e6)); + syslog(LOG_ERR, "fopen(\"/proc/net/tcp\", \"r\"): %s", strerror(e)); + return -1; + } #else + FILE *fp; + while ((fp = fopen("/proc/net/tcp", "r")) == NULL && errno == EINTR) ; if (fp == NULL) -#endif { syslog(LOG_ERR, "fopen(\"/proc/net/tcp\", \"r\"): %m"); return -1; } +#endif *misc = (void *) fp; return 0; @@ -100,6 +99,8 @@ int r_lport, r_rport, mylport, myrport; int euid; + if (fp == NULL) + return -1; r_lport = ntohs(SGPORT(kp->local)); r_rport = ntohs(SGPORT(kp->remote)); @@ -130,49 +131,26 @@ return -1; } -int -ka_lookup(void *vp, struct kernel *kp) +static int +ka_lookup6(FILE *fp, + struct kernel *kp, + struct in6_addr *r_laddr, + struct in6_addr *r_raddr) { - FILE *fp; long dummy; unsigned dummy2; char buf[512]; + struct in6_addr myladdr, myraddr; int r_lport, r_rport, mylport, myrport; int euid; -#ifdef HAVE_IPV6 - struct in6_addr *r_laddr, *r_raddr, myladdr, myraddr; -#endif - if (SGFAM(kp->remote) == AF_INET) - { - return ka_lookup4(((FILE **)vp)[FP_INET], - kp, - * (UINT32 *) SGADDRP(kp->local), - * (UINT32 *) SGADDRP(kp->remote)); - } - -#ifdef HAVE_IPV6 - r_laddr = (struct in6_addr *) SGADDRP(kp->local); - r_raddr = (struct in6_addr *) SGADDRP(kp->remote); - - if (IN6_IS_ADDR_V4MAPPED(r_raddr)) - { - return ka_lookup4(((FILE **)vp)[FP_INET], - kp, - r_laddr->s6_addr32[3], - r_raddr->s6_addr32[3]); - } + if (fp == NULL) + return -1; r_lport = ntohs(SGPORT(kp->local)); r_rport = ntohs(SGPORT(kp->remote)); - fp = ((FILE **)vp)[FP_INET6]; - - if (fp == NULL) - return -1; - kp->ruid = NO_UID; - rewind(fp); /* eat header */ @@ -198,6 +176,52 @@ } } } + + return -1; +} + +int +ka_lookup(void *vp, struct kernel *kp) +{ +#ifdef HAVE_IPV6 + struct in6_addr r_laddr, r_raddr; + + switch(SGFAM(kp->remote)) { + case AF_INET: + memset(&r_laddr, 0, sizeof(r_laddr)); + memset(&r_raddr, 0, sizeof(r_raddr)); + r_laddr.s6_addr16[5] = 0xffff; + r_raddr.s6_addr16[5] = 0xffff; + r_laddr.s6_addr32[3] = *(UINT32 *)SGADDRP(kp->local); + r_raddr.s6_addr32[3] = *(UINT32 *)SGADDRP(kp->remote); + break; + case AF_INET6: + memcpy(&r_laddr, SGADDRP(kp->local), sizeof(r_laddr)); + memcpy(&r_raddr, SGADDRP(kp->remote), sizeof(r_raddr)); + break; + default: + return -1; + } + + if(!ka_lookup6(((FILE **)vp)[FP_INET6], kp, &r_laddr, &r_raddr)) + return 0; + + if(SGFAM(kp->remote) == AF_INET6 && !IN6_IS_ADDR_V4MAPPED(&r_raddr)) + return -1; + + return ka_lookup4(((FILE **)vp)[FP_INET], + kp, + r_laddr.s6_addr32[3], + r_raddr.s6_addr32[3]); + +#else + if (SGFAM(kp->remote) == AF_INET) + { + return ka_lookup4(((FILE **)vp)[FP_INET], + kp, + * (UINT32 *) SGADDRP(kp->local), + * (UINT32 *) SGADDRP(kp->remote)); + } #endif return -1;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor