Version 0.3.
[pwmd.git] / PROTOCOL
blob92a25bcce3de54c207c4580da56096a5b5ad1f1c
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 a file cache and shared memory passwords do not need to be issued for each
4 file each time a 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 an (optional) description followed by a newline character. There are three
9 non-data related response codes: NFO for informational messages, ERR for error
10 messages and OK if the 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 Protocol commands:
19 OPEN <filename> [<key>]
20     Opens <filename> using <key>. If file is not found on the filesystem, then
21     a new file is created. If 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.
27 SAVE [<key>]
28     Encrypts and writes any changes to the file to disk. If <key> is not
29     specified then the currently cached key will be used. If the file is a new
30     file which hasn't yet been saved, <key> is required.
33 CACHE CLEARALL | CLEAR <filename> | ISCACHED <filename>
34     CLEARALL - Remove all files from the cache. This will require a key for
35                the next OPEN or SAVE command for existing files.
37     CLEAR    - Like CLEARALL but only for the specified file.
39     ISCACHED - A response code of OK will be returned if the specified file is
40                in the file cache. If not in the cache or the file doesn't
41                exist on the filesystem and ERR response is returned.
43     A file doesn't need to be opened to use this command.
46 LIST [<account>]
47     If no account is given, then a list of accounts is returned with a BEGIN
48     repsonse code. If given, then the element tree for the account is
49     returned. See the ATTR command and the VALUE attribute.
52 STORE <account> [TAB <element> [TAB <element> ...] TAB <value>]
53     Stores an element tree into the existing <account>, creates a new
54     <account> tree or modifies the existing element path. If no elements are
55     specifed an empty account is created. Otherwise, elements are TAB
56     deliminated and the value will be the last TAB deliminated argument. The
57     only restriction of element names is that they not contain any whitespace.
58     There is no whitespace between the TAB deliminated element arguments. It
59     is recommended that the value be base 64 encoded to prevent libXML and
60     pwmd parsing errors.
61     
63 DELETE <account> [TAB <element> [TAB <element> ...]]
64     Removes an element tree from <account> or the entire <account> if no
65     elements are given.
68 GET <account> TAB <element> [TAB <element> ...]
69     Retrieves the value for the specified element tree. See the ATTR command
70     and VALUE attribute below. The data is returned with the BEGIN response
71     code.
74 ATTR SET | DELETE | LIST [<attribute>] <arg1> [arg2]
75     ATTR SET attribute account[<TAB>element[...]] attribute_value
76     ATTR DELETE attribute account[<TAB>element[...]]
77     ATTR LIST account[<TAB>element[...]]
79     The NAME attribute cannot be DELETE'd if the element path is only the
80     account name. Although it can be SET to change the account name.
82     There is one other special attribute which is TARGET. This is like a
83     "pointer" that points to another element in the document:
85     ATTR SET TARGET account[<TAB>element[...]] account[<TAB>element[...]]
87     Then the GET and LIST commands for <arg1> would show the value of <arg2>.
88     Note that if <arg1> has both a TARGET attribute and an element value, then
89     only the TARGET attribute will be used in other commands. If the target
90     has been renamed or deleted afterwards then the GET command will fail and
91     the LIST command will silently ignore the target.
94 HELP [<command>]
95     Shows protocol command help for <command> or shows available commands if
96     <command> is not specified. A file doesn't need to be opened to use this
97     comand.
100 DUMP
101     Show the in memory document. Useful for pruning empty elements which
102     aren't shown with the LIST command.
105 QUIT
106     Closes the connection. Use the SAVE command before this command as any
107     changes will be lost.
110 If a command fails then the ERR response is returned followed by a protocol
111 error code and description. See src/pwmd_error.h or libpwmd/libpwmd.h for
112 error codes.
114 Ben Kibbey <bjk@luxsci.net>