- New port: security/gvm-libs

This is the libraries module for the Greenbone Vulnerability Management
Solution.

It is used for the Greenbone Security Manager appliances and provides various
functionalities to support the integrated service daemons.

WWW: https://github.com/greenbone/gvm-libs
This commit is contained in:
Jose Alonso Cardenas Marquez 2021-01-06 08:42:12 +00:00
parent 14355e18b3
commit a22e5bb83a
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=560472
14 changed files with 526 additions and 0 deletions

View file

@ -0,0 +1,44 @@
# $FreeBSD$
PORTNAME= gvm
DISTVERSION= 20.8.0
DISTVERSIONPREFIX= v
CATEGORIES= security
PKGNAMESUFFIX= -libs
MAINTAINER= acm@FreeBSD.org
COMMENT= libraries module for the GVM solution
LICENSE= GPLv2+
BUILD_DEPENDS= doxygen>0:devel/doxygen
LIB_DEPENDS= libgpgme.so:security/gpgme \
libgnutls.so:security/gnutls \
libuuid.so:misc/e2fsprogs-libuuid \
libssh.so:security/libssh \
libhiredis.so:databases/hiredis \
libgcrypt.so:security/libgcrypt
RUN_DEPENDS= doxygen>0:devel/doxygen
USE_GITHUB= yes
GH_ACCOUNT= greenbone
GH_PROJECT= ${PORTNAME}${PKGNAMESUFFIX}
USES= cmake gnome pkgconfig
USE_GNOME= glib20 libxml2
USE_LDCONFIG= yes
OPTIONS_DEFINE= LDAP RADIUS
LDAP_CMAKE_ON= -DBUILD_WITH_LDAP=1
LDAP_CMAKE_OFF= -DBUILD_WITH_LDAP=0
LDAP_USE= OPENLDAP=yes
RADIUS_CMAKE_ON=-DBUILD_WITH_RADIUS=1
RADIUS_CMAKE_OFF=-DBUILD_WITH_RADIUS=0
RADIUS_LIB_DEPENDS= libfreeradius-client.so:net/freeradius-client
post-patch:
@${REINPLACE_CMD} -e 's|2.25.0|1.45.6|g' ${WRKSRC}/util/libgvm_util.pc.in
@${REINPLACE_CMD} -e 's|uuid>=2.25.0|uuid>=1.45.6|g' ${WRKSRC}/util/CMakeLists.txt
.include <bsd.port.mk>

View file

@ -0,0 +1,3 @@
TIMESTAMP = 1609528750
SHA256 (greenbone-gvm-libs-v20.8.0_GH0.tar.gz) = 83331f27e33675f83925194a34fe3d3aae4537b3fcb3d16252153b066d28e9ef
SIZE (greenbone-gvm-libs-v20.8.0_GH0.tar.gz) = 265661

View file

@ -0,0 +1,29 @@
--- CMakeLists.txt.orig 2020-08-12 04:56:00.000000000 -0500
+++ CMakeLists.txt 2021-01-03 17:25:26.973466000 -0500
@@ -155,7 +155,7 @@
endif (NOT LIBDIR)
if (NOT LOCALSTATEDIR)
- set (LOCALSTATEDIR "${CMAKE_INSTALL_PREFIX}/var")
+ set (LOCALSTATEDIR "/var")
endif (NOT LOCALSTATEDIR)
if (NOT INCLUDEDIR)
@@ -167,7 +167,7 @@
endif (NOT DATADIR)
if (NOT GVM_PID_DIR)
- set (GVM_PID_DIR "${LOCALSTATEDIR}/run")
+ set (GVM_PID_DIR "${LOCALSTATEDIR}/run/gvm")
endif (NOT GVM_PID_DIR)
if (NOT GVM_SYSCONF_DIR)
@@ -176,7 +176,7 @@
if (NOT REDIS_SOCKET_PATH)
- set (REDIS_SOCKET_PATH "/run/redis/redis.sock")
+ set (REDIS_SOCKET_PATH "/var/run/redis/redis.sock")
endif ()
add_definitions (-DREDIS_SOCKET_PATH="${REDIS_SOCKET_PATH}")

View file

@ -0,0 +1,53 @@
--- base/hosts.c 2020-12-30 14:04:30.773110000 -0500
+++ base/hosts.c 2020-12-30 23:46:15.994709000 -0500
@@ -34,11 +34,11 @@
#include <arpa/inet.h> /* for inet_pton, inet_ntop */
#include <assert.h> /* for assert */
#include <ctype.h> /* for isdigit */
-#include <malloc.h>
#include <netdb.h> /* for getnameinfo, NI_NAMEREQD */
#include <stdint.h> /* for uint8_t, uint32_t */
#include <stdio.h> /* for sscanf, perror */
#include <stdlib.h> /* for strtol, atoi */
+#include <malloc_np.h>
#include <string.h> /* for strchr, memcpy, memcmp, bzero, strcasecmp */
#include <sys/socket.h> /* for AF_INET, AF_INET6, sockaddr */
@@ -1068,7 +1068,7 @@
hosts->count -= duplicates;
hosts->removed += duplicates;
hosts->current = 0;
- malloc_trim (0);
+ // malloc_trim (0);
}
/**
@@ -1263,7 +1263,7 @@
gvm_hosts_deduplicate (hosts);
g_strfreev (split);
- malloc_trim (0);
+ //malloc_trim (0);
return hosts;
}
@@ -1410,8 +1410,8 @@
gvm_vhost_t *vhost;
new = gvm_host_new ();
- if (ip6->s6_addr32[0] != 0 || ip6->s6_addr32[1] != 0
- || ip6->s6_addr32[2] != htonl (0xffff))
+ if (ip6->s6_addr[0] != 0 || ip6->s6_addr[1] != 0
+ || ip6->s6_addr[2] != 0xff)
{
new->type = HOST_TYPE_IPV6;
memcpy (&new->addr6, ip6, sizeof (new->addr6));
@@ -1419,7 +1419,7 @@
else
{
new->type = HOST_TYPE_IPV4;
- memcpy (&new->addr6, &ip6->s6_addr32[3], sizeof (new->addr));
+ memcpy (&new->addr6, &ip6->s6_addr[12], sizeof (new->addr));
}
vhost =
gvm_vhost_new (g_strdup (host->name), g_strdup ("Forward-DNS"));

View file

@ -0,0 +1,87 @@
--- base/networking.c 2020-12-30 23:53:55.170376000 -0500
+++ base/networking.c 2020-12-31 00:06:29.941646000 -0500
@@ -30,28 +30,30 @@
#include <errno.h> /* for errno, EAFNOSUPPORT */
#include <glib/gstdio.h>
#include <ifaddrs.h> /* for ifaddrs, freeifaddrs, getifaddrs */
+#include <sys/types.h>
#include <net/if.h> /* for IFNAMSIZ */
+#include <netinet/in.h>
#include <stdint.h> /* for uint32_t, uint8_t */
#include <stdlib.h> /* for atoi, strtol */
#include <string.h> /* for memcpy, bzero, strchr, strlen, strcmp, strncpy */
#include <sys/socket.h> /* for AF_INET, AF_INET6, AF_UNSPEC, sockaddr_storage */
#include <unistd.h> /* for close */
-#ifdef __FreeBSD__
-#include <netinet/in.h>
-#define s6_addr32 __u6_addr.__u6_addr32
-#endif
+//#ifdef __FreeBSD__
+//#include <netinet/in.h>
+//#define s6_addr32 __u6_addr.__u6_addr32
+//#endif
/* Global variables */
/* Source interface name eg. eth1. */
-char global_source_iface[IFNAMSIZ] = {'\0'};
+char global_source_iface[IFNAMSIZ];
/* Source IPv4 address. */
-struct in_addr global_source_addr = {.s_addr = 0};
+struct in_addr global_source_addr;
/* Source IPv6 address. */
-struct in6_addr global_source_addr6 = {.s6_addr32 = {0, 0, 0, 0}};
+struct in6_addr global_source_addr6;
/* Source Interface/Address related functions. */
@@ -244,10 +246,19 @@
if (ip4 == NULL || ip6 == NULL)
return;
- ip6->s6_addr32[0] = 0;
- ip6->s6_addr32[1] = 0;
- ip6->s6_addr32[2] = htonl (0xffff);
- memcpy (&ip6->s6_addr32[3], ip4, sizeof (struct in_addr));
+ ip6->s6_addr[0] = 0;
+ ip6->s6_addr[1] = 0;
+ ip6->s6_addr[2] = 0;
+ ip6->s6_addr[3] = 0;
+ ip6->s6_addr[4] = 0;
+ ip6->s6_addr[5] = 0;
+ ip6->s6_addr[6] = 0;
+ ip6->s6_addr[7] = 0;
+ ip6->s6_addr[8] = 0;
+ ip6->s6_addr[9] = 0;
+ ip6->s6_addr[10] = 0xff;
+ ip6->s6_addr[11] = 0xff;
+ memcpy (&ip6->s6_addr[12], ip4, sizeof (struct in_addr));
}
/**
@@ -262,7 +273,7 @@
if (!addr6)
return;
if (IN6_IS_ADDR_V4MAPPED (addr6))
- inet_ntop (AF_INET, &addr6->s6_addr32[3], str, INET6_ADDRSTRLEN);
+ inet_ntop (AF_INET, &addr6->s6_addr[12], str, INET6_ADDRSTRLEN);
else
inet_ntop (AF_INET6, addr6, str, INET6_ADDRSTRLEN);
}
@@ -808,11 +819,11 @@
if (IN6_IS_ADDR_V4MAPPED (&addr6))
{
/* addr is 0.0.0.0 */
- if (addr6_p->s6_addr32[3] == 0)
+ if (addr6_p->s6_addr[12] == 0)
return 1;
/* addr starts with 127.0.0.1 */
- if ((addr6_p->s6_addr32[3] & htonl (0xFF000000))
+ if ((addr6_p->s6_addr[12] & htonl (0xFF000000))
== htonl (0x7F000000))
return 1;
}

View file

@ -0,0 +1,10 @@
--- base/networking.h 2020-12-31 00:01:35.140537000 -0500
+++ base/networking.h 2020-12-31 00:04:13.003782000 -0500
@@ -27,6 +27,7 @@
#include "array.h" /* for array_t */
+#include <netinet/in.h>
#include <netdb.h> /* for struct in6_addr */
/**

View file

@ -0,0 +1,16 @@
--- boreas/alivedetection.c.orig 2020-12-30 23:49:07.498953000 -0500
+++ boreas/alivedetection.c 2020-12-30 23:50:37.570417000 -0500
@@ -39,7 +39,12 @@
#include <netinet/ip6.h>
#include <netinet/ip_icmp.h>
#include <netinet/tcp.h>
-#include <netpacket/packet.h> /* for sockaddr_ll */
+#ifdef AF_LINK
+# include <net/if_dl.h>
+#endif
+#ifdef AF_PACKET
+# include <netpacket/packet.h>
+#endif
#include <pcap.h>
#include <pthread.h>
#include <stdlib.h>

View file

@ -0,0 +1,114 @@
--- boreas/ping.c 2020-12-31 00:53:07.116404000 -0500
+++ boreas/ping.c 2020-12-31 02:11:16.635441000 -0500
@@ -29,15 +29,21 @@
#include <net/ethernet.h>
#include <net/if.h> /* for if_nametoindex() */
#include <netinet/icmp6.h>
+#include <sys/types.h>
#include <netinet/in.h>
+#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/ip_icmp.h>
#include <netinet/tcp.h>
-#include <netpacket/packet.h> /* for sockaddr_ll */
+#ifdef AF_LINK
+# include <net/if_dl.h>
+#endif
+#ifdef AF_PACKET
+# include <netpacket/packet.h>
+#endif
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/time.h>
-#include <sys/types.h>
#include <unistd.h>
#undef G_LOG_DOMAIN
@@ -138,12 +144,12 @@
struct icmphdr *icmp;
icmp = (struct icmphdr *) sendbuf;
- icmp->type = ICMP_ECHO;
- icmp->code = 0;
+ icmp->icmp_type = ICMP_ECHO;
+ icmp->icmp_code = 0;
len = 8 + datalen;
- icmp->checksum = 0;
- icmp->checksum = in_cksum ((u_short *) icmp, len);
+ icmp->icmp_cksum = 0;
+ icmp->icmp_cksum = in_cksum ((u_short *) icmp, len);
memset (&soca, 0, sizeof (soca));
soca.sin_family = AF_INET;
@@ -197,7 +203,7 @@
}
else
{
- dst4.s_addr = dst6_p->s6_addr32[3];
+ dst4.s_addr = dst6_p->s6_addr[12];
send_icmp_v4 (scanner->icmpv4soc, dst4_p);
}
}
@@ -431,7 +437,7 @@
}
else
{
- dst4.s_addr = dst6_p->s6_addr32[3];
+ dst4.s_addr = dst6_p->s6_addr[12];
send_tcp_v4 (scanner, dst4_p);
}
}
@@ -445,7 +451,7 @@
static void
send_arp_v4 (int soc, struct in_addr *dst_p)
{
- struct sockaddr_ll soca;
+ struct sockaddr_dl soca;
struct arp_hdr arphdr;
int frame_length;
uint8_t *ether_frame;
@@ -505,10 +511,10 @@
}
/* Fill in sockaddr_ll.*/
- soca.sll_ifindex = ifaceindex;
- soca.sll_family = AF_PACKET;
- memcpy (soca.sll_addr, src_mac, 6 * sizeof (uint8_t));
- soca.sll_halen = 6;
+ soca.sdl_index = ifaceindex;
+ soca.sdl_family = AF_LINK;
+ memcpy (soca.sdl_data, src_mac, 6 * sizeof (uint8_t));
+ soca.sdl_alen = 6;
/* Fill ARP header.*/
/* IP addresses. */
@@ -520,7 +526,7 @@
* Protocol address length is length of IPv4.
* OpCode is ARP request. */
arphdr.htype = htons (1);
- arphdr.ptype = htons (ETH_P_IP);
+ arphdr.ptype = htons(AF_INET);
arphdr.hlen = 6;
arphdr.plen = 4;
arphdr.opcode = htons (1);
@@ -535,8 +541,8 @@
memcpy (ether_frame, dst_mac, 6 * sizeof (uint8_t));
memcpy (ether_frame + 6, src_mac, 6 * sizeof (uint8_t));
/* ethernet type code */
- ether_frame[12] = ETH_P_ARP / 256;
- ether_frame[13] = ETH_P_ARP % 256;
+ ether_frame[12] = AF_ARP / 256;
+ ether_frame[13] = AF_ARP % 256;
/* ARP header. ETH_HDRLEN = 14, ARP_HDRLEN = 28 */
memcpy (ether_frame + 14, &arphdr, 28 * sizeof (uint8_t));
@@ -592,7 +598,7 @@
}
else
{
- dst4.s_addr = dst6_p->s6_addr32[3];
+ dst4.s_addr = dst6_p->s6_addr[12];
send_arp_v4 (scanner->arpv4soc, dst4_p);
}
}

View file

@ -0,0 +1,11 @@
--- boreas/sniffer.c 2021-01-04 16:55:42.803387000 -0500
+++ boreas/sniffer.c 2021-01-04 16:57:10.155504000 -0500
@@ -25,6 +25,8 @@
#include <arpa/inet.h>
#include <errno.h>
#include <glib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
#include <net/if_arp.h>
#include <netinet/ip.h>
#include <stdlib.h>

View file

@ -0,0 +1,62 @@
--- boreas/util.c 2020-12-30 23:52:07.849996000 -0500
+++ boreas/util.c 2020-12-31 01:36:37.600382000 -0500
@@ -21,12 +21,20 @@
#include "../base/networking.h" /* for range_t */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
#include <errno.h>
#include <glib.h>
#include <ifaddrs.h> /* for getifaddrs() */
#include <net/ethernet.h>
#include <net/if.h> /* for if_nametoindex() */
-#include <netpacket/packet.h> /* for sockaddr_ll */
+#ifdef AF_LINK
+# include <net/if_dl.h>
+#endif
+#ifdef AF_PACKET
+# include <netpacket/packet.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
@@ -109,22 +117,22 @@
{
for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
- if ((ifa->ifa_addr) && (ifa->ifa_addr->sa_family == AF_PACKET)
+ if ((ifa->ifa_addr) && (ifa->ifa_addr->sa_family == AF_LINK)
&& !(ifa->ifa_flags & (IFF_LOOPBACK)))
{
if (interface_provided)
{
if (g_strcmp0 (interface, ifa->ifa_name) == 0)
{
- struct sockaddr_ll *s =
- (struct sockaddr_ll *) ifa->ifa_addr;
- memcpy (mac, s->sll_addr, 6 * sizeof (uint8_t));
+ struct sockaddr_dl *s =
+ (struct sockaddr_dl *) ifa->ifa_addr;
+ memcpy (mac, s->sdl_data, 6 * sizeof (uint8_t));
}
}
else
{
- struct sockaddr_ll *s = (struct sockaddr_ll *) ifa->ifa_addr;
- memcpy (mac, s->sll_addr, 6 * sizeof (uint8_t));
+ struct sockaddr_dl *s = (struct sockaddr_dl *) ifa->ifa_addr;
+ memcpy (mac, s->sdl_data, 6 * sizeof (uint8_t));
}
}
}
@@ -508,7 +516,7 @@
break;
case ARPV4:
{
- soc = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
+ soc = socket (PF_LINK, SOCK_RAW, 0);
if (soc < 0)
{
g_warning ("%s: failed to open ARPV4 socket: %s", __func__,

View file

@ -0,0 +1,22 @@
--- osp/osp.c 2021-01-03 15:42:39.761321000 -0500
+++ osp/osp.c 2021-01-03 15:48:50.962832000 -0500
@@ -134,7 +134,6 @@
if (host && *host == '/')
{
struct sockaddr_un addr;
- int len;
connection = g_malloc0 (sizeof (*connection));
connection->socket = socket (AF_UNIX, SOCK_STREAM, 0);
@@ -142,9 +141,8 @@
return NULL;
addr.sun_family = AF_UNIX;
- strncpy (addr.sun_path, host, sizeof (addr.sun_path) - 1);
- len = strlen (addr.sun_path) + sizeof (addr.sun_family);
- if (connect (connection->socket, (struct sockaddr *) &addr, len) == -1)
+ strcpy (addr.sun_path, host);
+ if (connect (connection->socket, (struct sockaddr *) &addr, sizeof(struct sockaddr_un)) == -1)
{
close (connection->socket);
return NULL;

View file

@ -0,0 +1,12 @@
--- util/radiusutils.c 2020-12-31 02:24:20.387082000 -0500
+++ util/radiusutils.c 2020-12-31 02:27:54.965720000 -0500
@@ -24,6 +24,9 @@
#ifdef ENABLE_RADIUS_AUTH
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#include <arpa/inet.h> /* for inet_pton */
#if defined(RADIUS_AUTH_FREERADIUS)

View file

@ -0,0 +1,7 @@
This is the libraries module for the Greenbone Vulnerability Management
Solution.
It is used for the Greenbone Security Manager appliances and provides various
functionalities to support the integrated service daemons.
WWW: https://github.com/greenbone/gvm-libs

View file

@ -0,0 +1,56 @@
include/gvm/base/array.h
include/gvm/base/credentials.h
include/gvm/base/cvss.h
include/gvm/base/drop_privileges.h
include/gvm/base/hosts.h
include/gvm/base/logging.h
include/gvm/base/networking.h
include/gvm/base/nvti.h
include/gvm/base/pidfile.h
include/gvm/base/prefs.h
include/gvm/base/proctitle.h
include/gvm/base/pwpolicy.h
include/gvm/base/settings.h
include/gvm/base/strings.h
include/gvm/base/version.h
include/gvm/boreas/alivedetection.h
include/gvm/boreas/boreas_error.h
include/gvm/boreas/boreas_io.h
include/gvm/boreas/cli.h
include/gvm/boreas/ping.h
include/gvm/boreas/sniffer.h
include/gvm/boreas/util.h
include/gvm/gmp/gmp.h
include/gvm/osp/osp.h
include/gvm/util/authutils.h
include/gvm/util/compressutils.h
include/gvm/util/fileutils.h
include/gvm/util/gpgmeutils.h
include/gvm/util/kb.h
include/gvm/util/ldaputils.h
include/gvm/util/nvticache.h
include/gvm/util/radiusutils.h
include/gvm/util/serverutils.h
include/gvm/util/sshutils.h
include/gvm/util/uuidutils.h
include/gvm/util/xmlutils.h
lib/libgvm_base.so
lib/libgvm_base.so.20
lib/libgvm_base.so.20.8.0
lib/libgvm_boreas.so
lib/libgvm_boreas.so.20
lib/libgvm_boreas.so.20.8.0
lib/libgvm_gmp.so
lib/libgvm_gmp.so.20
lib/libgvm_gmp.so.20.8.0
lib/libgvm_osp.so
lib/libgvm_osp.so.20
lib/libgvm_osp.so.20.8.0
lib/libgvm_util.so
lib/libgvm_util.so.20
lib/libgvm_util.so.20.8.0
libdata/pkgconfig/libgvm_base.pc
libdata/pkgconfig/libgvm_boreas.pc
libdata/pkgconfig/libgvm_gmp.pc
libdata/pkgconfig/libgvm_osp.pc
libdata/pkgconfig/libgvm_util.pc