forked from ports/contrib
arpon: fixed build
This commit is contained in:
parent
53ec2738c5
commit
125a264d48
@ -1,6 +1,8 @@
|
||||
untrusted comment: verify with /etc/ports/contrib.pub
|
||||
RWSagIOpLGJF37sDNq2yi7o7/NLhEwBd//3ynf0ZiwV/PEG9tit2LgVGzYB4Prya8GnGD+5s85alg9SnSArFgoRw03A3QbsF6AQ=
|
||||
SHA256 (Pkgfile) = b80aa3adad0a815e77e7420a022b1033728353058b33ab40dc5b0294997b6450
|
||||
RWSagIOpLGJF30BDHnuNlDzTmGCW1xoQCWQ0m+U7E9rcFAMDFGVNNm617bzISf8OFXP7LGXVjIHI8fmtweITiEK3UmTrJKWqIAs=
|
||||
SHA256 (Pkgfile) = 87f84f9c234960490dbee10dbe914eef0140df2eef88748e9d8eb273d5936026
|
||||
SHA256 (.footprint) = 8025ac39d61d0f228f05023a9c995fde0a026ba3943a69af1c517e8ea46747dd
|
||||
SHA256 (ArpON-3.0-ng.tar.gz) = ea55d1641b4573b19103ca596368e418aecd2a1409adbdce3a9f76dc8ebad590
|
||||
SHA256 (arpon) = 295d1363e52e0c0f4799651a0da2e60d6da0178b5eac8276fb256fc47feae2c6
|
||||
SHA256 (arpon-gcc7.patch) = 1106207e420aa9fff9db9e2c43d767de361b2845e053c00acab5f4edf1e8ddbf
|
||||
SHA256 (arpon-syslog.patch) = 151c2e4f51a8b2e34739c57dbf2d76a2bf86e30d22e0294dd5bc1910451251c1
|
||||
|
@ -1,24 +1,26 @@
|
||||
# Description: daemon and tools to handle all ARP aspects
|
||||
# URL: http://arpon.sf.net
|
||||
# Maintainer: Thomas Penteker, tek at serverop dot de
|
||||
# Depends on: libdnet
|
||||
# Depends on: cmake libdnet
|
||||
|
||||
name=arpon
|
||||
version=3.0-ng
|
||||
release=1
|
||||
source=(http://download.sourceforge.net/$name/ArpON-$version.tar.gz \
|
||||
arpon)
|
||||
source=(http://download.sourceforge.net/$name/ArpON-$version.tar.gz
|
||||
arpon
|
||||
# https://aur.archlinux.org/cgit/aur.git/tree/?h=arpon-ng
|
||||
arpon-gcc7.patch arpon-syslog.patch)
|
||||
|
||||
build() {
|
||||
install arpon -D $PKG/etc/rc.d/arpon
|
||||
cd ArpON-$version
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
|
||||
make
|
||||
make DESTDIR=$PKG install
|
||||
|
||||
rm -r $PKG/usr/share/doc
|
||||
install arpon -D $PKG/etc/rc.d/arpon
|
||||
patch -Np2 -d ArpON-$version -i $SRC/arpon-gcc7.patch
|
||||
patch -Np2 -d ArpON-$version -i $SRC/arpon-syslog.patch
|
||||
|
||||
cmake -SArpON-$version -Bbuild \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_FLAGS="-Wno-error=stringop-truncation"
|
||||
cmake --build build
|
||||
DESTDIR=$PKG cmake --build build --target install
|
||||
rm -r $PKG/usr/share/doc
|
||||
}
|
||||
|
41
arpon/arpon-gcc7.patch
Normal file
41
arpon/arpon-gcc7.patch
Normal file
@ -0,0 +1,41 @@
|
||||
diff --unified -r src/ArpON-3.0-ng/src/opt.c src-gcc7fix/ArpON-3.0-ng/src/opt.c
|
||||
--- src/ArpON-3.0-ng/src/opt.c 2016-01-28 20:56:19.000000000 -0500
|
||||
+++ src-gcc7fix/ArpON-3.0-ng/src/opt.c 2017-05-31 02:22:54.053601192 -0400
|
||||
@@ -222,6 +222,8 @@
|
||||
/* Print the version command option, cleanup and exit. */
|
||||
std_version();
|
||||
exit_cleanup(true);
|
||||
+ /* Explicit break because exit_cleanup conditionally exits (noreturn unsuitable). */
|
||||
+ break;
|
||||
|
||||
case 'h':
|
||||
MSG_DEBUG("-h or --help command option");
|
||||
@@ -229,6 +231,8 @@
|
||||
/* Print the help screen command option, cleanup and exit. */
|
||||
std_help();
|
||||
exit_cleanup(true);
|
||||
+ /* Explicit break because exit_cleanup conditionally exits (noreturn unsuitable). */
|
||||
+ break;
|
||||
|
||||
case '?':
|
||||
case ':':
|
||||
@@ -285,7 +289,7 @@
|
||||
}
|
||||
|
||||
/* Re-initialize the interface name command option to no interface? */
|
||||
- if (opt->interface != '\0')
|
||||
+ if (opt->interface[0] != '\0')
|
||||
memset(opt->interface, '\0', (size_t)IF_NAMESIZE);
|
||||
|
||||
/* Set the value of the interface name command option. */
|
||||
diff --unified -r src/ArpON-3.0-ng/src/sig.c src-gcc7fix/ArpON-3.0-ng/src/sig.c
|
||||
--- src/ArpON-3.0-ng/src/sig.c 2016-01-28 21:06:37.000000000 -0500
|
||||
+++ src-gcc7fix/ArpON-3.0-ng/src/sig.c 2017-05-31 02:17:58.216940834 -0400
|
||||
@@ -204,6 +204,7 @@
|
||||
case SIGINT:
|
||||
/* Remove ^C symbol from the output terminal. */
|
||||
printf("\r");
|
||||
+ __attribute__ ((fallthrough));
|
||||
|
||||
case SIGTERM:
|
||||
MSG_DEBUG("Caught %s (%d)..", SIG_ITOA(sig), sig);
|
334
arpon/arpon-syslog.patch
Normal file
334
arpon/arpon-syslog.patch
Normal file
@ -0,0 +1,334 @@
|
||||
diff --git a/ArpON-3.0-ng/src/main.c b/ArpON-3.0-ng/src/main.c
|
||||
index 7045a13..23d9f0d 100644
|
||||
--- a/ArpON-3.0-ng/src/main.c
|
||||
+++ b/ArpON-3.0-ng/src/main.c
|
||||
@@ -33,6 +33,9 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <syslog.h>
|
||||
|
||||
#include "dmn.h"
|
||||
#include "env.h"
|
||||
@@ -43,12 +46,33 @@
|
||||
#include "sig.h"
|
||||
#include "thd.h"
|
||||
|
||||
+int syslog_verbosity;
|
||||
+
|
||||
/*
|
||||
* ArpON Main.
|
||||
*/
|
||||
int
|
||||
main(int argc, char **argv, char **envp)
|
||||
{
|
||||
+ char* verbosity = getenv("ARPON_SYSLOG_VERBOSITY");
|
||||
+
|
||||
+ if (verbosity == NULL)
|
||||
+ syslog_verbosity = LOG_INFO;
|
||||
+ else if (strcmp(verbosity, "CRIT") == 0)
|
||||
+ syslog_verbosity = LOG_CRIT;
|
||||
+ else if (strcmp(verbosity, "ERR") == 0)
|
||||
+ syslog_verbosity = LOG_ERR;
|
||||
+ else if (strcmp(verbosity, "WARNING") == 0)
|
||||
+ syslog_verbosity = LOG_WARNING;
|
||||
+ else if (strcmp(verbosity, "INFO") == 0)
|
||||
+ syslog_verbosity = LOG_INFO;
|
||||
+ else if (strcmp(verbosity, "DEBUG") == 0)
|
||||
+ syslog_verbosity = LOG_DEBUG;
|
||||
+ else
|
||||
+ syslog_verbosity = LOG_INFO;
|
||||
+
|
||||
+ /* Initialize syslog. */
|
||||
+ openlog("arpon", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
|
||||
|
||||
/* Audit the environment. */
|
||||
env_audit(argv, envp);
|
||||
diff --git a/ArpON-3.0-ng/src/msg.c b/ArpON-3.0-ng/src/msg.c
|
||||
index 77ee70d..174c6e2 100644
|
||||
--- a/ArpON-3.0-ng/src/msg.c
|
||||
+++ b/ArpON-3.0-ng/src/msg.c
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
+#include <syslog.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "exit.h"
|
||||
@@ -58,23 +59,12 @@
|
||||
*/
|
||||
#define MSG_MESSAGESIZE 512 /* 512 bytes. */
|
||||
|
||||
-/*
|
||||
- * Log file permissions to 640.
|
||||
- */
|
||||
-#define MSG_LOGPERMS S_IRUSR | S_IWUSR | S_IRGRP
|
||||
+extern int syslog_verbosity;
|
||||
|
||||
/*
|
||||
* Function prototypes not exported.
|
||||
*/
|
||||
-static void msg_init(void);
|
||||
-static void msg_destroy(void);
|
||||
static void msg_gettimestamp(char *ts);
|
||||
-static void msg_putmessage(FILE *stream, const char *msg);
|
||||
-
|
||||
-/*
|
||||
- * Initialize the log file stream.
|
||||
- */
|
||||
-static FILE *log = NULL;
|
||||
|
||||
/*
|
||||
* Initialize the message mutex.
|
||||
@@ -82,7 +72,7 @@ static FILE *log = NULL;
|
||||
static pthread_mutex_t msg_mtx = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
/*
|
||||
- * Initialize the log file stream and print the message with logging.
|
||||
+ * Print the message.
|
||||
* The syntax of each message is:
|
||||
*
|
||||
* timestamp1 [log level] message1
|
||||
@@ -93,21 +83,38 @@ static pthread_mutex_t msg_mtx = PTHREAD_MUTEX_INITIALIZER;
|
||||
void
|
||||
msg(FILE *stream, const char *level, const char *fmt, ...)
|
||||
{
|
||||
-
|
||||
do {
|
||||
char ts[MSG_TIMESTAMPSIZE], msg[MSG_MESSAGESIZE];
|
||||
va_list ap;
|
||||
int len1, len2, tot_len = MSG_MESSAGESIZE;
|
||||
+ int syslog_lvl;
|
||||
|
||||
/* Lock the mutex of the message. */
|
||||
if (pthread_mutex_lock(&msg_mtx) != 0)
|
||||
break;
|
||||
|
||||
- /* Log file stream of the messages already initialized and open? */
|
||||
- if (log == NULL) {
|
||||
- /* Initialize the log file stream of the messages. */
|
||||
- msg_init();
|
||||
- }
|
||||
+ if (strcmp(level, "BUG") == 0)
|
||||
+ syslog_lvl = LOG_CRIT;
|
||||
+ else if (strcmp(level, "ERROR") == 0)
|
||||
+ syslog_lvl = LOG_ERR;
|
||||
+ else if (strcmp(level, "WARN") == 0)
|
||||
+ syslog_lvl = LOG_WARNING;
|
||||
+ else if (strcmp(level, "INFO") == 0)
|
||||
+ syslog_lvl = LOG_INFO;
|
||||
+ else if (strcmp(level, "DEBUG") == 0)
|
||||
+ syslog_lvl = LOG_DEBUG;
|
||||
+ else
|
||||
+ syslog_lvl = LOG_NOTICE;
|
||||
+
|
||||
+ if (syslog_verbosity < syslog_lvl)
|
||||
+ return;
|
||||
+
|
||||
+ va_start(ap, fmt);
|
||||
+
|
||||
+ /* Print the message to syslog. */
|
||||
+ vsyslog(syslog_lvl, fmt, ap);
|
||||
+
|
||||
+ va_end(ap);
|
||||
|
||||
/* Get the timestamp of the message. */
|
||||
msg_gettimestamp(ts);
|
||||
@@ -139,125 +146,17 @@ msg(FILE *stream, const char *level, const char *fmt, ...)
|
||||
/* No message truncated. */
|
||||
assert(tot_len > 0);
|
||||
|
||||
- /* Print the message in the log file stream and the file stream. */
|
||||
- msg_putmessage(stream, msg);
|
||||
-
|
||||
- /* Unlock the mutex of the message. */
|
||||
- if (pthread_mutex_unlock(&msg_mtx) != 0)
|
||||
- break;
|
||||
-
|
||||
- return;
|
||||
- } while (0);
|
||||
-
|
||||
- ERROR("%s", strerror(errno));
|
||||
- exit(EXIT_FAILURE);
|
||||
-}
|
||||
-
|
||||
-/*
|
||||
- * Initialize the log file stream of the messages.
|
||||
- */
|
||||
-static void
|
||||
-msg_init(void)
|
||||
-{
|
||||
-
|
||||
- do {
|
||||
- struct stat stats;
|
||||
- bool UNUSED(logcreate) = false;
|
||||
-
|
||||
- /* Check if the log file exist. */
|
||||
- if (stat(LOG_FILE, &stats) < 0) {
|
||||
- if (errno == ENOENT) {
|
||||
- int fd;
|
||||
-
|
||||
- /* Create and open the log file with the 640 perms. */
|
||||
- if ((fd = open(LOG_FILE, O_CREAT, MSG_LOGPERMS)) < 0)
|
||||
- break;
|
||||
-
|
||||
- /* Close the log file descriptor. */
|
||||
- if (close(fd) < 0)
|
||||
- break;
|
||||
-
|
||||
- /* Call again. */
|
||||
- if (stat(LOG_FILE, &stats) < 0)
|
||||
- break;
|
||||
-
|
||||
-#ifndef NDEBUG
|
||||
- /* Log file created. */
|
||||
- logcreate = true;
|
||||
-#endif /* !NDEBUG */
|
||||
- } else {
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /* Check if the log file is a regular file. */
|
||||
- if (S_ISREG(stats.st_mode) == 0) {
|
||||
- ERROR("%s is not a regular file", LOG_FILE);
|
||||
- exit(EXIT_FAILURE);
|
||||
- }
|
||||
-
|
||||
- /* Fix the log file perms to 640. */
|
||||
- if (chmod(LOG_FILE, MSG_LOGPERMS) < 0)
|
||||
- break;
|
||||
+ /* Print the message in the file stream. */
|
||||
+ fprintf(stream, "%s", msg);
|
||||
|
||||
- /* Open the log file stream to append. */
|
||||
- if ((log = fopen(LOG_FILE, "a")) == NULL)
|
||||
+ /* Flush the file stream. */
|
||||
+ if (fflush(stream) == EOF)
|
||||
break;
|
||||
|
||||
-#ifndef NDEBUG
|
||||
/* Unlock the mutex of the message. */
|
||||
if (pthread_mutex_unlock(&msg_mtx) != 0)
|
||||
break;
|
||||
|
||||
- /* Log file created? */
|
||||
- if (logcreate == true)
|
||||
- MSG_DEBUG("Create %s with 640 perms successful", LOG_FILE);
|
||||
-#endif /* !NDEBUG */
|
||||
-
|
||||
- MSG_DEBUG("Open %s successful", LOG_FILE);
|
||||
- MSG_DEBUG("Start logging");
|
||||
-
|
||||
- /* Push msg_destroy() to be called on exit_cleanup(). */
|
||||
- exit_push(msg_destroy, "msg_destroy");
|
||||
-
|
||||
-#ifndef NDEBUG
|
||||
- /* Lock the mutex of the message. */
|
||||
- if (pthread_mutex_lock(&msg_mtx) != 0)
|
||||
- break;
|
||||
-#endif /* !NDEBUG */
|
||||
-
|
||||
- return;
|
||||
- } while (0);
|
||||
-
|
||||
- ERROR("%s", strerror(errno));
|
||||
- exit(EXIT_FAILURE);
|
||||
-}
|
||||
-
|
||||
-/*
|
||||
- * Destroy the log file stream of the messages.
|
||||
- */
|
||||
-static void
|
||||
-msg_destroy(void)
|
||||
-{
|
||||
-
|
||||
- do {
|
||||
- /* Unlock the mutex of the message before the destruction. */
|
||||
- if (pthread_mutex_unlock(&msg_mtx) != 0)
|
||||
- break;
|
||||
-
|
||||
- /* Log file stream of the messages already destroyed and closed? */
|
||||
- if (log != NULL) {
|
||||
- MSG_DEBUG("End logging");
|
||||
- MSG_DEBUG("Close %s successful", LOG_FILE);
|
||||
-
|
||||
- /* Close the log file stream. */
|
||||
- if (fclose(log) == EOF)
|
||||
- break;
|
||||
-
|
||||
- /* Set the log file stream to NULL. */
|
||||
- log = NULL;
|
||||
- }
|
||||
-
|
||||
return;
|
||||
} while (0);
|
||||
|
||||
@@ -299,64 +198,6 @@ msg_gettimestamp(char *ts)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
-/*
|
||||
- * Put the message in the log file stream and the file stream.
|
||||
- */
|
||||
-static void
|
||||
-msg_putmessage(FILE *stream, const char *msg)
|
||||
-{
|
||||
-
|
||||
- do {
|
||||
- struct stat stats;
|
||||
-
|
||||
- /* Check if the log file exist. */
|
||||
- if (stat(LOG_FILE, &stats) < 0) {
|
||||
- if (errno == ENOENT) {
|
||||
- /* Close the log file stream. */
|
||||
- if (fclose(log) == EOF)
|
||||
- break;
|
||||
-
|
||||
- /* Set the log file stream to NULL. */
|
||||
- log = NULL;
|
||||
-
|
||||
- /* Re-initialize the log file stream. */
|
||||
- msg_init();
|
||||
-
|
||||
- /* Call again. */
|
||||
- if (stat(LOG_FILE, &stats) < 0)
|
||||
- break;
|
||||
- } else {
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- /* Check if the log file is a regular file. */
|
||||
- if (S_ISREG(stats.st_mode) == 0) {
|
||||
- ERROR("%s is not a regular file", LOG_FILE);
|
||||
- exit(EXIT_FAILURE);
|
||||
- }
|
||||
-
|
||||
- /* Print the message in the log file stream. */
|
||||
- fprintf(log, "%s", msg);
|
||||
-
|
||||
- /* Flush the log file stream. */
|
||||
- if (fflush(log) == EOF)
|
||||
- break;
|
||||
-
|
||||
- /* Print the message in the file stream. */
|
||||
- fprintf(stream, "%s", msg);
|
||||
-
|
||||
- /* Flush the file stream. */
|
||||
- if (fflush(stream) == EOF)
|
||||
- break;
|
||||
-
|
||||
- return;
|
||||
- } while (0);
|
||||
-
|
||||
- ERROR("%s", strerror(errno));
|
||||
- exit(EXIT_FAILURE);
|
||||
-}
|
||||
-
|
||||
/*
|
||||
* EOF
|
||||
*
|
Loading…
x
Reference in New Issue
Block a user