Fix for compiling the library with g++.
[pwmd.git] / PROTOCOL
blob76debccdcc487df97c8341d97fbfd23ec6698265
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 | GET | 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[...]]
78     ATTR GET attribute account[<TAB>element[...]]
80     The NAME attribute cannot be DELETE'd if the element path is only the
81     account name. Although it can be SET to change the account name.
83     There is one other special attribute which is TARGET. This is like a
84     "pointer" that points to another element in the document:
86     ATTR SET TARGET account[<TAB>element[...]] account[<TAB>element[...]]
88     Then the GET and LIST protocol commands for <arg1> would show the value of
89     <arg2>. Note that if <arg1> has both a TARGET attribute and an element
90     value, then only the TARGET attribute will be used in other protocol
91     commands. If the target has been renamed or deleted afterwards then the
92     GET protocol command will fail and the LIST protocol command will silently
93     ignore the target.
96 HELP [<command>]
97     Shows protocol command help for <command> or shows available commands if
98     <command> is not specified. A file doesn't need to be opened to use this
99     comand.
102 DUMP
103     Show the in memory document. Useful for pruning empty elements which
104     aren't shown with the LIST command.
107 QUIT
108     Closes the connection. Use the SAVE command before this command as any
109     changes will be lost.
112 If a command fails then the ERR response is returned followed by a protocol
113 error code and description. See src/pwmd_error.h or libpwmd/libpwmd.h for
114 error codes.
116 Ben Kibbey <bjk@luxsci.net>