socsvn commit: r272148 - in soc2014/shonali/head: contrib/bsnmp/snmpd usr.sbin/bsnmpd/bsnmpd
shonali at FreeBSD.org
shonali at FreeBSD.org
Sat Aug 9 21:05:30 UTC 2014
Author: shonali
Date: Sat Aug 9 21:05:28 2014
New Revision: 272148
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272148
Log:
Moved check_priv_XX functions to transport modules, modify Makefile to compile trans_udpv6.c
Modified:
soc2014/shonali/head/contrib/bsnmp/snmpd/main.c
soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c
soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c
soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c
soc2014/shonali/head/usr.sbin/bsnmpd/bsnmpd/Makefile
Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/main.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/main.c Sat Aug 9 20:40:03 2014 (r272147)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/main.c Sat Aug 9 21:05:28 2014 (r272148)
@@ -1028,33 +1028,6 @@
pi->length -= pi->consumed;
}
-static void
-check_priv_dgram(struct port_input *pi, struct sockcred *cred)
-{
-
- /* process explicitly sends credentials */
- if (cred)
- pi->priv = (cred->sc_euid == 0);
- else
- pi->priv = 0;
-}
-
-static void
-check_priv_stream(struct port_input *pi)
-{
- struct xucred ucred;
- socklen_t ucredlen;
-
- /* obtain the accept time credentials */
- ucredlen = sizeof(ucred);
-
- if (getsockopt(pi->fd, 0, LOCAL_PEERCRED, &ucred, &ucredlen) == 0 &&
- ucredlen >= sizeof(ucred) && ucred.cr_version == XUCRED_VERSION)
- pi->priv = (ucred.cr_uid == 0);
- else
- pi->priv = 0;
-}
-
/*
* Input from a socket
*/
@@ -1072,6 +1045,7 @@
#ifdef USE_TCPWRAPPERS
char client[16];
#endif
+ struct msghdr msg;
struct iovec iov[1];
ret = tport->transport->vtab->recv(tport, pi);
Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c Sat Aug 9 20:40:03 2014 (r272147)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_lsock.c Sat Aug 9 21:05:28 2014 (r272148)
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/un.h>
+#include <sys/ucred.h>
#include <sys/stat.h>
#include <stdio.h>
@@ -59,6 +60,7 @@
static ssize_t lsock_send(struct tport *, const u_char *, size_t,
const struct sockaddr *, size_t);
static ssize_t lsock_recv(struct tport *, struct port_input *);
+static void check_priv_stream(struct port_input *);
/* exported */
const struct transport_def lsock_trans = {
@@ -471,6 +473,22 @@
return (0);
}
+static void
+check_priv_stream(struct port_input *pi)
+{
+ struct xucred ucred;
+ socklen_t ucredlen;
+
+ /* obtain the accept time credentials */
+ ucredlen = sizeof(ucred);
+
+ if (getsockopt(pi->fd, 0, LOCAL_PEERCRED, &ucred, &ucredlen) == 0 &&
+ ucredlen >= sizeof(ucred) && ucred.cr_version == XUCRED_VERSION)
+ pi->priv = (ucred.cr_uid == 0);
+ else
+ pi->priv = 0;
+}
+
/*
* Dependency to create a lsock port
*/
Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c Sat Aug 9 20:40:03 2014 (r272147)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udp.c Sat Aug 9 21:05:28 2014 (r272148)
@@ -32,6 +32,7 @@
*/
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/ucred.h>
#include <stdlib.h>
#include <syslog.h>
@@ -56,6 +57,7 @@
const struct sockaddr *, size_t);
static ssize_t udp_recv(struct tport *, struct port_input *);
static int recv_dgram(struct port_input *, struct in_addr *);
+static void check_priv_dgram(struct port_input *, struct sockcred *);
/* exported */
const struct transport_def udp_trans = {
@@ -326,6 +328,17 @@
return (0);
}
+static void
+check_priv_dgram(struct port_input *pi, struct sockcred *cred)
+{
+
+ /* process explicitly sends credentials */
+ if (cred)
+ pi->priv = (cred->sc_euid == 0);
+ else
+ pi->priv = 0;
+}
+
/*
* Port table
*/
Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c Sat Aug 9 20:40:03 2014 (r272147)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/trans_udpv6.c Sat Aug 9 21:05:28 2014 (r272148)
@@ -38,6 +38,7 @@
*/
#include <sys/types.h>
#include <sys/queue.h>
+#include <sys/ucred.h>
#include <stdlib.h>
#include <syslog.h>
@@ -62,6 +63,7 @@
const struct sockaddr *, size_t);
static ssize_t udpv6_recv(struct tport *, struct port_input *);
static int recv_v6dgram(struct port_input *, struct in6_addr *);
+static void check_priv_dgram(struct port_input *, struct sockcred *);
/* exported */
const struct transport_def udpv6_trans = {
@@ -334,6 +336,17 @@
return (0);
}
+static void
+check_priv_dgram(struct port_input *pi, struct sockcred *cred)
+{
+
+ /* process explicitly sends credentials */
+ if (cred)
+ pi->priv = (cred->sc_euid == 0);
+ else
+ pi->priv = 0;
+}
+
/*
* Port table
*/
Modified: soc2014/shonali/head/usr.sbin/bsnmpd/bsnmpd/Makefile
==============================================================================
--- soc2014/shonali/head/usr.sbin/bsnmpd/bsnmpd/Makefile Sat Aug 9 20:40:03 2014 (r272147)
+++ soc2014/shonali/head/usr.sbin/bsnmpd/bsnmpd/Makefile Sat Aug 9 21:05:28 2014 (r272148)
@@ -8,11 +8,12 @@
.PATH: ${CONTRIB}/snmpd
PROG= bsnmpd
-SRCS= main.c action.c config.c export.c trap.c trans_udp.c trans_lsock.c
+SRCS= main.c action.c config.c export.c trap.c trans_udp.c trans_lsock.c trans_udpv6.c
SRCS+= oid.h tree.c tree.h
XSYM= snmpMIB begemotSnmpdModuleTable begemotSnmpd begemotTrapSinkTable \
sysUpTime snmpTrapOID coldStart authenticationFailure \
begemotSnmpdTransUdp begemotSnmpdTransLsock begemotSnmpdLocalPortTable \
+ begemotSnmpdTransIpv6Udp \
freeBSD freeBSDVersion
CLEANFILES= oid.h tree.c tree.h
MAN= bsnmpd.1 snmpmod.3
More information about the svn-soc-all
mailing list