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