Fix a few 'gcc -fanalyzer' warnings.
[pwmd.git] / doc / pwmd.texi
blob67c133918a7adf78634d23b8818d07030943ad84
1 \input texinfo
2 @c %**start of header 
3 @setfilename pwmd.info 
4 @settitle pwmd Manual
6 @macro manpage {a}
7 @end macro
8 @macro mansect {a}
9 @end macro
10 @macro manpause
11 @end macro
12 @macro mancont
13 @end macro
14 @c %**end of header
16 @dircategory Miscellaneous
17 @direntry
18 * pwmd: (pwmd).         Password Manager Daemon
19 @end direntry
21 @titlepage 
22 @title pwmd Manual
23 @subtitle Commands and syntax
24 @author by Ben Kibbey
25 @end titlepage
26 @contents 
28 @c    Node, Next, Previous, Up 
29 @node Top , , , (dir) 
30 @top
32 @ifinfo 
33 This manual documents @command{pwmd} version 3.3 protocol commands and
34 their syntax.
35 @end ifinfo 
37 @menu 
38 * Introduction::          Overview of pwmd.
39 * Access Control::        ACL of a single XML element.
40 * Cache Control::         Key and data file cache handling.
41 * Invoking::              Command line options.
42 * Configuration::         Configuration file options.
43 * Commands::              Protocol commands.
44 * Bulk Commands::         Running multiple commands in sequence.
45 * Status Messages::       Status lines and their meaning.
46 * Target Attribute::      A kind of symbolic link.
47 * Other Attributes::      Other attributes specially handled by pwmd.
48 * Key Expiration::        What to do when a key expires.
49 * Signals::               Signals known to pwmd.
50 * Index::                 Index of concepts.
51 @end menu
53 @c    Node,     Next,    Previous, Up 
54 @node Introduction, Access Control,        , Top 
55 @chapter Overview of @command{pwmd} 
57 @manpage pwmd.1
58 @ifset manverb
59 .B pwmd
60 \- a universal data server
61 @end ifset
63 @mansect synopsis
64 @ifset manverb
65 .B pwmd
66 [options] [file1] [...]
67 @end ifset
69 @mansect description
70 @dfn{Password Manager Daemon} (or @command{pwmd}) is a server that users or
71 applications connect to and send commands to store and retrieve data that is
72 stored in an OpenPGP encrypted @acronym{XML} document. It mimics a filesystem
73 in a lot of ways including per element @acronym{ACL}'s, but also has the
74 advantage of remote connections over @acronym{TLS} and a document cache. The
75 document cache is needed for a data file encrypted with secret keys stored on
76 a smartcard and without availability of an @acronym{HSM}.
78 The server uses the Assuan protocol and is the same used by
79 @command{gpg-agent}, @command{pinentry}, @command{gpgme} and
80 @command{scdaemon}. It also uses @cite{libgpg-error} for error reporting with
81 @var{GPG_ERR_SOURCE_USER_1} being the error source.
82 @ifset isman
84 You can import an existing @command{pwmd} version @var{3.0.x} data file by
85 dumping the raw @acronym{XML} data with
86 .BR pwmd-dump(1)
87 to a file, then
88 importing that file by using @command{pwmd}'s @option{--import} command line
89 option. Please
90 see the
91 .BR pwmd-dump(1)
92 manual page for details.
94 It is recommended to read the texinfo documentation of @command{pwmd}
95 since it contains protocol commands and syntax and other details not
96 found here.
97 @end ifset
98 @manpause
100 The @acronym{XML} document uses the following @acronym{DTD}:
102 @example
103     <?xml version="1.0"?>
104     <!DOCTYPE pwmd [
105     <!ELEMENT pwmd (element*)>
106     <!ATTLIST element _name CDATA #REQUIRED>
107     ]>
108 @end example
110 The @code{pwmd} element is the document root node while all other elements
111 of the document have the name @code{element} with an attribute @code{_name}
112 whose value uniquely identifies the element at the current element tree depth.
113 It is done this way to avoid @acronym{XML} parsing errors for commonly used
114 characters.  A @acronym{URL} for example would be an invalid @acronym{XML}
115 element since the @acronym{URI} contains a @samp{:} which is also the
116 @acronym{XML} namespace separator.
118 As mentioned, an element name must be unique for the current element tree
119 depth. You cannot have two elements containing the same @code{_name} attribute
120 value. @command{pwmd} will stop searching for an element of an @emph{element
121 path} at the first match then continue searching for the next element of the
122 element path beginning at the child node of the matched element.
124 An @emph{element path} is a @code{TAB} delimited character string where each
125 @code{TAB} separates each element in the path.  For example, the element path
126 @code{a@code{TAB}b@code{TAB}c} has the following @acronym{XML} document
127 structure:
129 @example
130         <pwmd>
131             <element _name="a">
132                 <element _name="b">
133                     <element _name="c">
134                         [@dots{} element value or content @dots{}]
135                     </element>
136                 </element>
137             </element>
138         </pwmd>
139 @end example
141 The only restriction of an element name is that it contain no whitespace
142 characters.
144 @c    Node,     Next,    Previous, Up 
145 @node Access Control, Cache Control, Introduction, Top 
146 @chapter Access Control
148 Like a filesystem has an @acronym{ACL} to grant or limit access to directories
149 or files for a specific user or group, @command{pwmd} can limit a local user,
150 group, @acronym{TLS} connection or a command to a specific element path. This
151 is done by storing an @acronym{ACL} in the element attribute @var{_acl}. Its
152 syntax is similar to the @var{allowed} configuration parameter
153 (@pxref{Configuration}) with the exception that a @acronym{TLS} fingerprint
154 hash is prefixed with a @code{#}.
156 Access is denied for any user that is not in the @acronym{ACL} of an element
157 with the exception of an invoking user (see @var{invoking_user}). The
158 connected client must be in the @acronym{ACL} for each element in an element
159 path otherwise an error is returned.
161 The first user listed in the @acronym{ACL} is considered the owner of the
162 element and must be a username or @acronym{TLS} fingerprint. This determines
163 which clients may modify an @var{_acl} attribute and store content for an
164 element. An @var{invoking_user} may always modify an @acronym{ACL}. As an
165 example:
167 @example
168 <element _name="test" _acl="username,-@@wheel,root,#ABCDEF,/usr/bin/pwmc">
169         <element _name="child"/>
170 </element>
171 @end example
173 The user @code{username} would be allowed both read and write access to the
174 @code{test} element but not if it is a member of the @code{wheel} group
175 although, the @code{root} user, who may be a member of the @code{wheel} group,
176 is allowed read-only access. The SHA-256 @acronym{TLS} fingerprint hash
177 @code{#ABCDEF} is also allowed.  No users other than an @var{invoking_user}
178 are allowed access to the @code{child} element. When a command path is found
179 in the @var{_acl} then the local client command name must match one of the
180 command paths in the @var{_acl} unless the client is the owner of the element.
181 The ability to specify read and write access for each user in an @acronym{ACL}
182 is a feature planned for a later release.
184 @c    Node,     Next,    Previous, Up 
185 @node Cache Control, Invoking, Access Control, Top 
186 @chapter Cache Control
188 @mancont
189 @mansect cache notes
190 While @command{pwmd} has its own cache settings for an @acronym{XML} document,
191 @command{gpg-agent} has cache settings for the keys used for crypto operations
192 of a data file. Specifically the @option{ignore-cache-for-signing},
193 @option{default-cache-ttl} and @option{max-cache-ttl} options. These
194 @command{gpg-agent} options may need to be adjusted depending on your usage
195 needs. For example, the @code{OPEN} command may not require a passphrase to
196 open a data file due to the gpg-agent having a cached key even though the
197 @code{ISCACHED} command returns an error indicating the data file is not
198 cached; which usually means a passphrase would be required. Keys for symmetric
199 data files are never kept in the @command{gpg-agent} cache regardless of
200 @command{gpg-agent} cache settings.
202 A copy-on-write operation is done for commands that modify the document; the
203 client that invoked the command will work on a copy of the in-memory document.
204 The first client to @code{SAVE} the changes to disk will require other clients
205 to reopen the data file due to the checksum being updated.
207 @c    Node,     Next,    Previous, Up 
208 @node Invoking, Configuration, Cache Control, Top 
209 @chapter Invoking @command{pwmd} 
211 @mansect options
212 @command{pwmd} uses GpgME for encryption, decryption and signing of the
213 OpenPGP data file. GpgME itself makes use of @command{gpg} for these
214 operations so some configuration of @command{gpg} may be needed.  Pwmd spawns
215 a separate @command{gpg-agent} process when @var{gpg_homedir}
216 (@pxref{Configuration}) is not set to an instance of an already running
217 gpg-agent. Any @command{gpg} configuration options that you need set should be
218 put in @var{~/.pwmd/.gnupg/gpg.conf} or the @var{gpg.conf} file located in
219 @var{gpg_homedir}. The same is true for the @var{gpg-agent.conf} file to set
220 any required @command{gpg-agent} options.
222 It is recommended to pass the @option{--allow-preset-passphrase}
223 option to @command{gpg-agent}. Doing so allows @command{pwmd}
224 cache pushing on startup. It is also recommended to pass the
225 @option{--allow-loopback-pinentry} to @command{gpg-agent} (this is the default
226 as of gnupg-2.1.15). This option allows a passphrase to be inquired from
227 @command{pwmd} when a @command{pinentry} is unavailable to the client
228 (@pxref{TLS}).
230 If you would like to use a keypair from your default gnupg keyring located in
231 ~/.gnupg, but would still like to use a separate gpg-agent process (the
232 default), you would need to first export the public key from the default
233 keyring then import it into the keyring that pwmd uses. You can do this by
234 first exporting the public key, then use the @option{--homedir ~/.pwmd/.gnupg}
235 option of @command{gpg} to import it into the new keyring. For private keys,
236 you would need to copy the private key associated with the exported public key
237 to @var{~/.pwmd/.gnupg/private-keys-v1.d}. If the private key is stored on
238 a smartcard you can also use the @code{KEYINFO --learn} command
239 (@pxref{KEYINFO}).
241 @cindex Running @command{pwmd} 
242 @command{pwmd} is executed as follows: 
244 @example 
245 pwmd @var{options} [ file1 ] [ @dots{} ]
246 @end example
248 Non-option arguments are data files to cache upon startup. When the data file
249 requires a passphrase for decryption a @command{pinentry} will prompt either
250 on the current TTY or from an X11 window when the @env{DISPLAY}
251 environment variable is set. @xref{Pinentry}.
253 @cindex Options 
254 @cindex Arguments 
255 The following command line options are supported:
257 @cindex Getting help 
258 @table @samp 
259 @item --debug protocol:level[,protocol:level]
260 Enable debugging output. This option can output sensitive information such as
261 passphrases and secret keys so care should be taken where the output gets
262 written to. The @var{protocol} is a single character representing the protocol
263 to log. Use @code{a} for @code{libassuan} with @var{level} being one or more
264 character flags: @code{i} for init, @code{x} for context, @code{e} for engine,
265 @code{d} for data, @code{s} for system IO or @code{c} for control.  To debug
266 @code{gpgme} use @code{g} as the @var{protocol} with @var{level} being an
267 integer from @code{1} to @code{9}. To enable @acronym{TLS} debugging output
268 use @code{t} as the @var{protocol} with @var{level} being an integer from
269 @code{1} to @code{9}. A value over @code{10} will enable all @acronym{TLS}
270 debugging output with @code{1} being the default.
272 @item --homedir directory
273 The root directory where pwmd will store its data and temporary files.  The
274 default is @file{~/.pwmd}.
276 @item --rcfile, -f rcfile
277 Specify an alternate configuration file. The default is
278 @file{~/.pwmd/config}.
280 @item --kill
281 Terminate an existing instance of pwmd. The process to terminate is determined
282 from the @option{--homedir} and @option{--rcfile} options.
284 @item --import, -I filename|-
285 Imports the @acronym{XML} @var{filename}. When @var{filename} is @code{-} the
286 @acronym{XML} is read from @code{stdin}. The @acronym{XML} file should be in conformance to
287 the @command{pwmd} @acronym{DTD} (@pxref{Introduction}). You will be prompted for
288 a passphrase to encrypt with.  The output is written to the filename specified
289 with @option{--outfile}. To make use of the imported data, place the output
290 file in @file{~/.pwmd/data}.
292 @item --output, -o filename|-
293 When importing, write the encrypted data file to @var{filename}. When
294 @var{filename} is @code{-} output will be written to @code{stdout}.
296 @item --passphrase-file, -k filename"
297 Obtain the passphrase to use when importing from the specified @var{filename}.
299 @item --keyid fingerprint[,fingerprint,@dots{}]
300 Specifies the fingerprint of the encryption key to use as a recipient when
301 importing. When not specified a new key-pair will be created.
303 @item --sign-keyid fingerprint
304 Specifies the fingerprint of the signing key to use for signing of the data
305 file when importing.  When not specified the signing key of the generated
306 key-pair or the signing key of the @option{--keyid} option will be used.
308 @item --symmetric, -s
309 Use symmetric or conventional encryption rather than pubic key encryption when
310 importing.  Signing is still possible by using the @option{--sign-keyid}
311 option. By default no signing is done when specifying this option.
313 @item --userid string
314 When importing, the user id used to identify the generated key. This should be
315 in the form @code{First Last <email>}.
317 @item --algo string
318 When importing, the algorithm to use when generating the new key pair. The
319 default is determined by @command{gpg}.
321 @item --expire seconds
322 When importing, the time, in seconds since epoch, when the generated key will
323 expire. Specifying @code{0} will never expire the key. The default is three
324 years.
326 @item --no-passphrase
327 When importing, don't require a passphrase for the generated key.
329 @item --disable-dump
330 Disable the @code{XPATH}, @code{XPATHATTR}, @code{LIST} and @code{DUMP}
331 protocol commands (@pxref{Commands}). This overrides any
332 @var{disable_list_and_dump} configuration parameter (@pxref{Configuration}).
334 @item --no-fork, -n
335 Run as a foreground process and do not fork into the background.
337 @item --force
338 Ignore cache pushing failures on startup. By default, @command{pwmd} will exit
339 if an error occurred due to an invalid passphrase or other error.
341 @item --version
342 Show the version, copyright and compile time features and exit.
344 @item --help 
345 Print a summary of options.
346 @end table
347 @manpause
349 @c    Node,     Next,    Previous, Up 
350 @node Configuration, TLS, Invoking, Top 
351 @chapter @command{pwmd} configuration file options
352 @mancont
353 @mansect configuration file
354 If no configuration file is specified with the @command{pwmd} @option{-f}
355 command line option, @command{pwmd} will read @file{~/.pwmd/config} if it
356 exists, and if not, will use defaults.  Blank lines and lines beginning with
357 @samp{#} are ignored. Some parameters may have data file specific settings by
358 placing them in a file section. A file section is declared by surrounding the
359 filename with braces (i.e., @samp{[filename]}).  Global options may be
360 specified in the @code{global} section (e.g., @samp{[global]}) and are the
361 default options for new or unspecified file sections.
363 A tilde @code{~} will be expanded to the home directory of the user starting
364 @command{pwmd} when contained in a parameter whose value is a filename.
366 @cindex Reloading the configuration file
367 The configuration file can be reloaded by sending the @emph{SIGHUP} signal to
368 a @command{pwmd} process. Some security sensitive settings may not be changed
369 until @command{pwmd} is stopped then restarted.
371 @cindex Global configuration options
372 The following options are only for use in the @code{[global]} section:
374 @table @samp 
375 @cindex socket_path
376 @item socket_path = /path/to/socket
377 Listen on the specified socket. The default is @file{~/.pwmd/socket}.
379 @cindex socket_perms
380 @item socket_perms = octal_mode
381 Permissions to set after creating the socket. This will override any
382 @cite{umask(2)} setting.
384 @cindex backlog
385 @item backlog = integer
386 The number of connections to queue. When this limit is reached then new
387 connections will be refused. The default is @code{128}.
389 @cindex invoking_user
390 @item invoking_user = [-!]user,[-!]@@group,[-!]#SHA-256,@dots{}
391 This parameter is not to be confused with setuid or setguid upon startup. It's
392 syntax is the same as the @code{allowed} parameter except that it is a list of
393 local usernames, group names and @acronym{TLS} fingerprint hashes that may use the
394 @command{XPATH}, @command{XPATHATTR} and @command{DUMP} commands (except when
395 disabled with the @code{disable_list_and_dump} option) and also who may modify
396 elements that have no @code{_acl} attribute or is not listed in an
397 @code{_acl}. It is similar to the system administrator root account but for a
398 data file and element paths (@pxref{Access Control}). The default is specified
399 at compile-time and also by default is the user @code{nobody}.
401 @cindex invoking_file
402 @item invoking_file = filename
403 A file containing one entry per line. An entry has the same syntax as the
404 @code{invoking_user} parameter. When both this parameter and the
405 @code{invoking_user} parameter are specified then the @code{invoking_user}
406 parameter will behave as if the @code{invoking_file} entries have been
407 appended to the @code{invoking_user} parameter value.
409 @cindex strict_open
410 @item strict_open = boolean
411 When @code{true}, disallow creation of a new data file when the current client
412 is not an @code{invoking_user}. The default is @code{false}.
414 @cindex strict_kill
415 @item strict_kill = boolean
416 When @code{false}, the @code{KILL} command (@pxref{KILL}) will allow killing
417 another client that is not of the same @code{UID} or @acronym{TLS} fingerprint of
418 the current client and when not an @code{invoking_user}. The default us
419 @code{false}.
421 @cindex allowed
422 @item allowed = [-!]user,[-!]@@group,[+,][-!]#SHA-256,[-!]/path/to/exec[@dots{}]
423 A comma separated list of local user names, group names or @acronym{TLS}
424 fingerprint SHA-256 hashes (in the case of a remote client) which are
425 allowed to connect.  Groups should be prefixed with a @samp{@@}. When not
426 specified only the user who started @command{pwmd} may connect. An entry in
427 the list may be prefixed with a @code{-} or @code{!} to prevent access. The
428 order of the list is important since a user may be a member of multiple
429 groups, for example.
431 Connections from local clients may also be limited by command name. A command
432 name is the full path to the execuatble on the filesystem. The command check
433 is done after all other user and group name checks. When no command is
434 specified all commands are allowed. This feature is ignored when the
435 connecting client is not of the same @acronym{UID} as the user that invoked
436 @command{pwmd}.
438 This parameter may also be specified in a filename section to allow or deny a
439 client to @code{OPEN} (@pxref{OPEN}) a data file. It also affects the cache
440 commands @code{CLEARCACHE} (@pxref{CLEARCACHE}) and @code{CACHETIMEOUT}
441 (@pxref{CACHETIMEOUT}). When not specified in a file section, any client
442 allowed to connect may also open any filename provided they can decrypt it.
443 Note that when specified in a file section that any @var{allowed} parameter in
444 the @code{global} seciton is not considered.
446 The following example would deny all users in group @code{primary} but
447 allow @code{username} who may be a member of @code{primary}. It will also
448 allow any @acronym{TLS} client except for the client with @acronym{TLS}
449 fingerprint hash @code{#ABCDEF}. For local connections, the connecting client
450 must be using the /usr/bin/pwmc program:
452 @example
453 allowed=-@@primary,username,+,!#ABCDEF,/usr/bin/pwmc
454 @end example
456 @cindex allowed_file
457 @item allowed_file = filename
458 A file containing one entry per line. An entry has the same syntax as the
459 @code{allowed} parameter except that a line beginning with a semicolon is
460 ignored. When both this parameter and the @code{allowed} parameter are
461 specified then the @code{allowed_file} entries will be appended to the
462 @code{allowed} parameter value.
464 @cindex encrypt_to
465 @item encrypt_to = boolean
466 When @code{true} and @command{SAVE}'ing a data file, allow @command{gpg} to
467 append it's configured key to the list of recipients. The default is
468 @code{false} meaning that only keys specified with @command{SAVE}
469 @option{--keyid} are recipients.
471 @cindex always_trust
472 @item always_trust = boolean
473 When @code{true}, allow encrypting to untrusted recipients or public
474 encryption keys. If you receive an error when @command{SAVE}'ing stating that
475 the public key is unusable, either enable this option or edit the keys' trust
476 value:
477 @example
478 gpg --homedir ~/.pwmd/.gnupg --edit-key <fingerprint>
479 @end example
480 The default is @code{false}.
482 @cindex gpg_homedir
483 @item gpg_homedir = path
484 The location where @command{gpg} will store its public and private keys and
485 configuration. The default is @file{HOMEDIR/.gnupg} where @var{HOMEDIR} is the
486 default (@file{~/.pwmd}) or the value specified on the command line with the
487 @option{--homedir} command line option (@pxref{Invoking}). If you want to use
488 your standard @command{gpg} keyring then set this to @file{~/.gnupg}. Note
489 that a new instance of @command{gpg-agent} will be started when @emph{not}
490 using the standard keyring and that any configuration options for
491 @command{gpg-agent} will need to placed in
492 @file{HOMEDIR/.gnupg/gpg-agent.conf}.
494 @cindex disable_mlockall
495 @item disable_mlockall = boolean
496 When set to @code{false}, @cite{mlockall(2)} will be called on startup.  This
497 will use more physical memory but may also be more secure since no swapping to
498 disk will occur. The default is @var{true}. If possible, use an encrypted swap
499 file or partition and leave this set to @var{true}.
501 @cindex log_path
502 @item log_path = /path/to/logfile
503 Logs informational messages to the specified file. The default is
504 @file{~/.pwmd/log}.
506 @cindex enable_logging
507 @item enable_logging = boolean
508 Enable or disable logging to @var{log_path}. The default is @code{false}.
510 @cindex log_keepopen
511 @item log_keepopen = boolean
512 When set to @code{false}, the log file specified with @var{log_path} will be
513 closed after writing each line. The default is @code{true}.
515 @cindex syslog
516 @item syslog = boolean
517 Enable logging to @cite{syslog(8)} with facility @emph{LOG_DAEMON} and priority
518 @emph{LOG_INFO}. The default is @code{false}.
520 @cindex log_level
521 @item log_level = level
522 When @code{0}, only connections and errors are logged. When @code{1}, data
523 file recipients and signers are logged during @code{OPEN} (@pxref{OPEN}) and
524 @code{SAVE} (@pxref{SAVE}). When @code{2}, client commands are also logged.
525 The default is @code{0}.
527 @cindex kill_scd
528 @item kill_scd = boolean
529 Attempt to kill @command{scdaemon} after a client disconnects.  The default is
530 @code{false}.
532 @cindex disable_list_and_dump
533 @item disable_list_and_dump = boolean
534 When @code{true} the @code{XPATH}, @code{XPATHATTR}, @code{LIST} and
535 @code{DUMP} protocol commands (@pxref{Commands}) will be disabled.
537 @cindex cache_push
538 @item cache_push = file1,file2
539 A comma separated list of filenames to be cached upon startup. @command{pwmd}
540 will prompt for the passphrase for each file unless specified with
541 @var{passphrase_file} parameter in a matching file section.
543 @cindex priority
544 @item priority = integer
545 The priority or niceness of the server. The default is inherited from the
546 parent process.
548 @cindex lock_timeout
549 @item lock_timeout = integer
550 The default timeout in tenths of a second before giving up while waiting for a
551 file lock and returning an error. The default is @code{50}.
553 @end table
555 @cindex Data file configuration options
556 @ifset manverb
558 @end ifset
559 The following options are defaults for new files when specified in the
560 @samp{global} section. When placed in a data file section they are options
561 specific to that data file only.
563 @table @samp 
564 @cindex require_save_key
565 @item require_save_key = boolean
566 Require the passphrase needed for signing before writing changes of the
567 document to disk regardless of the key cache status. The default is
568 @code{true}. This option compliments @command{gpg-agent} option
569 @option{--ignore-cache-for-signing} and is used as a fail-safe.
571 @cindex backup
572 @item backup = boolean
573 Whether to create a backup of the data file when saving. The backup filename
574 has the @file{.backup} extension appended to the opened file. The default is
575 @code{true}. 
577 @cindex cache_timeout
578 @item cache_timeout = seconds
579 The number of seconds to keep the cache entry for this file. If @code{-1}, the
580 cache entry is kept forever. If @code{0}, each time an encrypted file is
581 @code{OPEN}ed (@pxref{OPEN}) a passphrase will be required. The default
582 is @code{600} or 10 minutes.
584 @cindex passphrase_file
585 @item passphrase_file = /path/to/filename
586 Obtain the passphrase to open the data file from @var{filename}. If specified
587 in the @samp{global} section then the @var{passphrase_file} is a default for
588 all data files. Note that if a client changes the passphrase for this data
589 file then the @var{passphrase_file} will need to be updated with the new
590 passphrase.
592 @cindex recursion_depth
593 @item recursion_depth = integer
594 The maximum number of times to resolve a @code{_target} attribute for an
595 element in an element path (@pxref{Target Attribute}). An error is returned
596 when this value is exceeded.  The default is @code{100} but can be disabled by
597 setting to @code{0} (@emph{not recommended}).
599 @item allowed = [-]user,[-]@@group,[!]#TLSFINGERPRINT,@dots{}
600 Same parameter value as the @code{allowed} parameter mentioned above in
601 the @samp{[global]} section but grants or denies a client from opening a
602 specific data file. The default is to allow any client that is allowed to
603 connect.
605 @end table
606 @menu
607 * TLS::                   Remote connections over TLS.
608 * Pinentry::              Configuration file and defaults.
609 @end menu
611 @node TLS, Pinentry, Configuration, Configuration
612 @chapter Configuring remote connections over TLS.
613 @ifset manverb
615 @end ifset
616 In addition to connecting to @command{pwmd} via a Unix Domain Socket, remote
617 connections can also be made to @command{pwmd} over @acronym{TLS}.
618 Authentication is done by using X.509 client certificates that are signed with
619 the same Certificate Authority (CA) as the server certificate.
621 The CA certificate is expected to be found in
622 @file{~/.pwmd/ca-cert.pem} while the @command{pwmd} server certificate and key
623 file should be put in @file{~/.pwmd/server-cert.pem} and
624 @file{~/.pwmd/server-key.pem}, respectively.
626 See the documentation of @command{certtool} or @command{openssl} for details
627 about creating self-signed certificates.
629 The following @acronym{TLS} configuration options are available:
631 @table @samp 
632 @cindex enable_tcp
633 @item enable_tcp = boolean
634 Whether to enable @acronym{TCP}/@acronym{TLS} server support. If enabled, both @acronym{TCP} and the local
635 unix domain socket will listen for connections. The default is
636 @code{false}.
638 @cindex tcp_port
639 @item tcp_port = integer
640 The @acronym{TCP} port to listen on when @var{enable_tcp} is @code{true}. The default is
641 @code{6466}.
643 @cindex tcp_bind
644 @item tcp_bind = string
645 The internet protocol to listen with. Must be one of @code{ipv4}, @code{ipv6}
646 or @code{any} to listen for both IPv4 and IPv6 connections. The default is
647 @code{any}.
649 @cindex tcp_interface
650 @item tcp_interface = string
651 Only useful if running as root.
653 @cindex tls_timeout
654 @item tls_timeout = seconds
655 The number of seconds to wait for a read() or write() call on a
656 @acronym{TLS} client file descriptor to complete before returning an
657 error. The default is @var{300}.
659 @cindex keepalive_interval
660 @item keepalive_interval = seconds
661 Send a keepalive status message to an idle remote client.  An idle
662 client is one that is not in a command. The purpose of this status
663 message is to disconnect a hung remote client and release any file mutex
664 locks so another client may open the same data file. The default is @code{60}.
666 @cindex tcp_require_key
667 @item tcp_require_key = boolean
668 When @code{true}, require the remote client to provide the passphrase to open
669 a data file even if the file is cached.  This option is a default for all
670 files when specified in the @samp{[global]} section. The default is
671 @code{false}.
673 @cindex tls_cipher_suite
674 @item tls_cipher_suite = string
675 The GnuTLS cipher suite and protocol to use. See the GnuTLS documentation for
676 information about the format of this string. The default is
677 @code{SECURE256:SECURE192:SECURE128:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1:-AES-128-CBC:-AES-256-CBC}.
679 @cindex tls_dh_params_file
680 @item tls_dh_params_file = filename
681 The PEM encoded filename containing DH parameters. If not specified
682 then DH algorithms will not be available to the client. See the
683 @command{openssl dhparam} or @command{certtool} manual pages for details about
684 generating this file.
686 Note that SIGHUP will not reload this file once @acronym{TLS} support has been enabled.
687 You will need to restart @command{pwmd} for changes to take effect.
689 @cindex tls_use_crl
690 @item tls_use_crl = boolean
691 When @code{true}, enable the use of @option{tls_crl_file}. The default is
692 @code{false}.
694 @cindex tls_crl_file
695 @item tls_crl_file = filename
696 This file is an X.509 Certificate Revocation List (@acronym{CRL}) and can be
697 used to deny clients by adding client certificates to it. @command{pwmd} will
698 need to be restarted to recognize any changes to this file.  When not
699 specified the default of @file{~/.pwmd/crl.pem} will be used when
700 @option{tls_use_crl} is @code{true}.
702 @cindex tls_ca_file
703 @item tls_ca_file = filename
704 The filename of the @acronym{CA} certificate to use. When not specified the
705 default of @file{~/.pwmd/ca-cert.pem} will be used.
707 @cindex tls_server_cert_file
708 @item tls_server_cert_file = filename
709 The filename of the server certificate to use. When not specified the default
710 of @file{~/.pwmd/server-cert.pem} will be used.
712 @cindex tls_server_key_file
713 @item tls_server_key_file = filename
714 The key filename of the server certificate to use. When not specified the
715 default of @file{~/.pwmd/server-key.pem} will be used.
717 @end table
719 @node Pinentry, Commands, TLS, Configuration
720 @chapter Pinentry configuration
721 @mansect Pinentry
722 The @command{pinentry} program is used to prompt the user for passphrase
723 input or as a confirmation dialog; it needs to know where to prompt for
724 the input; from a terminal or an X11 display.
726 It is the responsibility of the client to tell @command{pinentry} about the
727 terminal or X11 display before requiring the input. This is done with the
728 @command{OPTION} command (@pxref{OPTION}) to either set or unset needed
729 @command{pwmd} environment variables and by using the
730 @command{gpg-connect-agent} program. Please read it's documentation about the
731 @emph{UPDATESTARTUPTTY} command.
733 @ifclear isman
734 @c    Node,     Next,    Previous, Up
735 @node Commands, Bulk Commands, Pinentry, Top
736 @chapter Protocol commands and their syntax
737 @include menu.texi
738 @include commands.texi
740 @c    Node,     Next,    Previous, Up
741 @node Bulk Commands, Status Messages, Commands, Top
742 @chapter Running multiple commands in sequence
743 Multiple commands may be run in sequence by using the @code{BULK} command
744 (@pxref{BULK}). Using this feature may speed up remote connections since less
745 socket IO is needed. The @code{BULK} command uses an @emph{INQUIRE} to obtain
746 an canonical s-expression of commands to be run. The s-expression syntax is as
747 follows:
749 @example
750 (2:id<I>:<id> <P>:<prot><D>:[<data>] [2:rc<R>:<code>[|<code>@dots{}2:id@dots{}| 2:id@dots{}])
751 @end example
753 Each token is prefixed with an unsigned integer that specifies the length of
754 the token, followed by a colon '@code{:}', followed by the token itself. Pwmd
755 uses token pairs to create a @emph{name=value} relationship. Whitespace is
756 allowed between token pairs. For example, the following is valid:
758 @example
759 ( 2:id 7:FirstID 4:LIST0: 2:rc 1:0 (2:id6:Second 7:GETINFO7:version))
760 @end example
762 The @code{id} token begins a new command and requires an @var{<id>} token
763 of length @var{<I>} to uniquely identify this command. The next token pair is
764 the protocol command name, without any command arguments, of length @var{<P>}
765 to run followed by a colon '@code{:}', followed by the command @var{<prot>}
766 itself, followed by the length @var{<D>} of both command arguments and data,
767 followed by a colon '@code{:}' and finally the @var{<data>} itself.  If no
768 arguments or data are needed for the command, set the length of the data
769 @var{<D>} to @code{0} and append the required colon '@code{:}'.
771 A new command enclosed in parentheses may be run when the previous command
772 returns an error code that matches the @var{<code>} token of length @var{<R>}
773 by appending @var{rc} tokens to the end of the previous commands @var{<data>}
774 token. You may also test another return code for the previous command by
775 placing the next @var{rc} token at the end of the closing parentheses of the
776 previous return code command.
778 Multiple @code{rc} @var{code}'s may be specified for a single command by
779 separating them with a pipe @code{|} character. This lets you specify an
780 @emph{if-this-and-that} expression for a commands return code.
782 If another command is to be run after the previous and does not specify an
783 @var{rc} token, the return value is ignored for the previous command and the
784 next command is run.  There is no limit on the number of commands or
785 sub-commands except for system memory.
787 After inquiring the commands to be run, @code{BULK} will run each command with
788 @var{<data>} as its argument and store the result code and data of the command
789 in a @code{bulk-result} canonical s-expression of the syntax:
791 @example
792 (11:bulk-result2:id<I>:<id>2:rc<R>:<code><D>:[<data>][2:id@dots{}])
793 @end example
795 The @code{11:bulk-result} token begins the result of all commands. The
796 @var{<id>} token of length @var{<I>} is the same that was associated with the
797 command from the @emph{INQUIRE}'d syntax and is prefixed with @code{2:id}. The
798 return code of the command is prefixed with @code{2:rc} followed by the length
799 @var{<R>} of the unsigned integer @var{<code>} then the return @var{<code>}
800 itself.  If the command returned any @var{<data>}, it is prefixed with a
801 length @var{<D>} and immediately following the return @var{<code>}. Otherwise,
802 @var{<D>} will be @code{0} and followed by a colon '@code{:}'.
805 @c    Node,     Next,    Previous, Up 
806 @node Status Messages, Target Attribute, Bulk Commands, Top
807 @chapter Status messages and their meanings
808 Some commands send status messages to inform the client about certain
809 operations or as a progress indicator.  Status messages begin with a
810 @code{KEYWORD} followed by a status description for status messages that
811 require it. What status messages are sent, when, and how often may depend on
812 configuration settings (@pxref{Configuration}).
814 @multitable @columnfractions .20 .25 .55
815 @headitem Message @tab Parameters @tab Description
816 @item CACHE
817 @cindex CACHE
818 @tab @code{<integer>}
819 @tab The number of cached documents. Sent to each client after connecting
820 (@pxref{GETINFO}) and to every client after a cache modification.
822 @item CLIENTS
823 @cindex CLIENTS
824 @tab @code{<integer>}
825 @tab The number of connected clients (@pxref{GETINFO}). Sent to each client
826 when another client either connects or disconnects.
828 @item DECRYPT
829 @cindex DECRYPT
830 @tab
831 @tab Sent to the current client during a decrypt operation. How often this
832 status message is sent is determined by the @code{keepalive_interval}
833 (@pxref{Configuration}) setting.
835 @item ENCRYPT
836 @cindex ENCRYPT
837 @tab
838 @tab Sent to the current client during an encrypt operation. How often this
839 status message is sent is determined by the @code{keepalive_interval}
840 (@pxref{Configuration}) setting.
842 @item GENKEY
843 @cindex GENKEY
844 @tab @code{[<sigkey_fpr> <pubkey_fpr>]}
845 @tab Sent to the current client during key generation. How often this
846 status message is sent is determined by the @code{keepalive_interval}
847 (@pxref{Configuration}) setting. The @var{sigkey_fpr} and @var{pubkey_fpr}
848 parameters are added when key generation has completed.
850 @item INQUIRE_MAXLEN
851 @cindex INQUIRE_MAXLEN
852 @tab @code{<bytes>}
853 @tab Sent to the current client from @command{gpg-agent} when inquiring data.
854 This specifies the maximum number of bytes allowed for the client to send and
855 should not be exceeded.
857 @item KEEPALIVE
858 @cindex KEEPALIVE
859 @tab
860 @tab Sent to each idle client every @var{keepalive_interval}
861 (@pxref{Configuration}) seconds.
863 @item LOCKED
864 @cindex LOCKED
865 @tab
866 @tab Sent to the current client when another client is holding the lock for
867 the mutex associated with a data file. How often this status message is sent
868 is determined by the @code{keepalive_interval} (@pxref{Configuration})
869 setting.
871 @item NEWFILE
872 @cindex NEWFILE
873 @tab
874 @tab Sent to the current client when the opened (@pxref{OPEN}) file does not
875 exist on the file-system.
877 @item MODIFIED
878 @cindex MODIFIED
879 @tab @code{<client_id>}
880 @tab Sent to each client with the same opened data file as @var{client_id} to
881 inform them of modifications that were written to disk using the
882 @command{SAVE} command.
884 @item XFER
885 @cindex XFER
886 @tab @code{<sent> <total>}
887 @tab Sent to the current client when transferring data. It has two space
888 delimited arguments. The first being the current amount of bytes transferred
889 and the other being the total bytes to be transferred. Note that since version
890 @code{3.1.1} of @command{pwmd} this status message is sent only once and
891 before the transfer begins with the @var{total} argument set to the size of the
892 data and the @var{sent} argument set to @code{0} leaving it to the client to
893 determine the progress of the transfer as the data is received.
895 @item STATE
896 @cindex STATE
897 @tab @code{<client_id> <state>}
898 @tab Sent to each client to indicate that @var{client_id} has changed to
899 @var{state} (@pxref{GETINFO} for client states). For a client to receive
900 another clients state the option @var{CLIENT-STATE} must be set
901 (@pxref{OPTION}).
903 @item EXPIRE
904 @cindex EXPIRE
905 @tab @code{<epoch_seconds> <epoch_future>|0}
906 @tab Sent to the current client when @code{GET} (@pxref{GET}) encounters an
907 @code{_expire} (@pxref{Other Attributes}) attribute that is in the past or when
908 @code{STORE} (@pxref{STORE}) updates the @code{_expire} attribute from the
909 @code{_age} attribute value. The second field will be @code{0} when @code{GET}
910 sends this status message.  Otherwise the second field is the time the next
911 expiry will be.
913 @item PASSPHRASE_HINT
914 @cindex PASSPHRASE_HINT
915 @tab <keyid> <userid>
916 @tab Forwarded from @code{GpgME}. Contains information that is useful in a
917 @command{pinentry}. Only sent when pinentry is disabled (@pxref{OPTION}).
919 @item PASSPHRASE_INFO
920 @cindex PASSPHRASE_INFO
921 @tab <flags> @dots{}
922 @tab Forwarded from @code{GpgME}. Contains information that is useful in a
923 @command{pinentry}. Only sent when pinentry is disabled (@pxref{OPTION}).
925 @item REHANDSHAKE
926 @cindex REHANDSHAKE
927 @tab
928 @tab Sent to each @acronym{TLS} client just before performing a cipher renegotiation
929 after a SIGHUP signal was received.
931 @item BULK
932 @cindex BULK
933 @tab @code{BEGIN|END <command id>}
934 @tab Sent to the current client before and after the @code{BULK} command
935 (@pxref{BULK}) runs each command. The @var{<command id>} is the same that was
936 associated with the command in the s-expression syntax.
937 @end multitable
939 @c    Node,     Next,    Previous, Up 
940 @node Target Attribute, Other Attributes, Status Messages, Top
941 @chapter The @code{target} attribute
942 @cindex target attribute
943 A @emph{case sensitive} attribute named @code{_target} is treated specially
944 when found in each element of an element path. This attribute, like other
945 element attributes, is created or modified with the @code{ATTR} command
946 (@pxref{ATTR}). The value of this attribute is an existing element path
947 somewhere in the document.  If you are familiar with @acronym{XML} entities or
948 maybe the HTML @code{id} or @code{_target} attributes or a symbolic link
949 in a file-system, you may find this attribute behaves similar to any of those.
951 To create a @code{_target} attribute use the following syntax:
953 @example
954 ATTR SET _target element[@code{TAB}child[..]] element[@code{TAB}child[..]]
955 @end example
957 Note the single space between the two element paths. The first element path is
958 where the @code{_target} attribute will be created. If the element path does
959 not exist then it will be created.  This is the only time the @code{ATTR}
960 (@pxref{ATTR}) command will create elements. The attribute is created in the
961 final element of the element path.
963 The second element path is the destination of where you want the first element
964 path to resolve to. When an element path is passed as an argument to a
965 protocol command @command{pwmd} looks for a @code{_target} attribute when
966 resolving each element and, if found, "jumps" to the attribute value and
967 continues resolving any remaining elements a commands element path.
969 When an element of a element path is removed that a @code{_target} attribute
970 resolves to then an error will occur when trying to access that element. You
971 may need to either update the @code{_target} attribute value with a new element
972 path or remove the attribute entirely.
974 Clients should be careful of creating @code{_target} loops, or targets that
975 resolve to themselves. See the @var{recursion_depth} in @ref{Configuration}
976 for details.
978 The @code{REALPATH} command (@pxref{REALPATH}) can be used to show the element
979 path after resolving all @code{_target} attributes.
981 @emph{Note that when setting this attribute any children of the element will
982 be removed.}
985 @c    Node,     Next,    Previous, Up 
986 @node Other Attributes, Key Expiration, Target Attribute, Top
987 @chapter Other special attributes
988 @cindex special attributes
989 In addition to the @code{_target} attribute (@pxref{Target Attribute}), there
990 are a few other attributes that are specially handled by @command{pwmd}. The
991 first is the @code{_ctime} attribute which is set to the current time when an
992 element is created. Next is the @code{_mtime} attribute which is created when
993 an element is created and also updated when an element is modified. Neither of
994 these attributes may be modified by the client. The @code{_acl} attribute
995 controls access to the element, albeit modifying or accessing element content,
996 or descending into child elements.  @xref{Access Control} for details. The
997 @code{_name} attribute contains the name of an element.
999 The above mentioned attributes are considered reserved attribute names.
1000 Reserved attributes are treated specially when a @code{_target} attribute is
1001 found for the current element. The @code{ATTR LIST} command will show these
1002 attribute values for the current element and not the attribute values for the
1003 resolved @code{_target} element. All other non-reserved attributes for the
1004 resolved @code{_target} are appended to the @code{ATTR LIST} command output.
1005 Other @code{ATTR} commands (@pxref{ATTR}) behave as usual. You can, for
1006 example, @code{ATTR DELETE} a non-reserved attribute for an element that
1007 contains a @code{_target} attribute. The resolved target elements' attribute
1008 will be removed rather than the element containing the @code{_target}
1009 attribute.
1011 Another specially handled attribute is the @code{_expire} attribute. This
1012 attribute value, like the @code{_ctime} and @code{_mtime} attributes, is a
1013 timestamp. But this timestamp is usually in the future and for use with the
1014 @code{GET} (@pxref{GET}) and @code{STORE} (@pxref{STORE}) commands. When the
1015 @code{GET} command is issued, it checks for an @code{_expire} attribute an
1016 compares its' value with the current time. If the @code{_expire} timestamp is
1017 in the past then a status message is sent (@pxref{Status Messages}) to inform
1018 the client that the element content should be updated.  When the content for
1019 an element containing an @code{_expire} attribute is set when using the
1020 @code{STORE} command, the value of the @code{_age} attribute is added to the
1021 current time and the @code{_expire} attribute value is updated.  When no
1022 @code{_age} attribute is found, no modification is done of the @code{_expire}
1023 attribute.
1026 @c    Node,     Next,    Previous, Up 
1027 @node Key Expiration, Signals, Other Attributes, Top
1028 @chapter Key Expiration
1029 @cindex key expiration
1030 When a key used for signing a data file has expired there is no indication
1031 until the next @code{SAVE} command is sent. The command will fail since one
1032 cannot sign the data file with an expired key. The client will need to either
1033 use a different key for signing by either specifying an existing non-expired
1034 key, generate a new key, or change the expire time of the existing key with
1035 @command{gpg}.
1037 To change the expiration of the currently used signing key with @command{gpg},
1038 use the @code{KEYINFO} command (@pxref{KEYINFO}) to obtain the fingerprint of
1039 the signing key of the current data file, then change the expire time with
1040 @command{gpg}:
1042 @example
1043 gpg --homedir ~/.pwmd/.gnupg --edit-key <fingerprint>
1044 @end example
1046 Then use the @code{expire} command to set the new key expire date. When
1047 finished, use the @code{save} command to save your changes.
1050 @c    Node,     Next,    Previous, Up
1051 @node Signals, Index, Key Expiration, Top
1052 @chapter Recognized signals
1053 @end ifclear
1054 @mansect signals
1055 Sending the @emph{SIGHUP} signal to a @command{pwmd} process will reload the
1056 configuration file and sending @emph{SIGUSR1} will clear the entire file
1057 cache.
1059 @mansect see also
1060 @ifset manverb
1061 .BR pwmd-dump (1)
1063 .BR gpg-agent (1)
1065 .BR pinentry (1)
1067 .BR gpg (1)
1068 @end ifset
1070 @ifclear isman
1071 @c    Node,     Next,    Previous, Up 
1072 @node Index, , Signals, Top 
1073 @unnumbered Index
1074 @printindex cp
1075 @end ifclear
1077 @bye