Amidxtaped protocol: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
(→‎command: user lower case)
m (typo)
Line 59: Line 59:
== datapath ==
== datapath ==


After the header is sent (or immediately, if no <tt>HEADER</tt> specification was given), if both ends of the connection have fe_amidtaped_datapath, then amidxtaped waits for a DATA-PATH line, one of
After the header is sent (or immediately, if no <tt>HEADER</tt> specification was given), if both ends of the connection have fe_amidxtaped_datapath, then amidxtaped waits for a DATA-PATH line, one of
  DATA-PATH AMANDA\r\n
  DATA-PATH AMANDA\r\n
  DATA-PATH DIRECT-TCP\r\n
  DATA-PATH DIRECT-TCP\r\n

Revision as of 02:17, 24 February 2010

This page picks up where Amandad Service Protocol leaves off. Amidxtaped sends exactly one dump in response to a set of parameters on its control stream. To get another dump, start a new amidxtaped.

REQ

An amidxtaped REQ packet looks like:

SERVICE amidxtaped
OPTIONS features=features;auth=auth;

All of the interesting specification of which data to send comes on the control connection, below.

REP

Amidxtaped sets up two streams in its REP packet:

CONNECT CTL ctlfd DATA datafd\n\n

the control connection is bidirectional, while the data connection only carries data from amidxtaped.

Started from Inetd

If amidxtaped is started directly from inetd, then it assumes its stdin and stdout are tied to a TCP socket.

This service expects to see the string

 SECURITY USER root\r\n

(or some other user than root). Note the \r\n at the end. I couldn't say why, but without the \r amidxtaped will hang. This line triggers a BSDTCP-style security check: the username and remote IP must match .amandahosts, the source port must be privileged, and the forward and reverse DNS must match. Note that the installchecks override this particular test.

Note that when amidxtaped is started directly from inetd, the main socket becomes the control connection after the SECURITY line.

Control Connection

command

The control connection begins with a command, given as a set of specifier lines, followed by an "END" line. All lines are terminated by "\r\n". Are you still asking why? Accept the insanity.

Not all specifiers must be given in any particular request. The available specifiers are:

LABEL=label
not a label, but a tapespec giving the files to be recovered
FSF=fsf
seek to this file before starting the recovery (ignored)
HEADER
prefix the data with an Amanda header (DISK_BLOCK_BYTES long)
FEATURES=features
reiterates the requester's feature-set (in case amidxtaped was started from inetd). When run from amandad, amidxtaped will immediately respond with the equivalent line giving its own features. When run from inetd, amidxtaped will respond with its features only, with no terminating newline of any sort. This relies on "normal" buffering of the TCP connection to receive the features in a single read operation.
DEVICE=device
tape device (or changer) to restore from
HOST=host
host match expression for this dump (ignored; optional)
DISK=disk
diskname match expression for this dump (ignored; optional)
DATESTAMP=datestamp
datestamp for this dump (ignored; optional)
CONFIG=config
Amanda configuration to use

the list of specifiers is terminated by

END\r\n

or by any line that starts with a digit (.. good, you didn't ask why -- you're learning!). Any non-matchting lines will be ignored.

When the requested dump is on a holding disk, then LABEL is omitted, and DEVICE specifies the holding file in Tapelist Specification format -- that is, with a :0 suffix, e.g.,

DEVICE=/A/p/hold\:ing/20100205181319/euclid._A_p_etc.1:0

(note that the : in the holding pathname is quoted)

data

Now the time comes to transfer the data stream.

If amidxtaped was invoked via amandad, then the data flows over the data stream. The fe_recover_splits feature must be set in this case.

Otherwise, if the FEATURES did not include fe_recover_splits, then the data is streamed directly over the control connection, and no further interaction is possible. Otherwise, amidxtapede opens a new, unprivileged TCP port, and sends a CONNECT line on the control connection.

 CONNECT 1234\n

(where 1234 is the port number) Note that there is no \r in this particular message. Amidxtaped then blocks waiting for an incoming connection. That incoming connection must be from a privileged port and begin with the same SECURITY USER line as appeared on the main connection. After that point, the data begins flowing.

datapath

After the header is sent (or immediately, if no HEADER specification was given), if both ends of the connection have fe_amidxtaped_datapath, then amidxtaped waits for a DATA-PATH line, one of

DATA-PATH AMANDA\r\n
DATA-PATH DIRECT-TCP\r\n

Based on the device it has in hand, amidxtaped makes a final decision about the data path to be used. If amrecover has requested AMANDA, or if the device is not DirectTCP-capable, then amidxtaped replies with

DATA-PATH AMANDA\r\n

Otherwise, amidxtaped replies with

DATA-PATH DIRECT-TCP xxx.xxx.xxx.xxx:xxx yyy.yyy.yyy.yyy:yyy\r\n

where the x's and y's are any number of IP:PORT pairs. It then accepts a connection at one of these addresses and begins transferring data - the DirectTCP connection takes the place of the data stream.

interaction

If amidxtaped has a message for the user, it sends a MESSAGE line on the control connection:

MESSAGE I like green eggs and ham.\r\n

Such messages are sent to amidxtaped's stderr if amrecover does not have fe_amrecover_message or if the control stream is being used for data (no fe_amrecover_splits support).

If amidxtaped needs the user to feed a particular volume, and if amrecover has the fe_amrecover_FEEDME feature, then it sends a FEEDME line:

FEEDME DailySet1-013\r\n

Labels longer than 132 bytes are not currently supported. If amidxtaped does not have the (oddly named) fe_amrecover_feedme_tape feature, then it expects an OK response and does not support trying some other device:

OK\r\n

If amrecover does have the fe_amrecover_feedme_tape feature, then also supports a TAPE response, specifying either the same device as used in the original request, or a new device:

TAPE tape:/dev/nrst0\r\n

indicating that amidxtaped should use the given device. There is no official "cancel" response, but amrecover uses ERROR\r\n to trigger a fatal error in amidxtaped when the user cancels a feedme request.

Note that, in the case of a split dump, MESSAGE or FEEDME lines may come after a significant quantity of data has been transferred.

user-visible notes

If the device given by the user doesn't work, no MESSAGE is sent - amidxtaped merely prompts for the correct volume.

If the device works but the correct volume is not found, then a corresponding MESSAGE is sent.