Update m4/ax_pthread.m4.
[libpwmd.git] / doc / libpwmd.3
blob0bff2ef9f6f190ee867b548cc11d3c95a5b8455c
1 .TH "libpwmd.h" 3 "Fri Dec 23 2016" "Version 8.1.0" "libpwmd" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 libpwmd.h - an API for accessing pwmd
6 .SH "Description"
7 .PP 
8 libpwmd is a library making it easy for applications to use the pwmd server\&. Pwmd version 3\&.1 or later is required; either locally or remotely\&.
9 .SH "Threads"
10 .PP
11 \fBlibpwmd\fP should be thread-safe on a per handle bases\&. Meaning that only one thread should access a \fBpwm_t\fP handle at a time\&.
12 .SH "Remote Connection Details"
13 .PP
14 There are two methods of connecting to a remote pwmd server: over SSH and over TLS\&.
15 .PP
16 Connections over SSH are done by creating an SSH channel to spawn a shell that executes a proxy server to connect to the pwmd local Unix Domain Socket\&. Authentication is done by using SSH public key (see \fBssh-keygen(1)\fP) authentication and verifying the host key against a local OpenSSH known hosts formatted file\&. A passphrase protected private SSH key is supported when \fBPWMD_OPTION_SSH_NEEDS_PASSPHRASE\fP is set\&.
17 .PP
18 An unknown servers public key can be added to a known hosts file after user confirmation by setting the callback function \fBpwmd_knownhost_cb_t\fP before connecting to the unknown host\&.
19 .PP
20 On the server side you'll need a proxy server to connect to the pwmd server\&. Below is an example of an \fBauthorized_keys(5)\fP entry that will do this\&. The \fIpublic_key\fP portion should be the same as the contents of the \fBssh-keygen(1)\fP \fIidentity\&.pub\fP file generated on the client machine\&. The private key should be passed as the \fIidentity\fP parameter to \fBpwmd_connect()\fP:
21 .PP
22 .PP
23 .nf
24 command="socat UNIX-CONNECT:$HOME/\&.pwmd/socket -" <public_key> \&.\&.\&.
25 .fi
26 .PP
27 .PP
28 Pwmd itself can accept TLS connections so no proxy program is needed as is when using SSH\&. Like SSH connections, TLS connections are created with \fBpwmd_connect()\fP\&. You will need to generate a client key and X509 certificate and then sign it with the same certificate authority (CA) that the pwmd server certificate was signed with\&.
29 .PP
30 Certificates are similar to SSH public and private keys but a little harder to setup correctly\&. See the \fBcerttool(1)\fP (recommended) and \fBopenssl(1)\fP manual pages for details\&.
31 .SH "Pinentry Details"
32 .PP
33 \fBpinentry(1)\fP is a program that prompts the user for input which is normally a passphrase or a confirmation\&. libpwmd can use this program either locally (X11 forwarding is not yet supported) or have the pwmd server (read: \fBgpg-agent(1)\fP) call pinentry to retrieve a passphrase when needed\&.
34 .PP
35 There are a few options that tell pinentry how and where to prompt for a needed passphrase\&. See the \fBpwmd_option_t\fP section for details\&. These options are sent to pwmd during \fBpwmd_open()\fP, \fBpwmd_save()\fP and \fBpwmd_passwd()\fP only when pinentry use has not been disabled (\fBPWMD_OPTION_NO_PINENTRY\fP) and when not over a remote connection\&.
36 .PP
37 Some pinentry options may also be specified in the local configuration file \fI'~/\&.config/libpwmd\&.conf'\fP\&.
38 .PP
39 \fBNote:\fP
40 .RS 4
41 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user\&.
42 .PP
43 The initial values for the pinentry TTY, TERM and DISPLAY are set during \fBpwmd_new()\fP depending on the current environment\&. They are then updated to the values specified in \fI~/\fP\&.config/libpwmd\&.conf\&. They can then be reset or changed as needed by using \fBpwmd_setopt()\fP\&.
44 .PP
45 After establishing a remote connection, pwmd's pinentry is disabled by sending the pwmd option \fI'disable-pinentry'\fP during \fBpwmd_open()\fP\&. A local pinentry will be used instead\&.
46 .RE
47 .PP
48 \fBSee also:\fP
49 .RS 4
50 \fBRemote Connection Details\fP, \fBConfiguration File\fP
51 .RE
52 .PP
53 .SH "Configuration File"
54 .PP
55 Initial values overriding libpwmd defaults for a handle may be specified in the configuration file \fI~/\fP\&.config/libpwmd\&.conf\&. This file is read only once during \fBpwmd_new()\fP\&. Option values may be updated by setting the associated option with \fBpwmd_setopt()\fP\&. Blank lines and lines beginning with a '#' are ignored as are unrecognized options\&. See the documentation for each option for its' value type\&. Valid options are:
56 .PP
57 \fBpinentry-path\fP
58 .RS 4
59 Same as \fBPWMD_OPTION_PINENTRY_PATH\fP\&.
60 .RE
61 .PP
62 \fBpinentry-display\fP
63 .RS 4
64 Same as \fBPWMD_OPTION_PINENTRY_DISPLAY\fP\&.
65 .RE
66 .PP
67 \fBpinentry-ttyname\fP
68 .RS 4
69 Same as \fBPWMD_OPTION_PINENTRY_TTY\fP\&.
70 .RE
71 .PP
72 \fBpinentry-ttytype\fP
73 .RS 4
74 Same as \fBPWMD_OPTION_PINENTRY_TERM\fP\&.
75 .RE
76 .PP
77 \fBpinentry-lc-messages\fP
78 .RS 4
79 Same as \fBPWMD_OPTION_PINENTRY_LC_MESSAGES\fP\&.
80 .RE
81 .PP
82 \fBpinentry-lc-ctype\fP
83 .RS 4
84 Same as \fBPWMD_OPTION_PINENTRY_LC_CTYPE\fP\&.
85 .RE
86 .PP
87 \fBpinentry-timeout\fP
88 .RS 4
89 Same as \fBPWMD_OPTION_PINENTRY_TIMEOUT\fP\&.
90 .RE
91 .PP
92 \fBpinentry-tries\fP
93 .RS 4
94 Same as \fBPWMD_OPTION_PINENTRY_TRIES\fP\&.
95 .RE
96 .PP
97 \fBno-pinentry\fP
98 .RS 4
99 Same as \fBPWMD_OPTION_NO_PINENTRY\fP\&.
102 \fBlocal-pinentry\fP
103 .RS 4
104 Same as \fBPWMD_OPTION_LOCAL_PINENTRY\fP\&.
107 \fBno-ssh-agent\fP
108 .RS 4
109 Same as \fBPWMD_OPTION_SSH_AGENT\fP\&.
112 \fBno-tls-verify\fP
113 .RS 4
114 Same as \fBPWMD_OPTION_TLS_VERIFY\fP\&.
117 \fBtls-priority\fP
118 .RS 4
119 Same as \fBPWMD_OPTION_TLS_PRIORITY\fP\&.
122 \fBsocket-timeout\fP
123 .RS 4
124 Same as \fBPWMD_OPTION_SOCKET_TIMEOUT\fP\&.
127 \fBno-lock\fP
128 .RS 4
129 Same as \fBPWMD_OPTION_LOCK_ON_OPEN\fP\&.
132 \fBinclude\fP
133 .RS 4
134 Path to file containing additional libpwmd\&.conf settings\&.
137 .SH "Errors"
139 libpwmd uses libgpg-error for all error codes\&. Error codes can be described by using \fBgpg_strerror()\fP, or the thread-safe \fBgpg_strerror_r()\fP\&.
141 \fBNote:\fP
142 .RS 4
143 libgpg-error returns an error code as a bitmask of an error source and the error code\&. Determining the error source can help you determine where the error occurred, be it from \fBpinentry(1)\fP, \fBgpg-agent(1)\fP, \fBlibgcrypt\fP, \fBpwmd(1)\fP or \fBlibpwmd(3)\fP\&. pwmd uses the \fBGPG_ERR_SOURCE_USER_1\fP error source and libpwmd uses \fBGPG_ERR_SOURCE_USER_2\fP\&. To view the error source and description of an error code the \fBgpg-error(1)\fP command line utility may be of use\&. Also see the \fBlibgpg-error\fP documentation for error code manipulation\&. 
147 .SH SYNOPSIS
150 .SS "Constants"
152 .in +1c
153 .ti -1c
154 .RI "#define \fBLIBPWMD_API\fP"
156 .ti -1c
157 .RI "#define \fBGPG_ERR_SOURCE_DEFAULT\fP   GPG_ERR_SOURCE_USER_2"
159 .ti -1c
160 .RI "#define \fBLIBPWMD_VERSION\fP   0x080100"
162 .ti -1c
163 .RI "#define \fBLIBPWMD_VERSION_MAJOR\fP   8"
165 .ti -1c
166 .RI "#define \fBLIBPWMD_VERSION_MINOR\fP   1"
168 .ti -1c
169 .RI "#define \fBLIBPWMD_VERSION_PATCH\fP   0"
171 .ti -1c
172 .RI "#define \fBLIBPWMD_VERSION_STR\fP   '8\&.1\&.0\-dev'"
174 .ti -1c
175 .RI "#define \fBPWMD_FEATURE_PINENTRY\fP"
177 .ti -1c
178 .RI "#define \fBPWMD_FEATURE_QUALITY\fP"
180 .ti -1c
181 .RI "#define \fBPWMD_FEATURE_SSH\fP"
183 .ti -1c
184 .RI "#define \fBPWMD_FEATURE_GNUTLS\fP"
186 .in -1c
187 .SS "Typedefs"
189 .in +1c
190 .ti -1c
191 .RI "typedef struct pwm_s \fBpwm_t\fP"
193 .ti -1c
194 .RI "typedef gpg_error_t(* \fBpwmd_status_cb_t\fP) (void *user, const char *line)"
196 .ti -1c
197 .RI "typedef gpg_error_t(* \fBpwmd_inquire_cb_t\fP) (void *user, const char *keyword, gpg_error_t rc, char **data, size_t *len)"
199 .ti -1c
200 .RI "typedef gpg_error_t(* \fBpwmd_knownhost_cb_t\fP) (void *user, const char *host, const char *hostkey, size_t len)"
202 .in -1c
203 .SS "Enumerations"
205 .in +1c
206 .ti -1c
207 .RI "enum \fBpwmd_socket_t\fP { \fBPWMD_SOCKET_LOCAL\fP, \fBPWMD_SOCKET_SSH\fP, \fBPWMD_SOCKET_TLS\fP }"
209 .ti -1c
210 .RI "enum \fBpwmd_pinentry_t\fP { \fBPWMD_PINENTRY_OPEN\fP, \fBPWMD_PINENTRY_OPEN_FAILED\fP, \fBPWMD_PINENTRY_SAVE\fP, \fBPWMD_PINENTRY_SAVE_CONFIRM\fP, \fBPWMD_PINENTRY_SAVE_FAILED\fP, \fBPWMD_PINENTRY_CONFIRM\fP, \fBPWMD_PINENTRY_USER\fP, \fBPWMD_PINENTRY_CLOSE\fP }"
212 .ti -1c
213 .RI "enum \fBpwmd_option_t\fP { \fBPWMD_OPTION_PINENTRY_PATH\fP, \fBPWMD_OPTION_PINENTRY_TTY\fP, \fBPWMD_OPTION_PINENTRY_TERM\fP, \fBPWMD_OPTION_PINENTRY_DISPLAY\fP, \fBPWMD_OPTION_PINENTRY_ERROR\fP, \fBPWMD_OPTION_PINENTRY_PROMPT\fP, \fBPWMD_OPTION_PINENTRY_DESC\fP, \fBPWMD_OPTION_PINENTRY_LC_CTYPE\fP, \fBPWMD_OPTION_PINENTRY_LC_MESSAGES\fP, \fBPWMD_OPTION_PINENTRY_TIMEOUT\fP, \fBPWMD_OPTION_PINENTRY_TRIES\fP, \fBPWMD_OPTION_STATUS_CB\fP, \fBPWMD_OPTION_STATUS_DATA\fP, \fBPWMD_OPTION_KNOWNHOST_CB\fP, \fBPWMD_OPTION_KNOWNHOST_DATA\fP, \fBPWMD_OPTION_INQUIRE_TOTAL\fP, \fBPWMD_OPTION_LOCK_ON_OPEN\fP, \fBPWMD_OPTION_SSH_AGENT\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_SOCKET_TIMEOUT\fP, \fBPWMD_OPTION_TLS_VERIFY\fP, \fBPWMD_OPTION_SIGPIPE\fP, \fBPWMD_OPTION_SERVER_VERSION\fP, \fBPWMD_OPTION_SSH_NEEDS_PASSPHRASE\fP, \fBPWMD_OPTION_SSH_PASSPHRASE\fP, \fBPWMD_OPTION_TLS_PRIORITY\fP }"
215 .in -1c
216 .SS "Functions"
218 .in +1c
219 .ti -1c
220 .RI "LIBPWMD_API const char * \fBpwmd_version\fP ()"
222 .ti -1c
223 .RI "LIBPWMD_API unsigned int \fBpwmd_features\fP ()"
225 .ti -1c
226 .RI "LIBPWMD_API gpg_error_t \fBpwmd_init\fP (void)"
228 .ti -1c
229 .RI "LIBPWMD_API void \fBpwmd_deinit\fP (void)"
231 .ti -1c
232 .RI "LIBPWMD_API gpg_error_t \fBpwmd_new\fP (const char *name, \fBpwm_t\fP **pwm)"
234 .ti -1c
235 .RI "LIBPWMD_API void \fBpwmd_set_pointer\fP (\fBpwm_t\fP *pwm, void *data)"
237 .ti -1c
238 .RI "LIBPWMD_API void * \fBpwmd_get_pointer\fP (\fBpwm_t\fP *pwm)"
240 .ti -1c
241 .RI "LIBPWMD_API gpg_error_t \fBpwmd_cancel\fP (\fBpwm_t\fP *pwm)"
243 .ti -1c
244 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect\fP (\fBpwm_t\fP *pwm, const char *url,\&.\&.\&.)"
246 .ti -1c
247 .RI "LIBPWMD_API int \fBpwmd_gnutls_error\fP (\fBpwm_t\fP *pwm, const char **str)"
249 .ti -1c
250 .RI "LIBPWMD_API gpg_error_t \fBpwmd_setopt\fP (\fBpwm_t\fP *pwm, int opt,\&.\&.\&.)"
252 .ti -1c
253 .RI "LIBPWMD_API gpg_error_t \fBpwmd_getopt\fP (\fBpwm_t\fP *pwm, int opt,\&.\&.\&.)"
255 .ti -1c
256 .RI "LIBPWMD_API gpg_error_t \fBpwmd_getpin\fP (\fBpwm_t\fP *pwm, const char *filename, char **result, size_t *len, \fBpwmd_pinentry_t\fP which)"
258 .ti -1c
259 .RI "LIBPWMD_API gpg_error_t \fBpwmd_password\fP (\fBpwm_t\fP *pwm, const char *keyword, char **result, size_t *size)"
261 .ti -1c
262 .RI "LIBPWMD_API gpg_error_t \fBpwmd_test_quality\fP (const char *passphrase, double *result)"
264 .ti -1c
265 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open\fP (\fBpwm_t\fP *pwm, const char *filename, \fBpwmd_inquire_cb_t\fP callback, void *data)"
267 .ti -1c
268 .RI "LIBPWMD_API gpg_error_t \fBpwmd_process\fP (\fBpwm_t\fP *pwm)"
270 .ti -1c
271 .RI "LIBPWMD_API gpg_error_t \fBpwmd_genkey\fP (\fBpwm_t\fP *pwm, const char *args, \fBpwmd_inquire_cb_t\fP callback, void *user)"
273 .ti -1c
274 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save\fP (\fBpwm_t\fP *pwm, const char *args, \fBpwmd_inquire_cb_t\fP callback, void *user)"
276 .ti -1c
277 .RI "LIBPWMD_API gpg_error_t \fBpwmd_passwd\fP (\fBpwm_t\fP *pwm, const char *args, \fBpwmd_inquire_cb_t\fP callback, void *user)"
279 .ti -1c
280 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command\fP (\fBpwm_t\fP *pwm, char **result, size_t *len, \fBpwmd_inquire_cb_t\fP callback, void *user, const char *cmd,\&.\&.\&.)"
282 .ti -1c
283 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command_ap\fP (\fBpwm_t\fP *pwm, char **result, size_t *len, \fBpwmd_inquire_cb_t\fP callback, void *user, const char *cmd, va_list ap)"
285 .ti -1c
286 .RI "LIBPWMD_API gpg_error_t \fBpwmd_disconnect\fP (\fBpwm_t\fP *pwm)"
288 .ti -1c
289 .RI "LIBPWMD_API void \fBpwmd_close\fP (\fBpwm_t\fP *pwm)"
291 .ti -1c
292 .RI "LIBPWMD_API gpg_error_t \fBpwmd_socket_type\fP (\fBpwm_t\fP *pwm, \fBpwmd_socket_t\fP *type)"
294 .ti -1c
295 .RI "LIBPWMD_API gpg_error_t \fBpwmd_fd\fP (\fBpwm_t\fP *pwm, int *fd)"
297 .ti -1c
298 .RI "LIBPWMD_API void \fBpwmd_free\fP (void *ptr)"
300 .ti -1c
301 .RI "LIBPWMD_API void * \fBpwmd_malloc\fP (size_t size)"
303 .ti -1c
304 .RI "LIBPWMD_API void * \fBpwmd_calloc\fP (size_t nmemb, size_t size)"
306 .ti -1c
307 .RI "LIBPWMD_API void * \fBpwmd_realloc\fP (void *ptr, size_t size)"
309 .ti -1c
310 .RI "LIBPWMD_API char * \fBpwmd_strdup\fP (const char *str)"
312 .ti -1c
313 .RI "LIBPWMD_API char * \fBpwmd_strdup_printf\fP (const char *fmt,\&.\&.\&.)"
315 .in -1c
316 .SH "Constant Details"
317 .PP 
318 .SS "#define LIBPWMD_VERSION   0x080100"
321 Version information\&. The version of this library\&. 
322 .SS "#define LIBPWMD_VERSION_MAJOR   8"
325 Version information\&. The major release number of this library\&. 
326 .SS "#define LIBPWMD_VERSION_MINOR   1"
329 Version information\&. The minor release number of this library\&. 
330 .SS "#define LIBPWMD_VERSION_PATCH   0"
333 Version information\&. The patch level of this library\&. 
334 .SS "#define LIBPWMD_VERSION_STR   '8\&.1\&.0\-dev'"
337 Version information\&. A string representation of the version of this library\&. 
338 .SS "#define PWMD_FEATURE_GNUTLS"
341 Remote connections over TLS\&. 
343 \fBSee also:\fP
344 .RS 4
345 \fBRemote Connection Details\fP 
349 .SS "#define PWMD_FEATURE_PINENTRY"
352 Pinentry support\&. This is for a local or fork()'ed pinentry\&. 
353 .SS "#define PWMD_FEATURE_QUALITY"
356 Password quality checking\&. A password quality meter is shown when the pinentry supports it\&. 
357 .SS "#define PWMD_FEATURE_SSH"
360 Remote connections over an SSH channel\&. 
362 \fBSee also:\fP
363 .RS 4
364 \fBRemote Connection Details\fP 
368 .SH "Typedef Details"
369 .PP 
370 .SS "\fBpwm_t\fP"
373 A libpwmd handle\&. When a pwmd handle or context is mentioned in this documentation it is a pointer of this type\&. A new handle is created with \fBpwmd_new()\fP\&. 
374 .SS "pwmd_inquire_cb_t"
377 Send data to the pwmd server\&. This is a callback function that is used for sending data to the server for commands that need to reply to an INQUIRE server response\&. The reason for this callback is to let the client send as many bytes as it wants rather than the entire data at once\&. It gets called during an internal \fBassuan_transact()\fP from an internal inquire callback function which in turn calls this function by looping over its return value\&.
379 \fBParameters:\fP
380 .RS 4
381 \fIuser\fP The user data pointer passed to the libpwmd function specifying this callback\&. 
383 \fIkeyword\fP The name of this inquire\&. Could be a command name or some keyword describing what needs to be sent\&. See the pwmd and \fBgpg-agent(1)\fP documentation for details\&. 
385 \fIrc\fP The result of the last internal call to \fBassuan_send_data()\fP which did the sending of the data to the pwmd server\&. On the first call to this callback it's value will always be 0 since no data has been sent yet\&. This should be checked during each call to this function and should return the same error code when set\&. Its purpose is to let the client clean up before letting the command fail\&. 
387 \fIdata\fP The next chunk of data to send or NULL\&. 
389 \fIlen\fP The length of \fIdata\fP or 0\&.
392 \fBReturn values:\fP
393 .RS 4
394 \fI0\fP There is more data to be sent\&. 
396 \fIGPG_ERR_EOF\fP No need to call this function again, the current \fIdata\fP is the last to send\&. 
398 \fIcode\fP Any other error code which will cancel the INQUIRE\&.
401 \fBNote:\fP
402 .RS 4
403 The sent data is processed line-per-line\&. The line is either newline terminated or is buffered until ASSUAN_LINELENGTH bytes have been allocated\&. Any remaining bytes are sent after the INQUIRE has finished\&. 
407 .SS "pwmd_knownhost_cb_t"
410 Verify a remote SSH connection\&. When the current SSH connections host key was not found in the known hosts file, then this callback function can be used to confirm the addition of the new host key to the known_hosts file\&. When \fBPWMD_OPTION_KNOWNHOST_CB\fP is not set then the default callback function will be used\&.
412 \fBParameters:\fP
413 .RS 4
414 \fIuser\fP User data which was set with \fBPWMD_OPTION_KNOWNHOST_DATA\fP\&. 
416 \fIhost\fP The hostname as passed to \fBpwmd_connect()\fP\&. 
418 \fIhostkey\fP The raw binary data of the host key\&. 
420 \fIlen\fP The length of \fIhostkey\fP\&. 
423 \fBReturn values:\fP
424 .RS 4
425 \fI0\fP Add the host key to the known hosts file\&. 
427 \fIGPG_ERR_NOT_CONFIRMED\fP Do not add the host key and abort the connection\&. This is the recommended error code although any other non-zero return value will also abort the connection\&.
430 \fBNote:\fP
431 .RS 4
432 If the known hosts file cannot be modified do to filesystem restrictions when adding the new host key, no error is returned\&. Instead, the host key is added to the current connections host key cache and the connection is accepted\&.
435 \fBSee also:\fP
436 .RS 4
437 \fBRemote Connection Details\fP 
441 .SS "pwmd_status_cb_t"
444 Process status messages\&. The value of the option \fBPWMD_OPTION_STATUS_CB\fP which is set with \fBpwmd_setopt()\fP\&.
446 \fBParameters:\fP
447 .RS 4
448 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_STATUS_DATA\fP\&. 
450 \fIline\fP The status message line received from the server\&. 
453 \fBReturns:\fP
454 .RS 4
455 0 on success or an error code which will cause a command to fail\&. 
459 .SH "Enumeration Details"
460 .PP 
461 .SS "enum \fBpwmd_option_t\fP"
464 libpwmd options\&. Options are set with \fBpwmd_setopt()\fP\&. Some options must be set before a connection is made to have any effect\&.
466 \fBNote:\fP
467 .RS 4
468 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user\&. 
473 \fBEnumerator\fP
474 .in +1c
476 \fB\fIPWMD_OPTION_PINENTRY_PATH \fP\fP
477 A string value which specifies the full path of the \fBpinentry(1)\fP binary\&. The default is specified at compile time\&.
479 \fBNote:\fP
480 .RS 4
481 This only affects the local pinentry\&. 
484 \fBSee also:\fP
485 .RS 4
486 \fBPinentry Details\fP 
491 \fB\fIPWMD_OPTION_PINENTRY_TTY \fP\fP
492 A string value which specifies the full path to the TTY that \fBpinentry(1)\fP will use to prompt on\&. When set and no DISPLAY is available, \fBPWMD_OPTION_PINENTRY_TERM\fP must also be set\&.
494 \fBSee also:\fP
495 .RS 4
496 \fBPinentry Details\fP 
501 \fB\fIPWMD_OPTION_PINENTRY_TERM \fP\fP
502 A string value which specifies the terminal type (i\&.e\&., vt100) that \fBpinentry(1)\fP will use when no X11 display is available\&.
504 \fBSee also:\fP
505 .RS 4
506 \fBPinentry Details\fP 
511 \fB\fIPWMD_OPTION_PINENTRY_DISPLAY \fP\fP
512 A string value which specifies the X11 display that \fBpinentry(1)\fP will use\&. \fBpinentry(1)\fP seems to make DISPLAY have a higher priority than \fBPWMD_OPTION_PINENTRY_TTY\fP\&.
514 \fBSee also:\fP
515 .RS 4
516 \fBPinentry Details\fP 
521 \fB\fIPWMD_OPTION_PINENTRY_ERROR \fP\fP
522 A character string that \fBpinentry(1)\fP will use in it's dialog window\&. 
524 \fB\fIPWMD_OPTION_PINENTRY_PROMPT \fP\fP
525 A character string that \fBpinentry(1)\fP will use in it's dialog window\&. 
527 \fB\fIPWMD_OPTION_PINENTRY_DESC \fP\fP
528 A character string that \fBpinentry(1)\fP will use in it's dialog window\&. 
530 \fB\fIPWMD_OPTION_PINENTRY_LC_CTYPE \fP\fP
531 For \fBpinentry(1)\fP localization\&. 
533 \fB\fIPWMD_OPTION_PINENTRY_LC_MESSAGES \fP\fP
534 For \fBpinentry(1)\fP localization\&. 
536 \fB\fIPWMD_OPTION_PINENTRY_TIMEOUT \fP\fP
537 An integer value that specifies the number of seconds \fBpinentry(1)\fP will wait for input before timing out and aborting the current command\&. If 0, then no timeout will be used\&. The default is 30\&.
539 \fBNote:\fP
540 .RS 4
541 This only affects the local pinentry\&. 
546 \fB\fIPWMD_OPTION_PINENTRY_TRIES \fP\fP
547 An integer value that specifies the number of times to prompt for a passphrase before returning an error\&.
549 \fBNote:\fP
550 .RS 4
551 This only affects the local pinentry\&. 
556 \fB\fIPWMD_OPTION_STATUS_CB \fP\fP
557 A function of type \fBpwmd_status_cb_t\fP that will process status messages received from the pwmd server\&. 
559 \fB\fIPWMD_OPTION_STATUS_DATA \fP\fP
560 A user data pointer which is passed to the status message function \fBPWMD_OPTION_STATUS_CB\fP\&. 
562 \fB\fIPWMD_OPTION_KNOWNHOST_CB \fP\fP
563 A function of type \fBpwmd_knownhost_cb_t\fP that will be used to confirm a host key that was not found in the known hosts file\&.
565 \fBSee also:\fP
566 .RS 4
567 \fBRemote Connection Details\fP 
572 \fB\fIPWMD_OPTION_KNOWNHOST_DATA \fP\fP
573 User supplied data which is passed to the known host function \fBPWMD_OPTION_KNOWNHOST_CB\fP\&.
575 \fBSee also:\fP
576 .RS 4
577 \fBRemote Connection Details\fP 
582 \fB\fIPWMD_OPTION_INQUIRE_TOTAL \fP\fP
583 When the total number of bytes to be sent via an INQUIRE is known, this should be set so XFER status messages can be parsed correctly\&. When not known or unset, 0 is used as the total argument to the XFER status message\&. This option should be reset in every function that uses an \fBpwmd_inquire_cb_t\fP\&.
585 \fBNote:\fP
586 .RS 4
587 During the INQUIRE, \fBPWMD_OPTION_STATUS_CB\fP is called, when set, after every iteration of the \fBpwmd_inquire_cb_t\fP\&.
589 This is a libpwmd feature\&. pwmd itself does not send XFER status messages during an INQUIRE\&. Status messages can be parsed only when \fBPWMD_OPTION_STATUS_CB\fP is set\&. 
594 \fB\fIPWMD_OPTION_LOCK_ON_OPEN \fP\fP
595 When set to 1, lock the file mutex during \fBpwmd_open()\fP as if the LOCK command had been sent\&. 
597 \fB\fIPWMD_OPTION_SSH_AGENT \fP\fP
598 Use ssh-agent to retrieve the private key to authenticate with when connecting to a remote pwmd server\&. 
600 \fB\fIPWMD_OPTION_NO_PINENTRY \fP\fP
601 When 1, disable pinentry use\&. This will prevent both pwmd and libpwmd from using a pinentry program and will prompt from the terminal if available\&.
603 \fBNote:\fP
604 .RS 4
605 This must be set before calling \fBpwmd_open()\fP\&. 
608 \fBSee also:\fP
609 .RS 4
610 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP 
615 \fB\fIPWMD_OPTION_LOCAL_PINENTRY \fP\fP
616 When 1, libpwmd will disable pwmd's pinentry and use it's own pinentry\&. This option is set by default when the connection is a remote one\&.
618 \fBNote:\fP
619 .RS 4
620 This must be set before calling \fBpwmd_open()\fP\&. 
625 \fB\fIPWMD_OPTION_OVERRIDE_INQUIRE \fP\fP
626 When set, override libpwmd's internal handling of server inquires with the PASSPHRASE, NEW_PASSPHRASE and SIGN_PASSPHRASE keywords\&. Handling of these keywords is done automatically when \fBPWMD_OPTION_NO_PINENTRY\fP or \fBPWMD_OPTION_LOCAL_PINENTRY\fP is set or when the connection is a remote one\&.
628 \fBSee also:\fP
629 .RS 4
630 \fBRemote Connection Details\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_password()\fP 
635 \fB\fIPWMD_OPTION_SOCKET_TIMEOUT \fP\fP
636 An int specifying a timeout in seconds before a TCP connection or data transfer function will timeout causing a connection or command to fail\&. This option can be specified both before and after a connection has been established\&. When 0, no timeout is used\&. 
638 \fB\fIPWMD_OPTION_TLS_VERIFY \fP\fP
639 An int specifying whether to enable TLS hostname verification against the server certificate chain\&. Default is 0 or disabled\&. 
641 \fB\fIPWMD_OPTION_SIGPIPE \fP\fP
642 Set to 1 to not modify the signal handler to ignore SIGPIPE\&. The default is 0, or to ignore this signal\&. 
644 \fB\fIPWMD_OPTION_SERVER_VERSION \fP\fP
645 Get the version of the pwmd server as an unsigned integer\&. This is a read-only setting and is only available after connecting\&. 
647 \fB\fIPWMD_OPTION_SSH_NEEDS_PASSPHRASE \fP\fP
648 The SSH identity file requires a passphrase\&. When set, prompt for the passphrase after connecting\&. Note that only libssh2 built with OpenSSL supports this feature as of libssh2-1\&.7\&.0\&. 
650 \fB\fIPWMD_OPTION_SSH_PASSPHRASE \fP\fP
651 Set SSH private identity passphrase\&. When set there is no need to set \fBPWMD_OPTION_SSH_NEEDS_PASSPHRASE\fP\&. The value of this option is duplicated then freed after the call to \fBpwmd_connect()\fP\&. Note that only libssh2 built with OpenSSL supports this feature as of libssh2-1\&.7\&.0\&. 
653 \fB\fIPWMD_OPTION_TLS_PRIORITY \fP\fP
654 The TLS cipher priority string to use for a TLS connection\&. The default is SECURE256:SECURE192:SECURE128:-VERS-SSL3\&.0:-VERS-TLS1\&.0\&. 
655 .SS "enum \fBpwmd_pinentry_t\fP"
658 Local pinentry commands and not pwmd pinentry\&. These determine what prompt a local pinentry uses\&. For use with \fBpwmd_getpin()\fP\&. 
660 \fBEnumerator\fP
661 .in +1c
663 \fB\fIPWMD_PINENTRY_OPEN \fP\fP
664 When opening a file\&. 
666 \fB\fIPWMD_PINENTRY_OPEN_FAILED \fP\fP
667 When opening a file failed due to a bad passphrase\&. 
669 \fB\fIPWMD_PINENTRY_SAVE \fP\fP
670 When saving a file\&. 
672 \fB\fIPWMD_PINENTRY_SAVE_CONFIRM \fP\fP
673 For passphrase confirmation\&. 
675 \fB\fIPWMD_PINENTRY_SAVE_FAILED \fP\fP
676 When saving a file and passphrase confirmation failed\&. 
678 \fB\fIPWMD_PINENTRY_CONFIRM \fP\fP
679 For confirmation of a user-defined prompt\&. 
681 \fB\fIPWMD_PINENTRY_USER \fP\fP
682 For the default or user defined string set with \fBPWMD_OPTION_PINENTRY_DESC\fP\&. 
684 \fB\fIPWMD_PINENTRY_CLOSE \fP\fP
685 To terminate the pinentry process created with \fBpwmd_getpin()\fP\&. 
686 .SS "enum \fBpwmd_socket_t\fP"
689 The type of socket a handle is connected to\&. For use with \fBpwmd_socket_type()\fP\&. 
691 \fBEnumerator\fP
692 .in +1c
694 \fB\fIPWMD_SOCKET_LOCAL \fP\fP
695 A local UNIX domain socket\&. 
697 \fB\fIPWMD_SOCKET_SSH \fP\fP
698 An SSH channel over a TCP socket\&. 
700 \fB\fIPWMD_SOCKET_TLS \fP\fP
701 A TLS connection over a TCP socket\&. 
702 .SH "Function Details"
703 .PP 
704 .SS "LIBPWMD_API void* pwmd_calloc (size_t nmemb, size_t size)"
707 A wrapper around calloc()\&. Like calloc(), but lets libpwmd keep track of the pointer\&.
709 \fBParameters:\fP
710 .RS 4
711 \fInmemb\fP The number of elements to allocate\&. 
713 \fIsize\fP The number of bytes to allocate\&. 
716 \fBReturns:\fP
717 .RS 4
718 A newly allocated pointer or NULL if there wasn't enough memory\&. 
721 \fBSee also:\fP
722 .RS 4
723 calloc(3), \fBpwmd_free()\fP 
727 .SS "LIBPWMD_API gpg_error_t pwmd_cancel (\fBpwm_t\fP * pwm)"
730 Cancel an operation\&. This is limited in functionality as it will only cancel an initiating connection to the pwmd server\&. Command cancellation is not yet supported\&.
732 \fBParameters:\fP
733 .RS 4
734 \fIpwm\fP A handle\&. 
737 \fBReturns:\fP
738 .RS 4
739 0 on success or an error code\&. 
743 .SS "LIBPWMD_API void pwmd_close (\fBpwm_t\fP * pwm)"
746 Close a handle\&. This will close the connection to a pwmd server and free any resources associated with it\&.
748 \fBParameters:\fP
749 .RS 4
750 \fIpwm\fP A handle\&. 
753 \fBReturns:\fP
754 .RS 4
755 Nothing\&. 
758 \fBSee also:\fP
759 .RS 4
760 \fBpwmd_disconnect()\fP, \fBpwmd_new()\fP 
764 .SS "LIBPWMD_API gpg_error_t pwmd_command (\fBpwm_t\fP * pwm, char ** result, size_t * len, \fBpwmd_inquire_cb_t\fP callback, void * user, const char * cmd,  \&.\&.\&.)"
767 Send a command to the pwmd server\&. You should avoid sending the BYE command here because the assuan context will be freed and bad things will happen\&. Use \fBpwmd_close()\fP instead\&.
769 For pwmd commands that use an INQUIRE to retrieve data from a client, the \fIcallback\fP parameter must be non-NULL and will be used to send the data to pwmd\&.
771 \fBParameters:\fP
772 .RS 4
773 \fIpwm\fP A handle\&. 
775 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP\&. 
777 \fIlen\fP The length of \fIresult\fP\&. 
779 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
781 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
783 \fIcmd\fP The command to send and any command arguments\&. 
786 \fBReturns:\fP
787 .RS 4
788 0 on success or an error code\&.
791 \fBNote:\fP
792 .RS 4
793 Not all commands return a \fIresult\fP\&. 
797 .SS "LIBPWMD_API gpg_error_t pwmd_command_ap (\fBpwm_t\fP * pwm, char ** result, size_t * len, \fBpwmd_inquire_cb_t\fP callback, void * user, const char * cmd, va_list ap)"
800 Send a command to the pwmd server\&. Like \fBpwmd_command()\fP but uses an argument pointer instead\&.
802 \fBParameters:\fP
803 .RS 4
804 \fIpwm\fP A handle\&. 
806 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP\&. 
808 \fIlen\fP The length of \fIresult\fP\&. 
810 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
812 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
814 \fIcmd\fP The command to send\&. 
816 \fIap\fP The arguments to \fIcmd\fP\&. 
819 \fBReturns:\fP
820 .RS 4
821 0 on success or an error code\&.
824 \fBNote:\fP
825 .RS 4
826 Not all commands return a \fIresult\fP\&. 
830 .SS "LIBPWMD_API gpg_error_t pwmd_connect (\fBpwm_t\fP * pwm, const char * url,  \&.\&.\&.)"
833 Establish a connection to a pwmd server\&. Connects to the pwmd server specified in \fIurl\fP\&. The format of \fIurl\fP is: 
835 \fB\fP
836 .RS 4
837 file:///path/to/socket, or 
840 \fB\fP
841 .RS 4
842 ssh[46]://[username@]hostname[:port], or 
845 \fB\fP
846 .RS 4
847 tls[46]://hostname[:port]
850 If \fIurl\fP is NULL then the default local pwmd socket \fI~/\fP\&.pwmd/socket will be used\&.
852 The remaining arguments are parameters for the \fIurl\fP\&.
854 For SSH connections, the first of the positional parameters should be the identity file to use and is required to be non-NULL unless \fBPWMD_OPTION_SSH_AGENT\fP is set\&. The final parameter is the known hosts file to use or NULL to use a default of \fI~/\fP\&.ssh/knownhosts\&.
856 For TLS connections, the first positional parameter should be the client certificate filename\&. The second parameter should be the client certificate key filename\&. The third parameter should be the Certificate Authority (CA) file that was used to sign the server certificate\&. The final parameter is an SHA-256 hash of the server fingerprint to verify against, or NULL\&.
858 For local connections, any remaining parameters are ignored\&.
860 \fBParameters:\fP
861 .RS 4
862 \fIpwm\fP A handle\&. 
864 \fIurl\fP The socket to connect to\&. 
866 \fI\&.\&.\&.\fP Remaining parameters for the \fIurl\fP\&. 
869 \fBReturns:\fP
870 .RS 4
871 0 on success or an error code\&. 
874 \fBNote:\fP
875 .RS 4
876 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user\&. 
879 \fBSee also:\fP
880 .RS 4
881 \fBPWMD_OPTION_SSH_AGENT\fP, \fBPWMD_OPTION_SOCKET_TIMEOUT\fP, \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP, \fBRemote Connection Details\fP 
885 .SS "LIBPWMD_API void pwmd_deinit (void)"
888 Deinitialize the library\&. This function is mainly for cleaning up other libraries that libpwmd links with to prevent memory and other leaks showing up in a debugger\&. It should be the final libpwmd function call before your app exits\&. 
889 .SS "LIBPWMD_API gpg_error_t pwmd_disconnect (\fBpwm_t\fP * pwm)"
892 Close a connection to the pwmd server\&. This will close the connection but keep any previously set options for the specified handle \fIpwm\fP\&. Calling \fBpwmd_connect()\fP will re-acquire an libassuan context\&.
894 \fBParameters:\fP
895 .RS 4
896 \fIpwm\fP A handle\&. 
899 \fBReturns:\fP
900 .RS 4
901 0 on success or an error code\&. 
904 \fBSee also:\fP
905 .RS 4
906 \fBpwmd_close()\fP 
910 .SS "LIBPWMD_API gpg_error_t pwmd_fd (\fBpwm_t\fP * pwm, int * fd)"
913 Get the file descriptor associated with a handle\&. May be useful to determine whether a handle is ready for reading or writing by using select(2) or poll(2)\&.
915 \fBParameters:\fP
916 .RS 4
917 \fIpwm\fP A handle\&. 
919 \fIfd\fP Set to the file descriptor associated with \fIpwm\fP\&. 
922 \fBReturns:\fP
923 .RS 4
924 0 on success or an error code\&. 
928 .SS "LIBPWMD_API unsigned int pwmd_features ()"
931 libpwmd compile time features\&. Useful for clients to determine what features are compiled into libpwmd at runtime\&.
933 \fBReturns:\fP
934 .RS 4
935 A bitmask of features\&. 
939 .SS "LIBPWMD_API void pwmd_free (void * ptr)"
942 Free a previously allocated pointer\&. Use this function to free resources allocated by the other libpwmd memory functions\&. Do not use it to free allocations made by other allocators\&.
944 The difference between the standard free() and this function is that this one will zero out the contents of the pointer before freeing it\&.
946 \fBParameters:\fP
947 .RS 4
948 \fIptr\fP The pointer to deallocate\&. 
951 \fBReturns:\fP
952 .RS 4
953 Nothing\&. 
956 \fBSee also:\fP
957 .RS 4
958 \fBpwmd_malloc()\fP, \fBpwmd_calloc()\fP, \fBpwmd_realloc()\fP, \fBpwmd_strdup()\fP, \fBpwmd_command()\fP 
962 .SS "LIBPWMD_API gpg_error_t pwmd_genkey (\fBpwm_t\fP * pwm, const char * args, \fBpwmd_inquire_cb_t\fP callback, void * user)"
965 Generate a new key\&. Generate a new signing or encryption key or both\&. This will only generate a key without saving the XML document to disk\&.
967 The inquire \fIcallback\fP function should be used when a GENKEY option specified in \fIargs\fP inquires data\&.
969 \fBParameters:\fP
970 .RS 4
971 \fIpwm\fP A handle\&. 
973 \fIargs\fP Any GENKEY protocol command options or NULL\&. 
975 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
977 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
980 \fBReturns:\fP
981 .RS 4
982 0 on success or an error code\&. 
985 \fBSee also:\fP
986 .RS 4
987 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_command()\fP, \fBPinentry Details\fP 
991 .SS "LIBPWMD_API void* pwmd_get_pointer (\fBpwm_t\fP * pwm)"
994 Get user data for a handle\&. Return the user data pointer previously set with \fBpwmd_set_pointer()\fP\&.
996 \fBParameters:\fP
997 .RS 4
998 \fIpwm\fP A handle\&. 
1001 \fBReturns:\fP
1002 .RS 4
1003 A pointer to the user data\&. 
1007 .SS "LIBPWMD_API gpg_error_t pwmd_getopt (\fBpwm_t\fP * pwm, int opt,  \&.\&.\&.)"
1010 Get the value for a handle option\&. Retrieves the default or previously set value for a handle option\&. See \fBpwmd_option_t\fP for option specific details\&.
1012 \fBParameters:\fP
1013 .RS 4
1014 \fIpwm\fP A handle\&. 
1016 \fIopt\fP The option\&. 
1018 \fI\&.\&.\&.\fP A pointer to the option value type to store the value\&. 
1021 \fBReturns:\fP
1022 .RS 4
1023 0 on success or an error code\&. 
1026 \fBNote:\fP
1027 .RS 4
1028 The value is returned as a pointer and not duplicated\&. 
1032 .SS "LIBPWMD_API gpg_error_t pwmd_getpin (\fBpwm_t\fP * pwm, const char * filename, char ** result, size_t * len, \fBpwmd_pinentry_t\fP which)"
1035 Launch a local pinentry\&. Does not send any command to the pwmd server\&. This maybe useful if a passphrase is needed while opening a file over a remote connection and during an \fBpwmd_open()\fP server inquire\&.
1037 This function may also be used to display a user confirmation dialog with pinentry when \fIwhich\fP is \fBPWMD_PINENTRY_CONFIRM\fP\&. The text show in the pinentry is set with \fBpwmd_setopt()\fP\&.
1039 \fBParameters:\fP
1040 .RS 4
1041 \fIpwm\fP A handle\&. 
1043 \fIfilename\fP The filename to use in the pinentry dialog strings when using the default pinentry strings\&. 
1045 \fIresult\fP The entered value in the pinentry dialog which should be freed with \fBpwmd_free()\fP\&. 
1047 \fIlen\fP The length of \fIresult\fP\&. 
1049 \fIwhich\fP Determines the default strings shown in the pinentry dialog\&. \fBpwmd_setopt()\fP may also be used to override the defaults\&. In this case \fBPWMD_PINENTRY_USER\fP should be used\&. \fBPWMD_PINENTRY_CLOSE\fP should be used to terminate the pinentry process when the pinentry is no longer needed\&.
1052 \fBReturns:\fP
1053 .RS 4
1054 0 on success or an error\&.
1057 \fBSee also:\fP
1058 .RS 4
1059 \fBpwmd_password()\fP 
1063 .SS "LIBPWMD_API int pwmd_gnutls_error (\fBpwm_t\fP * pwm, const char ** str)"
1066 Get the error code of a failed GnuTLS function\&. When an TLS error occurs while connecting or during a command, this function can be used to get the error code and error description\&.
1068 \fBParameters:\fP
1069 .RS 4
1070 \fIpwm\fP A handle\&. 
1072 \fIstr\fP The textual representation of the gnutls error code\&. 
1075 \fBReturns:\fP
1076 .RS 4
1077 0 on success or a GnuTLS error code\&. 
1081 .SS "LIBPWMD_API gpg_error_t pwmd_init (void)"
1084 Initialize the library\&. This function must be the first function called in the library before any others\&. It sets up the memory allocators and internationalization among other things\&.
1086 \fBReturns:\fP
1087 .RS 4
1088 0 on success or an error code\&. 
1092 .SS "LIBPWMD_API void* pwmd_malloc (size_t size)"
1095 A wrapper around malloc\&. Like malloc(), but lets libpwmd keep track of the pointer\&.
1097 \fBParameters:\fP
1098 .RS 4
1099 \fIsize\fP The number of bytes to allocate\&. 
1102 \fBReturns:\fP
1103 .RS 4
1104 A newly allocated pointer or NULL if there wasn't enough memory\&. 
1107 \fBSee also:\fP
1108 .RS 4
1109 malloc(3), \fBpwmd_free()\fP 
1113 .SS "LIBPWMD_API gpg_error_t pwmd_new (const char * name, \fBpwm_t\fP ** pwm)"
1116 Creates a new handle\&. Creates a new handle or context for use with the other functions\&.
1118 \fBParameters:\fP
1119 .RS 4
1120 \fIname\fP If not NULL, the name of the application\&. The application name is sent to the pwmd server after successfully connecting and is used in pwmd logging\&. 
1122 \fIpwm\fP A new handle for use with the other functions\&.
1125 \fBReturns:\fP
1126 .RS 4
1127 0 on success or an error code\&. 
1131 .SS "LIBPWMD_API gpg_error_t pwmd_open (\fBpwm_t\fP * pwm, const char * filename, \fBpwmd_inquire_cb_t\fP callback, void * data)"
1134 Open a file on the pwmd server\&. This will send the OPEN command to the server\&.
1136 To make use of \fIcallback\fP, \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP must also be set\&.
1138 \fBParameters:\fP
1139 .RS 4
1140 \fIpwm\fP A handle\&. 
1142 \fIfilename\fP The filename to open\&. The \fIfilename\fP is not a full path but the data filename only\&. 
1144 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
1146 \fIdata\fP User data passed to the \fIcallback\fP function\&. 
1149 \fBReturns:\fP
1150 .RS 4
1151 0 on success or an error code\&. 
1154 \fBSee also:\fP
1155 .RS 4
1156 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPinentry Details\fP, \fBpwmd_password()\fP 
1160 .SS "LIBPWMD_API gpg_error_t pwmd_passwd (\fBpwm_t\fP * pwm, const char * args, \fBpwmd_inquire_cb_t\fP callback, void * user)"
1163 Change the passphrase for a data file\&. This will send the PASSWD command to the server taking care of pinentry settings\&.
1165 The inquire \fIcallback\fP function should be used when a PASSWD option specified in \fIargs\fP inquires data\&.
1167 \fBParameters:\fP
1168 .RS 4
1169 \fIpwm\fP A handle\&. 
1171 \fIargs\fP Any PASSWD protocol command options or NULL\&. 
1173 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
1175 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
1178 \fBReturns:\fP
1179 .RS 4
1180 0 on success or an error code\&. 
1183 \fBSee also:\fP
1184 .RS 4
1185 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_command()\fP, \fBPinentry Details\fP 
1189 .SS "LIBPWMD_API gpg_error_t pwmd_password (\fBpwm_t\fP * pwm, const char * keyword, char ** result, size_t * size)"
1192 Obtain a passphrase from a local pinentry\&. This is the same function that libpwmd uses during an inquire when using the local pinentry and the inquire keyword is one of PASSPHRASE, NEW_PASSPHRASE or SIGN_PASSPHRASE\&. Provided for convenience since it sets proper pinentry strings and handles new passphrase confirmation\&.
1194 \fBParameters:\fP
1195 .RS 4
1196 \fIpwm\fP A handle\&. 
1198 \fIkeyword\fP The keyword to determine pinentry strings\&. Usually one of PASSPHRASE, NEW_PASSPHRASE or SIGN_PASSPHRASE as sent by pwmd\&. 
1200 \fIresult\fP The obtained passphrase which should be freed with \fBpwmd_free()\fP\&. 
1202 \fIsize\fP The length of \fIresult\fP\&.
1205 \fBReturns:\fP
1206 .RS 4
1207 0 on success or an error\&. 
1211 .SS "LIBPWMD_API gpg_error_t pwmd_process (\fBpwm_t\fP * pwm)"
1214 Check for socket activity\&. This function should be called periodically to check for any pending status messages sent from the server and when \fInot\fP in a command\&.
1216 \fBParameters:\fP
1217 .RS 4
1218 \fIpwm\fP A handle\&. 
1221 \fBReturns:\fP
1222 .RS 4
1223 0 on success or an error code\&.
1226 \fBNote:\fP
1227 .RS 4
1228 This function makes use of \fBpwmd_status_cb_t\fP\&. 
1232 .SS "LIBPWMD_API void* pwmd_realloc (void * ptr, size_t size)"
1235 A wrapper around realloc()\&. Like realloc(), but lets libpwmd keep track of the pointer\&.
1237 \fBParameters:\fP
1238 .RS 4
1239 \fIptr\fP The pointer to reallocate\&. 
1241 \fIsize\fP The new number of bytes to allocate\&. 
1244 \fBReturns:\fP
1245 .RS 4
1246 A newly allocated pointer or NULL if there wasn't enough memory\&. 
1249 \fBSee also:\fP
1250 .RS 4
1251 realloc(3), \fBpwmd_free()\fP 
1255 .SS "LIBPWMD_API gpg_error_t pwmd_save (\fBpwm_t\fP * pwm, const char * args, \fBpwmd_inquire_cb_t\fP callback, void * user)"
1258 Save a file on the pwmd server\&. This will send the SAVE command and write any changes to the document to disk\&.
1260 The inquire \fIcallback\fP function should be used when a SAVE option specified in \fIargs\fP inquires data\&.
1262 \fBParameters:\fP
1263 .RS 4
1264 \fIpwm\fP A handle\&. 
1266 \fIargs\fP Any SAVE protocol command options or NULL\&. 
1268 \fIcallback\fP A callback function to invoke when pwmd inquires data from the client\&. 
1270 \fIuser\fP User data passed to the \fIcallback\fP function\&. 
1273 \fBReturns:\fP
1274 .RS 4
1275 0 on success or an error code\&. 
1278 \fBSee also:\fP
1279 .RS 4
1280 \fBPWMD_OPTION_OVERRIDE_INQUIRE\fP, \fBPWMD_OPTION_NO_PINENTRY\fP, \fBPWMD_OPTION_LOCAL_PINENTRY\fP, \fBpwmd_command()\fP, \fBPinentry Details\fP 
1284 .SS "LIBPWMD_API void pwmd_set_pointer (\fBpwm_t\fP * pwm, void * data)"
1287 Set user data for a handle\&. Use this function to associate user data with a handle that can later be retrieved with \fBpwmd_get_pointer()\fP\&.
1289 \fBParameters:\fP
1290 .RS 4
1291 \fIpwm\fP A handle\&. 
1293 \fIdata\fP A pointer to the user data\&. 
1296 \fBReturns:\fP
1297 .RS 4
1298 Nothing\&. 
1302 .SS "LIBPWMD_API gpg_error_t pwmd_setopt (\fBpwm_t\fP * pwm, int opt,  \&.\&.\&.)"
1305 Set handle options\&. See \fBpwmd_option_t\fP for option specific details\&.
1307 \fBParameters:\fP
1308 .RS 4
1309 \fIpwm\fP A handle\&. 
1311 \fIopt\fP The option\&. 
1313 \fI\&.\&.\&.\fP The option value\&. 
1316 \fBReturns:\fP
1317 .RS 4
1318 0 on success or an error code\&. 
1322 .SS "LIBPWMD_API gpg_error_t pwmd_socket_type (\fBpwm_t\fP * pwm, \fBpwmd_socket_t\fP * type)"
1325 The type of connection a handle has\&. Useful when you need to know what kind of connection a handle has\&.
1327 \fBParameters:\fP
1328 .RS 4
1329 \fIpwm\fP A handle\&. 
1331 \fItype\fP The type of socket\&. 
1334 \fBReturns:\fP
1335 .RS 4
1336 0 on success or an error code\&.
1339 \fBSee also:\fP
1340 .RS 4
1341 \fBpwmd_socket_t\fP 
1345 .SS "LIBPWMD_API char* pwmd_strdup (const char * str)"
1348 A wrapper around strdup()\&. Like strdup(), but lets libpwmd keep track of the pointer\&.
1350 \fBParameters:\fP
1351 .RS 4
1352 \fIstr\fP The string to duplicate\&. 
1355 \fBReturns:\fP
1356 .RS 4
1357 A newly allocated character pointer or NULL if there wasn't enough memory\&. 
1360 \fBSee also:\fP
1361 .RS 4
1362 strdup(3), \fBpwmd_free()\fP 
1366 .SS "LIBPWMD_API char* pwmd_strdup_printf (const char * fmt,  \&.\&.\&.)"
1369 Duplicate a formatted string\&. Like \fBasprintf(3)\fP, but lets libpwmd keep track of the pointer\&.
1371 \fBParameters:\fP
1372 .RS 4
1373 \fIfmt\fP The formatted string and any following arguments\&. 
1376 \fBReturns:\fP
1377 .RS 4
1378 A newly allocated character pointer or NULL if there wasn't enough memory\&. 
1381 \fBSee also:\fP
1382 .RS 4
1383 \fBpwmd_free()\fP 
1387 .SS "LIBPWMD_API gpg_error_t pwmd_test_quality (const char * passphrase, double * result)"
1390 Test the quality of a passphrase\&. When built with passphrase quality checking, you can test the amount of entropy a passphrase contains with this function\&. It simply wraps around the zxcvbn-c quality checking function\&.
1392 \fBParameters:\fP
1393 .RS 4
1394 \fIpassphrase\fP The passphrase to test\&. 
1396 \fIresult\fP The entropy of the passphrase in bits\&.
1399 \fBReturns:\fP
1400 .RS 4
1401 0 on success or an error code\&. 
1405 .SS "LIBPWMD_API const char* pwmd_version ()"
1408 Returns this version of libpwmd\&. As a string\&. 
1410 \fBReturns:\fP
1411 .RS 4
1412 A string\&. 
1416 .SH "Author"
1417 .PP 
1418 Generated automatically by Doxygen for libpwmd from the source code\&.