1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
6 \use_default_options false
7 \maintain_unincluded_children false
9 \language_package default
14 \font_typewriter default
15 \font_default_family default
16 \use_non_tex_fonts false
23 \default_output_format default
25 \bibtex_command default
26 \index_command default
27 \paperfontsize default
39 \paperorientation portrait
48 \paragraph_separation indent
49 \paragraph_indentation default
50 \quotes_language english
53 \paperpagestyle default
54 \tracking_changes false
76 \begin_layout Plain Layout
86 \begin_inset CommandInset toc
87 LatexCommand tableofcontents
98 \begin_layout Standard
99 This is a tutorial showing the basic usage of libpwmd
103 \begin_layout Plain Layout
104 http://libpwmd.sourceforge.net/
114 is a library making it easy for applications to use pwmd
118 \begin_layout Plain Layout
119 http://pwmd.sourceforge.net/
126 Password Manager Daemon).
127 Password Manager Daemon
129 is a universal data server.
130 It began as a way to keep track of my passwords for accounts like email
131 and websites but can be used to store anything you want.
134 \begin_layout Standard
135 There are other password management tools but pwmd has a couple of distinguishin
139 \begin_layout Itemize
140 It does not depend on a desktop environment but has the ability for applications
141 to connect to it like a desktop solution provides.
144 \begin_layout Itemize
145 Some portion of a stored data can be shared with another portion in the
147 This feature behaves a lot like a symbolic link on a file system, XML entities,
148 or HTML targets if you're familiar with those, but implemented in a different
150 This means less duplication of content.
152 \begin_inset CommandInset ref
154 reference "sec:Linking-elements"
161 \begin_layout Itemize
162 The XML document is encrypted with libgcrypt and can also use gpg-agent.
163 Libgcrypt provides symmetric encryption while gpg-agent supports both PKI
167 \begin_layout Standard
168 Other features include:
171 \begin_layout Itemize
173 More than one client may access the same data file while optionally locking
177 \begin_layout Itemize
178 Secure memory management.
179 Pwmd will zero out memory before freeing it and the contents of the cached
180 document are encrypted.
183 \begin_layout Itemize
184 Remote connections over TLS with client certificates used as authentication.
187 \begin_layout Itemize
188 Remote connections over SSH.
191 \begin_layout Section
192 File Format and Element Paths
195 \begin_layout Standard
196 The document is saved as an XML document and is manipulated by commands
198 Commands that access data take what is called an
203 An element path is a character string containing XML element names representing
204 branches of an element tree.
205 The branches are separated with a TAB (ASCII 0x09) character.
206 Why a TAB? So other characters can be used in the element name.
207 If for example a '/' were used as the separator, then a URL (i.e., http://sf.net/)
208 could not be used as an element name.
211 \begin_layout Standard
212 For the rest of this tutorial, when you see <TAB>, replace it with a real
214 For example, the element path "root<TAB>child<TAB>last" has the following
231 Content or XML CDATA of the "last" element.
246 \begin_layout Standard
247 I should say that the XML structure that pwmd uses is a little more complicated.
248 It really looks like the following internally, but we will use the above
249 format in this tutorial for simplicity:
253 <element _name="root">
257 <element _name="child">
261 <element _name="last">
265 Content or CDATA of the "last" element.
280 \begin_layout Standard
281 Every element created has an element named
294 attribute is what an element in an element path refers to.
295 It is done this way so that a wider range of characters can be used in
296 an element name while maintaining valid XML.
297 In fact the only restriction of an element name is that it not contain
298 whitespace characters and not begin with an exclamation point (ASCII 0x21
303 \begin_inset CommandInset ref
305 reference "sec:Linking-elements"
314 \begin_layout Standard
315 There is one other difference from your normal XML document in that only
316 the first match of an element is considered for the current element tree
318 When an element of the current depth of an element tree is found, the next
319 element in the element path is searched for beginning at the child node
320 of the found element.
321 From the example above:
337 Content or XML CDATA of the "last" element.
353 This element will never be reached.
364 \begin_layout Standard
365 The second "child" element is never reached.
368 \begin_layout Section
372 \begin_layout Standard
377 client to send commands to the pwmd server.
382 includes a client named
387 It is command-line based and there are not any fancy graphics, but it is
388 good for understanding how
392 commands are processed.
393 If you want a more user friendly client that resembles a file manager and
394 has a point and click interface, try QPwmc
398 \begin_layout Plain Layout
399 http://qpwmc.sourceforge.net/
404 which uses the Qt4 toolkit and is also a full featured client.
407 \begin_layout Standard
408 In this tutorial we will use the
412 client included with libpwmd.
417 has two modes that commands are read from: interactive and stdin.
418 The interactive mode uses the readline library and has command history,
419 while reading from standard input (stdin) makes shell scripting and automation
421 For the examples, we will be connecting to the default local unix domain
422 socket that pwmd waits for connections on.
423 Remote connections are possible over TLS or an SSH channel but those are
425 Read the pwmc(1) manual page for details about how to do that.
428 \begin_layout Standard
429 The example filename we will use is "datafile".
430 It is initially a non-existent file but it will be created once we have
432 Now let us connect to the server in interactive mode and open the data
448 \begin_layout Standard
449 The "pwm>" prompt is a readline prompt that has command history and can
450 do filename completion.
451 It also is annoying because, as mentioned, elements in element paths are
452 TAB delimited, but command completion in readline uses the TAB character,
454 To insert a real TAB character in interactive mode rather than do readline
455 completion, you will need to first press CTRL-V and then press TAB.
458 \begin_layout Section
462 \begin_layout Standard
463 There are two different types of commands: client commands and protocol
465 The client commands are
469 specific and only available to the
474 Protocol commands are commands sent from any client and to the
479 All pwmc client commands are prefixed with a dot '.' followed by the command
481 Protocol commands are sent without any prefix.
482 To see the available pwmc and protocol commands, send the HELP command:
489 \begin_layout Standard
497 \begin_layout Standard
498 To store some data in an element path, you will need to know what element
500 It is up to you how you want your data organized.
501 If for example you will be storing account information it may be good to
502 categorize what the account is for: email, instant messaging, blogging,
504 An application that uses libpwmd may require that a certain element path
506 Refer to that applications documentation to determine what element paths
510 \begin_layout Standard
511 In the following example we will setup mail server element paths which can
512 be used for other applications requiring a mail server configuration.
513 First, lets create the hostname element path:
520 \begin_layout Standard
521 The STORE command is a
526 This and a few other commands, use what is called a
530 to retrieve data from the client while other commands retrieve the data
531 only from the command arguments.
532 The server inquire will wait for the client to finish sending its data
533 before completing the command.
534 When responding to a server inquire in pwmc, pwmc will show a message telling
535 you that it is waiting for data to be sent.
536 Enter the element path and its content, then press <CTRL-D> twice to finish
537 sending the data and to let
541 complete the command:
549 email<TAB>isp<TAB>IMAP<TAB>hostname<TAB>imap.server.com<CTRL-D><CTRL-D>
552 \begin_layout Standard
553 Remember that you should replace <TAB> in the examples with a real TAB character.
554 It should be known that when sending data via a server inquire there is
555 no need to press <CTRL-V> to insert the <TAB> character.
556 That is only needed to be done from the readline command prompt and when
557 not doing a server inquire.
560 \begin_layout Standard
561 After pressing the first <CTRL-D>, the characters that were entered are
566 and the inquire continues.
567 To terminate the inquire and finish sending data for the command press
568 <CTRL-D> a second time.
571 \begin_layout Standard
572 If you were to have pressed <RETURN> before any <CTRL-D> then the inquired
573 line would have been sent in full including a newline character.
574 Since in this example a newline character in a hostname is not a valid
575 hostname, this is not what we want.
578 \begin_layout Standard
579 We have just created an element path whose XML structure looks like the
596 <hostname>imap.server.com</hostname>
611 \begin_layout Standard
612 The GET protocol command returns the value, or content, of the last element
614 To retrieve the hostname of the element path we just created, do:
618 pwm> GET email<TAB>isp<TAB>IMAP<TAB>hostname
625 \begin_layout Standard
626 Remember that in interactive mode and when not doing a server inquire, you
627 will need to press <CTRL-V> before pressing <TAB>.
630 \begin_layout Standard
631 Let us create the rest of the needed elements:
639 email<TAB>isp<TAB>IMAP<TAB>port<TAB>993<CTRL-D><CTRL-D>
647 email<TAB>isp<TAB>IMAP<TAB>ssl<TAB>1<CTRL-D><CTRL-D>
655 email<TAB>isp<TAB>username<TAB>myusername<CTRL-D><CTRL-D>
663 email<TAB>isp<TAB>password<TAB>mypassword<CTRL-D><CTRL-D>
666 \begin_layout Standard
667 Now the element structure for the "email" element looks like this:
683 <hostname>imap.server.com</hostname>
699 <username>myusername</username>
703 <password>mypassword</password>
714 \begin_layout Standard
715 If you wanted to change your password (after changing it on the mail server,
716 of course) just do as you did when initially creating the password element
718 The new content will overwrite the existing content:
726 email<TAB>isp<TAB>password<TAB>newpassword<CTRL-D><CTRL-D>
729 \begin_layout Standard
730 An application using libpwmd that needs to know mail server information
731 now has all the information it needs.
732 The only thing left to do now is to save the changes:
739 \begin_layout Standard
740 After pressing <CTRL-D> a prompt will be shown asking what to do next.
742 \begin_inset Quotes eld
746 \begin_inset Quotes erd
749 to save what we have created.
752 \begin_layout Standard
753 Since this is a new file, you will be prompted for a passphrase to use for
755 Once done, the data file is encrypted and written to disk and the passphrase
756 is cached in pwmd so you do not need to enter it the next time your data
757 file is opened or saved.
758 There are a few pwmd configuration parameters and commands that affect
764 documentation for details.
767 \begin_layout Section
768 \begin_inset CommandInset label
770 name "sec:Linking-elements"
777 \begin_layout Standard
778 One distinguishing feature of pwmd is the ability to share data of one element
780 If for example your ISP lets you host a blog on their server and you use
781 a blogging client that can use libpwmd for authentication details, you
782 can share authentication information with the email example above when
783 the account details are the same.
784 When element linking is used, this avoids the need to change the content
785 for both the blogging and email password elements.
788 \begin_layout Standard
789 This is done by setting a special
790 \begin_inset Quotes eld
794 \begin_inset Quotes erd
797 attribute for an element.
798 It behaves similarly to the HTML
799 \begin_inset Quotes eld
803 \begin_inset Quotes erd
806 attribute or XML entities or a symbolic link on a filesystem.
810 \begin_layout Standard
811 Let's create an example blogging element path:
819 blog<TAB>isp<TAB>hostname<TAB>blog.myisp.com<CTRL-D><CTRL-D>
827 pwm> ATTR SET target blog<TAB>isp<TAB>username email<TAB>isp<TAB>username
831 pwm> ATTR SET target blog<TAB>isp<TAB>password email<TAB>isp<TAB>password
834 \begin_layout Standard
835 Now each access of the "blog/isp/username" and "blog/isp/password" element
836 paths, which were created if they did not already exist, will point to
837 "email/isp/username" and "email/isp/password", respectively.
838 To retrieve the value or content of an element that contains a "target"
839 attribute without following any
840 \begin_inset Quotes eld
844 \begin_inset Quotes erd
847 attribute, prefix the element with a '!' when specifying it in an element
853 pwm> GET blog<TAB>isp<TAB>!password
857 ERR 536870938: No value
860 \begin_layout Standard
861 An error is returned because we have not assigned a value to the literal
863 A literal element is an element that either contains no "target" attribute
864 or ignores it by prefixing the element with the mentioned literal element
866 Let us try storing an example password to the literal element to show usage:
874 blog<TAB>isp<TAB>!password<TAB>literalpassword<CTRL-D><CTRL-D>
877 \begin_layout Standard
878 Now when we redo the previous GET command:
882 pwm> GET blog<TAB>isp<TAB>!password
889 \begin_layout Standard
890 This is the value of the literal password element of the element path.
891 To follow the element path stored in the "target" attribute, omit the '!'
892 in the password element.
894 \begin_inset Quotes eld
898 \begin_inset Quotes erd
905 pwm> GET blog<TAB>isp<TAB>password
912 \begin_layout Standard
913 A "target" attribute may also refer to another element with a "target" attribute.
914 Every "target" attribute will be followed until there are no others to
916 To get the real element path and resolve all "target" attributes, use the
921 pwm> REALPATH blog<TAB>isp<TAB>password
925 !email<TAB>!isp<TAB>!password
928 \begin_layout Standard
929 As you can see each element is prefixed with the literal '!' character meaning
930 that no "target" attribute exists in any element of the resulting element
934 \begin_layout Standard
935 Using the LIST command is useful to show the element structure of a document:
963 !email<TAB>!isp<TAB>!username
967 !email<TAB>!isp<TAB>!password
971 !email<TAB>!isp<TAB>!IMAP<TAB>!hostname
975 !email<TAB>!isp<TAB>!IMAP<TAB>!port
979 !email<TAB>!isp<TAB>!IMAP<TAB>!ssl
995 !blog<TAB>!isp<TAB>!username
999 !blog<TAB>!isp<TAB>username
1003 !blog<TAB>!isp<TAB>!password
1007 !blog<TAB>!isp<TAB>password
1010 \begin_layout Standard
1011 Notice that there are two username and password elements in the
1012 \begin_inset Quotes eld
1016 \begin_inset Quotes erd
1019 element path: each with and without the literal element character prefix.
1020 This shows that both the username and password elements contain a "target"
1024 \begin_layout Standard
1025 For the final example, we will remove the
1026 \begin_inset Quotes eld
1030 \begin_inset Quotes erd
1033 attribute of the blogging password element:
1037 pwm> ATTR DELETE target blog<TAB>isp<TAB>!password
1040 \begin_layout Standard
1041 If we were to have omitted the '!' from the password element then pwmd would
1042 try to remove the "target" attribute from the "email/isp/password" element
1044 That would return an error because no
1045 \begin_inset Quotes eld
1049 \begin_inset Quotes erd
1052 attribute had been set for that element.
1055 \begin_layout Standard
1056 Note that the "blog" and "isp" elements have no literal element character
1057 prepended to them in the example.
1058 It is not needed because they have no
1059 \begin_inset Quotes eld
1063 \begin_inset Quotes erd
1066 attribute themselves.
1069 \begin_layout Standard
1071 \begin_inset Quotes eld
1075 \begin_inset Quotes erd
1078 attributes can be confusing.
1079 The best way to get the hang of linking elements is to experiment and use
1080 the LIST and DUMP commands to show the document structure.
1081 Remember to use the literal element prefix '!' when you do not want to
1082 follow any "target" attributes.