diff --git a/comms/Makefile b/comms/Makefile index d47269bd144b..b0ab6dad9458 100644 --- a/comms/Makefile +++ b/comms/Makefile @@ -5,6 +5,7 @@ SUBDIR += acfax SUBDIR += aldo + SUBDIR += aprsd SUBDIR += asmodem SUBDIR += atslog SUBDIR += bfhist diff --git a/comms/aprsd/Makefile b/comms/aprsd/Makefile new file mode 100644 index 000000000000..33c72694ad60 --- /dev/null +++ b/comms/aprsd/Makefile @@ -0,0 +1,59 @@ +# ports collection makefile for: aprsd +# Date created: 14 Jan 2008 +# Whom: db +# +# $FreeBSD$ +# + +PORTNAME= aprsd +PORTVERSION= 2.2.515 +CATEGORIES= comms hamradio +MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} +MASTER_SITE_SUBDIR= aprsd +DISTNAME= aprsd-2.2.5-15 + +MAINTAINER= db@FreeBSD.org +COMMENT= Server daemon providing Internet access to APRS packet data + +GNU_CONFIGURE= yes +PKGMESSAGE= ${FILESDIR}/pkg_message.in +WRK_PKGMESSAGE= ${WRKDIR}/pkg_message + +.include + +post-patch: + @${REINPLACE_CMD} -e 's|%%CONFPATH%%|${PREFIX}/etc/aprsd/|' \ + -e 's|%%LOGPATH%%|/var/log/aprsd/|' \ + ${WRKSRC}/src/aprsd.cpp + @${REINPLACE_CMD} -e 's|%%LOGPATH%%|/var/log/aprsd/|' \ + ${WRKSRC}/src/utils.cpp +post-configure: + @${REINPLACE_CMD} -e 's|-lpthread|${PTHREAD_LIBS}|' \ + ${WRKSRC}/Makefile +pre-install: + @${MKDIR} ${PREFIX}/etc/aprsd + @${MKDIR} "/var/log/aprsd" + @${CP} ${PKGMESSAGE} ${WRK_PKGMESSAGE} + @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|' \ + ${WRK_PKGMESSAGE} + @${SETENV} "PKG_PREFIX=${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL +post-install: + @cd ${WRKSRC}/admin +.for f in INIT.TNC RESTORE.TNC aprsd.conf welcome.txt user.deny + @${INSTALL_DATA} ${WRKSRC}/admin/$f ${PREFIX}/etc/aprsd/$f.samp +.endfor + ${MKDIR} ${EXAMPLESDIR} +.for f in chkaprsd udp_example + @${INSTALL_DATA} ${WRKSRC}/admin/$f ${EXAMPLESDIR} +.endfor + @${INSTALL_SCRIPT} ${FILESDIR}/aprsd ${LOCALBASE}/etc/rc.d +.if !defined(NOPORTDOCS) + @${MKDIR} ${DOCSDIR} + @${CP} ${WRKSRC}/doc/*.html ${DOCSDIR} + @${ECHO} + @${ECHO} docs are in ${PREFIX}/share/doc/aprsd + @${ECHO} +.endif + @${CAT} ${WRK_PKGMESSAGE} + +.include diff --git a/comms/aprsd/distinfo b/comms/aprsd/distinfo new file mode 100644 index 000000000000..82b34c259b6e --- /dev/null +++ b/comms/aprsd/distinfo @@ -0,0 +1,3 @@ +MD5 (aprsd-2.2.5-15.tar.gz) = c380ecc57c573f1db79ced0b73e0d644 +SHA256 (aprsd-2.2.5-15.tar.gz) = 9aa7f89782d2df24fe6e3143f24c3eabfbe77d70526898e48c0057bd447cb1bd +SIZE (aprsd-2.2.5-15.tar.gz) = 226105 diff --git a/comms/aprsd/files/aprsd b/comms/aprsd/files/aprsd new file mode 100644 index 000000000000..5556e8572595 --- /dev/null +++ b/comms/aprsd/files/aprsd @@ -0,0 +1,70 @@ +#!/bin/sh +# +# PROVIDE: aprsd +# REQUIRE: NETWORKING +# +# Add the following lines to /etc/rc.conf +# aprsd_enable="YES" +# aprsd_root="YES" or aprsd_root="NO" + +. /etc/rc.subr + +name="aprsd" +rcvar=`set_rcvar` +load_rc_config $name +aprsd_enable=${aprsd_enable-"NO"} +aprsd_root=${aprsd_root-"NO"} + +command="/usr/local/bin/aprsd" +start_cmd=aprsd_start +stop_cmd=aprsd_stop + +PIDFILE="/var/run/aprsd.pid" +UID="aprsd" +GID="aprsd" +# +# aprsd.init for version 2.1.5. starts or stops aprsd server. +# This file should be placed in /usr/local/etc/rc.d/ +# +# +# +# Author: Dale Heatherington +# Modified: Diane Bruce + +# Source function library. +#. /etc/rc.d/init.d/functions +# See how we were called. +aprsd_start() +{ + if [ -s ${PIDFILE} ] ; then + kill -0 `cat ${PIDFILE}` >&- 2>&- + if [ $? -eq 0 ]; then + echo "aprs server is already running." + return 0 + fi + fi + if [ ${aprsd_root} != "YES" ]; then + echo "Starting aprs server as user ${UID}:${GID}." + touch ${PIDFILE} + chown ${UID}:${GID} ${PIDFILE} + chown ${UID}:${GID} /var/log/aprsd + chown ${UID}:${GID} /var/log/aprsd/* + su ${UID} -m -c "${command} -d" + else + echo "Starting aprs server as root." + chown root:wheel ${PIDFILE} + chown root:wheel /var/log/aprsd + chown root:wheel /var/log/aprsd/* + + ${command} -d + fi + return 0 +} +aprsd_stop() +{ + echo "Stopping aprs server daemon. " + kill -INT `cat ${PIDFILE}` + return 0 +} + +run_rc_command "$1" diff --git a/comms/aprsd/files/patch-admin_aprsd.conf b/comms/aprsd/files/patch-admin_aprsd.conf new file mode 100644 index 000000000000..0a5437a4b479 --- /dev/null +++ b/comms/aprsd/files/patch-admin_aprsd.conf @@ -0,0 +1,35 @@ +--- admin/aprsd.conf.orig 2008-01-22 20:08:12.000000000 -0500 ++++ admin/aprsd.conf 2008-01-22 20:12:45.000000000 -0500 +@@ -46,7 +46,7 @@ + #Define the TNC beacon. The TNC will supply the ax25 path header. + #It's optional and you may use the TNC BTEXT in the INIT.TNC file instead. + # +-TncBeacon 10 !3802.21N/07830.61W& Linux APRS Server ++TncBeacon 10 !3802.21N/07830.61W& FreeBSD APRS Server + # + # + #Send 2 extra message acks is addition to each received ack to TNC +@@ -65,12 +65,12 @@ + #If undefined all TNC related functions are disabled. + #Permissable baud rates are 1200,2400,4800,9600 and 19200. + # +-#tncport /dev/ttyS0 ++#tncport /dev/cuad0 + #tncport radio + #tncbaud 1200 + + #Define the path for transmitted packets +-#This is only used when using Linux sockets, not the TNC. ++#This is only used when using FreeBSD sockets, not the TNC. + #For the TNC, set this in INIT.TNC. Note the format is + #slightly different to the TNC command. + aprspath APRS v WIDE +@@ -97,7 +97,7 @@ + logAllRF no + # + # Allow the insecure aprs passcodes to be used +-# Note: "no" means all users need Linux user names and passwords ++# Note: "no" means all users need FreeBSD user names and passwords + # and aprsd must be run as root for that to work. + aprsPass yes + # diff --git a/comms/aprsd/files/patch-src_aprsString.h b/comms/aprsd/files/patch-src_aprsString.h new file mode 100644 index 000000000000..981efc52fddb --- /dev/null +++ b/comms/aprsd/files/patch-src_aprsString.h @@ -0,0 +1,12 @@ +--- src/aprsString.h.orig 2008-01-12 18:11:00.000000000 -0500 ++++ src/aprsString.h 2008-01-12 18:11:35.000000000 -0500 +@@ -196,7 +196,8 @@ + void parseLogon(void); + bool parseCommand(void); + bool parsePortFilter(void); +- void aprsString::getMsgText(string& msg); ++// void aprsString::getMsgText(string& msg); ++ void getMsgText(string& msg); + void print(ostream& os); + string getAX25Source(void); + string getAX25Dest(void); diff --git a/comms/aprsd/files/patch-src_aprsd.cpp b/comms/aprsd/files/patch-src_aprsd.cpp new file mode 100644 index 000000000000..60ae52f0a921 --- /dev/null +++ b/comms/aprsd/files/patch-src_aprsd.cpp @@ -0,0 +1,41 @@ +--- src/aprsd.cpp.orig 2003-05-28 23:09:39.000000000 -0400 ++++ src/aprsd.cpp 2008-01-24 01:13:26.000000000 -0500 +@@ -98,7 +98,8 @@ + int msgsn; + + const string HOMEDIR("/home/aprsd2"); +-const string CONFPATH(""); ++const string LOGPATH("%%LOGPATH%%"); ++const string CONFPATH("%%CONFPATH%%"); + const string CONFFILE("aprsd.conf"); + const string MAINLOG("aprsd.log"); + const string STSMLOG("thirdparty.log"); +@@ -126,7 +127,7 @@ + WriteLog(string("Server Shutdown"), MAINLOG); + tcsetattr(fileno(stdin),TCSANOW,&initial_settings); //restore terminal mode + +- string outFile = CONFPATH; ++ string outFile = LOGPATH; + outFile += SAVE_HISTORY; + int n = SaveHistory(outFile); + +@@ -872,8 +873,8 @@ + if (f.is_open()) { + f.read(s, 10); + xx = atoi(s); +- kill(xx, SIGCHLD); // Meaningless kill to determine if pid is used +- if (errno != ESRCH) { ++ kill(xx, 0); // Meaningless kill to determine if pid is used ++ if (errno == 0) { + cout << "aprsd already running" << endl; + cout << "PID: " << pid_file << endl; + exit(1); +@@ -977,7 +978,7 @@ + + //fdump = fopen("dump.txt","w+"); //debug + +- string histFile = CONFPATH; ++ string histFile = LOGPATH; + histFile += SAVE_HISTORY; + ReadHistory(histFile); + diff --git a/comms/aprsd/files/patch-src_osdep.h b/comms/aprsd/files/patch-src_osdep.h new file mode 100644 index 000000000000..69b2ffe64a8a --- /dev/null +++ b/comms/aprsd/files/patch-src_osdep.h @@ -0,0 +1,46 @@ +--- src/osdep.h.orig 2003-04-20 14:34:47.000000000 -0400 ++++ src/osdep.h 2008-01-23 23:29:47.000000000 -0500 +@@ -32,6 +32,14 @@ + extern "C" + { + #include ++#if (defined(__unix__) || defined(unix)) && !defined(USG) ++#include ++#endif ++#ifdef BSD ++#include ++#include ++#include ++#endif + + #if TIME_WITH_SYS_TIME + # include +@@ -63,10 +71,27 @@ + char *buf, size_t buflen, struct hostent **result, + int *h_errnop) + { +-#ifdef __GLIBC__ ++#ifdef BSD ++#if (__FreeBSD_version >= 600000) + return ::gethostbyname_r (name.c_str (), result_buf, + buf, buflen, result, h_errnop); + #else ++ struct hostent *h; ++ h = gethostbyname (name.c_str()); ++ if (h != NULL) { ++ memcpy(result_buf,h,sizeof(*h)); ++ *result = h; ++ *h_errnop = 0; ++ return 0; ++ } else { ++ *h_errnop = 0; ++ return 1; ++ } ++#endif ++#endif ++#ifdef __GLIBC__ ++ return ::gethostbyname_r (name.c_str (), result_buf, ++ buf, buflen, result, h_errnop); + if (buflen < sizeof (hostent_data)) + { + if (h_errnop != NULL) diff --git a/comms/aprsd/files/patch-src_queryResp.cpp b/comms/aprsd/files/patch-src_queryResp.cpp new file mode 100644 index 000000000000..94d0ce44ed9f --- /dev/null +++ b/comms/aprsd/files/patch-src_queryResp.cpp @@ -0,0 +1,34 @@ +--- src/queryResp.cpp.orig 2003-03-30 23:49:40.000000000 -0500 ++++ src/queryResp.cpp 2008-01-23 22:12:30.000000000 -0500 +@@ -40,6 +40,9 @@ + + #include + #include ++#if (defined(__unix__) || defined(unix)) && !defined(USG) ++#include ++#endif + + #include "constant.h" + #include "utils.h" +@@ -84,7 +87,6 @@ + if ((rc = gethostname(hostname,80)) != 0) + strcpy(hostname, "Host_Unknown"); + else { +- + //Thread-Safe verison of gethostbyname() + h = NULL; + rc = gethostbyname_r(hostname, +@@ -94,12 +96,10 @@ + &h, + &h_err); + +- +- + if ((rc == 0) && (h!= NULL)) { + strncpy(hostname,h->h_name,80); //Copy Full host name + hostname[79] = '\0'; //Be sure it's terminated +- strncpy((char*)hip,h->h_addr_list[0],4); //Copy Host IP ++ memcpy((void*)hip,(void*)h->h_addr_list[0],4); //Copy Host IP + } + } + diff --git a/comms/aprsd/files/patch-src_servers.cpp b/comms/aprsd/files/patch-src_servers.cpp new file mode 100644 index 000000000000..783b15b13da4 --- /dev/null +++ b/comms/aprsd/files/patch-src_servers.cpp @@ -0,0 +1,19 @@ +--- src/servers.cpp.orig 2003-10-01 12:58:27.000000000 -0400 ++++ src/servers.cpp 2008-01-23 23:26:01.000000000 -0500 +@@ -2627,7 +2627,6 @@ + &hostinfo, + &h_err); + +- + if (rc || (hostinfo == NULL)){ + char* cp = new char[256]; + memset(cp, 0, 256); +@@ -3277,7 +3276,7 @@ + + //---------------------------------------------------------------------- + +-inline string convertUpTime(int dTime) ++string convertUpTime(int dTime) + { + std::ostringstream ostr; + int x; diff --git a/comms/aprsd/files/patch-src_servers.h b/comms/aprsd/files/patch-src_servers.h new file mode 100644 index 000000000000..1812f1abf994 --- /dev/null +++ b/comms/aprsd/files/patch-src_servers.h @@ -0,0 +1,34 @@ +--- src/servers.h.orig 2008-01-12 18:18:53.000000000 -0500 ++++ src/servers.h 2008-01-12 18:36:15.000000000 -0500 +@@ -28,6 +28,12 @@ + + #include + #include ++#if (defined(__unix__) || defined(unix)) && !defined(USG) ++#include ++#endif ++#ifdef BSD ++#include ++#endif + + #include "aprsd.h" + #include "mutex.h" +@@ -135,11 +141,17 @@ + + + //Stuff for trusted UDP source IPs ++#ifdef BSD ++struct sTrusted { ++ struct in_addr sin_addr; //ip address ++ struct in_addr sin_mask; //subnet mask ++}; ++#else + struct sTrusted { + in_addr sin_addr; //ip address + in_addr sin_mask; //subnet mask + }; +- ++#endif + + struct sLogon{ + char *user; diff --git a/comms/aprsd/files/patch-src_utils.cpp b/comms/aprsd/files/patch-src_utils.cpp new file mode 100644 index 000000000000..42e7150ab10d --- /dev/null +++ b/comms/aprsd/files/patch-src_utils.cpp @@ -0,0 +1,36 @@ +--- src/utils.cpp.orig 2003-10-01 12:58:27.000000000 -0400 ++++ src/utils.cpp 2008-01-22 21:54:44.000000000 -0500 +@@ -41,6 +41,7 @@ + + static RecursiveMutex pmtxLog; + ++const string LOGPATH("%%LOGPATH%%"); + + int WriteLog(const string& sp, const string& LogFile) + { +@@ -50,11 +51,12 @@ + static Lock locker(pmtxLog, false); + + locker.get(); ++ string pLogFile = LOGPATH + LogFile; + +- ofstream ofs(LogFile.c_str(), ios::out | ios::app); ++ ofstream ofs(pLogFile.c_str(), ios::out | ios::app); + + if (!ofs) +- cerr << "File I/O Error: Unable to open/create file " << LogFile << endl; ++ cerr << "File I/O Error: Unable to open/create file " << pLogFile << endl; + + time(<ime); // Timestamp + ctime_r(<ime, szTime); // "threadsafe" ctime +@@ -91,8 +93,8 @@ + + pthread_mutex_lock(pmtxLog); + +- char* pLogFile = new char[CONFPATH.length() + strlen(LogFile) +1]; +- strcpy(pLogFile,CONFPATH.c_str()); ++ char* pLogFile = new char[LOGPATH.length() + strlen(LogFile) +1]; ++ strcpy(pLogFile,LOGPATH.c_str()); + strcat(pLogFile, LogFile); + + f = fopen(pLogFile, "a"); diff --git a/comms/aprsd/files/patch-src_validate.cpp b/comms/aprsd/files/patch-src_validate.cpp new file mode 100644 index 000000000000..51894c79abf4 --- /dev/null +++ b/comms/aprsd/files/patch-src_validate.cpp @@ -0,0 +1,115 @@ +--- src/validate.cpp.orig 2008-01-13 20:00:27.000000000 -0500 ++++ src/validate.cpp 2008-01-13 20:45:17.000000000 -0500 +@@ -34,6 +34,10 @@ + #include + #include + #include ++#include ++#if (defined(__unix__) || defined(unix)) && !defined(USG) ++#include ++#endif + + using namespace std; + +@@ -47,11 +51,17 @@ + const string group; + }; + #else ++#ifdef BSD ++#include ++#include ++#define MAXGROUPSIZE 1024 ++#else + #include + #include + #include + #include + #endif ++#endif + + #include "validate.h" + +@@ -140,12 +150,21 @@ + pam_end(pamh, PAM_SUCCESS); + return 0; + #else ++#ifdef BSD ++ passwd *ppw = NULL; ++ struct group *pgrp = NULL; ++ struct spwd *pspwd = NULL; ++ char *member = NULL; ++ struct group grp; ++ struct passwd pwd; ++#else + passwd *ppw = NULL; + group *pgrp = NULL; + spwd *pspwd = NULL; + char *member = NULL; + struct group grp; + struct passwd pwd; ++#endif + int i; + char salt[16]; + int usrfound = 0 ; +@@ -158,7 +177,11 @@ + #endif + + ++#ifdef BSD ++ size_t bufsize=MAXGROUPSIZE; ++#else + size_t bufsize = sysconf(_SC_GETGR_R_SIZE_MAX); ++#endif + char *buffer1 = new char[bufsize]; + //Thread-Safe getgrnam() + getgrnam_r(szGroup.c_str(), /* Does group name szGroup exist? */ +@@ -171,9 +194,11 @@ + delete buffer1; + return rc; /* return BADGROUP if not */ + } +- ++#ifdef BSD ++ bufsize = MAXGROUPSIZE; ++#else + bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); +- ++#endif + char *buffer2 = new char[bufsize]; + //Thread-Safe getpwnam() + getpwnam_r(szUser.c_str(), +@@ -214,6 +239,7 @@ + + pwLength = strlen(ppw->pw_passwd); + ++#if 0 + if (ppw->pw_passwd[0] != '$') { + /* DES salt */ + strncpy(salt,ppw->pw_passwd,2); +@@ -230,15 +256,18 @@ + salt[i++] = '$'; + salt[i] = '\0'; + } ++#endif ++ + #ifdef DEBUG + cout << "salt=" << salt << endl; + #endif + +- if (strcmp(crypt(szPass.c_str(), salt), ppw->pw_passwd) == 0 ) ++ if (strcmp(crypt(szPass.c_str(), ppw->pw_passwd), ppw->pw_passwd) == 0 ) + rc = 0; + else + rc = BADPASSWD; + ++#ifndef BSD /* BSD passwords are always shadowed */ + if ((rc == BADPASSWD) && (strcmp("x",ppw->pw_passwd) == 0)) { + #ifdef DEBUG + cout << "Shadow passwords enabled\n"; +@@ -288,6 +317,7 @@ + << endl; + #endif + } ++#endif + delete buffer1; + delete buffer2; + return rc; diff --git a/comms/aprsd/files/pkg_message.in b/comms/aprsd/files/pkg_message.in new file mode 100644 index 000000000000..2ed67ce89297 --- /dev/null +++ b/comms/aprsd/files/pkg_message.in @@ -0,0 +1,9 @@ +aprsd is now installed + +aprsd has various config files to set up in %%PREFIX%%/etc/aprsd +logs are kept in /var/log/aprsd + +To enable aprsd you need to add: aprsd_enable="YES" to /etc/rc.conf +to run aprsd as UID aprsd add: aprsd_root="NO" to /etc/rc.conf + +- 73 Diane VA3DB diff --git a/comms/aprsd/pkg-deinstall b/comms/aprsd/pkg-deinstall new file mode 100644 index 000000000000..45108ced6931 --- /dev/null +++ b/comms/aprsd/pkg-deinstall @@ -0,0 +1,16 @@ +#!/bin/sh + +if [ "x$2" != "xPOST-DEINSTALL" ]; then + exit 0; +fi + +echo "Killing aprsd if running" +kill -9 `cat /var/run/aprsd.pid` +rm -f /var/run/aprsd.pid + +cat< /dev/null ; then + echo "You already have a group \"${gid_name}\", so I will use it." + else + if pw groupshow ${gid} 2> /dev/null ; then + echo "You already have a gid \"${gid}\". Please create a user ${gid_name}" + echo "with a default group of \"${gid_name}\"." + exit 1 + fi + echo "You need a group \"${gid_name}\"." + if which -s pw && yesno "Would you like me to create it" y; then + pw groupadd ${gid_name} -g ${gid} || exit + echo "Done." + else + echo "Please create it, and try again." + if ! pw usershow ${uid_name} 2> /dev/null ; then + echo "While you're at it, please create a user \"${uid_name}\"" + echo 'too, with a default group of "${gid_name}".' + fi + exit 1 + fi + fi + + if pw usershow ${uid_name} 2> /dev/null ; then + echo "You already have a user \"${uid_name}\", so I will use it." + else + if pw usershow ${uid} 2> /dev/null ; then + echo "You already have a uid \"${uid}\". Please create a user \"${uid_name}\"" + echo "with a default group of \"${gid_name}\"." + exit 1 + fi + echo "You need a user \"${uid_name}\"." + if which -s pw && yesno "Would you like me to create it" y; then + pw useradd ${uid_name} -g ${gid_name} -u ${uid} -h - -d /nonexistent \ + -s /bin/sh -c "${daemon_name}" || exit + echo "Done." + else + echo "Please create it, and try again." + exit 1 + fi + fi +} + +(adduser ${UID} ${GID} ${UID_NAME} ${GID_NAME} ${DAEMON_NAME}) + +echo `pw groupshow dialer`|grep -q ${UID_NAME} +if [ $? -eq 0 ]; then + echo "You already have \"${UID_NAME}\" in the dialer group, so I will use this." +else +cat< /dev/null ; then + if which -s pw && yesno "Would you like to add \"${UID_NAME}\" to the dialer group?" y; then + pw groupmod -n "dialer" -m ${UID_NAME} || exit + echo "Done." + fi + fi +fi + +if ! pw usershow ${TNC_UID_NAME} 2> /dev/null ; then +cat<