Janus FTP Server examples

From m204wiki
Revision as of 16:52, 21 February 2012 by JAL2 (talk | contribs) (→‎See also)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The examples in the first two of the following subsections show how to set up Janus FTP Servers in an online. The Janus FTP commands in the examples are introduced in "Janus FTP Server command overview" and described in greater detail in "Janus FTP Server command reference". The "FTP client and server interaction" subsection looks at examples of tracing messages for an attempted file transfer in two different FTP environments.

A simple development environment

In this example, a Janus FTP Server is set up for a development environment with the following characteristics.

  • Test as well as production procedure files, each type defined within its own folder (/TEST and /PROD). These are set up with JANUS FTP ASSIGN.
  • Everyone can read from the test procedure file. This is set up with the DEFAULTPRIVS parameter on the ASSIGN for /TEST.
  • A Janus user group is used for the development team. This allows fewer FTP commands to be used, since the ALLOW commands can then reference the group using the USRGROUP parameter.
  • All developers can update the test procedure file. This is set up with the JANUS FTP ALLOW for /TEST.
  • All developers can read the production procedure file. This is set up with the first JANUS FTP ALLOW for /PROD.
  • Only the team leader (Moe) can update production. This is set up with the second JANUS FTP ALLOW for /PROD.
  • Everyone has the test area as a home folder. This is set up with the JANUS FTP HOME that references ALL.
  • There will be no anonymous FTP access (no ANONYMOUS parameter is specified on the JANUS DEFINE for the FTP Server).
  • Active FTP is supported (perhaps the whole system is behind a firewall, so there is no exposure, and active permits a greater variety of FTP clients). Active is enabled by:
    1. Specifying a CLIENTSOCKET value on the JANUS DEFINE for the FTPDEVEL FTP server
    2. Defining a CLSOCK port whose name is the CLIENTSOCKET value

The commands for the development FTP Server follow. Notice that to enable active transfers, the client (CLSOCK) port must be started as well as the main FTP port.

* Create the development team JANUS DEFUSG STOOGES MOE LARRY CURLEY SHEMP GLW * FTP server on port 3000 JANUS DEFINE FTPDEVEL 3000 - FTPSERVER 4 - CLIENTSOCKET FTPDCLIENT - AUDTERM - PASVPORT 3001 - BINDADDR 198.242.244.100 * Client port definition for active transfers JANUS DEFINE FTPDCLIENT * - CLSOCK 5 REMOTE * * - SOCKPMAX 5 JANUS CLSOCK FTPDCLIENT ALLOW * Set up ftp access to test area. * By default, all users can read it. JANUS FTP FTPDEVEL ASSIGN /TEST TO FILE FTPTEST DEFAULTPRIVS READ * Set up ftp access to prod area. * There is no default access. JANUS FTP FTPDEVEL ASSIGN /PROD TO FILE FTPPROD * All developers can update test. JANUS FTP FTPDEVEL ALLOW /TEST - WRITE TO USGROUP STOOGES * All developers can read prod. JANUS FTP FTPDEVEL ALLOW /PROD - READ TO USGROUP STOOGES * Moe is the boss; he can update production. JANUS FTP FTPDEVEL ALLOW /PROD - WRITE TO USER MOE * All start out with test as a home folder. JANUS FTP FTPDEVEL HOME /TEST TO ALL * Start them up. JANUS START FTPDEVEL JANUS START FTPDCLIENT

A simple anonymous FTP Server

This example sets up a public anonymous FTP Server from which files may be downloaded — a great way to distribute files. It has the following characteristics:

  • A single folder, /PUB, that anonymous users read from to download files.
  • The big boss, Moe, is the only one who can upload files to the server.
  • Prefixing, using the default slash character (/), is displayed (see the PREFIX parameter on the FTP ASSIGN command for /PUB).
  • Only passive FTP file transfers are permitted (no CLIENTSOCKET is specified on the JANUS DEFINE command).

The commands for an anonymous FTP Server follow:

* Create FTP server on port 2121, anonymous allowed, * only passive access is provided. JANUS DEFINE FTPANON 2121 FTPSERVER 10 - ANONYMOUS * - AUDTERM - PASVPORT 2555 - BINDADDR 198.242.244.100 * Create public folder and use prefixing. JANUS FTP FTPANON ASSIGN /PUB TO FILE FTPTEST PREFIX * Grant Anonymous read access to the /PUB folder. JANUS FTP FTPANON ALLOW /PUB READ TO ANONYMOUS * Make user MOE the only person who can place files * in the Anonymous FTP area. JANUS FTP FTPANON ALLOW /PUB WRITE TO USER MOE * Make /PUB the home folder for Anonymous users and Moe. JANUS FTP FTPANON HOME /PUB TO ANONYMOUS JANUS FTP FTPANON HOME /PUB TO USER MOE JANUS START FTPANON JANUS DISPLAYSOCK FTPANON

After connecting to the FTP server from his FTP client, MOE puts/uploads the README file into his home folder, /PUB. A fragment from a DISPLAY PROC LIST result for the FTPTEST file confirms the prefixing used in the example. Procedure README is stored with the folder name as a prefix:

/PUB/README 10/07/04 12:08:28 124 MOE

FTP client and server interaction

To connect to the Janus FTP server, FTP clients must specify (in the way that is appropriate for the particular tool) both the host ID and port of the FTP server. A command line client trying to connect to the Janus FTP Server defined in "A simple anonymous FTP Server", for example, might use:

open 198.242.244.100 2121

The FTP server correctly handles the type of upload (text or binary) that the client FTP package indicates. This indication may be from an explicit user selection of a type, or it may be from an FTP client that auto detects the appropriate mode. By default, the server assumes type A (ASCII, with translation to EBCDIC) until notified otherwise.

Users can upload multiple files at a time (in the way that is appropriate for the particular client tool), although the protocol dictates that multiple-file requests be handled internally as multiple individual-file transfers. Users can also upload directories and subdirectories (if and only if a matching folder structure is predefined for the server). For more information about defining these folder structures, see JANUS FTP ASSIGN.

Since the Janus FTP Server uses a Janus socket port and supports the TRACE parameter (JANUS DEFINE command) and JANUS TRACE command for the port, you can debug your FTP application by setting TRACE and viewing the Model 204 audit trail, as well as by invoking debugging and viewing your client tool log. In the audit trail, Janus FTP server and client interactions are helpfully marked with arrow indicators that identify whether RK lines are messages from the client to the server or from the server to the client.

For example, the lines below show Janus SirScan output (when TRACE is set at its default value, X'00') for a failed upload of a file to an FTP server. FTP C->S: identifies messages from the FTP client to the server, and FTP S->C: the reverse.

19095422 2 1 RK TERM: FTP C->S: PWD 19095422 2 1 RK TERM: FTP S->C: 257 "/TEST/PUBS" 19095422 2 1 RK TERM: FTP C->S: TYPE A 19095422 2 1 RK TERM: FTP S->C: 200 ASCII mode enabled. EBCDIC conversion automatic. 19095423 2 1 RK TERM: FTP C->S: PASV 19095423 2 1 RK TERM: FTP S->C: 227 Entering passive mode (198,242,244,100,12,42) 19095423 3 2 AD MSIR.0114: Processing connection for port FTPPSV3004 from 198.242.244.36 19095423 3 2 RK TERM: FTP: PASV Server Socket connect. 19095423 2 1 RK TERM: FTP C->S: STOR COLORNOTES 19095423 2 1 RK TERM: FTP S->C: 150 storing: "/TEST/PUBS/COLORNOTES" 19095423 3 2 RK TERM: FTP: PASV Server Socket wakes up. 19095423 3 2 RK TERM: FTP: PASV Server Open. 19095424 3 2 RK TERM: *** M204.0620: FILE FTPTEST OPENED 19095424 3 2 RK TERM: *** M204.1203: FILE FTPTEST WAS LAST UPDATED ON 05.038 FEB 07 18.52.41 19095424 3 2 RK TERM: FTP: PASV Server Start XFER. 19095424 3 2 RK TERM: FTP: PASV Server End XFER. 19095424 3 2 LI 19095424 3 2 MS M204.1029: USER CONNECTION LOST (PHONE WAS HUNG UP) 19095424 3 2 AD M204.1022: USER RESTARTING SOFTLY 19095424 3 2 ST USERID='MOE' ACCOUNT='NO ACCOUNT' CNCT=12 SQWR=2 CPU=10 MOVE=7 AUDIT=13 DKPR=3 19095424 3 2 AD M204.0352: IODEV=15, OK MOE NO ACCOUNT LOGOUT 05.039 FEB 08 19.09.54 -52 C6F2F410 19095424 3 2 AD M204.1024: USER RESTARTED SOFTLY 19095425 3 1 RK TERM: FTP S->C: 500 Line too long, transfer aborted.

The FTP server in the example is defined much like the one in "A simple development environment", able to accommodate active and passive FTP mode. The audit trail above shows the use of passive FTP, as requested by the FTP client. The FTP Server dynamically creates a server socket (to which the FTP client connects for the transfer of the file), which runs on a separate thread in the Online. When the transfer is done (successfully or not), the dynamically created socket thread terminates, and the audit trail records a soft restart.

In comparison, the following example shows the same attempted upload as the one above, but from a command-line client that uses active FTP only. The lines beginning with ftp> are the user entries in the client tool. The lines beginning with integers are the FTP server messages received by the client. The lines beginning with ---> are the commands the client actually sends to the FTP server, as reported by the client's debugging facility.

ftp> put colornotes ---> PORT 198,242,244,36,8,235 200 Port command OK: "198,242,244,36,8,235" ---> STOR colorNotes 150 Storing: "TEST/PUBS/COLORNOTES" 500 Line too long, transfer aborted.

The client's PORT command above signals an active FTP transfer. It identifies the data port (server socket) to which the FTP server's CLSOCK socket must connect for the upload. The first four decimal digits following PORT form the IP address of the FTP client host, and the last two digits form the TCP address of the port.

In addition to the Model 204 DISPLAY PROC LIST command (or the Sirius SirPro product), other useful FTP Server debugging and reporting commands are:

JANUS DISPLAY For a display of the FTP Server port definitions
JANUS STATUS For a display of the FTP Server port activity (or inactivity)
JANUS DISPLAYSOCK For a display of the FTP-specific settings like folder mappings and user permissions

See also

The following topics complete the description of Janus FTP Server support: