- aprsd is a server daemon that provides Internet gateway and client

access to amateur radio APRS packet data.
This commit is contained in:
Diane Bruce 2008-01-24 18:23:27 +00:00
parent 54296cc4d7
commit 86b4c48051
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=206142
18 changed files with 696 additions and 0 deletions

View file

@ -5,6 +5,7 @@
SUBDIR += acfax
SUBDIR += aldo
SUBDIR += aprsd
SUBDIR += asmodem
SUBDIR += atslog
SUBDIR += bfhist

59
comms/aprsd/Makefile Normal file
View file

@ -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 <bsd.port.pre.mk>
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 <bsd.port.post.mk>

3
comms/aprsd/distinfo Normal file
View file

@ -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

70
comms/aprsd/files/aprsd Normal file
View file

@ -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 <aprsd1@wa4dsy.net>
# Modified: Diane Bruce <va3db@amsat.org>
# 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"

View file

@ -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
#

View file

@ -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);

View file

@ -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);

View file

@ -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 <netdb.h>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+#ifdef BSD
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
@@ -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)

View file

@ -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 <netinet/in.h>
#include <arpa/inet.h>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#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
}
}

View file

@ -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;

View file

@ -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 <string>
#include <sstream>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+#ifdef BSD
+#include <netinet/in.h>
+#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;

View file

@ -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(&ltime); // Timestamp
ctime_r(&ltime, 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");

View file

@ -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 <iostream>
#include <strstream>
#include <iomanip>
+#include <netdb.h>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
using namespace std;
@@ -47,11 +51,17 @@
const string group;
};
#else
+#ifdef BSD
+#include <pwd.h>
+#include <grp.h>
+#define MAXGROUPSIZE 1024
+#else
#include <crypt.h>
#include <grp.h>
#include <pwd.h>
#include <shadow.h>
#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;

View file

@ -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

16
comms/aprsd/pkg-deinstall Normal file
View file

@ -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<<EOF
If you really want to remove this package completely
remove what is left in /usr/local/etc/aprsd /var/log/aprsd.
Also be sure to remove user and groups aprsd and tnc
and remember to remove aprsd from dialer group.
EOF

7
comms/aprsd/pkg-descr Normal file
View file

@ -0,0 +1,7 @@
aprsd is a server daemon that provides Internet gateway and client access
to amateur radio APRS packet data.
WWW: http://sourceforge.net/projects/aprsd/
- Diane Bruce, VA3DB
db@db.net

142
comms/aprsd/pkg-install Normal file
View file

@ -0,0 +1,142 @@
#!/bin/sh
UID=240
GID=${UID}
DAEMON_NAME="aprsd"
UID_NAME=${DAEMON_NAME}
GID_NAME=${DAEMON_NAME}
TNC_UID=241
TNC_GID=${TNC_UID}
TNC_UID_NAME="tnc"
TNC_GID_NAME="tnc"
if [ "x$2" != "xPRE-INSTALL" ]; then
exit 0;
fi
ask() {
local question default answer
question=$1
default=$2
if [ -z "${PACKAGE_BUILDING}" ]; then
read -p "${question} [${default}]? " answer
fi
if [ x${answer} = x ]; then
answer=${default}
fi
echo ${answer}
}
yesno() {
local dflt question answer
question=$1
dflt=$2
while :; do
answer=$(ask "${question}" "${dflt}")
case "${answer}" in
[Yy]*) return 0;;
[Nn]*) return 1;;
esac
echo "Please answer yes or no."
done
}
adduser() {
local uid gid uid_name gid_name daemon_name
uid=$1
gid=$2
uid_name=$3
gid_name=$4
daemon_name=$5
if which -s pw ; then
:
else
cat <<EOF
Your system does not include the "pw" utility. You should upgrade
to a newer version of FreeBSD. Without "pw" this script will not
run.
EOF
exit 1
fi
echo ""
if pw groupshow ${gid_name} 2> /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<<EOF
${DAEMON_NAME} needs access to serial ports to talk to an
external tnc. You will be asked if you wish to add ${DAEMON_NAME}
to the dialer group for that purpose.
EOF
if pw usershow ${UID_NAME} 2> /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<<EOF
"${DAEMON_NAME}" has an optional login "${TNC_UID_NAME}",
(This is described in the aprsd docs.) if you
wish to allow remote logins. "${DAEMON_NAME}" needs to run as
root for this to work, if you do not plan to run
"${DAEMON_NAME}" ever as root, you can skip this step.
You can always add it manually later if you change your mind.
EOF
if which -s pw && yesno "Would you like to add a ${TNC_UID_NAME} login" y; then
(adduser ${TNC_UID} ${TNC_GID} ${TNC_UID_NAME} ${TNC_GID_NAME} ${DAEMON_NAME})
fi
else
echo "You already have an user \"${TNC_UID_NAME}\" so I will use it."
fi

17
comms/aprsd/pkg-plist Normal file
View file

@ -0,0 +1,17 @@
bin/aprsd
bin/aprspass
etc/aprsd/INIT.TNC.samp
etc/aprsd/RESTORE.TNC.samp
etc/aprsd/aprsd.conf.samp
etc/aprsd/user.deny.samp
etc/aprsd/welcome.txt.samp
etc/rc.d/aprsd
%%EXAMPLESDIR%%/chkaprsd
%%EXAMPLESDIR%%/udp_example
%%PORTDOCS%%%%DOCSDIR%%/aprsddoc.html
%%PORTDOCS%%%%DOCSDIR%%/ports.html
%%PORTDOCS%%%%DOCSDIR%%/q.html
%%PORTDOCS%%%%DOCSDIR%%/qalgorithm.html
%%PORTDOCS%%@dirrm %%DOCSDIR%%
@dirrm %%EXAMPLESDIR%%
@dirrmtry etc/aprsd