Have pwmd_command() set error argument to the protocol error code when
[pwmd.git] / PROTOCOL
blob0dc6d70c227bd45a0d037375a1da07f7bc5c6cd5
1 The data is stored in an AES-128-ECB encrypted XML file. A client connects to
2 the server and issues commands that manipulate the data. Through the use of
3 shared memory, passwords do not need to be issued for each file each time a
4 client connects.
6 The server uses a simple protocol to communicate with a client. All non-data
7 responses are prefixed by a server response code followed by a space followed
8 by a description followed by a newline character. There are three non-data
9 related response codes: NFO for informational messages, ERR for error messages
10 and OK if the last command succeeded.
12 A data response is prefixed with a BEGIN response code followed by a space
13 then an integer specifying the number of following data bytes then a newline
14 character. After all of the bytes have been sent a newline character then an
15 OK response code then another newline will be sent.
17 Here are the protocol commands and their syntax:
19 OPEN <filename> [<key>]
20     Opens <filename> using <key>. If file is not found on the filesystem, then
21     a new file is created. The file is found, it is looked for in the file
22     cache for an existing key. If found, the existing key will be used for
23     decryption. If the cached key fails then the <key>, if specified, will be
24     tried. Note that <key> should be base64 encoded.
26 SAVE [<key>]
27     Encrypts and writes any changes to the file to disk. If <key> is not
28     specified then the currently cached key will be used. Note that <key>
29     should be base64 encoded.
31 CACHE clearall | clear <filename> | iscached <filename>
32     CLEARALL - Remove all files from the cache. This will require a key for
33                the next OPEN or SAVE command.
35     CLEAR    - Like CLEARALL but only for the specified file.
37     ISCACHED - A response code of OK will be returned if the specified file is
38                in the file cache, ERR otherwise.
40 LIST [<account>]
41     If no account is given, then a list of accounts is returned with a BEGIN
42     repsonse code. If given, then the element tree for the account is
43     returned.
45 STORE <account> [TAB <element> [TAB <element> ...] TAB <value>]
46     Stores an element tree into <account>. If no element are specifed an empty
47     account is created. Otherwise, elements are TAB deliminated and the value
48     will be the last element. The only restriction of element names is that
49     they not contain any whitespace.
50     
51 DELETE <account> [TAB <element> [TAB <element> ...]]
52     Removes an element tree from <account>.
54 GET <account> TAB <element> [TAB <element> ...]
55     Retrieves the base64 encoded value from <account> and the specified
56     element tree. The data is returned with the BEGIN response code.
58 SETATTR <account> <attribute> <value>
59     Sets an XML attribute for <account> where attribute is one of:
61     NAME - Change the <account> to <value>. This will fail if there is already
62            an account named <value>.
64 HELP [<command>]
65     Shows protocol command help for <command> or shows available commands if
66     <command> is not specified.
68 QUIT
69     Closes the connection.
72 Ben Kibbey <bjk@luxsci.net>