16 @dircategory Miscellaneous
18 * pwmd: (pwmd). Password Manager Daemon
23 @subtitle Commands and syntax
28 @c Node, Next, Previous, Up
33 This manual documents @command{pwmd} version 3.3 protocol commands and
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.
53 @c Node, Next, Previous, Up
54 @node Introduction, Access Control, , Top
55 @chapter Overview of @command{pwmd}
60 \- a universal data server
66 [options] [file1] [...]
70 @dfn{Password Manager Daemon} (or @command{pwmd}) is a server that
71 applications connect to and send commands to put and get data that is stored
72 in an OpenPGP encrypted @acronym{XML} document. It mimics a filesystem in a
73 lot of ways including per element @acronym{ACL}'s, but also has the advantage
74 of remote connections over @acronym{TLS} and a document cache. The document cache is
75 needed for a data file encrypted with secret keys stored on a smartcard.
77 The server uses the Assuan protocol and is the same used by
78 @command{gpg-agent}, @command{pinentry}, @command{gpgme} and
79 @command{scdaemon}. It also uses @cite{libgpg-error} for error reporting with
80 @var{GPG_ERR_SOURCE_USER_1} being the error source.
83 You can import an existing @command{pwmd} version @var{3.0.x} data file by
84 dumping the raw @acronym{XML} data with
87 importing that file by using @command{pwmd}'s @option{--import} command line
91 manual page for details.
93 It is recommended to read the texinfo documentation of @command{pwmd}
94 since it contains protocol commands and syntax and other details not
99 The @acronym{XML} document uses the following @acronym{DTD}:
102 <?xml version="1.0"?>
104 <!ELEMENT pwmd (element*)>
105 <!ATTLIST element _name CDATA #REQUIRED>
109 The @code{pwmd} element is the document root node while all other elements
110 of the document have the name @code{element} with an attribute @code{_name}
111 whose value uniquely identifies the element at the current element tree depth.
112 It is done this way to avoid @acronym{XML} parsing errors for commonly used
113 characters. A @acronym{URL} for example would be an invalid @acronym{XML}
114 element since the @acronym{URI} contains a @samp{:} which is also the
115 @acronym{XML} namespace separator.
117 As mentioned, an element name must be unique for the current element tree
118 depth. You cannot have two elements containing the same @code{_name} attribute
119 value. @command{pwmd} will stop searching for an element of an @emph{element
120 path} at the first match then continue searching for the next element of the
121 element path beginning at the child node of the matched element.
123 An @emph{element path} is a @code{TAB} delimited character string where each
124 @code{TAB} separates each element in the path. For example, the element path
125 @code{a@code{TAB}b@code{TAB}c} has the following @acronym{XML} document
133 [... element value or content ...]
140 The only restriction of an element name is that it contain no whitespace
143 @c Node, Next, Previous, Up
144 @node Access Control, Cache Control, Introduction, Top
145 @chapter Access Control
147 Like a filesystem has an @acronym{ACL} to grant or limit access to directories
148 or files for a specific user or group, @command{pwmd} can limit a local user,
149 group or a @acronym{TLS} connection to a specific element path. This is done
150 by storing an @acronym{ACL} in the element attribute @var{_acl}. Its syntax is
151 similar to the @var{allowed} configuration parameter (@pxref{Configuration})
152 with the exception that a @acronym{TLS} fingerprint hash is prefixed with a
155 Access is denied for any user that is not in the @acronym{ACL} of an element
156 with the exception of an invoking user (see the @var{invoking_user}). The
157 connected client must be in the @acronym{ACL} for each element in an element
158 path otherwise an error is returned. As an example:
161 <element _name="test" _acl="username,-@@wheel,root,#ABCDEF">
162 <element _name="child"/>
166 The user @code{username} would be allowed access to the @code{test} element
167 but not if it is a member of the @code{wheel} group although, the @code{root}
168 user, who may be a member of the @code{wheel} group, is allowed. The SHA-256
169 @acronym{TLS} fingerprint hash @code{#ABCDEF} is also allowed. No users other than an
170 @var{invoking_user} are allowed access to the @code{child} element.
172 The first user listed in the @acronym{ACL} is considered the owner of the
173 element. This determines which clients may modify an @var{_acl} attribute and
174 store content for an element. An @var{invoking_user} may always modify an
177 @c Node, Next, Previous, Up
178 @node Cache Control, Invoking, Access Control, Top
179 @chapter Cache Control
183 While @command{pwmd} has its own cache settings for an @acronym{XML} document,
184 @command{gpg-agent} has cache settings for the keys used for crypto operations
185 of a data file. Specifically the @option{ignore-cache-for-signing},
186 @option{default-cache-ttl} and @option{max-cache-ttl} options. These
187 @command{gpg-agent} options may need to be adjusted depending on your usage
188 needs. For example, the @code{OPEN} command may not require a passphrase to
189 open a data file due to the gpg-agent having a cached key even though the
190 @code{ISCACHED} command returns an error indicating the data file is not
191 cached; which usually means a passphrase would be required. Keys for symmetric
192 data files are never kept in the @command{gpg-agent} cache regardless of
193 @command{gpg-agent} cache settings.
195 A copy-on-write operation is done for commands that modify the document; the
196 client that invoked the command will work on a copy of the in-memory document.
197 The first client to @code{SAVE} the changes to disk will require other clients
198 to reopen the data file due to the checksum being updated.
200 @c Node, Next, Previous, Up
201 @node Invoking, Configuration, Cache Control, Top
202 @chapter Invoking @command{pwmd}
205 @command{pwmd} uses GpgME for encryption, decryption and signing of the
206 OpenPGP data file. GpgME itself makes use of @command{gpg} for these
207 operations so some configuration of @command{gpg} may be needed. Pwmd spawns
208 a separate @command{gpg-agent} process when @var{gpg_homedir}
209 (@pxref{Configuration}) is not set to an instance of an already running
210 gpg-agent. Any @command{gpg} configuration options that you need set should be
211 put in @var{~/.pwmd/.gnupg/gpg.conf} or the @var{gpg.conf} file located in
212 @var{gpg_homedir}. The same is true for the @var{gpg-agent.conf} file to set
213 any required @command{gpg-agent} options.
215 It is recommended to pass the @option{--allow-preset-passphrase}
216 option to @command{gpg-agent}. Doing so allows @command{pwmd}
217 cache pushing on startup. It is also recommended to pass the
218 @option{--allow-loopback-pinentry} to @command{gpg-agent} (this is the default
219 as of gnupg-2.1.15). This option allows a passphrase to be inquired from
220 @command{pwmd} when a @command{pinentry} is unavailable to the client
223 If you would like to use a keypair from your default gnupg keyring located in
224 ~/.gnupg, but would still like to use a separate gpg-agent process (the
225 default), you would need to first export the public key from the default
226 keyring then import it into the keyring that pwmd uses. You can do this by
227 first exporting the public key, then use the @option{--homedir ~/.pwmd/.gnupg}
228 option of @command{gpg} to import it into the new keyring. For private keys,
229 you would need to copy the private key associated with the exported public key
230 to @var{~/.pwmd/.gnupg/private-keys-v1.d}. If the private key is stored on
231 a smartcard you can also use the @code{KEYINFO --learn} command
234 @cindex Running @command{pwmd}
235 @command{pwmd} is executed as follows:
238 pwmd @var{options} [ file1 ] [ @dots{} ]
241 Non-option arguments are data files to cache upon startup. When the data file
242 requires a passphrase for decryption a @command{pinentry} will prompt either
243 on the current TTY or from an X11 window when the @env{DISPLAY}
244 environment variable is set. @xref{Pinentry}.
248 The following command line options are supported:
252 @item --debug protocol:level[,protocol:level]
253 Enable debugging output. This option can output sensitive information such as
254 passphrases and secret keys so care should be taken where the output gets
255 written to. The @var{protocol} is a single character representing the protocol
256 to log. Use @code{a} for @code{libassuan} with @var{level} being one or more
257 character flags: @code{i} for init, @code{x} for context, @code{e} for engine,
258 @code{d} for data, @code{s} for system IO or @code{c} for control. To debug
259 @code{gpgme} use @code{g} as the @var{protocol} with @var{level} being an
260 integer from @code{1} to @code{9}. To enable @acronym{TLS} debugging output
261 use @code{t} as the @var{protocol} with @var{level} being an integer from
262 @code{1} to @code{9}. A value over @code{10} will enable all @acronym{TLS}
263 debugging output with @code{1} being the default.
265 @item --homedir directory
266 The root directory where pwmd will store its data and temporary files. The
267 default is @file{~/.pwmd}.
269 @item --rcfile, -f rcfile
270 Specify an alternate configuration file. The default is
271 @file{~/.pwmd/config}.
274 Terminate an existing instance of pwmd. The process to terminate is determined
275 from the @option{--homedir} and @option{--rcfile} options.
277 @item --import, -I filename|-
278 Imports the @acronym{XML} @var{filename}. When @var{filename} is @code{-} the
279 @acronym{XML} is read from @code{stdin}. The @acronym{XML} file should be in conformance to
280 the @command{pwmd} @acronym{DTD} (@pxref{Introduction}). You will be prompted for
281 a passphrase to encrypt with. The output is written to the filename specified
282 with @option{--outfile}. To make use of the imported data, place the output
283 file in @file{~/.pwmd/data}.
285 @item --output, -o filename|-
286 When importing, write the encrypted data file to @var{filename}. When
287 @var{filename} is @code{-} output will be written to @code{stdout}.
289 @item --passphrase-file, -k filename"
290 Obtain the passphrase to use when importing from the specified @var{filename}.
292 @item --keyid fingerprint[,fingerprint,...]
293 Specifies the fingerprint of the encryption key to use as a recipient when
294 importing. When not specified a new key-pair will be created.
296 @item --sign-keyid fingerprint
297 Specifies the fingerprint of the signing key to use for signing of the data
298 file when importing. When not specified the signing key of the generated
299 key-pair or the signing key of the @option{--keyid} option will be used.
301 @item --symmetric, -s
302 Use symmetric or conventional encryption rather than pubic key encryption when
303 importing. Signing is still possible by using the @option{--sign-keyid}
304 option. By default no signing is done when specifying this option.
306 @item --userid string
307 When importing, the user id used to identify the generated key. This should be
308 in the form @code{First Last <email>}.
311 When importing, the algorithm to use when generating the new key pair. The
312 default is determined by @command{gpg}.
314 @item --expire seconds
315 When importing, the time, in seconds since epoch, when the generated key will
316 expire. Specifying @code{0} will never expire the key. The default is three
319 @item --no-passphrase
320 When importing, don't require a passphrase for the generated key.
323 Disable the @code{XPATH}, @code{XPATHATTR}, @code{LIST} and @code{DUMP}
324 protocol commands (@pxref{Commands}). This overrides any
325 @var{disable_list_and_dump} configuration parameter (@pxref{Configuration}).
328 Run as a foreground process and do not fork into the background.
331 Ignore cache pushing failures on startup. By default, @command{pwmd} will exit
332 if an error occurred due to an invalid passphrase or other error.
335 Show the version, copyright and compile time features and exit.
338 Print a summary of options.
342 @c Node, Next, Previous, Up
343 @node Configuration, TLS, Invoking, Top
344 @chapter @command{pwmd} configuration file options
346 @mansect configuration file
347 If no configuration file is specified with the @command{pwmd} @option{-f}
348 command line option, @command{pwmd} will read @file{~/.pwmd/config} if it
349 exists, and if not, will use defaults. Blank lines and lines beginning with
350 @samp{#} are ignored. Some parameters may have data file specific settings by
351 placing them in a file section. A file section is declared by surrounding the
352 filename with braces (i.e., @samp{[filename]}). Global options may be
353 specified in the @code{global} section @samp{e.g., [global]} and are the
354 default options for new or unspecified file sections.
356 A tilde @code{~} will be expanded to the home directory of the user starting
357 @command{pwmd} when contained in a parameter whose value is a filename.
359 @cindex Reloading the configuration file
360 The configuration file can be reloaded by sending the @emph{SIGHUP} signal to
361 a @command{pwmd} process. Some security sensitive settings may not be changed
362 until @command{pwmd} is restarted.
364 @cindex Global configuration options
365 The following options are only for use in the @code{[global]} section:
368 @item socket_path = /path/to/socket
369 Listen on the specified socket. The default is @file{~/.pwmd/socket}.
371 @item socket_perms = octal_mode
372 Permissions to set after creating the socket. This will override any
373 @cite{umask(2)} setting.
375 @item backlog = integer
376 The number of connections to queue. When this limit is reached then new
377 connections will be refused. The default is @code{128}.
379 @item invoking_user = [-!]user,[-!]@@group,[-!]#SHA-256,...
380 This parameter is not to be confused with setuid or setguid upon startup. It's
381 syntax is the same as the @code{allowed} parameter except that it is a list of
382 local usernames, group names and @acronym{TLS} fingerprint hashes that may use the
383 @command{XPATH}, @command{XPATHATTR} and @command{DUMP} commands (except when
384 disabled with the @code{disable_list_and_dump} option) and also who may modify
385 elements that have no @code{_acl} attribute or is not listed in an
386 @code{_acl}. It is similar to the system administrator root account but for a
387 data file and element paths (@pxref{Access Control}). The default is specified
388 at compile-time and also by default is the user @code{nobody}.
390 @item invoking_file = filename
391 A file containing one entry per line. An entry has the same syntax as the
392 @code{invoking_user} parameter. When both this parameter and the
393 @code{invoking_user} parameter are specified then the @code{invoking_user}
394 parameter will behave as if the @code{invoking_file} entries have been
395 appended to the @code{invoking_user} parameter value.
397 @item strict_open = boolean
398 When @code{true}, disallow creation of a new data file when the current client
399 is not an @code{invoking_user}. The default is @code{false}.
401 @item strict_kill = boolean
402 When @code{false}, the @code{KILL} command (@pxref{KILL}) will allow killing
403 another client that is not of the same @code{UID} or @acronym{TLS} fingerprint of
404 the current client and when not an @code{invoking_user}. The default us
407 @item allowed = [-!]user,[-!]@@group,[-!]/path/to/exec,[+,][-!]#SHA-256,...
408 A comma separated list of local user names, group names or @acronym{TLS}
409 fingerprint SHA-256 hashes (in the case of a remote client) which are
410 allowed to connect. Groups should be prefixed with a @samp{@@}. When not
411 specified only the user who started @command{pwmd} may connect. An entry in
412 the list may be prefixed with a @code{-} or @code{!} to prevent access. The
413 order of the list is important since a user may be a member of multiple
416 Connections from local clients may also be limited by command name. A command
417 name is the full path to the execuatble on the filesystem. The command check
418 is done after all other user and group name checks. When no command is
419 specified all commands are allowed. When the connecting client is not of the
420 same @acronym{UID} as the user that invoked @command{pwmd} this feature is
423 This parameter may also be specified in a filename section to allow or deny a
424 client to @code{OPEN} (@pxref{OPEN}) a data file. It also affects the cache
425 commands @code{CLEARCACHE} (@pxref{CLEARCACHE}) and @code{CACHETIMEOUT}
426 (@pxref{CACHETIMEOUT}). When not specified in a file section, any client
427 allowed to connect may also open any filename provided they can decrypt it.
428 Note that when specified in a file section that any @var{allowed} parameter in
429 the @code{global} seciton is not considered.
431 The following example would deny all users in group @code{primary} but
432 allow @code{username} who may be a member of @code{primary}. It will also
433 allow any @acronym{TLS} client except for the client with @acronym{TLS}
434 fingerprint hash @code{#ABCDEF}. For local connections, the connecting client
435 must be using the /usr/bin/pwmc program:
438 allowed=-@@primary,username,+,!#ABCDEF,/usr/bin/pwmc
441 @item allowed_file = filename
442 A file containing one entry per line. An entry has the same syntax as the
443 @code{allowed} parameter except that a line beginning with a semicolon is
444 ignored. When both this parameter and the @code{allowed} parameter are
445 specified then the @code{allowed_file} entries will be appended to the
446 @code{allowed} parameter value.
448 @item encrypt_to = boolean
449 When @code{true} and @command{SAVE}'ing a data file, allow @command{gpg} to
450 append it's configured key to the list of recipients. The default is
451 @code{false} meaning that only keys specified with @command{SAVE}
452 @option{--keyid} are recipients.
454 @item always_trust = boolean
455 When @code{true}, allow encrypting to untrusted recipients or public
456 encryption keys. If you receive an error when @command{SAVE}'ing stating that
457 the public key is unusable, either enable this option or edit the keys' trust
460 gpg --homedir ~/.pwmd/.gnupg --edit-key <fingerprint>
462 The default is @code{false}.
464 @item gpg_homedir = path
465 The location where @command{gpg} will store its public and private keys and
466 configuration. The default is @file{HOMEDIR/.gnupg} where @var{HOMEDIR} is the
467 default (@file{~/.pwmd}) or the value specified on the command line with the
468 @option{--homedir} command line option (@pxref{Invoking}). If you want to use
469 your standard @command{gpg} keyring then set this to @file{~/.gnupg}. Note
470 that a new instance of @command{gpg-agent} will be started when @emph{not}
471 using the standard keyring and that any configuration options for
472 @command{gpg-agent} will need to placed in
473 @file{HOMEDIR/.gnupg/gpg-agent.conf}.
475 @item disable_mlockall = boolean
476 When set to @code{false}, @cite{mlockall(2)} will be called on startup. This
477 will use more physical memory but may also be more secure since no swapping to
478 disk will occur. The default is @var{true}. If possible, use an encrypted swap
479 file or partition and leave this set to @var{true}.
481 @item log_path = /path/to/logfile
482 Logs informational messages to the specified file. The default is
485 @item enable_logging = boolean
486 Enable or disable logging to @var{log_path}. The default is @code{false}.
488 @item log_keepopen = boolean
489 When set to @code{false}, the log file specified with @var{log_path} will be
490 closed after writing each line. The default is @code{true}.
492 @item syslog = boolean
493 Enable logging to @cite{syslog(8)} with facility @emph{LOG_DAEMON} and priority
494 @emph{LOG_INFO}. The default is @code{false}.
496 @item log_level = level
497 When @code{0}, only connections and errors are logged. When @code{1}, data
498 file recipients and signers are logged during @code{OPEN} (@pxref{OPEN}) and
499 @code{SAVE} (@pxref{SAVE}). When @code{2}, client commands are also logged.
500 The default is @code{0}.
502 @item kill_scd = boolean
503 Attempt to kill @command{scdaemon} after a client disconnects. The default is
506 @item disable_list_and_dump = boolean
507 When @code{true} the @code{XPATH}, @code{XPATHATTR}, @code{LIST} and
508 @code{DUMP} protocol commands (@pxref{Commands}) will be disabled.
510 @item cache_push = file1,file2
511 A comma separated list of filenames to be cached upon startup. @command{pwmd}
512 will prompt for the passphrase for each file unless specified with
513 @var{passphrase_file} parameter in a matching file section.
515 @item priority = integer
516 The priority or niceness of the server. The default is inherited from the
519 @item lock_timeout = integer
520 The default timeout in tenths of a second before giving up while waiting for a
521 file lock and returning an error. The default is @code{50}.
525 @cindex Data file configuration options
529 The following options are defaults for new files when specified in the
530 @samp{global} section. When placed in a data file section they are options
531 specific to that data file only.
534 @item require_save_key = boolean
535 Require the passphrase needed for signing before writing changes of the
536 document to disk regardless of the key cache status. The default is
537 @code{true}. This option compliments @command{gpg-agent} option
538 @option{--ignore-cache-for-signing} and is used as a fail-safe.
540 @item backup = boolean
541 Whether to create a backup of the data file when saving. The backup filename
542 has the @file{.backup} extension appended to the opened file. The default is
545 @item cache_timeout = seconds
546 The number of seconds to keep the cache entry for this file. If @code{-1}, the
547 cache entry is kept forever. If @code{0}, each time an encrypted file is
548 @code{OPEN}ed (@pxref{OPEN}) a passphrase will be required. The default
549 is @code{600} or 10 minutes.
551 @item passphrase_file = /path/to/filename
552 Obtain the passphrase to open the data file from @var{filename}. If specified
553 in the @samp{global} section then the @var{passphrase_file} is a default for
554 all data files. Note that if a client changes the passphrase for this data
555 file then the @var{passphrase_file} will need to be updated with the new
558 @item recursion_depth = integer
559 The maximum number of times to resolve a @code{_target} attribute for an
560 element in an element path (@pxref{Target Attribute}). An error is returned
561 when this value is exceeded. The default is @code{100} but can be disabled by
562 setting to @code{0} (@emph{not recommended}).
564 @item allowed = [-]user,[-]@@group,[!]#TLSFINGERPRINT,...
565 Same parameter value as the @code{allowed} parameter mentioned above in
566 the @samp{[global]} section but grants or denies a client from opening a
567 specific data file. The default is to allow any client that is allowed to
572 * TLS:: Remote connections over TLS.
573 * Pinentry:: Configuration file and defaults.
576 @node TLS, Pinentry, Configuration, Configuration
577 @chapter Configuring remote connections over TLS.
581 In addition to connecting to @command{pwmd} via a Unix Domain Socket, remote
582 connections can also be made to @command{pwmd} over @acronym{TLS}.
583 Authentication is done by using X.509 client certificates that are signed with
584 the same Certificate Authority (CA) as the server certificate.
586 The CA certificate is expected to be found in
587 @file{~/.pwmd/ca-cert.pem} while the @command{pwmd} server certificate and key
588 file should be put in @file{~/.pwmd/server-cert.pem} and
589 @file{~/.pwmd/server-key.pem}, respectively.
591 See the documentation of @command{certtool} or @command{openssl} for details
592 about creating self-signed certificates.
594 The following @acronym{TLS} configuration options are available:
597 @item enable_tcp = boolean
598 Whether to enable @acronym{TCP}/@acronym{TLS} server support. If enabled, both @acronym{TCP} and the local
599 unix domain socket will listen for connections. The default is
602 @item tcp_port = integer
603 The @acronym{TCP} port to listen on when @var{enable_tcp} is @code{true}. The default is
606 @item tcp_bind = string
607 The internet protocol to listen with. Must be one of @code{ipv4}, @code{ipv6}
608 or @code{any} to listen for both IPv4 and IPv6 connections. The default is
611 @item tcp_interface = string
612 Only useful if running as root.
614 @item tls_timeout = seconds
615 The number of seconds to wait for a read() or write() call on a
616 @acronym{TLS} client file descriptor to complete before returning an
617 error. The default is @var{300}.
619 @item keepalive_interval = seconds
620 Send a keepalive status message to an idle remote client. An idle
621 client is one that is not in a command. The purpose of this status
622 message is to disconnect a hung remote client and release any file mutex
623 locks so another client may open the same data file. The default is @code{60}.
625 @item tcp_require_key = boolean
626 When @code{true}, require the remote client to provide the passphrase to open
627 a data file even if the file is cached. This option is a default for all
628 files when specified in the @samp{[global]} section. The default is
631 @item tls_cipher_suite = string
632 The GnuTLS cipher suite and protocol to use. See the GnuTLS documentation for
633 information about the format of this string. The default is
634 @code{SECURE256:SECURE192:SECURE128:-VERS-SSL3.0:-VERS-TLS1.0:-VERS-TLS1.1:-AES-128-CBC:-AES-256-CBC}.
636 @item tls_dh_params_file = filename
637 The PEM encoded filename containing DH parameters. If not specified
638 then DH algorithms will not be available to the client. See the
639 @command{openssl dhparam} or @command{certtool} manual pages for details about
640 generating this file.
642 Note that SIGHUP will not reload this file once @acronym{TLS} support has been enabled.
643 You will need to restart @command{pwmd} for changes to take effect.
645 @item tls_use_crl = boolean
646 When @code{true}, enable the use of @option{tls_crl_file}. The default is
649 @item tls_crl_file = filename
650 This file is an X.509 Certificate Revocation List (@acronym{CRL}) and can be
651 used to deny clients by adding client certificates to it. @command{pwmd} will
652 need to be restarted to recognize any changes to this file. When not
653 specified the default of @file{~/.pwmd/crl.pem} will be used when
654 @option{tls_use_crl} is @code{true}.
656 @item tls_ca_file = filename
657 The filename of the @acronym{CA} certificate to use. When not specified the
658 default of @file{~/.pwmd/ca-cert.pem} will be used.
660 @item tls_server_cert_file = filename
661 The filename of the server certificate to use. When not specified the default
662 of @file{~/.pwmd/server-cert.pem} will be used.
664 @item tls_server_key_file = filename
665 The key filename of the server certificate to use. When not specified the
666 default of @file{~/.pwmd/server-key.pem} will be used.
670 @node Pinentry, Commands, TLS, Configuration
671 @chapter Pinentry configuration
673 The @command{pinentry} program is used to prompt the user for passphrase
674 input or as a confirmation dialog; it needs to know where to prompt for
675 the input; from a terminal or an X11 display.
677 It is the responsibility of the client to tell @command{pinentry} about the
678 terminal or X11 display before requiring the input. This is done with the
679 @command{OPTION} command (@pxref{OPTION}) to either set or unset needed
680 @command{pwmd} environment variables and by using the
681 @command{gpg-connect-agent} program. Please read it's documentation about the
682 @emph{UPDATESTARTUPTTY} command.
685 @c Node, Next, Previous, Up
686 @node Commands, Bulk Commands, Pinentry, Top
687 @chapter Protocol commands and their syntax
689 @include commands.texi
691 @c Node, Next, Previous, Up
692 @node Bulk Commands, Status Messages, Commands, Top
693 @chapter Running multiple commands in sequence
694 Multiple commands may be run in sequence by using the @code{BULK} command
695 (@pxref{BULK}). Using this feature may speed up remote connections since less
696 socket IO is needed. The @code{BULK} command uses an @emph{INQUIRE} to obtain
697 an canonical s-expression of commands to be run. The s-expression syntax is as
701 (2:id<I>:<id> <P>:<prot><D>:[<data>] [2:rc<R>:<code>[|<code>...](2:id...) | 2:id...])
704 Each token is prefixed with an unsigned integer that specifies the length of
705 the token, followed by a colon '@code{:}', followed by the token itself. Pwmd
706 uses token pairs to create a @emph{name=value} relationship. Whitespace is
707 allowed between token pairs. For example, the following is valid:
710 ( 2:id 7:FirstID 4:LIST0: 2:rc 1:0 (2:id6:Second 7:GETINFO7:version))
713 The @code{id} token begins a new command and requires an @var{<id>} token
714 of length @var{<I>} to uniquely identify this command. The next token pair is
715 the protocol command name, without any command arguments, of length @var{<P>}
716 to run followed by a colon '@code{:}', followed by the command @var{<prot>}
717 itself, followed by the length @var{<D>} of both command arguments and data,
718 followed by a colon '@code{:}' and finally the @var{<data>} itself. If no
719 arguments or data are needed for the command, set the length of the data
720 @var{<D>} to @code{0} and append the required colon '@code{:}'.
722 A new command enclosed in parentheses may be run when the previous command
723 returns an error code that matches the @var{<code>} token of length @var{<R>}
724 by appending @var{rc} tokens to the end of the previous commands @var{<data>}
725 token. You may also test another return code for the previous command by
726 placing the next @var{rc} token at the end of the closing parentheses of the
727 previous return code command.
729 Multiple @code{rc} @var{code}'s may be specified for a single command by
730 separating them with a pipe @code{|} character. This lets you specify an
731 @emph{if-this-and-that} expression for a commands return code.
733 If another command is to be run after the previous and does not specify an
734 @var{rc} token, the return value is ignored for the previous command and the
735 next command is run. There is no limit on the number of commands or
736 sub-commands except for system memory.
738 After inquiring the commands to be run, @code{BULK} will run each command with
739 @var{<data>} as its argument and store the result code and data of the command
740 in a @code{bulk-result} canonical s-expression of the syntax:
743 (11:bulk-result2:id<I>:<id>2:rc<R>:<code><D>:[<data>][2:id...])
746 The @code{11:bulk-result} token begins the result of all commands. The
747 @var{<id>} token of length @var{<I>} is the same that was associated with the
748 command from the @emph{INQUIRE}'d syntax and is prefixed with @code{2:id}. The
749 return code of the command is prefixed with @code{2:rc} followed by the length
750 @var{<R>} of the unsigned integer @var{<code>} then the return @var{<code>}
751 itself. If the command returned any @var{<data>}, it is prefixed with a
752 length @var{<D>} and immediately following the return @var{<code>}. Otherwise,
753 @var{<D>} will be @code{0} and followed by a colon '@code{:}'.
756 @c Node, Next, Previous, Up
757 @node Status Messages, Target Attribute, Bulk Commands, Top
758 @chapter Status messages and their meanings
759 Some commands send status messages to inform the client about certain
760 operations or as a progress indicator. Status messages begin with a
761 @code{KEYWORD} followed by a status description for status messages that
762 require it. What status messages are sent, when, and how often may depend on
763 configuration settings (@pxref{Configuration}).
765 @multitable @columnfractions .20 .25 .55
766 @headitem Message @tab Parameters @tab Description
769 @tab @code{<integer>}
770 @tab The number of cached documents. Sent to each client after connecting
771 (@pxref{GETINFO}) and after every cache modification.
775 @tab @code{<integer>}
776 @tab The number of connected clients (@pxref{GETINFO}). Sent to each client
777 when another client either connects or disconnects.
782 @tab Sent to the current client during a decrypt operation. How often this
783 status message is sent is determined by the @code{keepalive_interval}
784 (@pxref{Configuration}) setting.
789 @tab Sent to the current client during an encrypt operation. How often this
790 status message is sent is determined by the @code{keepalive_interval}
791 (@pxref{Configuration}) setting.
795 @tab @code{[<sigkey_fpr> <pubkey_fpr>]}
796 @tab Sent to the current client during key generation. How often this
797 status message is sent is determined by the @code{keepalive_interval}
798 (@pxref{Configuration}) setting. The @var{sigkey_fpr} and @var{pubkey_fpr}
799 parameters are added when key generation has completed.
802 @cindex INQUIRE_MAXLEN
804 @tab Sent to the client from @command{gpg-agent} when inquiring data. This
805 specifies the maximum number of bytes allowed for the client to send and
806 should not be exceeded.
811 @tab Sent to each idle client every @var{keepalive_interval}
812 (@pxref{Configuration}) seconds.
817 @tab Sent to the current client when another client is holding the lock for
818 the mutex associated with a file. How often this status message is sent is
819 determined by the @code{keepalive_interval} (@pxref{Configuration}) setting.
824 @tab Sent to the current client when the opened (@pxref{OPEN}) file does not
825 exist on the file-system.
829 @tab @code{<sent> <total>}
830 @tab Sent to the current client when transferring data. It has two space
831 delimited arguments. The first being the current amount of bytes transferred
832 and the other being the total bytes to be transferred. Note that since version
833 @code{3.1.1} of @command{pwmd} this status message is sent only once and
834 before the transfer begins with the @var{total} argument set to the size of the
835 data and the @var{sent} argument set to @code{0} leaving it to the client to
836 determine the progress of the transfer as the data is received.
840 @tab @code{<client_id> <state>}
841 @tab Sent to each client to indicate that @var{client_id} has changed to
842 @var{state} (@pxref{GETINFO} for client states). For a client to receive
843 another clients state the option @var{CLIENT-STATE} must be set.
844 @xref{OPTION} command.
848 @tab @code{<epoch_seconds> <epoch_future>|0}
849 @tab Sent to the current client when @code{GET} (@pxref{GET}) encounters an
850 @code{_expire} (@pxref{Other Attributes}) attribute that is in the past or when
851 @code{STORE} (@pxref{STORE}) updates the @code{_expire} attribute from the
852 @code{_age} attribute value. The second field will be @code{0} when @code{GET}
853 sends this status message. Otherwise the second field is the time the next
856 @item PASSPHRASE_HINT
857 @cindex PASSPHRASE_HINT
858 @tab <keyid> <userid>
859 @tab Forwarded from @code{GpgME}. Contains information that is useful in a
860 @command{pinentry}. Only sent when pinentry is disabled (@pxref{OPTION}).
862 @item PASSPHRASE_INFO
863 @cindex PASSPHRASE_INFO
865 @tab Forwarded from @code{GpgME}. Contains information that is useful in a
866 @command{pinentry}. Only sent when pinentry is disabled (@pxref{OPTION}).
871 @tab Sent to each @acronym{TLS} client just before performing a cipher renegotiation
872 after a SIGHUP signal was received.
876 @tab @code{BEGIN|END <command id>}
877 @tab Sent to the current client before and after the @code{BULK} command
878 (@pxref{BULK}) runs each command. The @var{<command id>} is the same that was
879 associated with the command in the s-expression syntax.
882 @c Node, Next, Previous, Up
883 @node Target Attribute, Other Attributes, Status Messages, Top
884 @chapter The @code{target} attribute
885 @cindex target attribute
886 A @emph{case sensitive} attribute named @code{_target} is treated specially
887 when found in each element of an element path. This attribute, like other
888 element attributes, is created or modified with the @code{ATTR} command
889 (@pxref{ATTR}). The value of this attribute is an existing element path
890 somewhere in the document. If you are familiar with @acronym{XML} entities or
891 maybe the HTML @code{id} or @code{_target} attributes or a symbolic link
892 in a file-system, you may find this attribute behaves similar to any of those.
894 To create a @code{_target} attribute use the following syntax:
897 ATTR SET _target element[@code{TAB}child[..]] element[@code{TAB}child[..]]
900 Note the single space between the two element paths. The first element path is
901 where the @code{_target} attribute will be created. If the element path does
902 not exist then it will be created. This is the only time the @code{ATTR}
903 (@pxref{ATTR}) command will create elements. The attribute is created in the
904 final element of the element path.
906 The second element path is the destination of where you want the first element
907 path to resolve to. When an element path is passed as an argument to a
908 protocol command @command{pwmd} looks for a @code{_target} attribute when
909 resolving each element and, if found, "jumps" to the attribute value and
910 continues resolving any remaining elements a commands element path.
912 When an element of a element path is removed that a @code{_target} attribute
913 resolves to then an error will occur when trying to access that element. You
914 may need to either update the @code{_target} attribute value with a new element
915 path or remove the attribute entirely.
917 Clients should be careful of creating @code{_target} loops, or targets that
918 resolve to themselves. See the @var{recursion_depth} (@pxref{Configuration})
919 configuration parameter for details.
921 The @code{REALPATH} command (@pxref{REALPATH}) can be used to show the element
922 path after resolving all @code{_target} attributes.
924 @emph{Note that when setting this attribute any children of the element will
928 @c Node, Next, Previous, Up
929 @node Other Attributes, Key Expiration, Target Attribute, Top
930 @chapter Other special attributes
931 @cindex special attributes
932 In addition to the @code{_target} attribute (@pxref{Target Attribute}), there
933 are a few other attributes that are specially handled by @command{pwmd}. The
934 first is the @code{_ctime} attribute which is set to the current time when an
935 element is created. Next is the @code{_mtime} attribute which is created when
936 an element is created and also updated when an element is modified. Neither of
937 these attributes may be modified by the client. The @code{_acl} attribute
938 controls access to the element, beit modifying or accessing element content,
939 or descending into child elements. @xref{Access Control} for details. The
940 @code{_name} attribute contains the name of an element.
942 The above mentioned attributes are considered reserved attribute names.
943 Reserved attributes are treated specially when a @code{_target} attribute is
944 found for the current element. The @code{ATTR LIST} command will show these
945 attribute values for the current element and not the attribute values for the
946 resolved @code{_target} element. All other non-reserved attributes for the
947 resolved @code{_target} are appended to the @code{ATTR LIST} command output.
948 Other @code{ATTR} commands (@pxref{ATTR}) behave as usual. You can, for
949 example, @code{ATTR DELETE} a non-reserved attribute for an element that
950 contains a @code{_target} attribute. The resolved target elements' attribute
951 will be removed rather than the element containing the @code{_target}
954 Another specially handled attribute is the @code{_expire} attribute. This
955 attribute value, like the @code{_ctime} and @code{_mtime} attributes, is a
956 timestamp. But this timestamp is usually in the future and for use with the
957 @code{GET} (@pxref{GET}) and @code{STORE} (@pxref{STORE}) commands. When the
958 @code{GET} command is issued, it checks for an @code{_expire} attribute an
959 compares its' value with the current time. If the @code{_expire} timestamp is
960 in the past then a status message is sent (@pxref{Status Messages}) to inform
961 the client that the element content should be updated. When the content for
962 an element containing an @code{_expire} attribute is set when using the
963 @code{STORE} command, the value of the @code{_age} attribute is added to the
964 current time and the @code{_expire} attribute value is updated. When no
965 @code{_age} attribute is found, no modification is done of the @code{_expire}
969 @c Node, Next, Previous, Up
970 @node Key Expiration, Signals, Other Attributes, Top
971 @chapter Key Expiration
972 @cindex key expiration
973 When a key used for signing a data file has expired there is no indication
974 until the next @code{SAVE} command is sent. The command will fail since one
975 cannot sign the data file with an expired key. The client will need to either
976 use a different key for signing by either specifying an existing non-expired
977 key, generate a new key, or change the expire time of the existing key with
980 To change the expiration of the currently used signing key with @command{gpg},
981 use the @code{KEYINFO} command (@pxref{KEYINFO}) to obtain the fingerprint of
982 the signing key of the current data file, then change the expire time with
986 gpg --homedir ~/.pwmd/.gnupg --edit-key <fingerprint>
989 Then use the @code{expire} command to set the new key expire date. When
990 finished, use the @code{save} command to save your changes.
993 @c Node, Next, Previous, Up
994 @node Signals, Index, Key Expiration, Top
995 @chapter Recognized signals
998 Sending the @emph{SIGHUP} signal to a @command{pwmd} process will reload the
999 configuration file and sending @emph{SIGUSR1} will clear the entire file
1014 @c Node, Next, Previous, Up
1015 @node Index, , Signals, Top