Amandad Service Protocol: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
(focus on the matter at hand)
(save)
Line 22: Line 22:
The service is run with the following command-line arguments:
The service is run with the following command-line arguments:
  ''service'' amandad ''auth''
  ''service'' amandad ''auth''
and with a stripped-down, "safe" environment
and with a stripped-down, "safe" environment.  The executable name is the name of the service, and must reside in the


= REP Packet =
== REQ Packet ==
 
The request packet sent from the client has its first two words and newline stripped.  The first must be <tt>SERVICE</tt>, and the second the name of the service.  The remainder of the request packet appears on the stdin of the service, and are service-specific.  The end of the packet data is signalled by EOF on stdin.
 
== REP Packet ==
 
Before using any other file descriptors, the service must send a REP packet on its stdout, signalling the end of the packet with EOF. 
 
= Service-Specific Hacks =

Revision as of 16:56, 4 February 2010

This article describes the way that amandad launches services like sendsize or amidxtaped. Amanda serves as a sort of amanda-specific inetd, but adds support for multiple parallel communication channels, authentication, and lots of crazy backward-compatibility hacks.

Note that most of amandad's activity takes place at connection set-up. There may be other pages on this wiki to describe the protocol observed by particular sevices. For example, amindexd protocol describes the protocol that amidxtaped speaks, and takes over where this page leaves off. Amandad is always on the receiving end of the Security API, so a familiarity with that API will help in reading this document.

Service Launch

File Descriptors

When amandad launches a service, the following file descriptors are open:

0 (stdin)
read any request arguments here
1 (stdout)
write a REP packet body here (see below)
2 (stderr)
??
50 (DATA_FD_OFFSET + 0*2 + 0)
write fd for first stream
51 (DATA_FD_OFFSET + 0*2 + 1)
read fd for first stream
52 (DATA_FD_OFFSET + 1*2 + 0)
write fd for second stream
53 (DATA_FD_OFFSET + 1*2 + 1)
read fd for second stream
54 (DATA_FD_OFFSET + 2*2 + 0)
write fd for third stream
55 (DATA_FD_OFFSET + 2*2 + 1)
read fd for third stream

more data streams can be added if necessary: they are limited by DATA_FD_COUNT, which is currently 3.

Note that OpenBSD's fake thread libraries have trouble dealing with nonstandard file descriptors open at process start; use fcntl(F_GETFD) to "notify" the runtime of these file descriptors before using them.

Command-line Arguments

The service is run with the following command-line arguments:

service amandad auth

and with a stripped-down, "safe" environment. The executable name is the name of the service, and must reside in the

REQ Packet

The request packet sent from the client has its first two words and newline stripped. The first must be SERVICE, and the second the name of the service. The remainder of the request packet appears on the stdin of the service, and are service-specific. The end of the packet data is signalled by EOF on stdin.

REP Packet

Before using any other file descriptors, the service must send a REP packet on its stdout, signalling the end of the packet with EOF.

Service-Specific Hacks