home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / ck9196.zip / iksd.txt < prev    next >
Text File  |  2000-01-01  |  62KB  |  1,439 lines

  1.           IKSD - The Internet Kermit Service Daemon
  2.  
  3.               UNIX SYSTEM ADMINISTRATOR'S GUIDE
  4.  
  5.                   The Kermit Project
  6.                  Columbia University
  7.                http://www.columbia.edu/kermit/
  8.  
  9.               Sat Jan  1 14:40:34 2000
  10.  
  11.  
  12. The Internet Kermit Service Deamon (IKSD) is C-Kermit 7.0 or later, started
  13. in a special way.  At this writing, only the UNIX version of C-Kermit
  14. contains IKSD functions, but these can be (easily?) added to the VMS, VOS,
  15. AOS/VS, and other versions too.
  16.  
  17.  
  18. CONTENTS
  19.  
  20.   1.   Why IKSD?
  21.   2.   System Configuration
  22.   3.   Compile-Time Configuration Options
  23.   4.   Runtime Configuration Options
  24.   4.1.   Command-Line Options
  25.   4.2.   System Logging
  26.   4.3.   The IKSD Log File
  27.   4.4.   IKSD Configuration File
  28.   4.5.   Initialization File
  29.   5.   Access to Services
  30.   5.1.   Automatic Settings
  31.   5.2.   Authentication
  32.   5.3.   The DISABLE Command
  33.   5.4.   Shell Access
  34.   5.5.   Anonymous Users
  35.   5.6.   Management Information
  36.   6.   Open Issues
  37.   6.1.   Connection Establishment
  38.   6.2.   Shell Access
  39.   6.3.   External and/or non-Kermit Protocols
  40.   6.4.   Additional Administrative Controls
  41.   6.5.   Known Bugs
  42.   7.   Monitoring
  43.   7.1.   Database Record Format
  44.   7.2    The Display Module
  45.   7.3.   Database Management
  46.   8.   Testing
  47.  
  48.  
  49. 1. Why IKSD?
  50.  
  51. Why run an Internet Kermit Service Daemon when you are already running
  52. an FTP server?
  53.  
  54.  . Like FTP, Kermit provides a service that can be accessed from many
  55.    different platforms with a consistent set of commands, but unlike FTP,
  56.    these commands include programming constructions such as variables,
  57.    arrays, looping and selection mechanisms, and local and remote procedure
  58.    calls, thus allowing file transfer and management operations of arbitrary
  59.    complexity to be easily automated.
  60.  
  61.  . Like FTP, Kermit provides both text- and binary-mode data transfer, as
  62.    well as file management capabilities.  But Kermit also offers numerous
  63.    features lacking from FTP, such as character-set translation, flexible
  64.    file selection mechanisms, preservation of timestamps and permissions,
  65.    automatic per-file text/binary mode switching (important in cross-platform
  66.    transfers), cross-platform directory-tree transfer, and a selection of file
  67.    collision options including "make backup copy of existing file and accept
  68.    incoming file", "reject incoming file", "accept incoming file only if newer
  69.    than existing file", etc.
  70.  
  71.  . Unlike FTP, Kermit supports atomic file movement, in which the source
  72.    file can be deleted (or renamed, or moved) when and only when it has been
  73.    transferred successfully, as part of the transfer operation itself.
  74.  
  75.  . Unlike most FTP implementations, Kermit supports recovery of interrupted
  76.    transfers from the point of failure.  You can even use it to recover
  77.    interrupted FTP transfers when FTP itself does not offer this option.
  78.  
  79.  . Unlike standard FTP, Kermit can transfer data through firewalls or
  80.    proxies or NATs on a single well-known port (unless the TCP port for the
  81.    connection has been explicitly filtered).
  82.  
  83.  . Unlike FTP, Kermit can transfer data across a combination of transports
  84.    (e.g. dial-up to a terminal server and thence to an Internet host).
  85.  
  86.  . Authentication and data transfer can take place over secure connections
  87.    (mutually authenticated and encrypted) using established Telnet
  88.    authentication and encryption options.
  89.  
  90.  . Unlike traditional Kermit use over Telnet, anonymous access is possible,
  91.    and the considerable overhead of the intervening Telnet server and
  92.    pseudoterminal service is eliminated.
  93.  
  94.  . Unlike the FTP daemon (ftpd), the IKSD can be monitored in real time
  95.    by the system administrator (see Section 7).
  96.  
  97. A prototype IKSD is available for public access at:
  98.  
  99.   kermit.columbia.edu, port 1649
  100.  
  101. This service is based in part on a new Telnet Kermit Option described in an
  102. Internet Draft:
  103.  
  104.   ftp://ftp.ietf.org/internet-drafts/draft-altman-telnet-kermit-server-01.txt
  105.  
  106. The Internet Kermit Service itself is discussed in a separate Internet Draft:
  107.  
  108.   ftp://ftp.ietf.org/internet-drafts/draft-columbia-kermit-service-01.txt
  109.  
  110.  
  111. 2. System Configuration
  112.  
  113. WARNING: Do NOT attempt to install a pre-7.0 version of C-Kermit as an IKSD.
  114. Earlier versions do not perform the necessary authentication and security
  115. functions, and therefore will leave your system wide open to anonymous root
  116. access.  (Don't worry, the installation procedure described here, if you
  117. follow it, and the interface to IKSD, prevent you from starting an earlier
  118. version of C-Kermit as an IKSD, since it lacks the needed command-line
  119. options and will halt with a usage message if you try to use them.)
  120.  
  121. Directory organization, file system, naming conventions, and other
  122. administrative details vary from system to system and site to site, so
  123. specific instructions can not be given here.  In general, however, the steps
  124. are:
  125.  
  126.  a. The C-Kermit executable should be copied to the directory that is
  127.     normally used for launching Internet services, and renamed to "iksd".
  128.     Normally the owner and group should be root and the permission 0750.
  129.  
  130.  b. The following entry should be added to the Internet services file,
  131.     normally /etc/services:
  132.  
  133.       kermit   1649/tcp
  134.  
  135.  c. An entry must be made in the inetd configuration file, normally
  136.     /etc/inetd.conf.  See your system-specific documentation for the
  137.     name, location, and format of this file, e.g. "man inetd" and
  138.     "man inetd.conf".  A typical example might be:
  139.  
  140.       kermit  stream  tcp  nowait  root  iksd -A <other-iksd-options>
  141.  
  142.     Or, with TCP wrappers:
  143.  
  144.       kermit  stream  tcp  nowait  root  tcpd iksd -A <other-iksd-options>
  145.  
  146.     Include full pathnames for tcpd and iksd if required.  See Section 4
  147.     for <iksd-options>.
  148.  
  149.     NOTE: Different platforms might require different syntax, e.g.:
  150.  
  151.       kermit stream tcp nowait root /usr/sbin/iksd iksd -A <other-iksd-options>
  152.  
  153.  d. When using TCP wrappers, make the appropriate entries in its
  154.     configuration file(s), such as /etc/hosts.allow and /etc/hosts.deny.
  155.     See the TCP wrappers documentation for further info.
  156.  
  157.  e. Make any required hard or soft links to the iksd executable.
  158.  
  159.  f. If desired, create an IKSD configuration file (/etc/iksd.conf by default).
  160.  
  161. This setup allows multiple simultaneous IKSD sessions.  A fresh IKSD process
  162. is started for each session, and disappears when IKSD exits, automatically
  163. closing the session and the connection.
  164.  
  165. To kill a particular instance of IKSD, find its pid with "ps ax | grep iksd",
  166. and then kill -9 <pid> (as root).
  167.  
  168. To update the IKSD program, simply replace the executable in the "launch"
  169. directory ((a) above).
  170.  
  171. To discontinue IKSD service quickly, delete the iksd executable, or (to avoid
  172. unwanted console logging) replace it with (say) /bin/false.
  173.  
  174.  
  175. 3. Compile-Time Configuration Options
  176.  
  177. You can use any C-Kermit configuration as an IKSD, ranging from a fully
  178. configured version, to a special IKSD-Only version, to any of the various
  179. "stripped-down" versions, as described in the C-Kermit Configuration Guide
  180. (ckccfg.txt) and/or Installation Instructions (ckuins.txt).
  181.  
  182. The following compile-time options are specific to or of special relevance
  183. to the IKSD:
  184.  
  185. TNCODE - Required for IKS.
  186.   Include Telnet protocol code, even if networking code is not included.
  187.   Defined by default if TCPSOCKET defined, otherwise must be defined
  188.   explicitly.
  189.  
  190. IKS_OPTION - Required for IKS.
  191.   Include code for the new Internet Kermit Service Option.
  192.   Currently defined automatically if TNCODE is defined.
  193.  
  194. CK_LOGIN - Required for IKS.
  195.   Include user authentication code.  Defined automatically for UNIX unless
  196.   NOLOGIN defined.
  197.  
  198. CK_PAM
  199.   The IKS is to be compiled to use PAM (Pluggable Authentication Modules)
  200.   to authenticate the user for interactive logins instead of Unix password
  201.   files.  The default PAM service type for IKSD is "kermit".
  202.  
  203. PAM_SERVICE_TYPE
  204.   If CK_PAM is defined and you wish to use a service type other than
  205.   "kermit" you can define PAM_SERVICE_TYPE to equal the string you
  206.   wish to use.
  207.  
  208. CK_SHADOW
  209.   If your host utilizes the shadow password system for storing user
  210.   passwords the IKS must be compiled with support for shadow passwords.
  211.   This might also require some additional libraries added the LIBS
  212.   clause, such as -lgen, for loading the getspnam() routine.
  213.  
  214. CKSYSLOG
  215.   Include code for making syslog entries.  This symbol is defined
  216.   automatically if (a) CK_LOGIN is defined; (b) UNIX is defined; and (c)
  217.   NOSYSLOG is not defined.
  218.  
  219. CKWTMP
  220.   Include code for making wtmp log entries.  This symbol is defined
  221.   automatically if (a) CK_LOGIN is defined; (b) UNIX is defined; and (c)
  222.   NOWTMP is not defined.
  223.  
  224. WTMPFILE
  225.   String containing pathname of the default wtmp logfile.  If not specified,
  226.   a default is supplied, currently /var/log/wtmp on Linux and /usr/adm/wtmp
  227.   elsewhere.  The wtmp file can also be specified at runtime; see next
  228.   section.
  229.  
  230. CK_CURSES
  231.   Need not be defined in an IKSD-only build, since curses is used only
  232.   in local mode, and the IKSD is always in remote mode, plus the fact that
  233.   curses initialization can cause spurious error messages in IKSD since it
  234.   might not have a terminal type (TERM variable) in its environment.
  235.  
  236. NOLOCAL
  237.   This may be defined to exclude all code relating to the making of
  238.   both serial and network connections from the C-Kermit/IKSD executable.
  239.   This code is presently not needed, and is never used, in the IKSD.
  240.   Compiling it out reduces the size of the executable and eliminates any
  241.   possibility that a loophole could be exploited to use the IKSD as a
  242.   relay.
  243.  
  244. NOPUSH
  245.   This symbol may be defined to exclude all code that is used to access
  246.   local shell or system functions, such as the RUN (!) command, the server
  247.   end of the REMOTE HOST command, file-transfer pipes and filters, etc.
  248.   Note that such code is disabled at runtime in the IKS anyway; compiling
  249.   it out completely reduces the size of the executable and the risk of
  250.   loopholes.
  251.  
  252. NOICP
  253.   Disables the interactive command parser as well as long-form command-line
  254.   options (Section 4.1).  In this configuration, the IKS runs only in Kermit
  255.   Server mode, and the size of the executable is reduced dramatically.
  256.   WARNING: NOICP also inhibits extended command-line options (the ones that
  257.   start with "--"), since these share the same parsing routines as the
  258.   interactive parser.
  259.  
  260. NOSPL
  261.   Disables the script programming language (INPUT, OUTPUT, FOR, WHILE,
  262.   IF, SWITCH, macros, variables, etc) without disabling the interactive
  263.   command parser.
  264.  
  265. NOGETUSERSHELL
  266.   Add this if the link steps fails because it can't resolve getusershell()
  267.   and/or endusershell().  Normally, IKSD will refuse a login if the user's
  268.   login shell is not one of those returned by getusershell() (normally,
  269.   getusershell() simply lists the shells listed in /etc/shells, but we
  270.   can't depend on this).  Thus if your site "invalidates" user IDs by
  271.   setting their login shell to something that is not really a shell (like
  272.   /etc/nologin), but does not have a getusershell() function, IKSD will
  273.   still let such users log in unless (a) you put them in the forbidden
  274.   users file (see Section 4.1), or (b) add some code to ckufio.c to check
  275.   for whatever invalid or valid shells might apply at your site.
  276.  
  277. NOIKSD
  278.   This defines the symbols NOLOGIN, NOSYSLOG, NOWTMP, NOPRINTFSUBST, which
  279.   in turn prevent the definition of symbols (CK_LOGIN, CKSYSLOG, etc) that
  280.   cause IKSD-specific code to be included.
  281.  
  282. CK_SYSINI
  283. CK_DSYSINI
  284.   System-wide initialization file; see Section 4.4.
  285.  
  286. IKSD
  287.   Is defined automatically if NOIKSD is not defined.
  288.  
  289. IKSDCONF
  290.   The name of the IKSD configuration file.  In UNIX this is
  291.   "/etc/iksd.conf" by default; elsewhere "iksd.cfg".
  292.  
  293. In an IKSD-only build, you should omit the termcap/termlib and (n)curses
  294. libraries, and set up the link step to make sure the IKSD is linked with
  295. the same user authorization libraries used by your local login program.
  296. Here is a sample for SunOS 4.1.3 at a particular site:
  297.  
  298. sunos41giks:
  299.     @echo Making C-Kermit $(CKVER) for SunOS 4.1 with gcc for IKS...
  300.     $(MAKE) wermit "CC= gcc" "CC2= gcc" \
  301.     "CFLAGS= -O -DSUNOS41 -DNDGPWNAM \
  302.     -DTNCODE -DNOLOCAL -DNOPUSH $(KFLAGS)" \
  303.     "LIBS= -L/usr/local/lib -lpwent -lcrypt"
  304.  
  305. -DNOLOCAL: excludes all code that is used to make connections.
  306. -DNOPUSH:  excludes all code that accesses local system shells and commands.
  307. -DTNCODE:  includes Telnet protocol code even though -DNOLOCAL is included.
  308.  
  309. At sites that use shadow passwords, you'll need to add -DCK_SHADOW to CFLAGS
  310. and perhaps -lgen to LIBS.
  311.  
  312. Also note that the crypt() function, which is used for verifying passwords,
  313. is normally found in libc, but on some platforms it has been broken out into
  314. a separate library, such as -lcrypt, and in that case must be included in
  315. the LIBS clause.
  316.  
  317. For PAM installations, here's an example /etc/pam.d/kermit file that uses
  318. EPS password files for user authentication and the standard unix modules for
  319. account and session management:
  320.  
  321.   auth      required       /lib/security/pam_eps_auth.so
  322.   password  required       /lib/security/pam_eps_passwd.so
  323.   account   required       /lib/security/pam_unix_acct.so
  324.   session   required       /lib/security/pam_unix_session.so
  325.  
  326. Kerberos IV, Kerberos V, and/or SRP, or any other authentication / security
  327. mechanism may be also selected at build time if you have the appropriate
  328. libraries and header files installed on your system.  See security.txt
  329. for further details.
  330.  
  331. For a build that excludes all IKSD functions, it is normally sufficient
  332. to add NOIKSD to the CFLAGS, e.g.:
  333.  
  334.   make aix41 KFLAGS=-DNOIKSD
  335.  
  336.  
  337. 4. Runtime Configuration Options
  338.  
  339. The IKSD can be configured at runtime with command-line options or by an
  340. initialization file or other auxilliary file(s), in any combination.
  341.  
  342. 4.1. Command-Line Options
  343.  
  344. To start C-Kermit as an Internet Kermit Service Daemon, include the '-A'
  345. command-line option.  This option not only configures C-Kermit as an IKSD, but
  346. it also ensures that you are running a version of C-Kermit that can do this,
  347. i.e. C-Kermit 7.0 or later built with all the necessary compile-time options
  348. (Section 3).  If either of these conditions does not apply, the '-A' option
  349. will be invalid and the Kermit program will halt immediately.
  350.  
  351. In addition to -A and the command-line options described in "Using C-Kermit"
  352. (2nd Edition), plus any other new ones described in the ckermit2.txt file, a
  353. selection of new long-form options apply specifically to the IKSD.  Long-form
  354. options work as follows:
  355.  
  356.  a. All long-form options must begin with "--" (two hyphens) or "-+".  If the
  357.     option begins with "--" it is executed before or after the C-Kermit
  358.     initializaton file, according to its internal keyword flags.  If it
  359.     begins with "-+", it is executed before the init file, regardless of the
  360.     keyword flags.  There is no way to force an argument to be executed after
  361.     the init file if it has the CM_PRE bit set (see table below).
  362.  
  363.  b. No spaces are allowed in the keyword.
  364.  
  365.  c. If an operand contains spaces, it (or the entire option) must be quoted
  366.     according to the rules of the shell from which Kermit is invoked.
  367.  
  368.  d. Case doesn't matter in the option keyword (unlike with regular
  369.     single-letter options).
  370.  
  371.  e. If an operand is required, it must be included.  If no operand is
  372.     required, no operand must be included.
  373.  
  374.  f. The operand follows the keyword, separated by a colon (:) or equal
  375.     sign (=).  There are no spaces between the separator and the keyword
  376.     or operand.
  377.  
  378.  g. Long-form option names may be abbreviated according to the same rules as
  379.     interactive keywords.
  380.  
  381.  h. On/Off operands can be On, Off, Yes, No, True, False, 0, 1, or OK (case
  382.     of letters does not matter).
  383.  
  384.  i. Long-form options are available only when the interactive command parser
  385.     is built-in (i.e. not NOICP).
  386.  
  387. The new long-form options are:
  388.  
  389.   Option        Values    Default      CM_PRE   Effect
  390.  
  391.   --anonymous   on/off    on             yes    anonymous login allowed
  392.   --bannerfile  filename  (none)         no     greeting message
  393.   -+cdfile      filelist  (see below)    no     CD message filename
  394.   -+cdmessage   on/off    on             no     CD messages on/off
  395.   -+cdmsg       on/off    on             no     synonym for cdmessage
  396.   --help        (none)    (n/a/)         no     list available --options
  397.   --helpfile    filename  (none)         no     custom text for HELP command
  398.   --initfile    filename  /.kermrc       yes    Init file for anonymous users
  399.   --nointerrupt (none)    (see below)    yes    Disables SIGINT and SIGTSTP
  400.   --permissions octalnum  0040           yes    anonymous upload permissions
  401.   --perms       octalnum  0040           yes    synonym for permissions
  402.   --root        directory /pub/ftp       yes    root for anonymous users
  403.   --syslog      number    3              yes    level of syslogging
  404.   --timeout     number    300            yes    time limit for login
  405.   --userfile    filename  /etc/ftpusers  yes    forbidden local users list
  406.   --wtmplog     on/off    on             yes    wtmp logging on/off
  407.   --wtmpfile    filename  (see below)    yes    pathname of wtmp logfile
  408.   --xferlog     on/off    off            yes    use an ftpd-logfile
  409.   --xferfile    filename  (see below)    yes    pathname of ftpd-like logfile
  410.  
  411. Note: in all options that take a <filename>, EXCEPT --cdfile, relative
  412. filenames or filenames that start with ~ are expanded to full pathnames.
  413.  
  414. In more detail:
  415.  
  416. --nointerrupts
  417.   Disables keyboard interrupts that are normally ensabled.  In IKSD, when it
  418.   is in interactive prompting state, commands can normally be interrupted
  419.   with Ctrl-C.  Suspending (normally via Ctrl-Z) is always disabled in IKSD.
  420.  
  421. --help
  422.   Lists the extended command-line options that are available in your version
  423.   of C-Kermit.  If any options seem to be missing, that is because your
  424.   copy of C-Kermit was built with compile-time options to deselect them.
  425.  
  426. --helpfile:<filename>
  427.   Specifies the name of a file to be displayed if the user types HELP
  428.   (not followed by a specific command or topic), in place of the built-in
  429.   top-level help text.  The file need not fit on one screen; more-prompting
  430.   is used if the file is more than one screen long if COMMAND MORE-PROMPTING
  431.   is ON, as it is by default.
  432.  
  433. --anonymous:{on,off}
  434.   Whether anonymous logins are allowed.  By default they are allowed, so
  435.   this option need be included only to disallow them (or for clarity, to
  436.   emphasize that they are allowed).  Anonymous login occurs when the username
  437.   "anonymous" or "ftp" is given, with any password (as with ftpd).
  438.  
  439. --timeout:<number>
  440.   This sets a limit (in seconds) on the amount of time the client has to log
  441.   in once the connection is made.  If successful login does not occur within
  442.   the given number of seconds, the connection is closed.  The default timeout
  443.   is 300 seconds (5 minutes).  A value of 0 or less indicates there is to be
  444.   no limit.
  445.  
  446. --bannerfile:<filename>
  447.   The name of a file containing a message to be printed after the user logs
  448.   in, in place of the normal message (Copyright notice, "Type HELP or ? for
  449.   help", "Default transfer mode is...", etc).
  450.  
  451. --permissions:<octalnum>
  452.   The permissions given to any file that is uploaded by an anonymous user.
  453.   0040 is the default and recommended value.  The default permits only
  454.   group-read access, and therefore prevents anonymous users from uploading
  455.   files (e.g. pirated sofware) to be downloaded by other anonymous users.
  456.   Synonym: --perms.
  457.  
  458. --initfile:<filename>
  459.   The initialization file to be executed for anonymous logins.  By default
  460.   it is /.kermrc, where "/" is the root of the chroot'd file system.  Any
  461.   <filename> that you specify here must be specified in the notation of the
  462.   the chroot'd file system.  This option is independent of the '-y' option
  463.   (alternative init file), which applies only to real users.
  464.  
  465. --cdmessage:{on,off,0,1,2}
  466.   For use in the Server-Side Server configuration; whenever the client
  467.   tells the server to change directory, the server sends the contents of a
  468.   "read me" file to the client's screen.  This feature is On by default,
  469.   and operates only in client/server mode when ON or 1.  If set to 2 or
  470.   higher, it also operates when the CD command is given at the IKSD> prompt.
  471.   Synonym: --cdmsg.
  472.  
  473. --cdfile:<filename> (or list)
  474.   When cdmessage is on, this is the name of the "read me" file to be sent.
  475.   Normally you would specify a relative (not absolute) name, since the file
  476.   is opened using the literal name you specified, after changing to the new
  477.   directory.  Example:
  478.  
  479.     --cdfile:READ.ME
  480.  
  481.   You can also give a list of up to 8 filenames by (a) enclosing each
  482.   filename in braces, and (b) enclosing the entire list in braces.  Example:
  483.   --cdfile:{{./.readme}{READ.ME}{aaareadme.txt}{README}{read-this-first}}
  484.   When a list is given, it is searched from left to right and the first
  485.   file found is displayed.  The default list for UNIX is:
  486.  
  487.     {{./.readme}{README.TXT}{READ.ME}}
  488.  
  489. --database:{on,off}
  490.   Whether an active-sessions database should be kept.  On by default.
  491.   If "on", but --dbfile is not specified, /var/log/iksd.db is used.
  492.   If this is not the appropriate directory for your computer, use the
  493.   --dbfile: option to specify the path that should be used.
  494.  
  495. --dbfile:<filename>
  496.   Use this option to specify an iksd database file name.  If you include
  497.   this option, it implies --database:on.
  498.  
  499. --syslog:<number> or {on,off}
  500.   Whether and what level of syslog entries should be made.  A level of 0
  501.   (or "off" or "false" or "no") means no syslogging.  A level of "on" (or
  502.   "yes" or "true") invokes the default syslogging level.  To choose a
  503.   non-default level of syslogging, specify a number (see Section 4.2).
  504.  
  505. --wtmplog:{on,off}
  506.   Whether wtmp log entries should be made.  On by default.  An entry is made
  507.   when the user logs in and when the session is closed.  The "tty name" field
  508.   is given as "iks_xxxx", where xxxx is the process ID (pid) of the IKSD.
  509.   Thus IKSD session history can be monitored via "last | grep iks_".
  510.   Anonymous logins are shown with a user ID of "ftp".
  511.  
  512. --wtmpfile:<filename>
  513.   The default wtmp log file is /var/log/wtmp in Linux, and /usr/adm/wtmp
  514.   elsewhere.  In case your system's wtmp log file does not match the default,
  515.   use this option to specify the appropriate filename.
  516.  
  517. --userfile:<filename>
  518.   This file contains a list of local usernames that are to be denied access
  519.   to Internet Kermit Service.  The default is /etc/ftpusers.  This can be the
  520.   same file that is used by wuftpd, and the syntax is the same: one username
  521.   per line; lines starting with "#" are ignored.  Use this option to specify
  522.   the name of a different forbidden-user file, or use --userfile:/dev/null
  523.   to disable this feature in case there is a /etc/ftpusers file but you
  524.   don't want to use it.
  525.  
  526. --xferlog:{on,off}
  527.   Whether a wu-ftpd-like log should be kept.  Off by default.  If "on", but
  528.   --xferfile is not specified, /var/log/iksd.log is used.  This log is
  529.   explained in Section 4.3.
  530.  
  531. --xferfile:<filename>
  532.   Use this option to specify an iksd log file name.  If you include this
  533.   option, it implies --xferlog:on.
  534.  
  535. --database:{on,off}
  536.   Whether an active-sessions database should be kept.  On by default.
  537.   If "on", but --dbfile is not specified, /var/log/iksd.db is used.
  538.  
  539. --dbfile:<filename>
  540.   Use this option to specify an iksd database file name.  If you include
  541.   this option, it implies --database:on.
  542.  
  543. Some of the traditional options have special significance in the IKS, e.g.:
  544.  
  545. -x (server mode).
  546.   If this option is included on the IKSD command line, the Client Side Server
  547.   configuration is disabled, and the user will not get a Username: or
  548.   Password: prompt, and will not be able to access the IKSD command prompt.
  549.   A FINISH command sent to the IKSD will log it out and close the
  550.   connection, rather than returning it to its prompt.
  551.  
  552. -y filename
  553.   Execute "filename" rather than the normal initialization file for real
  554.   users; this option does not apply to anonymous users.
  555.  
  556. -Y (no init file)
  557.   Do not execute an initialization file, even if a real user is logging in.
  558.  
  559. Examples:
  560.  
  561. iksd -A
  562.   Starts the Internet Kermit Server with all defaults in effect.
  563.  
  564. iksd -A --syslog:5
  565.   As above, but with the highest level of syslogging (section 4.2).
  566.  
  567. iksd -A --anonymous:off --cdfile:READ.ME
  568.   Starts the IKSD with anonymous access forbidden and changes the name of
  569.   CD message file from the default list to READ.ME.
  570.  
  571. iksd -A -x --anonym:no --cdf:READ.ME
  572.   As above, but forces the IKSD to operate only in Kermit server mode,
  573.   thus preventing user access to the IKSD command prompt.  Also illustrates
  574.   abbreviation of long-form option keywords and use of "no" as a synonym
  575.   for "off".
  576.  
  577. Bad syntax in an extended command-line option causes immediate termination
  578. with the message "Extended option error", and an exit status code of 1.
  579.  
  580. Brief help about command line options may be obtained at the C-Kermit prompt
  581. with "help options", and for extended options with "help extended-options".
  582.  
  583. You can prototype the IKSD command line by including any desired extended
  584. options, but omitting the -A option, and then when you get the C-Kermit>
  585. prompt, use "show extended-options" to check the parsing of the options you
  586. have included.  Example:
  587.  
  588. $ kermit --anonymous:ok --root:/tmp --userfile:/etc/badusers
  589. (/usr/olga/) C-Kermit>show extended-options
  590.  --bannerfile=(null)
  591.  --cdfile:./.readme
  592.  --cdmessage:0
  593.  --syslog:3
  594.  --wtmplog:1
  595.  --wtmpfile=(null)
  596.  --anonymous:1
  597.  --permission:0040
  598.  --initfile:(null)
  599.  --userfile:/etc/badusers
  600.  --root:/tmp
  601.  --xferlog=0
  602.  --xferfile=(null)
  603.  --timeout:300
  604. (/usr/olga) C-Kermit>
  605.  
  606. Note that this only shows the values that were given as arguments to the
  607. extended options, or their default values, if they have any, but it does
  608. not show values that will be computed dynamically at runtime in the absence
  609. of a command-line value.  For example, --wtmplog:1 and --wtmpfile:(null)
  610. mean that an appropriate default will be supplied for the wtmp logfile name
  611. at runtime.
  612.  
  613. Also note that SHOW EXTENDED-OPTIONS does not show the IKSD-specific options
  614. when this command given at the IKSD prompt by the user.  Thus this command
  615. is useful only as a prototyping tool.  (And as noted elsewhere, the IKSD
  616. command-line argument vector is also inaccessible to the IKSD user via other
  617. methods such as the \&@[] array.)
  618.  
  619. 4.2. System Logging
  620.  
  621. System logging in UNIX is via the standard syslog() facility ("man syslog"
  622. and/or "man syslogd" for further info).
  623.  
  624. All IKSD entries (except debugging, see below) appear in the daemon log, as
  625. defined in the syslog.conf file with a tag of "iksd" and the process ID (pid)
  626. of the IKSD process, and therefore can be extracted by grepping for "iksd".
  627.  
  628. The system logging levels are:
  629.  
  630.   0 = no logging
  631.   1 = Login/out, failed login attempts, failed Kerberos (etc) authentication
  632.   2 = Dialing out (does not apply to IKSD)
  633.   3 = Making any kinds of connections (does not apply to IKSD)
  634.   4 = Creating / receiving / deleting / renaming / copying files
  635.   5 = Sending / typing / reading / transmitting files
  636.   6 = All top-level commands and all server commands sent to iksd
  637.   7 = Commands executed from macros and command files
  638.   8 = Debug
  639.  
  640. Each level includes all the levels beneath it (except 0 is not included if
  641. the logging level is greater than 0).
  642.  
  643. The default logging level is 5, and is used if the --syslog: option is not
  644. included on the command line, or if is given with an affirmative keyword
  645. (yes, true, on, ok) rather than a number.  If you specify a number higher than
  646. the the maximum, it is the same as specifying the maximum.
  647.  
  648. Syslog entries are at LOG_INFO priority, except for refused logins, which
  649. are at LOG_NOTICE priority, and failed Telnet-level authentication (such as
  650. Kerberos), which are at LOG_ERR priority.
  651.  
  652. Note that if C-Kermit is built with -DSYSLOGLEVEL=n (where n is a number) on
  653. the cc command line, this turns on syslogging and hardwires it to the given
  654. level for all users.  See ckuins.txt for further info.
  655.  
  656. WARNING: Debug level produces VOLUMINOUS amounts of information -- it is
  657. equivalent to (in fact, it *is*) C-Kermit's debug log.  Furthermore, there is
  658. a good possibility it will contain sensitive information such as clear-text
  659. passwords.  Debug records are written to the syslog DEBUG facility, as defined
  660. (or not defined) in syslog.conf.  If you use this level of logging, make sure
  661. that the logfile defined for "daemon.debug" is secured from the public, and
  662. that there is plenty of space for it.
  663.  
  664. ANOTHER WARNING: In some UNIX systems, syslogging does not work once a
  665. chroot() has occurred, which is done by iksd just as it is by ftpd for
  666. anonymous users, to restrict them to the /pub/ftp (or other desired) directory
  667. tree.  At present, SunOS and Linux are known to have this deficiency and there
  668. probably are many others.  THERE IS NO SYSLOGGING FOR ANONYMOUS USERS on these
  669. systems.  The only way to log the activities of anonymous users on such
  670. systems is to specify a transfer iksd log on the command line (Sections 4.1
  671. and 4.3).
  672.  
  673. 4.3. The Transfer Log File
  674.  
  675. The transfer log is disabled by default; it must be enabled on the command
  676. line (Section 4.1).
  677.  
  678. The transfer log has the same format as the wu-ftpd log, and so all the same
  679. scripts can be used to process it, collect statistics, etc.  In fact, you
  680. can even have ftpd and iksd share the same log, in which case records will
  681. be intermixed.
  682.  
  683. The Transfer log can also be used in regular user-mode C-Kermit sessions.
  684.  
  685. The first field is fixed-length and contains spaces; subsequent fields are
  686. variable length, contain no spaces, and are separated by one or more spaces.
  687. The fields are:
  688.  
  689. Timestamp
  690.   This is an asctime-style timestamp, example: "Wed Sep 16 20:19:05 1998"
  691.   It is always exactly 24 characters long, and the subfields are always in
  692.   fixed positions.
  693.  
  694. Elapsed time
  695.   The whole number of seconds required to transfer the file, as a string
  696.   of decimal digits, e.g. "24".
  697.  
  698. Connection
  699.   In IKSD, the IP hostname or address of the client.  For user-mode C-Kermit
  700.   transfers, The name of the network host to which C-Kermit is connected, or
  701.   the name of the serial device through which it has dialed (or has a direct
  702.   connection), or "/dev/tty" for transfers in remote mode.
  703.  
  704. Bytes transferred
  705.   The number of bytes transferred, decimal digits, e.g. "1537904".
  706.  
  707. Filename
  708.   The full pathname of the file that was transferred, e.g.
  709.   "/pub/ftp/kermit/a/README.TXT".  If the filename contains any spaces or
  710.   control characters, each such character is replaced by an underscore ('_')
  711.   character.
  712.  
  713. Mode
  714.   The letter 'b' if the file was transferred in binary mode, or 'a'
  715.   if it was transferred in text (ASCII) mode.
  716.  
  717. Options
  718.   For compatibility with the wuftpd log.  This field always contains an
  719.   underscore ('_') character.
  720.  
  721. Direction
  722.   The letter 'o' if the file was transferred Out, and 'i' if the file was
  723.   transferred In.
  724.  
  725. User class
  726.   The letter 'r' for real users, or 'a' for anonymous users.
  727.  
  728. User identification
  729.   The user ID of a real user, or the password given by an anonymous user.
  730.  
  731. Server identification
  732.   The string "iks" (Internet Kermit Server), or if C-Kermit is running
  733.   in user mode, "kermit".  This distinguishes a Kermit transfer log
  734.   record from a WU-FTPD record, which contains "ftp" in this field.
  735.  
  736. Authentication class
  737.   The digit '1' if we know the user's ID on the client system,
  738.   otherwise '0'.  Currently, always '0'.
  739.  
  740. Authenticated user
  741.   If the authentication class is '1', this is the user's ID on the client
  742.   system.  Otherwise it is an asterisk ('*').  Currently it is always an
  743.   asterisk.
  744.  
  745. 4.4. The IKSD Configuration File
  746.  
  747. The IKSD configuration file is a place to put commands that should always
  748. be executed for every client, real or anonymous.
  749.  
  750. When C-Kermit is started as IKSD, it always begins by reading the IKSD
  751. configuration file, if any.  By default this is /etc/iksd.conf (you may
  752. change the definition at compile time by adding -DIKSDCONF=\"filename\" to
  753. CFLAGS).  This file contains ordinary C-Kermit commands.  Normally these
  754. would be SET or DISABLE commands.  In case any commands in this file write to
  755. standard output, remember that IKSD's standard output is the connection to
  756. the client.  For more ideas about what can go in the iksd.conf file,
  757. read the next section -- the difference is that when you put commands in
  758. the iksd.conf file, they apply not only to anonymous users, but to real
  759. users too.  So, for example, if you want to disable uploads for all users,
  760. you could put DISABLE SEND in the iksd.conf file, whereas if you wanted to
  761. disable them only for anonymous users, you would put this command in the
  762. anonymous-user initialization file.
  763.  
  764. The IKSD configuration file is executed before the user logs in (or is
  765. otherwise authenticated), before the C-Kermit initialization file, and before
  766. any extended-format command line options that start with "--", but after any
  767. that are marked CM_PRE in the table in Section 4.1, or that start with "-+".
  768. Since execution occurs before login, the \v(user) variable is meaningless
  769. here.
  770.  
  771. 4.5. The Initialization File
  772.  
  773. When a real user logs in to the IKSD, the C-Kermit initialization file is
  774. executed in the normal manner, depending on the compile-time configuration of
  775. the IKSD.  Normally, the user's own .kermrc file is executed, and this, in
  776. turn, executes the user's customization file, .mykermrc.  If the IKSD was
  777. built with the CK_SYSINI or CK_DSYSINI compile-time options (described in
  778. ckccfg.txt), a single, shared system-wide initialization file is executed
  779. instead; this may, in turn, execute a customization file out of the user's
  780. home directory.  You may override C-Kermit's automatic selection of
  781. initialization with the regular C-Kermit -y or -Y options on the IKSD command
  782. line, described in the C-Kermit manual.
  783.  
  784. For anonymous users, the default initialization file, if any, is .kermrc in
  785. the chroot'd file system.  This default may be overridden with the
  786. --initfile:xxx command-line option.  The system administrator may include
  787. commands in this file to disable selected services for anonymous users, e.g.:
  788.  
  789.   disable delete  ; Don't let anonymous users delete files
  790.   disable send    ; Don't let anonymous users send files
  791.  
  792. Of course, any Kermit commands at all may be included: settings, macro
  793. definitions, etc.  (Also see Section 5.5.)
  794.  
  795. When the sysadmin specifies the initialization file, this allows a high degree
  796. of fine-grained control over who is allowed access to what commands and
  797. resources, using standard C-Kermit commands, functions, and variables.  The
  798. following are particularly useful:
  799.  
  800. \v(date), \v(ndate)
  801.   The current date, in case you want to restrict access by date.
  802.   (Also read about the new date-related functions in Section 1.6 of
  803.   ckermit2.txt.)
  804.  
  805. \v(day), \v(nday)
  806.   The day of the week, in case you want to restrict access to certain days
  807.   of the week.
  808.  
  809. \v(home)
  810.   The user's home directory.
  811.  
  812. \v(host)
  813.   The hostname of the IKS.
  814.  
  815. \v(ipaddress)
  816.   The IP address of the IKS.  This and/or \v(host) may be used when you are
  817.   running an IKS on multiple hosts and want to have different setups on each,
  818.   but still have a common initialization file.
  819.  
  820. \v(line)
  821.   The IP host name or address of the client's host.
  822.  
  823. \v(time), \v(ntime)
  824.   The current time of day, in case you wish to restrict access to certain
  825.   times of day.
  826.  
  827. \v(userid)
  828.   The ID with which the user logged in to the IKS.  For anonymous logins,
  829.   this is "ftp".
  830.  
  831. So, for example, if the sysadmin wishes to prevent user "olga" from using the
  832. IKS on Mondays, the initialization file could contain a command like:
  833.  
  834.   if equal \v(user) olga -
  835.     if equal \v(nday) 1 -
  836.        exit 1 Sorry Olga - please come back another day
  837.  
  838. Or suppose it is desirable to block access from all xyzcorp.com hosts between
  839. 9:00am and noon:
  840.  
  841.   if match \v(line) *.xyzcorp.com -
  842.     if lgt \v(time) 09:00:00 -
  843.       if llt \v(time) 12:00:00 -
  844.          exit 1 Sorry - Please come back after noon
  845.  
  846. Or suppose a certain user is to be allowed to GET files from the server, but
  847. not SEND, PRINT, or MAIL them:
  848.  
  849.   xif equal \v(user) ivan {
  850.       disable send
  851.       disable print
  852.       disable mail
  853.       disable enable
  854.   }
  855.  
  856. 5. Access to Services
  857.  
  858. The IKSD behaves at runtime just like the regular C-Kermit program, with
  859. any restrictions resulting from compile-time options, and with the differences
  860. noted in this section and in Section 4.
  861.  
  862. 5.1. Automatic Settings
  863.  
  864. When C-Kermit is started as an Internet Kermit Service, the following settings
  865. occur automatically:
  866.  
  867.  a. Login (authentication) is required.
  868.  b. Shell access is disabled.
  869.  c. Server-side Telnet negotiation is enabled.
  870.  d. SET RELIABLE ON (see ckermit2.txt).
  871.  e. FAST file-transfer settings, including "cautious" unprefixing.
  872.  f. No flow control, no parity.
  873.  
  874. Items d-f can be overridden with command-line options and/or in the
  875. initialization file.
  876.  
  877. 5.2. Authentication
  878.  
  879. The IKSD command prompt will not appear, and no commands may be given, before
  880. the user is authenticated.
  881.  
  882. When the IKSD has been started without the '-x' command-line option, it issues
  883. a Username: prompt.  The user may type a username at the prompt, in which case
  884. a Password: prompt is issued, and the user must enter a password.  Three login
  885. attempts are allowed, with a pause enforced between each one.  If all three
  886. fail, the connection is closed.
  887.  
  888. The user may also authenticate from the client by sending a [ REMOTE ] LOGIN
  889. command (again, only 3 tries are allowed), or by Telnet Authentication
  890. negotiations.  Prior to authentication, the IKSD will respond to only the
  891. following client commands:
  892.  
  893.   [ REMOTE ] LOGIN
  894.   [ REMOTE ] LOGOUT
  895.   REMOTE HELP (or RHELP)
  896.   REMOTE EXIT (or REXIT)
  897.   BYE
  898.  
  899. Once authenticated, the user may not re-authenticate or change identities.
  900.  
  901. The connection persists until it is broken in any of the following ways:
  902.  
  903.  a. Client sends BYE or REMOTE EXIT (REXIT) or [ REMOTE ] LOGOUT to IKSD.
  904.  b. Client sends FINISH to IKSD that has been started with '-x'.
  905.  c. User gives HANGUP or CLOSE command to the client.
  906.  d. User gives EXIT, QUIT, or LOGOUT command at IKSD prompt.
  907.  
  908. The connection is also closed if the user exits from the client, but only if
  909. it was an end-to-end Telnet connection.  There can be no guarantee that
  910. exiting from a serial communication program will close and hang up the serial
  911. connection.
  912.  
  913. 5.3. The DISABLE Command
  914.  
  915. In the IKSD, the DISABLE command applies not only to client/server functions,
  916. but also to the corresponding commands when given at the prompt.  For example,
  917. DISABLE DELETE disables not only REMOTE DELETE commands given from the client,
  918. but also DELETE commands given at the IKSD's command prompt, as well as
  919. implicit forms of file deletion, such as when the target of a COPY command is
  920. an existing file.
  921.  
  922. The DISABLE ENABLE command is irreversible; once this command is given, the
  923. ENABLE command can not be re-enabled, and therefore no other disabled commands
  924. can be enabled either.  ENABLE is DISABLEd automatically for anonymous users,
  925. so any DISABLE commands in the anonymous-user initialization file (Section 4.4)
  926. are also irreversible.
  927.  
  928. 5.4. Shell Access
  929.  
  930. All forms of system and shell access are disabled in the IKS.  Thus the user
  931. can not execute REMOTE HOST commands from the client, nor access the shell
  932. from the IKS command prompt via shell escapes (!), the RUN or PUSH command, or
  933. by specifying pipes or filters in file-transfer commands, or by pipe
  934. specifications in REMOTE commands, or in any other way.  This is true even if
  935. the executable was built without the NOPUSH compile-time option.
  936.  
  937. 5.5. Anonymous Users
  938.  
  939. Anonymous users are allowed by default, but can be denied with --anonymous:no
  940. on the command line (Section 4.1).
  941.  
  942. Anonymous users are handled in about the same way as they are by ftpd.  Their
  943. effective user ID is set to "ftp" and their file-system access is restricted
  944. to the tree rooted at the home directory of the "ftp" user, normally /pub/ftp,
  945. via chroot.  If /pub/ftp does not exist, login will fail.  In that case (or
  946. for any other desired reason), the anonymous root directory can be changed
  947. with the --root: option, e.g. --root:/tmp.  Note that, unlike ftpd, iksd does
  948. not necessarily require any particular binaries (such as ls) to be in the
  949. chroot'd tree.  DLLs might be another story, but so far these have not been
  950. needed, even with dynamically linked Kermit binaries (at least in Linux and
  951. Solaris).  Should DLLs be a problem, use a statically linked Kermit binary
  952. (if possible), or install the needed DLLs in the anonymous root.
  953.  
  954. File access is according to user "ftp" and the directory and file permissions
  955. of the /pub/ftp tree.  If anonymous uploads are to be allowed, then usually
  956. only specific directories (often with a name like "incoming") are given write
  957. permission, and any files that are created in such a directory have owner
  958. "ftp", with the group set to the group of the directory.  As noted in section
  959. 4.1, the permission for all files created by anonymous users is 0040
  960. (group-read only), or whatever else the sysadmin has specified in the
  961. --permissions: command-line option.
  962.  
  963. Thus, if you already have a public ftp server, most likely everything is set
  964. up appropriately already.  If anonymous ftp is allowed (by the presence of
  965. a valid user "ftp" in your system's password file), it will be allowed also
  966. for IKSD unless explicitly disallowed on the IKSD command-line (or if
  967. /pub/ftp doesn't exist and you did not supply a --root: option on the command
  968. line).
  969.  
  970. In addition to the FTP-like restrictions, certain Kermit services are always
  971. denied to anonymous users.  These include:
  972.  
  973.  . PRINT (at IKSD prompt) and REMOTE PRINT (from client)
  974.  . MAIL (or SEND /MAIL) at IKSD prompt and from client.
  975.  . Creation of any logs (transaction, debug, packet, etc).
  976.  . No file may be deleted, including implicitly, e.g. by the COPY command.
  977.  . FILE COLLISION is set to RENAME and may not be changed.
  978.  
  979. The latter three provisions mean that anonymous users can not delete,
  980. overwrite, rename, or alter any existing files in any way, whether by file
  981. transfer or with the DELETE or RENAME command.
  982.  
  983. Note that IKSD, like FTPD, does not allow directory creation by anonymous
  984. users, even when file/directory permissions would otherwise allow it.  To
  985. change this, add:
  986.  
  987.   enable mkdir    ; Enable directory creation
  988.  
  989. to /pub/ftp/.kermrc (or whatever other initialization file you have designated
  990. for anonymous users with --initfile).  Similarly for directory removal:
  991.  
  992.   enable rmdir    ; Enable directory removal
  993.  
  994. Of course directories can be removed only if (a) they are empty, and (b)
  995. their permissions allow it.
  996.  
  997. 5.6. Management Information
  998.  
  999. The command-line argument vector, normally accessible in the \&@[] array,
  1000. the top-level \%0..9 variables, or by other means, is inaccessible to IKSD
  1001. users.  Thus IKSD clients can not discover the IKSD startup path or options,
  1002. the logfile pathnames or directories, logging level, etc.
  1003.  
  1004. 6. Open Issues
  1005.  
  1006. Several services that are normally provided by C-Kermit are not available
  1007. when it is an Internet Kermit Service Daemon.
  1008.  
  1009. 6.1. Connection Establishment
  1010.  
  1011. If the user has access to the IKSD command prompt, why not allow her to "set
  1012. host" or "set line" from there to another place?  Obviously this would be a
  1013. security risk if allowed for anonymous users.  For authenticated users, it
  1014. should be OK, but is not currently possible for Telnet connections since the
  1015. IKSD is already a Telnet server on the incoming connection, and is not
  1016. designed to conduct two separate Telnet sessions simultaneously.  It might be
  1017. possible to allow the user to make a dialout connection, but some coding and
  1018. testing would be needed should this prove desirable.
  1019.  
  1020. 6.2. Shell Access
  1021.  
  1022. Shell access is forbidden to anonymous users for obvious reasons.  From a
  1023. security standpoint, it could be allowed for authenticated users, but there
  1024. remains a technical obstacle: the absence of a terminal driver for the
  1025. connection.
  1026.  
  1027. 6.3. External and/or non-Kermit Protocols
  1028.  
  1029. External protocols such as Zmodem can not be expected to perform any of the
  1030. logging or security functions that are done by C-Kermit itself within its
  1031. protocol and file modules.  Thus external protocols are disabled in the IKSD.
  1032. Plus the fact that such protocols are likely to be incompatible with Telnet
  1033. connections in the first place.  In more detail:
  1034.  
  1035.  . When the user is 'anonymous' the file system is chroot'd, which means
  1036.    that any external executables must exist in the chroot'd file system.
  1037.    This leaves open the possibility that executables might be replaced by a
  1038.    different file of the same name that has been uploaded either on top of
  1039.    the existing file or just into the same directory.  If "." is in the
  1040.    PATH for the process anything the user uploads with the name 'rz' or
  1041.    'sz' might be executed in its place.  Therefore, the IKSD does not use
  1042.    any external commands of any kind.  Not 'ls', not 'cp', not 'df', not
  1043.    anything.  To allow the execution of external programs is a major
  1044.    security hole in this setting.
  1045.  
  1046.  . Most implementations of 'sz' and 'rz' are designed for remote use over a
  1047.    terminal connection.  They expect to be run underneath a pseudoterminal
  1048.    (PTY).  When IKSD is running there is no PTY.  In fact, when IKSD is
  1049.    running there is only a raw socket; the IKSD handles all necessary
  1050.    Telnet protocol translations including Telnet Network Virtual Terminal
  1051.    (NVT) rules regarding quoting of Carriage Return and 0xFF depending upon
  1052.    the state of the BINARY Telnet option in each direction.  'sz' and 'rz'
  1053.    are completely incapable of performing these translations in either
  1054.    direction and any attempt to transfer a file with them will result in a
  1055.    transfer failure and the corruption of the data stream.
  1056.  
  1057.  . IKSD supports encrypted sessions, in which case it handles the
  1058.    encryption and decryption itself; an external protocol module would not
  1059.    do this, and so could not be used on encrypted channels in any case.
  1060.  
  1061. 6.4. Additional Administrative Controls
  1062.  
  1063. Certain options available in wu-ftpd are not implemented in iksd:
  1064.  
  1065.  . Ability to select IKSD logging for real vs anonymous users.
  1066.  . Ability to select IKSD logging for inbound vs outbound files.
  1067.      - Currently all transfers are logged or not logged.
  1068.  
  1069.  . Ability to allow/restrict chmod/delete/overwrite for anonymous users.
  1070.      - Currently there is no command for changing file permissions.
  1071.      - Guests may not delete files, period.
  1072.      - FILE COLLISION is set to RENAME for guests and may not be changed
  1073.        since all the other options allow existing files to be altered.
  1074.      - There is no way to grant these capabilities to guests.
  1075.  
  1076.  . Ability to allow directory creation by anonymous users.
  1077.      - Anonymous users may not create or remove directories.
  1078.  
  1079.  . Ability to allow/specify CD messages on a per-directory basis.
  1080.  . RFC931 authentication of remote (client) user (but wu-ftpd doesn't either).
  1081.  
  1082. These or other controls can be added if there is sufficient reason or demand.
  1083.  
  1084. 6.5. Known Bugs
  1085.  
  1086.  . When commands are logged in syslog, the EXIT command appears twice.
  1087.  
  1088.  . wtmp entries show pids in hex due to length restrictions, so you'll
  1089.    need to convert them to decimal before using them with ps, kill, etc.
  1090.  
  1091. 7. MONITORING
  1092.  
  1093. Unless you disable it, all IKSDs keep current session information in a shared
  1094. database.  The IKSD instances can be within one computer or running on any
  1095. number of different computers that share the same file system on the same
  1096. network.  The database can be monitored by the sysadmin with a simple
  1097. "systat"-like display program, which shows who is logged in, from where, and
  1098. what they're doing.  (The idea is easily adapted to other servers, such as
  1099. FTP.)  For maximum portability and reliability, the database is an ordinary
  1100. file on disk.
  1101.  
  1102. The IKSD database file should reside in its own directory (to avoid conflicts
  1103. with other servers that might use the same filename conventions), and this
  1104. directory and its files should be visible to the sysadmin without privileges
  1105. (e.g. by group access) but hidden from the public for privacy reasons if other
  1106. such logs (e.g. the ftpd log, syslog, etc) also are.
  1107.  
  1108. The database is a random-access file indexed by "slot number", which is
  1109. self-assigned during a quick search at startup.  Once a slot is claimed, there
  1110. is no more searching; each IKSD updates its own slot in place and does not
  1111. touch the others.  Slots never move.
  1112.  
  1113. When an IKSD instance starts, it must obtain a "slot allocation lock" before
  1114. it can claim its slot.  Otherwise there could be a race condition when another
  1115. IKSD instance starts at the same time, in which the two could wind up with the
  1116. same slot.
  1117.  
  1118. Since exclusive access is a nonportable concept, we obtain the lock in a
  1119. crude but portable manner, without recourse to kernel locks, interprocess
  1120. communication, semaphores, memory-mapped files, or other platform-specific
  1121. mechanisms:
  1122.  
  1123.  a. Create a temp file in the database directory called <ip>.<pid>, where
  1124.     <ip> is the local IP address as 8 hex digits and <pid> is my own
  1125.     process ID (PID) in hex (no leading zeros).  This is guaranteed to be
  1126.     a unique name (and if by chance a file of this name already exists, it
  1127.     can't possibly be valid, so it it's ok to overwrite it).
  1128.  
  1129.  b. Write my own ID string into the file.  The ID string is <ip>:<pid>,
  1130.     where <ip> is (again) my IP address as 8 hex digits, and <pid> is my
  1131.     PID in decimal (not hex).  (The reason for decimal here is
  1132.     readability, so sysadmins can easily enter it into other tools or
  1133.     commands; it has to be hex in the temp filename for compactness in
  1134.     case of 14-character filename limitations.)
  1135.  
  1136.  c. Try to open iksd.lck, which is the real lockfile.  If this succeeds,
  1137.     read its contents (an <ip>:<pid> string).  If the <ip> not the same as
  1138.     mine, consider the file locked.  If it is the same, extract the PID
  1139.     and check its validity.  If it is not valid, delete the lockfile.
  1140.     (Currently this step is skipped by K95 since it can't check PIDs.)
  1141.  
  1142.  d. At this point the iksd.lck file might or might not exist.  Try to
  1143.     rename the temp file to iksd.lck.  This will fail if the lockfile
  1144.     exists, in which case we sleep, loop, and try again, up to a certain
  1145.     number of times -- say 16 tries spaced 1 second apart.  If we fail to
  1146.     get a lock, we let the user on anyway, in the spirit of service over
  1147.     management.  If the rename succeeds, on the other hand, we have a lock.
  1148.  
  1149. When and if we have obtained a lock, we open the database file itself and
  1150. search the whole database (sequentially) for:
  1151.  
  1152.  a. Free slots (In-Use flag is 0), or:
  1153.  
  1154.  b. Stale slots(*), or:
  1155.  
  1156.  c. Any slot with our own IP and PID (a special kind of stale slot).
  1157.  
  1158. (*) In-Use flag is 1 and IP address is ours, but PID is invalid.
  1159.  
  1160. In C-Kermit only (not K-95) we also perform some housekeeping duties while
  1161. searching (the Windows APIs include no provisions for this):
  1162.  
  1163.  a. Whenever a stale slot is found, we free it (set its In-Use flag to 0).
  1164.  
  1165.  b. We remove all free slots after the last in-use slot by truncating the
  1166.     database file (this keeps the database file from constantly growing as
  1167.     new highwater marks are reached).
  1168.  
  1169. Then we claim the first one of these that was found.  If no slot was claimed,
  1170. we add a new slot at the end and claim it.  If the database file did not
  1171. exist, we create it and claim the first slot.  (In Windows, the IKSD listener
  1172. simply deletes the existing database, if any, on initial startup.)
  1173.  
  1174. To claim a slot:
  1175.  
  1176.  a. We set the In-Use flag to 1, fill in the Server PID and IP address
  1177.     fields with our own PID and IP address, fill in the session-start and
  1178.     update time fields, and clear the other fields.
  1179.  
  1180.  b. Then we release the lock.
  1181.  
  1182. From this point, we can write freely into our slot regardless of locks.
  1183.  
  1184. Notes:
  1185.  
  1186.  a. Since all IKSDs follow the same procedure, only one can have a lock a
  1187.     at a time.
  1188.  
  1189.  b. The lockfile is readable text; it can be typed (cat'd).  The contents
  1190.     are the same format on every platform, regardless of byte order or
  1191.     word size.
  1192.  
  1193.  c. This scheme allows (but does not require) multiple computers that share
  1194.     a common file system to have a single IKSD database, which in turn allows
  1195.     the site manager to monitor all IKSDs on all computers at once.  This
  1196.     works if each computer has a unique IP address (which it must if they are
  1197.     on the same network sharing a common file system; nevertheless, care must
  1198.     be taken regarding IP address pools, etc).  It also depends on the file-
  1199.     sharing mechanism (such as NFS) to propogate updates promptly and in
  1200.     sequence.
  1201.  
  1202.  d. While one IKSD is allocating its slot, nothing prevents other IKSD
  1203.     instances that already have their own slots from updating them, since
  1204.     that does not interfere with slot allocation.
  1205.  
  1206.  e. The tempfile name format is UNIXish and will need modification for file
  1207.     systems with restrictive names, such as FAT, 14-char UNIXes, etc.  In
  1208.     such cases we could (a) omit the IP address if we're not concerned about
  1209.     multiple computers sharing a single database, or (b) encode the IP
  1210.     address in Base 64 to make it shorter.  But probably none of this will
  1211.     ever come up.
  1212.  
  1213.  f. The design accommodates 64-bit IPv6 addresses, but for now the software
  1214.     uses only 32 bits.
  1215.  
  1216. 7.1. Database Record Format
  1217.  
  1218. A slot is 4K (4096 octets), divided into 4 1K chunks.  The first chunk is
  1219. further subdivided into shorter fields.  Numeric fields are coded in
  1220. hexadecimal, right-adjusted, and left-padded with 0's.  Text fields are
  1221. left-adjusted and right-padded with blanks.  Date-time fields are
  1222. right-adjusted within a field of 18 with the leading blank reserved for Y10K.
  1223. Date-time format is:
  1224.  
  1225.   yyyymmdd hh:mm:ss
  1226.  
  1227. where yyyymmdd are the numeric year, month, and day, and hh:mm:ss are the hour
  1228. (24-hour clock), minute, and second.  Months and days are 1-based, leading 0's
  1229. are supplied where needed.
  1230.  
  1231. The layout of each slot is as follows (fields and byte positions are numbered
  1232. from 0):
  1233.  
  1234.    0. FLAGS (Slot/Session Flags)
  1235.       Start:     0
  1236.       Length:    4
  1237.       Type:   Bit Mask
  1238.       Format: Hex digits.
  1239.       Bit Values:
  1240.        1: 1 = Slot in use, 0 = Slot is free.
  1241.        2: 1 = Real user, 0 = Anonymous user.
  1242.        4: 1 = Logged in, 0 = Not logged in.
  1243.  
  1244.    1. AUTHTYPE (Authorization Type)
  1245.       Start:     4
  1246.       Length:    4
  1247.       Type:   Number
  1248.       Format: Hex digits.
  1249.       Values:
  1250.        0: None          8: (reserved)
  1251.        1: Kerberos IV   9: (reserved)
  1252.        2: Kerberos V   10: LOKI
  1253.        3: SPX          11: SSA
  1254.        4: MINK         12: KEA_SJ
  1255.        5: SRP          13: KEA_INTEG
  1256.        6: RSA          14: DSS
  1257.        7: SSL          15: NTLM
  1258.  
  1259.    2. AUTHMODE (Authorization Type)
  1260.       Start:     8
  1261.       Length:    4
  1262.       Type:   Number
  1263.       Format: Hex digits.
  1264.       Values:
  1265.        0: Rejected
  1266.        1: Unknown
  1267.        2: Other
  1268.        3: User
  1269.        4: Valid
  1270.  
  1271.    3. STATE (IKSD State)
  1272.       Start:    12
  1273.       Length:    4
  1274.       Type:   Bit Mask
  1275.       Format: Hex digits.
  1276.       Bit Values:
  1277.        1: Initializing
  1278.        2: Sending a file
  1279.        4: Receiving a file
  1280.        8: Executing a REMOTE command
  1281.       32: At command prompt
  1282.  
  1283.    4. PID (IKSD's Process ID)
  1284.       Start:    16
  1285.       Length:   16
  1286.       Type:   Number
  1287.       Format: Hex digits.
  1288.  
  1289.    5. SERVER IP (IKSD's IP Address)
  1290.       Start:    32
  1291.       Length:   16
  1292.       Type:   IP address as a series of numeric octets in network byte order
  1293.       Format: Hex digits
  1294.  
  1295.    6. CLIENT IP (Client's IP Address)
  1296.       Start:    48
  1297.       Length:   16
  1298.       Type:   IP address as a series of numeric octets in network byte order
  1299.       Format: Hex digits
  1300.  
  1301.    7. SESSION START (Date and Time session started)
  1302.       Start:    64
  1303.       Length:   18
  1304.       Type:   Date-time
  1305.       Format: Date-time string
  1306.  
  1307.    8. LAST UPDATE (Date and Time this record was last updated)
  1308.       Start:    82
  1309.       Length:   18
  1310.       Type:   Date-time
  1311.       Format: Date-time string
  1312.  
  1313.    9. ULENGTH (Username length)
  1314.       Start:   100
  1315.       Length:    4
  1316.       Type:   Number
  1317.       Format: Hex digits, right adjusted
  1318.  
  1319.   10. DLENGTH (Length of current directory)
  1320.       Start:   104
  1321.       Length:    4
  1322.       Type:   Number
  1323.       Format: Hex digits, right adjusted
  1324.  
  1325.   11. ILENGTH (Length of state-specific information)
  1326.       Start:   108
  1327.       Length:    4
  1328.       Type:   Number
  1329.       Format: Hex digits, right adjusted
  1330.  
  1331.   12. RESERVED
  1332.       Start:   112
  1333.       Length:  912
  1334.       Type:   None
  1335.       Format: Filled with blanks
  1336.  
  1337.   13. USERNAME (Username; if anonymous "anonymous:<password>")
  1338.       Start:  1024
  1339.       Length: 1024
  1340.       Type:   None
  1341.       Format: Text, ULENGTH sigificant chars, right-filled with blanks
  1342.  
  1343.   14. DIRECTORY (Current directory)
  1344.       Start:  2048
  1345.       Length: 1024
  1346.       Type:   None
  1347.       Format: Text, DLENGTH sigificant chars, right-filled with blanks
  1348.  
  1349.   15. INFO (State-specific information)
  1350.       Start:  3072
  1351.       Length: 1024
  1352.       Type:   None
  1353.       Format: Text, ILENGTH sigificant chars, right-filled with blanks
  1354.  
  1355. The state-specific information tells you whether IKSD is at its command prompt
  1356. or in server command wait, if it is sending or receiving a file (in which case
  1357. the filename is shown), it is executing a REMOTE command (in which case the
  1358. command is shown), or how it was terminated (BYE, REMOTE EXIT, disconnect, etc)
  1359.  
  1360. Notes:
  1361.  
  1362.  a. There are no control characters (CR, LF, NUL, etc) or 8-bit
  1363.     characters; only ASCII graphic characters are used in the
  1364.     database.  Fields are left- or right-padded with Space or '0' as
  1365.     indicated.
  1366.  
  1367.  b. Since the USERNAME, DIRECTORY, and INFO fields are right-padded
  1368.     with spaces, it would be laborious to isolate their actual values
  1369.     by trimming spaces from the right (since we must allow for
  1370.     internal spaces); hence the ULENGTH, DLENGTH, and ILENGTH fields.
  1371.  
  1372.  c. The USERNAME, DIRECTORY, and INFO fields are 1K each since 1K is
  1373.     the maximum pathname length found on common UNIX platforms (even
  1374.     though many platforms have smaller maximums).  Thus, for example,
  1375.     the current directory string might be exactly 1K long.  This is why
  1376.     its length is kept outside the block.  Also the division of the
  1377.     record into four 1K blocks tends to make for more efficient i/o.
  1378.  
  1379.  d. The IKSD database does not provide a permanent record or give
  1380.     complete information.  That's what the syslog entries and the IKSD
  1381.     log are for.
  1382.  
  1383. 7.2 The Display Module
  1384.  
  1385. The straightforward data definitions and formats allow a display module to be
  1386. written easily in the language of your choice, including scripting languages
  1387. such as Kermit's own.  A sample display module, iksdpy, is provided as a
  1388. "Kerbang" script, providing a running display of the active IKSD sessions from
  1389. the database.  In its startup mode, it lists each session in the database,
  1390. refreshing every 4 seconds.  Various keystroke commands are available for
  1391. help, quitting, etc, and to enter the detail screen for a specific session.
  1392. The detail screen, too, refreshes itself every 4 seconds.  Here you have keys
  1393. to return to the main screen, to pick another session, to cycle through
  1394. sessions, and so on.
  1395.  
  1396. When a slot is freed, its information is left intact so you can still see who
  1397. was using it, when, and from where, and the last thing they did before logging
  1398. out.  The old info persists until the slot is removed or reclaimed, which will
  1399. happen when the next new IKSD session starts.
  1400.  
  1401. The iksdpy script is short, simple, and easily extensible.  For example, while
  1402. watching a detail screen and you see somebody doing something bad, you might
  1403. like to have a "K" key to kill the session (the script already knows the pid,
  1404. so it need simply form a "!kill -9" command, including the pid).
  1405.  
  1406. 7.3. Database Management
  1407.  
  1408. The following command-line options let you disable/enable the database and
  1409. specify its location:
  1410.  
  1411. --database:{on,off}
  1412.   Whether an active-sessions database should be kept.  On by default.
  1413.   If "on", but --dbfile is not specified, /var/log/iksd.db is used.
  1414.  
  1415. --dbfile:<filename>
  1416.   Use this option to specify an iksd database file name.  If you include
  1417.   this option, it implies --database:on.
  1418.  
  1419. In UNIX, the system startup procedure can delete the database file before
  1420. starting inetd, since nothing in it is valid; however, this is not necessary
  1421. since normal cleanup procedures will do the job too.  In Windows, the IKSD
  1422. listener takes care of it.
  1423.  
  1424. To capture a snapshot of IKSD usage, simply copy the database file.
  1425.  
  1426. 8. TESTING
  1427.  
  1428. In case you want to test IKSD on a port other than 1649, be aware that
  1429. IKS-aware Kermit clients (such as C-Kermit 7.0 and K95 1.1.18) will not
  1430. initiate Telnet negotiations with it, since it is not on a Telnet port
  1431. (i.e. 23 or 1649).  To get correct operation you'll need to force the client
  1432. to negotiate, e.g.:
  1433.  
  1434.   telnet hostname 3000
  1435.   set host hostname 3000 /telnet
  1436.  
  1437. (End of IKSD.TXT)
  1438.  
  1439.