From: Bdale Garbee Date: Thu, 5 Jun 2008 23:28:47 +0000 (-0600) Subject: Imported Upstream version 1.0 X-Git-Tag: upstream/1.0^0 X-Git-Url: https://git.gag.com/?p=debian%2Fp10cfgd;a=commitdiff_plain;h=c1397621dd9c67ea3e3b8db3d5acc7ad687ce055 Imported Upstream version 1.0 --- c1397621dd9c67ea3e3b8db3d5acc7ad687ce055 diff --git a/debian/README.debian b/debian/README.debian new file mode 100644 index 0000000..5652fa4 --- /dev/null +++ b/debian/README.debian @@ -0,0 +1,17 @@ +This is a daemon that is only useful for owners of the Gracilis Packeten +amateur radio network packet switch product. + +This package is maintained for Debian GNU/Linux by Bdale Garbee, N3EUA, +bdale@gag.com. + +The Gracilis Packeten includes a remote configuration command that allows +loading of configuration files, and/or information files, into the switch +at boot time. This feature requires a daemon running on some system that +is reachable over the network from the Packeten. This package provides +such a daemon, written in Perl. + +The original author is John Conner, WD0FHG, conner@empire.com. If John +hadn't wanted to learn Perl at just the right instant, this daemon would +probably never have been written! Recent updates have mostly been Bdale's +handiwork. + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..b993c61 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,22 @@ +p10cfgd (1.0-4) unstable; urgency=low + + * New package format. + * Cosmetic changes to debian control files. + + -- Bdale Garbee Wed, 30 Oct 1996 10:36:17 -0800 + +Mon Apr 22 23:04:22 MDT 1996 Bdale Garbee + + * fixed architecture to be 'all' and not 'i386', since we're Perl + +Tue Apr 16 22:40:11 MDT 1996 Bdale Garbee + + * fixed extended description syntax in debian.control + +Mon Oct 30 02:40:54 MST 1995 Bdale Garbee + + * Initial version for Debian. + +Local variables: +mode: debian-changelog +End: diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..d5181aa --- /dev/null +++ b/debian/control @@ -0,0 +1,17 @@ +Source: p10cfgd +Section: hamradio +Priority: extra +Maintainer: Bdale Garbee +Standards-Version: 2.1.0.0 + +Package: p10cfgd +Architecture: all +Depends: netbase (>=1.23), perl +Description: Remote configuration daemon for Gracilis Packeten. + The 'p10cfgd' daemon provides support for the 'rmtcfg' command in the + Gracilis Packeten amateur radio network packet switch. With this daemon, + and appropriate entries in the non-volatile configuration memory of a + Packeten, it is possible to have the switch load commands and information + at boot time. Further, this daemon appends a command which sets the date + and time in the clock on the Packeten. + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..50981ba --- /dev/null +++ b/debian/copyright @@ -0,0 +1,37 @@ +* +* Copyright (c) 1993, 1995 by Colorado Digital Eclectics (CODE) +* All rights reserved. +* +* This code is derived from software contributed to CODE by +* John Conner, WD0FHG. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. All advertising materials mentioning features or use of this software +* must display the following acknowledgement: +* This product includes software developed by Colorado Digital Eclectics +* and its contributors. +* 4. Neither the CODE name nor the names of its contributors may be used +* to endorse or promote products derived from this software without +* specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY CODE AND CONTRIBUTORS ``AS IS'' AND +* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL CODE OR THE CONTRIBUTORS BE LIABLE +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* + +CODE may be reached at info@code.org, or at http://www.code.org/ diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..0fcd526 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,7 @@ +#! /bin/bash + +# add our entry to the /etc/inetd.conf file + +update-inetd --group "HAM-RADIO" --add "rmtcfg stream tcp nowait root /usr/bin/p10cfgd p10cfgd" + + diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..3370f7e --- /dev/null +++ b/debian/prerm @@ -0,0 +1,6 @@ +#! /bin/bash + +# clean up the /etc/inetd.conf file + +update-inetd --disable rmtcfg + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..294b29b --- /dev/null +++ b/debian/rules @@ -0,0 +1,58 @@ +#!/usr/bin/make -f +# Sample debian.rules file - for GNU Hello (1.3). +# Copyright 1994,1995 by Ian Jackson. +# I hereby give you perpetual unlimited permission to copy, +# modify and relicense this file, provided that you do not remove +# my name from the file itself. (I assert my moral right of +# paternity under the Copyright, Designs and Patents Act 1988.) +# This file may have to be extensively modified + +# There used to be `source' and `diff' targets in this file, and many +# packages also had `changes' and `dist' targets. These functions +# have been taken over by dpkg-source, dpkg-genchanges and +# dpkg-buildpackage in a package-independent way, and so these targets +# are obsolete. + +package=p10cfgd + +build: + $(checkdir) + touch build + +clean: + $(checkdir) + -rm -f build + -rm -rf *~ debian/tmp debian/*~ debian/files* + +binary-indep: checkroot build + $(checkdir) + +binary-arch: checkroot build + $(checkdir) + -rm -rf debian/tmp + install -d debian/tmp/usr/bin debian/tmp/usr/man/man1 + install -g root -m 755 -o root p10cfgd debian/tmp/usr/bin/p10cfgd + install -g root -m 644 -o root p10cfgd \ + debian/tmp/usr/man/man1/p10cfgd.1 + debstd $(package) CHANGES INSTALL README* TODO + dpkg-gencontrol + chown -R root.root debian/tmp + chmod -R g-ws debian/tmp + dpkg --build debian/tmp .. + +define checkdir + test -f debian/rules +endef + +# Below here is fairly generic really + +binary: binary-indep binary-arch + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +checkroot: + $(checkdir) + test root = "`whoami`" + +.PHONY: binary binary-arch binary-indep clean checkroot diff --git a/p10cfgd b/p10cfgd new file mode 100644 index 0000000..ed6f2f4 --- /dev/null +++ b/p10cfgd @@ -0,0 +1,314 @@ +#!/usr/bin/perl +'di '; +'ig00 '; +# +#* +#* Copyright (c) 1993, 1995 by Colorado Digital Eclectics (CODE) +#* All rights reserved. +#* +#* This code is derived from software contributed to CODE by +#* John Conner, WD0FHG. +#* +#* Redistribution and use in source and binary forms, with or without +#* modification, are permitted provided that the following conditions +#* are met: +#* 1. Redistributions of source code must retain the above copyright +#* notice, this list of conditions and the following disclaimer. +#* 2. Redistributions in binary form must reproduce the above copyright +#* notice, this list of conditions and the following disclaimer in the +#* documentation and/or other materials provided with the distribution. +#* 3. All advertising materials mentioning features or use of this software +#* must display the following acknowledgement: +#* This product includes software developed by Colorado Digital Eclectics +#* and its contributors. +#* 4. Neither the CODE name nor the names of its contributors may be used +#* to endorse or promote products derived from this software without +#* specific prior written permission. +#* +#* THIS SOFTWARE IS PROVIDED BY CODE AND CONTRIBUTORS ``AS IS'' AND +#* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +#* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +#* ARE DISCLAIMED. IN NO EVENT SHALL CODE OR THE CONTRIBUTORS BE LIABLE +#* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +#* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +#* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +#* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +#* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +#* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +#* SUCH DAMAGE. +#* +# + +$FILEDIR = "/etc/p10cfgd/"; +$LOGFILE = "/var/log/p10cfgd.log"; + +$AF_INET = 2; +$SOCK_STREAM = 1; +$IPPORT_RMTCFG = 1236; +$sockaddr = 'S n a4 x8'; +$fileaddr = 'S n a4'; + +# just incase someone wants to set on a different port +($port) = @ARGV; +$port = $IPPORT_RMTCFG unless $port; + +open(LOG,">>$LOGFILE") || die "Can't open log file: $!\n"; + +($sec,$min,$hour,$mday,$mon,$year) = gmtime(time); +++$mon; +print LOG "Starting p10cfgd: $mon/$mday/$year $hour:$min:$sec\n"; + +# if we were started by inetd then STDIN will be our +# socket and getsockname will return $myport == $port +$mysockaddr = getsockname(STDIN); +($family, $myport, $myaddr) = unpack($fileaddr,$mysockaddr); +print LOG "Started by inetd port=$myport\n"; +if ( $myport == $port ) { + # we were started by inetd + open(NS,"+<&STDIN"); + $addr = getpeername(NS); + $con = "inetd"; + &ServiceConnection; + exit; #should never get here +} + +# we were started normally + +($name, $aliases, $proto) = getprotobyname('tcp'); +if ($port !~ /^\d+$/) { + ($name, $aliases, $port) = getservbyport($port, 'tcp'); +} + +$this = pack($sockaddr, $AF_INET, $port, "\0\0\0\0"); + +select(NS); $| = 1; select(stdout); + +socket(S, $AF_INET, $SOCK_STREAM, $proto) || die "socket: $!"; +bind(S,$this) || die "bind: $!"; +listen(S,5) || die "connect: $!"; + +select(S); $| = 1; select(stdout); + +$con = 0; +print LOG "Listening for connection on Port = $port\n"; +close(LOG); + +for(;;) { + # wait here for connection + ($addr = accept(NS,S)) || die $!; + + $con++; + # now process the remote's file request + if (($child[$con] = fork()) == 0) { + unless (fork) { # child[$con]'s child + &ServiceConnection; + } + #first child exits quickly + exit; + } + wait; #parent reaps first child quickly + close(NS); +} + +sub ServiceConnection { + open(LOG,">>$LOGFILE") || die "Can't open log file: $!\n"; + ($sec,$min,$hour,$mday,$mon,$year) = gmtime(time); + ++$mon; + print LOG "$con: $mon/$mday/$year $hour:$min:$sec\n"; + + ($af,$port,$inetaddr) = unpack($sockaddr,$addr); + @inetaddr = unpack('C4',$inetaddr); + print LOG "$con: accept ok connection from @inetaddr\n"; + + # the only thing we are expecting from the remote is a file name + $file = ; + chop( $file ); # get rid of the newline + $file =~ s/\r$//; # get rid of the return that may be at the end + + print LOG "$con: Requested file - $file\n"; + print NS "# Config file: $file\n"; #Send a comment line + + $file = "$FILEDIR$file"; + + do { + print NS "# Unable to open requested config file.\n"; + close( NS ); + print LOG "$con: Could not open file $file: $!\n"; + exit; + } unless open( FILE, $file ); + + # now copy the requested file to the socket + while ( ) { + chop; + s/^$/ /; #make sure that all lines have at least one char + s/^_$//; #except for lines starting with a underscore + print NS "$_\n"; + } + + # now send the time (MMDDYYHHMM) this should work for all files and + # set the switch time when any command file is read. It should just + # add a time stamp to the info files. + + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime( time ); + $mon++; + + printf (NS "time %2.2d%2.2.2d%2.2d%2.2d%2.2d \n",$mon,$mday,$year,$hour,$min); + + close(FILE); + close(NS); + close(LOG); + exit; +} # end-ServiceConnection + + +############################################################### + + # These next few lines are legal in both Perl and nroff. + +.00; # finish .ig + +'di \" finish diversion--previous line must be blank +.nr nl 0-1 \" fake up transition to first page again +.nr % 0 \" start at page 1 +'; __END__ ##### From here on it's a standard manual page ##### + +.TH P10CFGD 1 "July 29, 1993" +.AT 3 +.SH NAME +p10cfgd \- remote configuration daemom for Gracilis PackeTen +.SH SYNOPSIS +.B p10cfgd [IP_PORT] +.SH COPYRIGHT +Copyright (c) 1993 by Colorado Digital Eclectics (CODE) + +All rights reserved. + +.SH DESCRIPTION +.I Rmtcfgd +is a server program used to send configuration +files to a Gracilis PackeTen. It can be run in +background or it can be run by inetd. +If +.I p10cfgd +is to be run by inetd, add the following line to +.I /etc/services + +.nf +rmtcfg 1236/tcp # Remote Configuration of PackeTen +.fi + +and add the following to +.I /etc/inetd.conf + +.nf +# Remote configuration service for PackeTen +rmtcfg stream tcp nowait root /usr/bin/p10cfgd p10cfgd +.fi + +.I P10cfgd +normally does not require the IP_PORT parameter. It +listens for connections on IP Port 1236 as a default. + +The program will send on a line by line basis the file requested +by the client that connects on the IP Port. The only expected +input from the client is the file name. When the file has been +sent, the connection is closed. The requested file must be in +the directory /etc/p10cfgd. + +.I Rmtcfgd +maintains a log of its activity in the file +/var/log/p10cfgd.log. Program startup and all connections are +logged in the file with GMT time stamps. The file is opened +in append mode. + +The protocol used by the PackeTen is very simple. +The PackeTen opens a tcp connection to port 1236 on +a host system. Once the connection is made, the PackeTen +sends the name of the file it wants to the host. The +host then opens the file and sends it line by line to +the PackeTen until all lines have been sent. The files +to be transfered must be plain text files and each line +must have at least one character in addition to the newline +at the end. +.I P10cfgd +replaces all blank lines with lines that contain two spaces. +If you wish to send a blank line, to stop loading of part +of a LocalInfo file for example, place an underscore '_' at +the begining of the line. The entire contents of the line will +be deleted and a blank line will be sent to the client. +At the end of the file, +the server sends a time command +( time MMDDYYHHMM ) with the UTC time on the server. +This will either set the time on the PackeTen or add a time stamp +to the LocalInfo file. +The server then closes the connection. + +The remote configuration command used on the PackeTen is +.nf + rmtcfg [options] + The valid options are + -t default is 60 sec + -p default is 1236 + -i the file is for LocalInfo + -h if the primary does not answer +.fi + +The rmtcfg commands would be placed in to the EEPROM on the +PackeTen so that they would be executed during a reboot. The +information stored in the EEPROM should include enough information +to set the PackeTen up to allow communications with the primary and +the secondary server. +This would include commands to set MYCALL and the IP_ADDRESS, to attach an +interface to the channel with the server, routing information and +so forth. A sample EEPROM configuration for a PackeTen, +empire.wd0fhg.ampr.org [44.32.0.32], +that gets its configuration from a remote system +winfree.n3eua.ampr.org [44.32.0.2], +over a 9600 baud ax25 path would be: + +.nf + # first the general setup of the PackeTen + ee hostname gw.wd0fhg + ee sitename empire + ee ipaddr 44.32.0.32 + ee mycall WD0FHG + # Then we attach a 9600 ax25 interface as ax1 + ee attach sync302 1 hdx ax25 ax1 8192 256 9600 ext ext nrzi + # and set the default route to send every thing out ax1 + ee route add default ax1 44.32.0.1 + ee password sure-thing + # + # Now we will ask for the remainder of the setup + # from the server winfree.n3eua.ampr.org [44.32.0.2] + # Note that we have a secondary server available at + # [44.20.0.195] that would be used if winfree is down. + # first the Local Information file + ee com 0 rmtcfg 44.32.0.2 empire.info -i -h 44.20.0.195 + # and then the remaining configuration command file + ee com 1 rmtcfg 44.32.0.2 empire.cfg -h 44.20.0.195 + # + ee save + # end-of-eeprom setup +.fi + +.I Rmtcfgd +started life as the simple server program in PERL by +Larry Wall and R.L. Schwartz published by ORA,Inc. + +.SH ENVIRONMENT +No environment variables are used. +.SH FILES +.nf +/etc/p10cfgd/* - files that can be accessed remotely +/var/log/p10cfgd.log - p10cfgd log file +.fi +.SH AUTHOR +.nf +John Conner, WD0FHG, conner@empire.com +hacked on by Bdale Garbee, N3EUA, bdale@gag.com. +.fi +.SH "SEE ALSO" +Gracilis, Inc. PackeTen Manual and NOS User's Manual + +.SH DIAGNOSTICS +Complains if it can't open a file to remote client and to log file.