Amidxtaped protocol: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
(→‎Control Connection: CONNECT for inetd mode)
(more info on inetd mode)
Line 15: Line 15:
the control connection is bidirectional, while the data connection only carries data from amidxtaped.
the control connection is bidirectional, while the data connection only carries data from amidxtaped.


= Control Connection =
= 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 <tt>root</tt>).  Note the <tt>\r\n</tt> at the end.  I couldn't say why, but without the <tt>\r</tt> amidxtaped will hang.  This line triggers a BSDTCP-style security check: the username and remote IP must match <tt>.amandahosts</tt>, 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 <tt>SECURITY</tt> line.
Note that when amidxtaped is started directly from inetd, the main socket becomes the control connection after the <tt>SECURITY</tt> line.


= Control Connection =
The control connection is a set of specifier lines, followed by an "END" line.  All lines are terminated by "<tt>\r\n</tt>".  Are you still asking why?  Accept the insanity.
The control connection is a set of specifier lines, followed by an "END" line.  All lines are terminated by "<tt>\r\n</tt>".  Are you still asking why?  Accept the insanity.


Line 40: Line 47:
(note that the <tt>:</tt> in the holding pathname is quoted)
(note that the <tt>:</tt> in the holding pathname is quoted)


If amidxtaped is run directly from inetd, then it needs to set up the data connection at this pointTo do so, it sends a CONNECT line to its stdout
Once the security is established, the socket takes on the role of the control stream in the [[amidxtaped protocol]]When the time comes to transfer a data stream, amidxtaped opens a new, unprivileged TCP port, and sends a CONNECT line on the control connection.
CONNECT 1234\n
  CONNECT 1234\n
Note that there is no <tt>\r</tt> in this particular message.
(where 1234 is the port number) Note that there is no <tt>\r</tt> 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 <tt>SECURITY USER</tt> line as appeared on the main connection.  After that point, the data begins flowing.  See [[amidxtaped protocol]] for information about other messages on the control stream.


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

Revision as of 02:04, 6 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

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

The control connection is 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 Tapelist Specification 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.
DEVICE=device
tape device (or changer) to restore from
HOST=host
host match expression for this dump
DISK=disk
diskname match expression for this dump
DATESTAMP=datestamp
datestamp for this dump
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. Any lines after the terminating line are also ignored. Amrecover sends an invalid DATA-PATH specifier after END, presumably to illustrate this point.

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)

Once the security is established, the socket takes on the role of the control stream in the amidxtaped protocol. When the time comes to transfer a data stream, amidxtaped 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. See amidxtaped protocol for information about other messages on the control stream.

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

If it needs the user to feed a particular volume, it sends a FEEDME line:

FEEDME DailySet1-013\r\n

Labels longer than 132 bytes are not currently supported. If the volume is not available (the user cancels), amidxtaped expects an ERROR response:

ERROR\r\n

Otherwise, if amidxtaped does not have the fe_amrecover_feedme_tape feature, then it expects an OK response and does not support trying some other device:

OK\r\n

Finally, if amidxtaped has the fe_amrecover_feedme_tape feature, then it expects 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.

If amidxtaped wants to indicate the datapath it is using, it can send a DATA-PATH message:

DATA-PATH AMNADA\r\n

or

DATA-PATH DIRECT-TCP\r\n

note the unusual use of a dash in the latter message. This is currently unsupported by amidxtaped, but amrecover supports it.

Once data is available, it starts flowing on the data connection. Note that, in the case of a split dump, MESSAGE or FEEDME lines may come after a significant quantity of dta has been transferred.