Presenting... Afghan Hound in Hypertext - a total waste of bandwidth production.
Home I

Server man page.

Home II
Games Quake Wibble Computers Home I Home II

man aqotdd:

Go back to the AQOTDD home page.

aqotdd - Afghan Hound RFC865 compliant server daemon.

SYNOPSIS

aqotdd [-hvd] [-f filename ]

DESCRIPTION

Once started, aqotdd listens (by default) on TCP and UDP ports 17. Whenever a remote client makes a connection (or sends a datagram, for UDP), the server returns a random quote of the day, consisting of ascii printing characters, spaces and carriage returns/line feeds up to 512. This forms a RFC865 compliant server. Options allow the administrator to change this behavior if required, and to select the database of quotes used.

Various logging options are available to record the number of quotes served, and the clients that have connected. Logging can either be to a file, syslog or standard error, see below for details.

To help stop the proliferation of incompatible file formats, aqotdd uses files in the text-file , text-file.dat format used by the BSD fortune(6) program, however, all the code in this implementation is unique. (and with good reason: nobody other than Afghan would want it - Ed.)

Command Line Options

The options are as follows:

  -h Print out a short help message, and exit.  
  -v Print out version information, and exit.  
  -d Enter debug mode. In debug mode, the daemon will not put itself into the background, and will ignore any logging options, writing messages to standard error instead.  
  -f filename Specify an alternate configuration file. Without this option, aqotdd will try to use various compile time defaults for its configuration. See below for more details on the structure of the configuration file, and under the FILES section for where aqotdd expects finds its configuration file.  

RUN TIME CONTROL

The following signals are acted upon by the server.

  SIGHUP Forces aqotdd to re-read it's configuration file, if one exists. This will also cause the re-reading of the quote database, if this has changed since start-up.

NOTE: If aqotdd is started by root, the configuration file must be readable by the user given in the 'user' section below, or the server will revert to built-in defaults on receiving a SIGHUP.
 
  SIGUSR1 Forces aqotdd to send it's current configuration to which ever log is currently active.  

CONFIGURATION

The configuration file is found by:

  1. Looking at the command line
  2. $PREFIX/etc/aqotdd.conf where PREFIX is defined in the Makefile.

The directives in the configuration file follow the glori- ous UN*X tradition: lines starting with "#" are comments, names and values are given as
name = value
and all (in this case) whitespace is ignored. Strings should not be quoted.

The configuration file is divided into two sections, the first of which can only be changed by restarting the server, the second of which can be altered at run-time by sending the server a SIGHUP. If no configuration file can be found at start-up, aqotdd uses it's own compile time defaults: subsequent SIGHUP's will only cause the quote database to be re-initialized.

Defaults are given, which represent the value the vari- ables assume if either the configuration file is missing, or the configuration file contains no entry for that vari- able.

Startup-only configuration variables.

These are set at server initialization, and will not be affected by any SIGHUP's issued to the program.

  use_tcp Set to 1 to enable listening on the specified TCP port, or 0 to disable TCP. Default = 1.  
  use_udp Set to 1 to enable listening on the specified UDP port, or 0 to disable UDP. Default = 1. Note that if neither of use_tcp or use_tcp are set, the server will exit immediately, after printing a random quote to the log. (Useful for debugging the quote generator, in combination with the -d command line flag.)  
  port_tcp    
  port_udp Used to specify the port for whichever of the two protocols are enabled. The port can be specified in either numerical form or by service name from /etc/services , in other words both
port_tcp = qotd
and
port_tcp = 17
are valid. Default = qotd(tcp) and qotd(udp).
 
  syslog If set, the system log is used for logging, and any subsequent references to a log file are ignored. Note that this variable is ignored if the -d command line flag is specified. Default = 1.  
  log_file If the syslog variable is not set, the file specified is used as a log file. Note that this variable is ignored if the -d command line flag is specified. Default = /var/log/qotdd.log  
  user If the server is started by root, to enable binding to port numbers below 1024, aqotdd will attempt to change to this user after starting. Can be given either as a string username or as a numerical user id, 500 This option is also ignored if the -d command line flag is given. Default = nobody. Note that if the user/userid given doesn't exist, aqotdd will try 'nobody', and if that fails, will remain as root. If not started by root, it will still attempt to change userid, and should fail silently, remaining as the calling user.  
  daemon Set to 0 or 1. If this is set to 1, and the -d flag is not given, aqotdd will detach from the current terminal, and put itself in the background; becoming a daemon. Default = 1.  

Run-Time configurable variables.

After editing the configuration file, these variables can be changed in a running server by sending the process a SIGHUP, eg by executing killall -HUP aqotdd (On Linux only - on other OS's, use pidof or ps to find (substituting SIGHUP for HUP as appropriate.))

  log_count Set to 0 or 1. If this is set to 1, then every mark_time seconds a report of the form Counts: X(udp),Y(tcp): Last Stat Z(seconds). will be generated if the total of tcp/udp connections is non-zero. The time Z gives the actual number of seconds since the last report, which will be a multiple of mark_time, depending on the server load.
X Represents the number of TCP connections in the last Z seconds.
Y Represents the number of UDP connections in the last Z seconds.
Default = 1
 
  mark_time Set to an integer value. If non-zero, specifies the time in seconds between printing reports to the log, and also flushing any outstanding log entries, in the case that a log file is being used. Default = 600  
  log_msg Set between 0 and 4. Defines how many messages are written to the log being used. 0 - Only fatal and vital messages. 4 - Lots of chatter. Not quite 'for loop completed successfully' 400 time a second, but close. Default = 2  
  log_con Takes a value between 0 and 3, and determines how much detail is recorded on each incoming connection.
0 Nothing.
1 IP address of remote client.
2 IP address and hostname (if available) of the remote client.
3 UDP: Same as 2.
TCP: As 2, also performs an RFC1413 style identd lookup on the remote user.
Default = 2
 
  chk_con Set to 0 or 1. If set, the incoming connection is checked according to the rules specified in the order, allow and deny configuration variables, described below. If the connection passes the tests, a quote is returned as normal, otherwise nothing is returned. In this event, a message is printed to the log (where it exists) with the IP address of the denied client. Default = 0.  
  order Set to 0 or 1. If set to 1 (deny, allow) the 'deny' list is checked first, if 0, the 'allow' list is checked first. Default = 0.  
  allow    
  deny A list of IP groups to be respectivly allowed and denied access to the server. May be specified as:
  1. An IP address/netmask combination:
    192.168.17.0/255.255.255.0
    which matches all 192.168.17.* addresses.
  2. An (in)complete IP number. The missing fields are then treated as wildcards:
    192.168
    is treated as 192.168.0.0/255.255.0.0 and will match all 192.168.*.* addresses.
  3. An IP/number of bits specification.
    192.168.17.0/8
    is treated as 192.168.17.0/255.0.0.0 and will match all 192.*.*.* addresses.
  4. A single IP address. (degenerate case of b)
    192.168.17.40
    will just match that IP.
  5. Everything.
    all
    matches all IP addresses.
Defaults: Allow = all. Deny = all.

In determining whether or not the connection is allowed, the order determines the effective default. The following table summerises which con- nections will be accepted (Result=1) or refused (Result=0), when the incoming IP address matches (=1) or does not match (=0) the allow and deny rules:
OrderAllowDenyResult 
1110 
1101 
1010 
1000 
0111 
0101 
0010 
0001 

NOTE : Note that the effect of screening TCP connection may not reduced network traffic as much as expected in the event of abuse: 'Denying' a TCP connection only saves the actual quote being sent, which with the 'rfc' option set will typically be only one packet out the *lots* needed to establish a TCP connection in the first place. A better solution is to use a OS based firewall/packet filter type thing: see man ipchains on Linux, for example.

 
  max_tcp    
  max_udp Set to an integer number, specifies the maximum number of TCP/UDP clients that allowed to connect to aqotdd per second. Defaults = 50(TCP), 1000(UDP)  
  rfc865 Set to 0 or 1. If set, the returned quotes are firstly restricted to 512 bytes, and secondly all non-printing characters (apart from line feed/carriage returns) are removed, to ensure full compliance with RFC865. Default = 1.  
  abs_min    
  abs_max Set to integers. Defines the minimum and maximum length quotes returned by aqotdd. Note that abs_max is overridden by rfc865, if set. Defaults = 8192/20.  
  offensive Set to 0 or 1. If set, rot13 encoded quotes will be decoded and sent, otherwise they will be ignored.
NOTE: The server only checks to see if the quote is certainly can't do that for the client users. Please check the fortune database for offensiveness first, making sure that offensive fortune files are not *just* marked with the name-o convention.
ALSO NOTE: Running a publicly accessible server with some of the 'offensive' fortune quote files I've seen may be illegal in your country. (Due to racist/sexist/homophobic, etc material being pre- sent.)
- In other words, only turn this on if you really mean it. Please.
Default = 0.
 
  directory The directory where the fortune - style quote files are located. Generally /usr/share/games/fortunes on RedHat based systems, can be in /usr/games/lib/for- tunes on some (Slackware, for example) systems. Check your fortune(6) installation for details. Note that this directory should be readable by the user aqotdd changes to after startup. Default = /usr/share/games/fortunes/ 

NOTE ON DEFAULTS

Note that on compilation of the source code to aqotdd, the generated aqotdd.conf will be set up to the same defaults as was set in config.h, as will the internal defaults and this man page. Ask whoever compiled the source if the behavior is wildly different from that described here.

QUOTE FILE FORMAT

See the man page for strfile(1). aqotdd use the same for- mat, with the possible exception that 'offensive' quotes are only marked by having the STR_ROTATED flag set (i.e. by being rot13 encoded.); the convention of adding the '-o' extension to the filename is ignored

CREDITS

The names owes something (everything?) to the original fortune program, and the server needs fortune style text/.dat files to work. Apart from that, it's all new(ish) code. Thanks to the compilers of the unix programming FAQ, the unix network programming FAQ's, the author(s) of nmap, etc.

HISTORY

This was originally written because just putting
/usr/games/fortune
in inetd.conf was too slow on my 386 - because fortune(6) takes too long to start - and it turns out that that isn't in accordance with the RFC in any case. So aqotdd was born, which hangs about with all the fortune .dat files loaded into, and wasting, memory but is then much faster to respond.

FILES

/etc/services
Used for mapping service name to port number.

$PREFIX/etc/aqotdd.conf
Location of configuration file, if not overridden on the command line.

/usr/share/games/fortunes , /usr/games/lib/fortunes
Possible location of quote files. (on RedHat, Slackware).

BUGS

The code's a mess, but everything seems to work properly. It doesn't even seem to leak memory. Even reading and parsing the configuration files works, and I'm hopeless at string parsing in C.

Who knows what will happen in practice? Probably half the 5<r1pT |<1|>|>135 on the internet will have root on your box within 10 minutes of installing this - despite the fact that it's supposed to drop root and I think I've done the RightThing(tm) wherever I was supposed to. Check the code! Let me know!

Bug reports to: aoqtdd-bug@afghanhound.org.uk

Last updated for version 0.7.0 at 16:02:10 on Mar 30 2001.

SEE ALSO

fortune-tcp(6), fortune-udp(6), fortune(6), strfile(1), rfc865, tcpbench(6), udpbench(6), rfc1413.


Man(1) output converted with man2html

Go back to the AQOTDD home page.

Afghan WebBug
   Also by this author: If you've enjoyed this page, you're probably insane. Why not try one of these as well?
Javascript Turtle  Fear of Flying  Office Quake Stats  Psychotherapist  
 
     Comments?    Links    About Last modified 03:44 pm, 29/04/03