2b75f1e92c
as operating system version specific and bump package version.
184 lines
4.3 KiB
Text
184 lines
4.3 KiB
Text
$NetBSD: patch-ac,v 1.5 2005/08/07 12:51:32 tron Exp $
|
|
|
|
--- src/kernel/netbsd.c.orig 2003-02-12 02:15:59.000000000 +0000
|
|
+++ src/kernel/netbsd.c 2005-08-07 13:48:57.000000000 +0100
|
|
@@ -29,6 +29,7 @@
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
+#include <sys/param.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/socketvar.h>
|
|
#include <netinet/in.h>
|
|
@@ -41,6 +42,16 @@
|
|
#include <netinet/tcp.h>
|
|
#include <netinet/ip_compat.h>
|
|
|
|
+#if __NetBSD_Version__ >= 399000300 /* 3.99.3 */
|
|
+#define SO_UIDINFO /* "struct socket" contains so_uidinfo" */
|
|
+
|
|
+#include <sys/proc.h>
|
|
+#include <sys/resource.h>
|
|
+#define _KERNEL 42
|
|
+#include <sys/resourcevar.h>
|
|
+#undef _KERNEL
|
|
+#endif
|
|
+
|
|
#ifdef WANT_IPV6
|
|
# include <sys/sysctl.h>
|
|
# include <netinet/ip_var.h>
|
|
@@ -99,7 +110,11 @@
|
|
kinfo->nl[N_TCB].n_name = "_tcbtable";
|
|
|
|
#ifdef WANT_IPV6
|
|
+#if __NetBSD_Version__ >= 106250000 /* 1.6Y */
|
|
+ kinfo->nl[N_TCB6].n_name = "_tcbtable";
|
|
+#else
|
|
kinfo->nl[N_TCB6].n_name = "_tcb6";
|
|
+#endif
|
|
#else
|
|
kinfo->nl[N_TCB6].n_name = "_oidentd_nonexistent";
|
|
#endif
|
|
@@ -162,7 +177,7 @@
|
|
if (tcbtablep == NULL)
|
|
return (NULL);
|
|
|
|
- kpcbp = tcbtablep->inpt_queue.cqh_first;
|
|
+ kpcbp = (struct inpcb *) tcbtablep->inpt_queue.cqh_first;
|
|
while (kpcbp != (struct inpcb *) ktcbtablep) {
|
|
if (getbuf((u_long) kpcbp, &pcb, sizeof(struct inpcb)) == -1)
|
|
break;
|
|
@@ -185,7 +200,7 @@
|
|
return (pcb.inp_socket);
|
|
}
|
|
|
|
- kpcbp = pcb.inp_queue.cqe_next;
|
|
+ kpcbp = (struct inpcb *) pcb.inp_queue.cqe_next;
|
|
}
|
|
|
|
return (NULL);
|
|
@@ -203,6 +218,9 @@
|
|
struct socket *sockp, sock;
|
|
struct inpcbtable tcbtable;
|
|
int ret;
|
|
+#ifdef SO_UIDINFO
|
|
+ struct uidinfo uidinfo;
|
|
+#endif
|
|
|
|
ret = getbuf(kinfo->nl[N_TCB].n_value, &tcbtable, sizeof(tcbtable));
|
|
if (ret == -1)
|
|
@@ -218,7 +236,17 @@
|
|
if (getbuf((u_long) sockp, &sock, sizeof(sock)) == -1)
|
|
return (-1);
|
|
|
|
+#ifdef SO_UIDINFO
|
|
+ if (sock.so_uidinfo == NULL)
|
|
+ return (-1);
|
|
+
|
|
+ if (getbuf((u_long) sock.so_uidinfo, &uidinfo, sizeof(uidinfo)) == -1)
|
|
+ return (-1);
|
|
+
|
|
+ return (uidinfo.ui_uid);
|
|
+#else
|
|
return (sock.so_uid);
|
|
+#endif
|
|
}
|
|
|
|
#ifdef MASQ_SUPPORT
|
|
@@ -327,12 +355,38 @@
|
|
** Returns NULL if no match.
|
|
*/
|
|
|
|
+#if __NetBSD_Version__ >= 106250000
|
|
+static struct socket *getlist6( struct inpcbtable *tcbtablep,
|
|
+ struct inpcbtable *ktcbtablep,
|
|
+#else
|
|
static struct socket *getlist6( struct in6pcb *tcb6,
|
|
+#endif
|
|
in_port_t lport,
|
|
in_port_t fport,
|
|
const struct in6_addr *laddr,
|
|
const struct in6_addr *faddr)
|
|
{
|
|
+#if __NetBSD_Version__ >= 106250000
|
|
+ struct in6pcb *kpcbp, pcb;
|
|
+
|
|
+ if (tcbtablep == NULL)
|
|
+ return (NULL);
|
|
+
|
|
+ kpcbp = (struct in6pcb *) tcbtablep->inpt_queue.cqh_first;
|
|
+ while (kpcbp != (struct in6pcb *) ktcbtablep) {
|
|
+ if (getbuf((u_long) kpcbp, &pcb, sizeof(struct in6pcb)) == -1)
|
|
+ break;
|
|
+ if (pcb.in6p_fport == fport &&
|
|
+ pcb.in6p_lport == lport &&
|
|
+ IN6_ARE_ADDR_EQUAL(&pcb.in6p_laddr, laddr) &&
|
|
+ IN6_ARE_ADDR_EQUAL(&pcb.in6p_faddr, faddr))
|
|
+ {
|
|
+ return (pcb.in6p_socket);
|
|
+ }
|
|
+
|
|
+ kpcbp = (struct in6pcb *) pcb.in6p_queue.cqe_next;
|
|
+ }
|
|
+#else
|
|
struct in6pcb *tcb6_cur, tcb6_temp;
|
|
|
|
if (tcb6 == NULL)
|
|
@@ -355,7 +409,7 @@
|
|
if (getbuf((u_long) tcb6_cur, &tcb6_temp, sizeof(tcb6_temp)) == -1)
|
|
break;
|
|
} while ((u_long) tcb6_cur != kinfo->nl[N_TCB6].n_value);
|
|
-
|
|
+#endif
|
|
return (NULL);
|
|
}
|
|
|
|
@@ -368,6 +422,22 @@
|
|
struct sockaddr_storage *laddr,
|
|
struct sockaddr_storage *faddr)
|
|
{
|
|
+#if __NetBSD_Version__ >= 106250000 /* 1.6Y */
|
|
+ struct socket *sockp, sock;
|
|
+ struct inpcbtable tcbtable;
|
|
+ int ret;
|
|
+#ifdef SO_UIDINFO
|
|
+ struct uidinfo uidinfo;
|
|
+#endif
|
|
+
|
|
+ ret = getbuf(kinfo->nl[N_TCB6].n_value, &tcbtable, sizeof(tcbtable));
|
|
+ if (ret == -1)
|
|
+ return (-1);
|
|
+
|
|
+ sockp = getlist6(&tcbtable,
|
|
+ (struct inpcbtable *) kinfo->nl[N_TCB6].n_value,
|
|
+ lport, fport, &SIN6(laddr)->sin6_addr, &SIN6(faddr)->sin6_addr);
|
|
+#else
|
|
struct socket *sockp, sock;
|
|
struct in6pcb tcb6;
|
|
int ret;
|
|
@@ -378,6 +448,7 @@
|
|
|
|
sockp = getlist6(&tcb6, lport, fport,
|
|
&SIN6(laddr)->sin6_addr, &SIN6(faddr)->sin6_addr);
|
|
+#endif
|
|
|
|
if (sockp == NULL)
|
|
return (-1);
|
|
@@ -385,7 +456,17 @@
|
|
if (getbuf((u_long) sockp, &sock, sizeof(sock)) == -1)
|
|
return (-1);
|
|
|
|
+#ifdef SO_UIDINFO
|
|
+ if (sock.so_uidinfo == NULL)
|
|
+ return (-1);
|
|
+
|
|
+ if (getbuf((u_long) sock.so_uidinfo, &uidinfo, sizeof(uidinfo)) == -1)
|
|
+ return (-1);
|
|
+
|
|
+ return (uidinfo.ui_uid);
|
|
+#else
|
|
return (sock.so_uid);
|
|
+#endif
|
|
}
|
|
|
|
#endif
|