git: 557ad9b56608 - main - security/gsad: New port: Greenbone Security Assistant HTTP server

From: Jose Alonso Cardenas Marquez <acm_at_FreeBSD.org>
Date: Sun, 22 May 2022 05:44:23 UTC
The branch main has been updated by acm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=557ad9b56608f2aadf5df410417c49768289d968

commit 557ad9b56608f2aadf5df410417c49768289d968
Author:     Jose Alonso Cardenas Marquez <acm@FreeBSD.org>
AuthorDate: 2022-05-22 05:16:51 +0000
Commit:     Jose Alonso Cardenas Marquez <acm@FreeBSD.org>
CommitDate: 2022-05-22 05:42:10 +0000

    security/gsad: New port: Greenbone Security Assistant HTTP server
    
    security/greenbone-security-assistant was splitted into gsa and gsad ports
---
 security/gsad/Makefile                   | 51 ++++++++++++++++++++++++++++++++
 security/gsad/distinfo                   |  3 ++
 security/gsad/files/gsad.in              | 27 +++++++++++++++++
 security/gsad/files/patch-CMakeLists.txt | 51 ++++++++++++++++++++++++++++++++
 security/gsad/files/patch-src_gsad_gmp.c | 16 ++++++++++
 security/gsad/pkg-descr                  | 10 +++++++
 6 files changed, 158 insertions(+)

diff --git a/security/gsad/Makefile b/security/gsad/Makefile
new file mode 100644
index 000000000000..66760cbac3b9
--- /dev/null
+++ b/security/gsad/Makefile
@@ -0,0 +1,51 @@
+PORTNAME=	gsad
+DISTVERSIONPREFIX=	v
+DISTVERSION=	21.4.4
+CATEGORIES=	security
+
+MAINTAINER=	acm@FreeBSD.org
+COMMENT=	Greenbone Security Assistant HTTP server
+
+LICENSE=	AGPLv3+
+
+LIB_DEPENDS=	libgvm_base.so:security/gvm-libs \
+		libgnutls.so:security/gnutls \
+		libgcrypt.so:security/libgcrypt \
+		libgpg-error.so:security/libgpg-error \
+		libmicrohttpd.so:www/libmicrohttpd
+RUN_DEPENDS=	doxygen>0:devel/doxygen \
+		${PYTHON_PKGNAMEPREFIX}polib>=0:devel/py-polib@${PY_FLAVOR}
+
+USES=		cmake gettext-runtime gnome pkgconfig python
+USE_GNOME=	glib20 libxml2
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	greenbone
+GH_PROJECT=	gsad
+
+USERS=		gvm
+GROUPS=		${USERS}
+
+USE_RC_SUBR=	gsad
+
+LDFLAGS+=	-lm
+
+ETCDIR=		${PREFIX}/etc/gvm
+
+post-extract:
+	@${MV} ${WRKSRC}/src/gsad_log_conf.cmake_in ${WRKSRC}/src/gsad_log.conf.sample
+
+post-patch:
+	${REINPLACE_CMD} -e 's|$${GVM_LOG_DIR}|/var/log/gvm|g' ${WRKSRC}/src/gsad_log.conf.sample
+
+post-install:
+	@${MKDIR} ${STAGEDIR}/var/run/gvm
+	@${MKDIR} ${STAGEDIR}${ETCDIR}
+	@${INSTALL_DATA} ${WRKSRC}/src/gsad_log.conf.sample ${STAGEDIR}${ETCDIR}
+
+	@${ECHO_CMD} "@sample etc/gvm/gsad_log.conf.sample" >> ${TMPPLIST}
+	@${ECHO_CMD} "sbin/gsad" >> ${TMPPLIST} >> ${TMPPLIST}
+	@${ECHO_CMD} "share/man/man8/gsad.8.gz" >> ${TMPPLIST}
+	@${ECHO_CMD} "@dir(gvm,gvm,750) /var/run/gsad" >> ${TMPPLIST}
+
+.include <bsd.port.mk>
diff --git a/security/gsad/distinfo b/security/gsad/distinfo
new file mode 100644
index 000000000000..7c66c0ba3f92
--- /dev/null
+++ b/security/gsad/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1650489331
+SHA256 (greenbone-gsad-v21.4.4_GH0.tar.gz) = ea60fc00a1e8d9a2e548aba5056472a8076cd8ba26012f3e20e44e3906b02525
+SIZE (greenbone-gsad-v21.4.4_GH0.tar.gz) = 220618
diff --git a/security/gsad/files/gsad.in b/security/gsad/files/gsad.in
new file mode 100644
index 000000000000..48d5b575c641
--- /dev/null
+++ b/security/gsad/files/gsad.in
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# PROVIDE: gsad
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+#
+# Add the following to /etc/rc.conf[.local] to enable this service
+#
+# gsad_enable  (bool):   Set to NO by default.
+#                Set it to YES to enable gsad.
+# gsad_flags (params):   Set params used to start gsad.
+#
+
+. /etc/rc.subr
+
+load_rc_config $name
+
+: ${gsad_enable="NO"}
+: ${gsad_flags="--http-cors="http://127.0.0.1" -k /var/lib/gvm/private/CA/serverkey.pem -c /var/lib/gvm/CA/servercert.pem --munix-socket=/var/run/gvmd/gvmd.sock"}
+
+name=gsad
+rcvar=${name}_enable
+command="%%PREFIX%%/sbin/gsad"
+command_args="${gsad_flags}"
+pidfile=/var/run/gsad/gsad.pid
+
+run_rc_command "$1"
diff --git a/security/gsad/files/patch-CMakeLists.txt b/security/gsad/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..5000d6714dd7
--- /dev/null
+++ b/security/gsad/files/patch-CMakeLists.txt
@@ -0,0 +1,51 @@
+--- CMakeLists.txt.orig	2022-04-20 16:19:23.710555000 -0500
++++ CMakeLists.txt	2022-04-20 16:22:09.030744000 -0500
+@@ -61,7 +61,7 @@
+ endif (CLANG_FORMAT)
+ 
+ if (NOT SYSCONFDIR)
+-  set (SYSCONFDIR "/etc")
++  set (SYSCONFDIR "{CMAKE_INSTALL_PREFIX}/etc")
+ endif (NOT SYSCONFDIR)
+ 
+ if (NOT EXEC_PREFIX)
+@@ -96,7 +96,7 @@
+ set (GSAD_CONFIG_DIR "${SYSCONFDIR}/gvm/")
+ 
+ if (NOT GSAD_RUN_DIR)
+-  set (GSAD_RUN_DIR  "/run/gsad")
++  set (GSAD_RUN_DIR  "${LOCALSTATEDIR}/run/gsad")
+ endif (NOT GSAD_RUN_DIR)
+ 
+ if (NOT GSAD_PID_PATH)
+@@ -104,7 +104,7 @@
+ endif (NOT GSAD_PID_PATH)
+ 
+ if (NOT GVMD_RUN_DIR)
+-  set (GVMD_RUN_DIR  "/run/gvmd")
++  set (GVMD_RUN_DIR  "${LOCALSTATEDIR}/run/gvmd")
+ endif (NOT GVMD_RUN_DIR)
+ 
+ if (NOT GSAD_PID_DIR)
+@@ -143,17 +143,17 @@
+ endif (NOT GVM_CA_CERTIFICATE)
+ 
+ 
+-configure_file (src/gsad_log_conf.cmake_in src/gsad_log.conf)
++#configure_file (src/gsad_log_conf.cmake_in src/gsad_log.conf)
+ 
+ ## Install
+ 
+ install (DIRECTORY DESTINATION ${GSAD_RUN_DIR})
+ 
+-install (FILES ${CMAKE_CURRENT_BINARY_DIR}/src/gsad_log.conf
+-         DESTINATION ${GSAD_CONFIG_DIR})
++#install (FILES ${CMAKE_CURRENT_BINARY_DIR}/src/gsad_log.conf
++#         DESTINATION ${GSAD_CONFIG_DIR})
+ 
+ add_subdirectory (src)
+-add_subdirectory (config)
++#add_subdirectory (config)
+ 
+ add_subdirectory (doc)
+ 
diff --git a/security/gsad/files/patch-src_gsad_gmp.c b/security/gsad/files/patch-src_gsad_gmp.c
new file mode 100644
index 000000000000..71780501f762
--- /dev/null
+++ b/security/gsad/files/patch-src_gsad_gmp.c
@@ -0,0 +1,16 @@
+--- src/gsad_gmp.c	2022-04-20 16:25:17.556260000 -0500
++++ src/gsad_gmp.c	2022-04-20 16:27:20.232932000 -0500
+@@ -16645,8 +16645,13 @@
+   /* Connect to server. */
+ 
+   address.sun_family = AF_UNIX;
++#if defined(__FreeBSD__)
++  strcpy (address.sun_path, path);
++  if (connect (sock, (struct sockaddr *) &address, sizeof (struct sockaddr_un)) == -1)
++#else
+   strncpy (address.sun_path, path, sizeof (address.sun_path) - 1);
+   if (connect (sock, (struct sockaddr *) &address, sizeof (address)) == -1)
++#endif
+     {
+       g_warning ("Failed to connect to server at %s: %s", path,
+                  strerror (errno));
diff --git a/security/gsad/pkg-descr b/security/gsad/pkg-descr
new file mode 100644
index 000000000000..7c5e8859d13d
--- /dev/null
+++ b/security/gsad/pkg-descr
@@ -0,0 +1,10 @@
+The Greenbone Security Assistant is the web interface developed for the 
+Greenbone Security Manager appliances.
+
+It connects to the Greenbone Vulnerability Manager GVM to provide a 
+full-featured user interface for vulnerability management.
+
+Greenbone Security Assistant consists of GSA - The webpage written in React
+and GSAD - The HTTP server talking to the GVM daemon
+
+WWW: https://github.com/greenbone/gsa