Mention that command options may be included in the command parameter to
[libpwmd.git] / doc / libpwmd.3
blob92b0bc565aa15d17ebd3cdf070ccce9ba4082fc0
1 .TH "libpwmd.h" 3 "Sat Oct 30 2010" "Version 6.0.3" "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 2.0 or later is required; either locally or remotely.
9 .SH "SSH Details"
10 .PP
11 A remote connection to a pwmd server is possible by using an SSH channel which spawns a shell and executes a proxy server that connects 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.
12 .PP
13 The servers public key can be had by using \fBpwmd_get_hostkey()\fP and storing the result in a file or done automatially by using a callback function \fBpwmd_knownhost_cb_t\fP while connecting to the unknown host.
14 .PP
15 On the server side you'll need a proxy server to connect to the real pwmd server. Here's an example \fBauthorized_keys(5)\fP entry that will do this. The hash portion should be the same as the contents of the generated \fBssh-keygen(1)\fP \fIidentity.pub\fP file which is passed as a parameter to the SSH connection functions:
16 .PP
17 .PP
18 .nf
19  command='socat UNIX-CONNECT:$HOME/.pwmd/socket -' <hash> ...
20 .fi
21 .PP
22 .PP
23 \fBNote:\fP
24 .RS 4
25 Only an SSH identity without a passphrase is supported. For now anyway. This is a limitation of libssh2 (version 1.1 as of this writing).
26 .RE
27 .PP
28 \fBVersion:\fP
29 .RS 4
30 6.0.3 The first version to use the OpenSSH known hosts file format exclusively. Earlier versions used only an SHA1 hash of the host key.
31 .RE
32 .PP
33 \fBTodo\fP
34 .RS 4
35 X11 port forwarding so a remote pinentry can use the local display. 
36 .RE
37 .PP
38 .SH "Pinentry Details"
39 .PP
40 \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 use it's pinentry to retrieve a passphrase when needed. How this is done depends what function gets called and whether the pwmd connection is over an SSH channel.
41 .PP
42 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 not sent (when using pwmd's pinentry, not the local one) until the pinentry is needed.
43 .PP
44 If using a local pinentry by calling \fBpwmd_open2()\fP, \fBpwmd_save2()\fP, \fBpwmd_open_async2()\fP or \fBpwmd_save_async2()\fP, libpwmd will send the command 'SET ENABLE_PINENTRY=0' to the pwmd server. This is needed so pwmd wont try to launch it's own pinentry on passphrase or confirmation failure. So you may need to reset this option manually depending on your needs; especially when changing pinentry methods when doing a save (the passphrase may be set as empty since the remote pinentry is disabled!).
45 .PP
46 Some pinentry options can also be specified in a local configuration file \fI'~/.pwmd/pinentry.conf'\fP. These options are initial values for each pinentry invokation (not retries) and may be changed by setting the appropriate \fBpwmd_option_t\fP. Each option and value is separated with a '=' on a single line. Unrecognized options are ignored. Here are the recognized options:
47 .PP
48 \fBParameters:\fP
49 .RS 4
50 \fIPATH\fP The full path to the location of the pinentry binary. 
51 .br
52 \fIDISPLAY\fP The X11 display to use. 
53 .br
54 \fITTYNAME\fP The full path to the tty that pinentry should prompt on. 
55 .br
56 \fITTYTYPE\fP The terminal type of the tty which is required if DISPLAY is not set.
57 .RE
58 .PP
59 \fBNote:\fP
60 .RS 4
61 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user.
62 .PP
63 The initial values for the pinentry TTY, TERM and DISPLAY are set during \fBpwmd_new()\fP depending on the current environment. They may need to be reset as needed.
64 .PP
65 After establishing an SSH connection, the pwmd pinentry is disabled by sending the command 'SET ENABLE_PINENTRY=0'. This is needed because there currently isn't a way to have the remote pinentry use the local display. You must be careful to use either a local pinentry or set a passphrase manually with \fBpwmd_setopt()\fP when a passphrase is required or needed.
66 .RE
67 .PP
68 \fBTodo\fP
69 .RS 4
70 X11 port forwarding so a remote pinentry can use the local display.
71 .RE
72 .PP
73 .PP
74 \fBSee also:\fP
75 .RS 4
76 \fBSSH Details\fP
77 .RE
78 .PP
79 .SH "Errors"
80 .PP
81 libpwmd uses libgpg-error for all error codes. Some are user defined GPG_ERR_USER_N codes, but most are reused from the existing ones. Error codes can be described by using \fBpwmd_strerror()\fP, or the thread-safe \fBpwmd_strerror_r()\fP.
82 .PP
83 \fBNote:\fP
84 .RS 4
85 libgpg-error normally returns an error code as a bitmask of an error source and the actual error code. In order to simplify the result codes, libpwmd strips any error source from the error code before returning it. 
86 .RE
87 .PP
89 .SH SYNOPSIS
90 .br
91 .PP
92 .SS "Data Structures"
94 .in +1c
95 .ti -1c
96 .RI "struct \fBpwmd_fd_t\fP"
97 .br
98 .in -1c
99 .SS "Constants"
101 .in +1c
102 .ti -1c
103 .RI "#define \fBLIBPWMD_H\fP"
105 .ti -1c
106 .RI "#define \fBLIBPWMD_VERSION\fP   0x603"
108 .ti -1c
109 .RI "#define \fBLIBPWMD_VERSION_MAJOR\fP   6"
111 .ti -1c
112 .RI "#define \fBLIBPWMD_VERSION_MINOR\fP   0"
114 .ti -1c
115 .RI "#define \fBLIBPWMD_VERSION_PATCH\fP   3"
117 .ti -1c
118 .RI "#define \fBLIBPWMD_VERSION_STR\fP   '6.0.3-git'"
120 .ti -1c
121 .RI "#define \fBPWMD_FD_READABLE\fP   0x01"
123 .ti -1c
124 .RI "#define \fBPWMD_FD_WRITABLE\fP   0x02"
126 .ti -1c
127 .RI "#define \fBEPWMD_NO_FILE\fP"
129 .ti -1c
130 .RI "#define \fBEPWMD_LIBXML_ERROR\fP"
132 .ti -1c
133 .RI "#define \fBEPWMD_FILE_MODIFIED\fP"
135 .ti -1c
136 .RI "#define \fBEPWMD_MAX\fP"
138 .in -1c
139 .SS "Typedefs"
141 .in +1c
142 .ti -1c
143 .RI "typedef struct pwm_s \fBpwm_t\fP"
145 .ti -1c
146 .RI "typedef gpg_error_t(* \fBpwmd_passphrase_cb_t\fP )(void *user, char **passphrase)"
148 .ti -1c
149 .RI "typedef int(* \fBpwmd_status_cb_t\fP )(void *user, const char *line)"
151 .ti -1c
152 .RI "typedef gpg_error_t(* \fBpwmd_inquire_cb_t\fP )(void *user, const char *cmd, gpg_error_t rc, char **data, size_t *len)"
154 .ti -1c
155 .RI "typedef gpg_error_t(* \fBpwmd_knownhost_cb_t\fP )(void *user, const char *host, const char *key, size_t len)"
157 .in -1c
158 .SS "Enumerations"
160 .in +1c
161 .ti -1c
162 .RI "enum \fBpwmd_async_t\fP { \fBASYNC_INIT\fP, \fBASYNC_PROCESS\fP, \fBASYNC_DONE\fP }"
164 .ti -1c
165 .RI "enum \fBpwmd_ip_version_t\fP { \fBPWMD_IP_ANY\fP, \fBPWMD_IPV4\fP, \fBPWMD_IPV6\fP }"
167 .ti -1c
168 .RI "enum \fBpwmd_socket_t\fP { \fBPWMD_SOCKET_LOCAL\fP, \fBPWMD_SOCKET_SSH\fP }"
170 .ti -1c
171 .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_CONFIRM\fP, \fBPWMD_PINENTRY_DEFAULT\fP, \fBPWMD_PINENTRY_CLOSE\fP }"
173 .ti -1c
174 .RI "enum \fBpwmd_option_t\fP { \fBPWMD_OPTION_PASSPHRASE_CB\fP, \fBPWMD_OPTION_PASSPHRASE_DATA\fP, \fBPWMD_OPTION_PASSPHRASE\fP, \fBPWMD_OPTION_PINENTRY_TRIES\fP, \fBPWMD_OPTION_PINENTRY_PATH\fP, \fBPWMD_OPTION_PINENTRY_TTY\fP, \fBPWMD_OPTION_PINENTRY_TERM\fP, \fBPWMD_OPTION_PINENTRY_DISPLAY\fP, \fBPWMD_OPTION_PINENTRY_TITLE\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_STATUS_CB\fP, \fBPWMD_OPTION_STATUS_DATA\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBPWMD_OPTION_KNOWNHOST_CB\fP, \fBPWMD_OPTION_KNOWNHOST_DATA\fP, \fBPWMD_OPTION_INQUIRE_TOTAL\fP, \fBPWMD_OPTION_LOCK_ON_OPEN\fP, \fBPWMD_OPTION_ITERATIONS\fP, \fBPWMD_OPTION_CIPHER\fP, \fBPWMD_OPTION_BASE64\fP }"
176 .in -1c
177 .SS "Functions"
179 .in +1c
180 .ti -1c
181 .RI "LIBPWMD_API const char * \fBpwmd_version\fP ()"
183 .ti -1c
184 .RI "LIBPWMD_API gpg_error_t \fBpwmd_init\fP (void)"
186 .ti -1c
187 .RI "LIBPWMD_API \fBpwm_t\fP * \fBpwmd_new\fP (const char *name)"
189 .ti -1c
190 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect\fP (\fBpwm_t\fP *pwm, const char *path)"
192 .ti -1c
193 .RI "LIBPWMD_API gpg_error_t \fBpwmd_ssh_connect\fP (\fBpwm_t\fP *pwm, const char *host, int port, const char *identity, const char *user, const char *known_hosts)"
195 .ti -1c
196 .RI "LIBPWMD_API gpg_error_t \fBpwmd_ssh_connect_async\fP (\fBpwm_t\fP *pwm, const char *host, int port, const char *identity, const char *user, const char *known_hosts)"
198 .ti -1c
199 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect_url\fP (\fBpwm_t\fP *pwm, const char *url)"
201 .ti -1c
202 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect_url_async\fP (\fBpwm_t\fP *pwm, const char *url)"
204 .ti -1c
205 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_hostkey\fP (\fBpwm_t\fP *pwm, const char *host, int port, char **result)"
207 .ti -1c
208 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_hostkey_async\fP (\fBpwm_t\fP *pwm, const char *host, int port)"
210 .ti -1c
211 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_fds\fP (\fBpwm_t\fP *pwm, \fBpwmd_fd_t\fP *fds, int *n_fds)"
213 .ti -1c
214 .RI "LIBPWMD_API gpg_error_t \fBpwmd_pending_line\fP (\fBpwm_t\fP *pwm)"
216 .ti -1c
217 .RI "LIBPWMD_API gpg_error_t \fBpwmd_setopt\fP (\fBpwm_t\fP *pwm, \fBpwmd_option_t\fP opt,...)"
219 .ti -1c
220 .RI "LIBPWMD_API gpg_error_t \fBpwmd_getpin\fP (\fBpwm_t\fP *pwm, const char *filename, char **result, \fBpwmd_pinentry_t\fP which)"
222 .ti -1c
223 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open\fP (\fBpwm_t\fP *pwm, const char *filename)"
225 .ti -1c
226 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open_inquire\fP (\fBpwm_t\fP *pwm, const char *filename, \fBpwmd_inquire_cb_t\fP func, void *user)"
228 .ti -1c
229 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open2\fP (\fBpwm_t\fP *pwm, const char *filename)"
231 .ti -1c
232 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open_async2\fP (\fBpwm_t\fP *pwm, const char *filename)"
234 .ti -1c
235 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open_async\fP (\fBpwm_t\fP *pwm, const char *filename)"
237 .ti -1c
238 .RI "LIBPWMD_API \fBpwmd_async_t\fP \fBpwmd_process\fP (\fBpwm_t\fP *pwm, gpg_error_t *rc, char **result)"
240 .ti -1c
241 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save\fP (\fBpwm_t\fP *pwm)"
243 .ti -1c
244 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_inquire\fP (\fBpwm_t\fP *pwm, \fBpwmd_inquire_cb_t\fP func, void *user)"
246 .ti -1c
247 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save2\fP (\fBpwm_t\fP *pwm)"
249 .ti -1c
250 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_async2\fP (\fBpwm_t\fP *pwm)"
252 .ti -1c
253 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_async\fP (\fBpwm_t\fP *pwm)"
255 .ti -1c
256 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd,...)"
258 .ti -1c
259 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command_ap\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd, va_list ap)"
261 .ti -1c
262 .RI "LIBPWMD_API gpg_error_t \fBpwmd_inquire\fP (\fBpwm_t\fP *pwm, const char *cmd, \fBpwmd_inquire_cb_t\fP func, void *user)"
264 .ti -1c
265 .RI "LIBPWMD_API gpg_error_t \fBpwmd_disconnect\fP (\fBpwm_t\fP *pwm)"
267 .ti -1c
268 .RI "LIBPWMD_API void \fBpwmd_close\fP (\fBpwm_t\fP *pwm)"
270 .ti -1c
271 .RI "LIBPWMD_API gpg_error_t \fBpwmd_socket_type\fP (\fBpwm_t\fP *pwm, \fBpwmd_socket_t\fP *type)"
273 .ti -1c
274 .RI "LIBPWMD_API void \fBpwmd_free\fP (void *ptr)"
276 .ti -1c
277 .RI "LIBPWMD_API void * \fBpwmd_malloc\fP (size_t size)"
279 .ti -1c
280 .RI "LIBPWMD_API void * \fBpwmd_calloc\fP (size_t nmemb, size_t size)"
282 .ti -1c
283 .RI "LIBPWMD_API void * \fBpwmd_realloc\fP (void *ptr, size_t size)"
285 .ti -1c
286 .RI "LIBPWMD_API char * \fBpwmd_strdup\fP (const char *str)"
288 .ti -1c
289 .RI "LIBPWMD_API char * \fBpwmd_strdup_printf\fP (const char *fmt,...)"
291 .ti -1c
292 .RI "LIBPWMD_API const char * \fBpwmd_strerror\fP (gpg_error_t code)"
294 .ti -1c
295 .RI "LIBPWMD_API int \fBpwmd_strerror_r\fP (gpg_error_t code, char *buf, size_t size)"
297 .in -1c
298 .SH "Constant Details"
299 .PP 
300 .SS "#define EPWMD_FILE_MODIFIED"
302 The data file has been modified. Rather than process the next command this error is returned to prevent overwriting new data which may have been saved by another client. 
303 .SS "#define EPWMD_LIBXML_ERROR"
305 libxml2 error. This can be a memory allocation error or a parse error. The details of the error cannot be obtained with libpwmd. You'd have to connect to the pwmd socket and do the command directly to get the actual error. 
306 .SS "#define EPWMD_MAX"
308 libgpg-error error code offset. If you use your own libgpg-error codes then this should be the base of them. 
309 .SS "#define EPWMD_NO_FILE"
311 No data file has been opened. Some commands don't require an open data file but most do. 
312 .SS "#define LIBPWMD_VERSION   0x603"
314 Version information. The version of this library. 
315 .SS "#define LIBPWMD_VERSION_MAJOR   6"
317 Version information. The major release number of this library. 
318 .SS "#define LIBPWMD_VERSION_MINOR   0"
320 Version information. The minor release number of this library. 
321 .SS "#define LIBPWMD_VERSION_PATCH   3"
323 Version information. The patch level of this library. 
324 .SS "#define LIBPWMD_VERSION_STR   '6.0.3-git'"
326 Version information. A string representation of the version of this library. 
327 .SS "#define PWMD_FD_READABLE   0x01"
329 For use with \fBpwmd_get_fds()\fP. Set when the file descriptor is readable. 
330 .SS "#define PWMD_FD_WRITABLE   0x02"
332 For use with \fBpwmd_get_fds()\fP. Set when the file descriptor is writable. 
333 .SH "Typedef Details"
334 .PP 
335 .SS "\fBpwm_t\fP"
337 libpwmd handle. When a handle is mentioned in this documentation it is a pointer of this type. A new handle is created with \fBpwmd_new()\fP. 
338 .SS "\fBpwmd_inquire_cb_t\fP"
340 Send data to the pwmd server. This is a callback function that gets passed to \fBpwmd_inquire()\fP. It is used for sending data to the server for commands that need to reply to an INQUIRE server response (STORE and IMPORT). The reason for this callback is to let the client send as many bytes as it wants rather than the entire chunk 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.
342 \fBParameters:\fP
343 .RS 4
344 \fIuser\fP The user data pointer passed to \fBpwmd_inquire()\fP. 
346 \fIcmd\fP The same as the \fIcmd\fP argument to \fBpwmd_inquire()\fP. 
348 \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. 
350 \fIdata\fP The next chunk of data to send or NULL. 
352 \fIlen\fP The length of \fIdata\fP or 0.
355 \fBReturn values:\fP
356 .RS 4
357 \fI0\fP There is more data to be sent. 
359 \fIGPG_ERR_EOF\fP No need to call this function again, the current \fIline\fP is the last to send. 
361 \fIcode\fP Any other error code which will terminate the INQUIRE.
364 \fBNote:\fP
365 .RS 4
366 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. 
370 .SS "\fBpwmd_knownhost_cb_t\fP"
372 Verify a remote SSH connection. When \fBPWMD_OPTION_KNOWNHOST_CB\fP is set and a the current 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.
374 \fBParameters:\fP
375 .RS 4
376 \fIuser\fP User data which was set with \fBPWMD_OPTION_KNOWNHOST_DATA\fP. 
378 \fIhost\fP The hostname as passed to the connecting function. 
380 \fIkey\fP The raw host key. Note that this differs from the format returned from \fBpwmd_get_hostkey()\fP. 
382 \fIlen\fP The host key length. 
385 \fBReturn values:\fP
386 .RS 4
387 \fI0\fP Add the host key to the known hosts file. 
389 \fIGPG_ERR_NOT_CONFIRMED\fP Do not add the host key and abort the connection.
392 \fBNote:\fP
393 .RS 4
394 If the known hosts file cannot be modified do to filesystem restrictions when trying to add 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 considered verified.
397 \fBSee also:\fP
398 .RS 4
399 \fBSSH Details\fP 
403 .SS "\fBpwmd_passphrase_cb_t\fP"
405 Custom passphrase retrieval function. The value of the option \fBPWMD_OPTION_PASSPHRASE_CB\fP which is set with \fBpwmd_setopt()\fP.
407 \fBParameters:\fP
408 .RS 4
409 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_PASSPHRASE_DATA\fP. 
411 \fIpassphrase\fP The passphrase which may be an empty string or NULL. It is not modified by libpwmd but must remain allocated for as long as it is needed. 
414 \fBReturns:\fP
415 .RS 4
416 0 on success or an error code which will cause a command to fail. 
420 .SS "\fBpwmd_status_cb_t\fP"
422 Process status messages. The value of the option \fBPWMD_OPTION_STATUS_CB\fP which is set with \fBpwmd_setopt()\fP.
424 \fBParameters:\fP
425 .RS 4
426 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_STATUS_DATA\fP. 
428 \fIline\fP The status message line received from the server. 
431 \fBReturns:\fP
432 .RS 4
433 0 on success or an error code which will cause a command to fail. 
437 .SH "Enumeration Details"
438 .PP 
439 .SS "enum \fBpwmd_async_t\fP"
441 Asynchronous return value. The return code of \fBpwmd_process()\fP which is used for all asynchronous commands. 
443 \fBEnumerator: \fP
444 .in +1c
446 \fB\fIASYNC_INIT \fP\fP
448 \fBFor internal use only.\fP
449 .RS 4
454 \fB\fIASYNC_PROCESS \fP\fP
455 \fBpwmd_process()\fP should be called again. 
457 \fB\fIASYNC_DONE \fP\fP
458 The command has completed. The result code should be checked for an error. 
459 .SS "enum \fBpwmd_ip_version_t\fP"
461 IP protocol version for remote SSH connections. The value of the option \fBPWMD_OPTION_IP_VERSION\fP which is set with \fBpwmd_setopt()\fP. 
463 \fBEnumerator: \fP
464 .in +1c
466 \fB\fIPWMD_IP_ANY \fP\fP
467 Try both IPv4 and IPv6 addresses. Note that IPv6 is tried first and that \fBPWMD_IP_ANY\fP only affects a hostname and not an IP address in the address specification. 
469 \fB\fIPWMD_IPV4 \fP\fP
470 Only try IPv4. 
472 \fB\fIPWMD_IPV6 \fP\fP
473 Only try IPv6. 
474 .SS "enum \fBpwmd_option_t\fP"
476 libpwmd options. Options are set with \fBpwmd_setopt()\fP.
478 \fBNote:\fP
479 .RS 4
480 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
485 \fBEnumerator: \fP
486 .in +1c
488 \fB\fIPWMD_OPTION_PASSPHRASE_CB \fP\fP
489 A custom passphrase retrieval function which, when set, will be used instead of \fBpinentry(1)\fP. This function will not be used if opening a file and the passphrase is cached on the server or the file is a new one. The value of this option should be a \fBpwmd_passphrase_cb_t\fP.
491 \fBNote:\fP
492 .RS 4
493 An empty string as the passphrase is allowed. 
498 \fB\fIPWMD_OPTION_PASSPHRASE_DATA \fP\fP
499 User supplied data which is passed to the custom passphrase function. 
501 \fB\fIPWMD_OPTION_PASSPHRASE \fP\fP
502 A string to use as the passphrase when doing an open or save. When not NULL, this option has precedence over \fBPWMD_OPTION_PASSPHRASE_CB\fP.
504 \fBNote:\fP
505 .RS 4
506 An empty string as the passphrase is allowed. 
511 \fB\fIPWMD_OPTION_PINENTRY_TRIES \fP\fP
512 An integer value that specifies the number of tries before \fBpinentry(1)\fP will give up when opening a file with the wrong supplied passphrase. The default is 3.
514 \fBNote:\fP
515 .RS 4
516 This option has no effect when trying to save a file. The user must either cancel the pinentry causing the save to fail or enter the correct passphrase during passphrase confirmation. 
521 \fB\fIPWMD_OPTION_PINENTRY_PATH \fP\fP
522 A character string value which specifies the full path of the \fBpinentry(1)\fP binary. For the local \fBpinentry(1)\fP method, the default is specified at compile time.
524 \fBSee also:\fP
525 .RS 4
526 \fBPinentry Details\fP 
531 \fB\fIPWMD_OPTION_PINENTRY_TTY \fP\fP
532 A 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.
534 \fBSee also:\fP
535 .RS 4
536 \fBPinentry Details\fP 
541 \fB\fIPWMD_OPTION_PINENTRY_TERM \fP\fP
542 A value which specifies the terminal type (e.g., vt100) that \fBpinentry(1)\fP will use when no X11 display is available.
544 \fBSee also:\fP
545 .RS 4
546 \fBPinentry Details\fP 
551 \fB\fIPWMD_OPTION_PINENTRY_DISPLAY \fP\fP
552 A value which specifies the X11 display that \fBpinentry(1)\fP will use.
554 \fBTodo\fP
555 .RS 4
556 X11 port forwarding so a remote pinentry can use the local display.
560 \fBSee also:\fP
561 .RS 4
562 \fBPinentry Details\fP 
567 \fB\fIPWMD_OPTION_PINENTRY_TITLE \fP\fP
568 A character string that \fBpinentry(1)\fP will use in it's dialog window. 
570 \fB\fIPWMD_OPTION_PINENTRY_PROMPT \fP\fP
571 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
573 \fB\fIPWMD_OPTION_PINENTRY_DESC \fP\fP
574 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
576 \fB\fIPWMD_OPTION_PINENTRY_LC_CTYPE \fP\fP
577 For \fBpinentry(1)\fP localization. 
579 \fB\fIPWMD_OPTION_PINENTRY_LC_MESSAGES \fP\fP
580 For \fBpinentry(1)\fP localization.  
582 \fB\fIPWMD_OPTION_PINENTRY_TIMEOUT \fP\fP
583 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. 
585 \fB\fIPWMD_OPTION_STATUS_CB \fP\fP
586 A function of type \fBpwmd_status_cb_t\fP that will process status messages received from the pwmd server. 
588 \fB\fIPWMD_OPTION_STATUS_DATA \fP\fP
589 A user data pointer which is passed to the status message function. 
591 \fB\fIPWMD_OPTION_IP_VERSION \fP\fP
592 The IP version of type \fBpwmd_ip_version_t\fP that \fBpwmd_ssh_connect()\fP and \fBpwmd_ssh_connect_async()\fP will use when connecting to the remote pwmd server. The default is \fBPWMD_IP_ANY\fP.
594 \fBNote:\fP
595 .RS 4
596 This option must be set before a connection is made when not the default. 
601 \fB\fIPWMD_OPTION_KNOWNHOST_CB \fP\fP
602 A function to confirm an unknown host hash which wasn't found in the known hosts file.
604 \fBSee also:\fP
605 .RS 4
606 \fBSSH Details\fP 
611 \fB\fIPWMD_OPTION_KNOWNHOST_DATA \fP\fP
612 User supplied data which is passed to the known host function.
614 \fBSee also:\fP
615 .RS 4
616 \fBSSH Details\fP 
621 \fB\fIPWMD_OPTION_INQUIRE_TOTAL \fP\fP
622 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 set before each call to \fBpwmd_inquire()\fP.
624 \fBNote:\fP
625 .RS 4
626 During the INQUIRE, PWMD_OPTION_STATUS_CB is called after every ASSUAN_LINELENGTH bytes have been successfully transferred.
628 This is a libpwmd feature. pwmd itself does not send XFER status messages during an INQUIRE. Status messages can be parsed only when PWMD_OPTION_STATUS_CB is set. 
633 \fB\fIPWMD_OPTION_LOCK_ON_OPEN \fP\fP
634 When set to 1, lock the file mutex after opening a file as if the LOCK command had been sent. 
636 \fB\fIPWMD_OPTION_ITERATIONS \fP\fP
637 A long integer specifying the number of iterations to encrypt with. When -1 then the next save operation will use the current iteration setting and no command will be sent to alter it. 
639 \fB\fIPWMD_OPTION_CIPHER \fP\fP
640 A string specifying the cipher to use to encrypt with. See the pwmd(1) manual page for available ciphers. 
642 \fB\fIPWMD_OPTION_BASE64 \fP\fP
643 When 1, tell pwmd that the passphrase is Base64 encoded. pwmd will decode the passphrase before encryption and decryption. 
644 .SS "enum \fBpwmd_pinentry_t\fP"
646 Local pinentry commands and not pwmd pinentry. For use with \fBpwmd_getpin()\fP. 
648 \fBEnumerator: \fP
649 .in +1c
651 \fB\fIPWMD_PINENTRY_OPEN \fP\fP
652 When opening a file. 
654 \fB\fIPWMD_PINENTRY_OPEN_FAILED \fP\fP
655 When opening a file failed. 
657 \fB\fIPWMD_PINENTRY_SAVE \fP\fP
658 When saving a file. 
660 \fB\fIPWMD_PINENTRY_SAVE_CONFIRM \fP\fP
661 For passphrase confirmation. 
663 \fB\fIPWMD_PINENTRY_CONFIRM \fP\fP
664 For confirmation of a user-defined prompt. 
666 \fB\fIPWMD_PINENTRY_DEFAULT \fP\fP
667 For the default or user defined string set with \fBPWMD_OPTION_PINENTRY_DESC\fP. 
669 \fB\fIPWMD_PINENTRY_CLOSE \fP\fP
670 To terminate the pinentry process created with \fBpwmd_getpin()\fP. 
671 .SS "enum \fBpwmd_socket_t\fP"
673 The type of socket a handle is connected to. For use with \fBpwmd_socket_type()\fP. 
675 \fBEnumerator: \fP
676 .in +1c
678 \fB\fIPWMD_SOCKET_LOCAL \fP\fP
679 A local domain socket. 
681 \fB\fIPWMD_SOCKET_SSH \fP\fP
682 An SSH connection over a TCP socket. 
683 .SH "Function Details"
684 .PP 
685 .SS "LIBPWMD_API void* pwmd_calloc (size_t nmemb, size_t size)"
687 A wrapper around calloc(). Like calloc(), but lets libpwmd keep track of the pointer.
689 \fBParameters:\fP
690 .RS 4
691 \fInmemb\fP The number of elements to allocate. 
693 \fIsize\fP The number of bytes to allocate. 
696 \fBReturns:\fP
697 .RS 4
698 A newly allocated pointer or NULL if there wasn't enough memory. 
701 \fBSee also:\fP
702 .RS 4
703 calloc(3), \fBpwmd_free()\fP 
707 .SS "LIBPWMD_API void pwmd_close (\fBpwm_t\fP * pwm)"
709 Close a handle. This will close the connection to a pwmd server and free any resources associated with it.
711 \fBParameters:\fP
712 .RS 4
713 \fIpwm\fP A handle. 
716 \fBReturns:\fP
717 .RS 4
718 Nothing. 
721 \fBSee also:\fP
722 .RS 4
723 \fBpwmd_disconnect()\fP, \fBpwmd_new()\fP 
727 .SS "LIBPWMD_API gpg_error_t pwmd_command (\fBpwm_t\fP * pwm, char ** result, const char * cmd,  ...)"
729 Send a command to the pwmd server. Sends 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. For commands that use an INQUIRE to send data to the server (STORE and IMPORT), \fBpwmd_inquire()\fP must be used and not this function.
731 \fBParameters:\fP
732 .RS 4
733 \fIpwm\fP A handle. 
735 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. 
737 \fIcmd\fP The command to send and any following arguments. 
740 \fBReturns:\fP
741 .RS 4
742 0 on success or an error code.
745 \fBNote:\fP
746 .RS 4
747 Not all commands return a result. 
751 .SS "LIBPWMD_API gpg_error_t pwmd_command_ap (\fBpwm_t\fP * pwm, char ** result, const char * cmd, va_list ap)"
753 Send a command to the pwmd server. Like \fBpwmd_command()\fP but uses an argument pointer instead.
755 \fBParameters:\fP
756 .RS 4
757 \fIpwm\fP A handle. 
759 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. 
761 \fIcmd\fP The command to send. 
763 \fIap\fP The arguments to \fIcmd\fP. 
766 \fBReturns:\fP
767 .RS 4
768 0 on success or an error code.
771 \fBNote:\fP
772 .RS 4
773 Not all commands return a result. 
777 .SS "LIBPWMD_API gpg_error_t pwmd_connect (\fBpwm_t\fP * pwm, const char * path)"
779 Connect to a local pwmd server. Connects to a local unix domain socket.
781 \fBParameters:\fP
782 .RS 4
783 \fIpwm\fP A handle. 
785 \fIpath\fP The socket path to connect to. If NULL, then a default of \fI'~/.pwmd/socket'\fP will be used. 
788 \fBReturns:\fP
789 .RS 4
790 0 on success or an error code. 
793 \fBNote:\fP
794 .RS 4
795 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
798 \fBSee also:\fP
799 .RS 4
800 \fBpwmd_ssh_connect()\fP, \fBpwmd_ssh_connect_async()\fP, \fBpwmd_disconnect()\fP 
804 .SS "LIBPWMD_API gpg_error_t pwmd_connect_url (\fBpwm_t\fP * pwm, const char * url)"
806 Establish a connection by parsing a URL. This allows for connecting to a pwmd server by parsing the given URL string. Whether the connection is to a remote or local server depends on the contents: 
809  file://[path/to/local/socket]
811  or
813  ssh[46]://[username@]hostname[:port],identity,known_hosts
818 The parameters in square brackets are optional and if not specified then defaults will be used. If neither socket specification is matched, the \fIurl\fP is assumed to be a file://.
820 \fBParameters:\fP
821 .RS 4
822 \fIpwm\fP A handle. 
824 \fIurl\fP The string to parse. 
827 \fBNote:\fP
828 .RS 4
829 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
832 \fBReturns:\fP
833 .RS 4
834 0 on success or an error code. 
837 \fBSee also:\fP
838 .RS 4
839 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
843 .SS "LIBPWMD_API gpg_error_t pwmd_connect_url_async (\fBpwm_t\fP * pwm, const char * url)"
845 Establish a connection by parsing a URL (asynchronously). This allows for connecting to a pwmd server by parsing the given URL string. Whether the connection is to a remote or local server depends on the contents: 
848  file://[path/to/local/socket]
850  or
852  ssh[46]://[username@]hostname[:port],identity,known_hosts
857 The parameters in square brackets are optional and if not specified then defaults will be used. If neither socket specification is matched, the \fIurl\fP is assumed to be a file://.
859 \fBpwmd_process()\fP should be called until the command completes.
861 \fBParameters:\fP
862 .RS 4
863 \fIpwm\fP A handle. 
865 \fIurl\fP The string to parse. 
868 \fBNote:\fP
869 .RS 4
870 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
873 \fBReturns:\fP
874 .RS 4
875 0 on success or an error code. 
878 \fBSee also:\fP
879 .RS 4
880 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
884 .SS "LIBPWMD_API gpg_error_t pwmd_disconnect (\fBpwm_t\fP * pwm)"
886 Close a connection to the pwmd server. This will close the connection but keep any previously set options for the specified handle.
888 \fBParameters:\fP
889 .RS 4
890 \fIpwm\fP A handle. 
893 \fBReturns:\fP
894 .RS 4
895 0 on success or an error code. 
898 \fBSee also:\fP
899 .RS 4
900 \fBpwmd_close()\fP 
904 .SS "LIBPWMD_API void pwmd_free (void * ptr)"
906 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.
908 The difference between the standard free() and this function is that this one will zero out the contents of the pointer before freeing it.
910 \fBParameters:\fP
911 .RS 4
912 \fIptr\fP The pointer to deallocate. 
915 \fBReturns:\fP
916 .RS 4
917 Nothing. 
920 \fBSee also:\fP
921 .RS 4
922 \fBpwmd_malloc()\fP, \fBpwmd_calloc()\fP, \fBpwmd_realloc()\fP, \fBpwmd_strdup()\fP, \fBpwmd_process()\fP, \fBpwmd_command()\fP 
926 .SS "LIBPWMD_API gpg_error_t pwmd_get_fds (\fBpwm_t\fP * pwm, \fBpwmd_fd_t\fP * fds, int * n_fds)"
928 Get the associated file descriptor(s) for a handle. This function lets the application manually poll the available file descriptors for the specified handle. It should be called after each asynchronous function call and after each call to \fBpwmd_process()\fP since the polled file descriptors may have been closed since the previous call.
930 After returning, \fIn_fds\fP is set to the number of available file descriptors which are stored in \fIfds\fP. The .flags member of \fBpwmd_fd_t\fP specifies what can be monitored and is a bitmask of \fBPWMD_FD_READABLE\fP and \fBPWMD_FD_WRITABLE\fP. When ready, \fBpwmd_process()\fP should be called.
932 \fBParameters:\fP
933 .RS 4
934 \fIpwm\fP A handle. 
936 \fIfds\fP Set to the file descriptor(s) of the associated handle. 
938 \fIn_fds\fP Initially the size of \fIfds\fP then updated to the number of available file descriptors which are stored in \fIfds\fP. 
941 \fBReturn values:\fP
942 .RS 4
943 \fI0\fP on success or an error code. 
945 \fIGPG_ERR_ERANGE\fP There are more file descriptors than the amount specified in \fIn_fds\fP. \fIfds\fP and \fIn_fds\fP are still usable though. 
948 \fBSee also:\fP
949 .RS 4
950 \fBpwmd_process()\fP 
954 .SS "LIBPWMD_API gpg_error_t pwmd_get_hostkey (\fBpwm_t\fP * pwm, const char * host, int port, char ** result)"
956 Retrieve a remote SSH public host key. This key is needed for host verification of the remote pwmd server. You should be sure that the remote host is really the host that your wanting to connect to and not subject to a man-in-the-middle attack.
958 \fBParameters:\fP
959 .RS 4
960 \fIpwm\fP A handle. 
962 \fIhost\fP The hostname or IP to connect to. 
964 \fIport\fP The port or -1 for the default of 22. 
966 \fIresult\fP An OpenSSH known hosts formatted string containing the servers public key which should be freed with \fBpwmd_free()\fP. If the \fIhost\fP was a hostname then two newline separated known host entries will be returned; one for the hostname and one for the resolved IP address. The IP known host entry will always be the second in the string. 
969 \fBReturns:\fP
970 .RS 4
971 0 on success or an error code.
974 \fBVersion:\fP
975 .RS 4
976 6.0.3 The connection is kept open but not verified after returning. It can be resumed from one of the SSH connection functions.
979 \fBSee also:\fP
980 .RS 4
981 \fBpwmd_get_hostkey_async()\fP, \fBpwmd_ssh_connect()\fP, \fBSSH Details\fP 
985 .SS "LIBPWMD_API gpg_error_t pwmd_get_hostkey_async (\fBpwm_t\fP * pwm, const char * host, int port)"
987 Retrieve a remote SSH host key (asynchronously). This key is needed for host verification of the remote pwmd server. You should be sure that the remote host is really the host that your wanting to connect to and not subject to a man-in-the-middle attack.
989 \fBpwmd_process()\fP should be called until the command completes.
991 \fBParameters:\fP
992 .RS 4
993 \fIpwm\fP A handle. 
995 \fIhost\fP The hostname or IP to connect to. 
997 \fIport\fP The port or -1 for the default of 22. 
1000 \fBReturns:\fP
1001 .RS 4
1002 0 on success or an error code. The result is obtained from \fBpwmd_process()\fP should be freed with \fBpwmd_free()\fP. It has the same format as the result from \fBpwmd_get_hostkey()\fP.
1005 \fBVersion:\fP
1006 .RS 4
1007 6.0.3 The connection is kept open but not verified after returning. It can be resumed from one of the SSH connection functions.
1010 \fBSee also:\fP
1011 .RS 4
1012 \fBpwmd_get_hostkey()\fP, \fBpwmd_ssh_connect_async()\fP, \fBpwmd_process()\fP, \fBSSH Details\fP 
1016 .SS "LIBPWMD_API gpg_error_t pwmd_getpin (\fBpwm_t\fP * pwm, const char * filename, char ** result, \fBpwmd_pinentry_t\fP which)"
1018 Launch a local pinentry. Does not send any command to the server. Maybe useful if a passphrase is needed before opening a file over a remote connection. This passphrase can then be set with \fBpwmd_setopt()\fP.
1020 This function may also be used to display a user confirmation dialog with pinentry when \fIwhich\fP is \fBPWMD_PINENTRY_CONFIRM\fP. The text to prompt with is set with \fBPWMD_OPTION_PINENTRY_TITLE\fP.
1022 \fBParameters:\fP
1023 .RS 4
1024 \fIpwm\fP A handle. 
1026 \fIfilename\fP The filename to use in the pinentry dialog strings. 
1028 \fIresult\fP The entered value in the pinentry dialog which should be freed with \fBpwmd_free()\fP. 
1030 \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_DEFAULT\fP should be used. \fBPWMD_PINENTRY_CLOSE\fP should be used to terminate the pinentry process when the pinentry is no longer needed.
1033 \fBReturns:\fP
1034 .RS 4
1035 0 on success or an error. 
1039 .SS "LIBPWMD_API gpg_error_t pwmd_init (void)"
1041 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.
1043 \fBReturns:\fP
1044 .RS 4
1045 0 on success or an error code. 
1049 .SS "LIBPWMD_API gpg_error_t pwmd_inquire (\fBpwm_t\fP * pwm, const char * cmd, \fBpwmd_inquire_cb_t\fP func, void * user)"
1051 Send data to a pwmd server. This lets commands that use an INQUIRE (STORE and IMPORT) send the data to the server. Use this function rather than \fBpwmd_command()\fP for these pwmd commands.
1053 \fBParameters:\fP
1054 .RS 4
1055 \fIpwm\fP A handle. 
1057 \fIcmd\fP The \fBpwmd(1)\fP command to send including any options. 
1059 \fIfunc\fP A callback function of type \fBpwmd_inquire_cb_t\fP which sets the data to be sent. 
1061 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1064 \fBReturns:\fP
1065 .RS 4
1066 0 on success or an error code.
1069 \fBSee also:\fP
1070 .RS 4
1071 \fBpwmd_inquire_cb_t\fP 
1075 .SS "LIBPWMD_API void* pwmd_malloc (size_t size)"
1077 A wrapper around malloc. Like malloc(), but lets libpwmd keep track of the pointer.
1079 \fBParameters:\fP
1080 .RS 4
1081 \fIsize\fP The number of bytes to allocate. 
1084 \fBReturns:\fP
1085 .RS 4
1086 A newly allocated pointer or NULL if there wasn't enough memory. 
1089 \fBSee also:\fP
1090 .RS 4
1091 malloc(3), \fBpwmd_free()\fP 
1095 .SS "LIBPWMD_API \fBpwm_t\fP* pwmd_new (const char * name)"
1097 Creates a new handle. Creates a new handle for use with the other functions.
1099 \fBParameters:\fP
1100 .RS 4
1101 \fIname\fP If not NULL, the name of the application. The application name is sent to the pwmd server after successfully connecting.
1104 \fBReturns:\fP
1105 .RS 4
1106 a new handle or NULL if there was not enough memory. 
1110 .SS "LIBPWMD_API gpg_error_t pwmd_open (\fBpwm_t\fP * pwm, const char * filename)"
1112 Open a file on the pwmd server. This will send the OPEN command to the server.
1114 \fBParameters:\fP
1115 .RS 4
1116 \fIpwm\fP A handle. 
1118 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1121 \fBReturns:\fP
1122 .RS 4
1123 0 on success or an error code. 
1126 \fBSee also:\fP
1127 .RS 4
1128 \fBPinentry Details\fP 
1132 .SS "LIBPWMD_API gpg_error_t pwmd_open2 (\fBpwm_t\fP * pwm, const char * filename)"
1134 Open a file on the pwmd server using a local pinentry. This will send the OPEN command to the server like \fBpwmd_open()\fP but will use the local pinentry and not pwmd's pinentry.
1136 \fBNote:\fP
1137 .RS 4
1138 This function will catch SIGALRM during the lifetime of the pinentry process and set it to SIG_DFL when finished. This is needed for pinentry timeouts.
1140 This pinentry method is not thread safe. It needs to set a couple of global variables for the pinentry timeout to work properly.
1143 \fBParameters:\fP
1144 .RS 4
1145 \fIpwm\fP A handle. 
1147 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1150 \fBReturns:\fP
1151 .RS 4
1152 0 on success or an error code. 
1155 \fBReturn values:\fP
1156 .RS 4
1157 \fIGPG_ERR_PIN_BLOCKED\fP Another handle is using the local pinentry. 
1160 \fBSee also:\fP
1161 .RS 4
1162 \fBPinentry Details\fP 
1166 .SS "LIBPWMD_API gpg_error_t pwmd_open_async (\fBpwm_t\fP * pwm, const char * filename)"
1168 Open a file on the pwmd server (asynchronously). This will send the OPEN command to the pwmd server. The difference from \fBpwmd_open()\fP is that it will not block if a pinentry is needed for passphrase input.
1170 \fBpwmd_process()\fP should be called until the command completes.
1172 \fBParameters:\fP
1173 .RS 4
1174 \fIpwm\fP A handle. 
1176 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1179 \fBReturns:\fP
1180 .RS 4
1181 0 on success or an error code. 
1184 \fBSee also:\fP
1185 .RS 4
1186 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1190 .SS "LIBPWMD_API gpg_error_t pwmd_open_async2 (\fBpwm_t\fP * pwm, const char * filename)"
1192 Open a file on the pwmd server asynchronously (fork method). This is kind of a hybrid of \fBpwmd_open2()\fP and \fBpwmd_open_async()\fP. It will use the local pinentry asynchronously and also do the OPEN command asynchronously.
1194 \fBpwmd_process()\fP should be called until the command completes.
1196 \fBNote:\fP
1197 .RS 4
1198 This function will catch SIGALRM during the lifetime of the pinentry process and set it to SIG_DFL when finished. This is needed for pinentry timeouts.
1201 \fBParameters:\fP
1202 .RS 4
1203 \fIpwm\fP A handle. 
1205 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1208 \fBReturns:\fP
1209 .RS 4
1210 0 on success or an error code. 
1213 \fBSee also:\fP
1214 .RS 4
1215 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1219 .SS "LIBPWMD_API gpg_error_t pwmd_open_inquire (\fBpwm_t\fP * pwm, const char * filename, \fBpwmd_inquire_cb_t\fP func, void * user)"
1221 Open a file on the pwmd server by using a server inquire. This is a convenience function to the OPEN command using \fBpwmd_inquire()\fP in that it passes the OPEN options that were set with \fBpwmd_setopt()\fP for you. It uses the specified callback function to retreive the passphrase.
1223 \fBNote:\fP
1224 .RS 4
1225 Only the passphrase should be sent when using this function and not any filename argument. That argument will be sent automatically when using this function.
1227 Pinentry is disabled when using this function.
1230 \fBParameters:\fP
1231 .RS 4
1232 \fIpwm\fP A handle. 
1234 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1236 \fIfunc\fP A callback function of type \fBpwmd_inquire_cb_t\fP which sets the passphrase to be sent. This acts as a normal \fBpwmd_inquire()\fP would. 
1238 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1241 \fBReturns:\fP
1242 .RS 4
1243 0 on success or an error code. 
1246 \fBSee also:\fP
1247 .RS 4
1248 \fBPWMD_OPTION_BASE64\fP 
1252 .SS "LIBPWMD_API gpg_error_t pwmd_pending_line (\fBpwm_t\fP * pwm)"
1254 Check for a unparsed buffered line. A buffered line is a line that was read from the server but has not yet been processed. This function determines if there is such a line.
1256 \fBParameters:\fP
1257 .RS 4
1258 \fIpwm\fP A handle. 
1261 \fBReturn values:\fP
1262 .RS 4
1263 \fI0\fP if there is a pending line. 
1265 \fIGPG_ERR_NO_DATA\fP if there is no pending line. 
1268 \fBSee also:\fP
1269 .RS 4
1270 \fBpwmd_process()\fP 
1274 .SS "LIBPWMD_API \fBpwmd_async_t\fP pwmd_process (\fBpwm_t\fP * pwm, gpg_error_t * rc, char ** result)"
1276 Process an asynchronous function. After an asynchronous function has been called and has returned successfully, this function must be called to process the command and retrieve the result and return value.
1278 This function may also be called when not in a command to check for pending status messages sent from the server or to process a pending line.
1280 \fBParameters:\fP
1281 .RS 4
1282 \fIpwm\fP A handle. 
1284 \fIrc\fP Set to the return code of the original command after ASYNC_DONE has been returned. This value must be checked to determine if the command succeeded. 
1286 \fIresult\fP Set to the result of the command when \fIrc\fP is 0. Note that not all commands return a result. 
1289 \fBReturn values:\fP
1290 .RS 4
1291 \fIASYNC_DONE\fP The command has completed. \fIrc\fP should be checked to determine if the command was successful or not. 
1293 \fIASYNC_PROCESS\fP The command is still running and this function should be called again. 
1296 \fBSee also:\fP
1297 .RS 4
1298 \fBpwmd_get_fds()\fP, \fBpwmd_pending_line()\fP 
1302 .SS "LIBPWMD_API void* pwmd_realloc (void * ptr, size_t size)"
1304 A wrapper around realloc(). Like realloc(), but lets libpwmd keep track of the pointer.
1306 \fBNote:\fP
1307 .RS 4
1308 This function will try and allocate the entire \fIsize\fP before freeing the original pointer and returning the new one.
1311 \fBParameters:\fP
1312 .RS 4
1313 \fIptr\fP The pointer to reallocate. 
1315 \fIsize\fP The new number of bytes to allocate. 
1318 \fBReturns:\fP
1319 .RS 4
1320 A newly allocated pointer or NULL if there wasn't enough memory. 
1323 \fBSee also:\fP
1324 .RS 4
1325 realloc(3), \fBpwmd_free()\fP 
1329 .SS "LIBPWMD_API gpg_error_t pwmd_save (\fBpwm_t\fP * pwm)"
1331 Save a file on the pwmd server. This will send the SAVE command.
1333 \fBParameters:\fP
1334 .RS 4
1335 \fIpwm\fP A handle. 
1338 \fBReturns:\fP
1339 .RS 4
1340 0 on success or an error code. 
1343 \fBSee also:\fP
1344 .RS 4
1345 \fBPinentry Details\fP 
1349 .SS "LIBPWMD_API gpg_error_t pwmd_save2 (\fBpwm_t\fP * pwm)"
1351 Save a file on the pwmd server using the local pinentry. This will send the SAVE command like \fBpwmd_save()\fP but will use a local pinentry and not pwmd's pinentry.
1353 \fBParameters:\fP
1354 .RS 4
1355 \fIpwm\fP A handle. 
1358 \fBReturns:\fP
1359 .RS 4
1360 0 on success or an error code. 
1363 \fBSee also:\fP
1364 .RS 4
1365 \fBPinentry Details\fP 
1369 .SS "LIBPWMD_API gpg_error_t pwmd_save_async (\fBpwm_t\fP * pwm)"
1371 Save changes to a file on the pwmd server (asynchronously). This will send the SAVE command to the pwmd server. The difference from \fBpwmd_save()\fP is that it will not block if a pinentry is needed for passphrase input.
1373 \fBpwmd_process()\fP should be called until the command completes.
1375 \fBParameters:\fP
1376 .RS 4
1377 \fIpwm\fP A handle. 
1380 \fBReturns:\fP
1381 .RS 4
1382 0 on success or an error code. 
1385 \fBSee also:\fP
1386 .RS 4
1387 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1391 .SS "LIBPWMD_API gpg_error_t pwmd_save_async2 (\fBpwm_t\fP * pwm)"
1393 Save a file on the pwmd server asynchronously (fork method). This is kind of a hybrid of \fBpwmd_save2()\fP and \fBpwmd_save_async()\fP. It will use the local pinentry asynchronously and also do the SAVE command asynchronously.
1395 \fBpwmd_process()\fP should be called until the command completes.
1397 \fBParameters:\fP
1398 .RS 4
1399 \fIpwm\fP A handle. 
1402 \fBReturns:\fP
1403 .RS 4
1404 0 on success or an error code. 
1407 \fBSee also:\fP
1408 .RS 4
1409 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1413 .SS "LIBPWMD_API gpg_error_t pwmd_save_inquire (\fBpwm_t\fP * pwm, \fBpwmd_inquire_cb_t\fP func, void * user)"
1415 Save a file on the pwmd server by using a server inquire. This is a convenience function to the SAVE command using \fBpwmd_inquire()\fP in that it passes the SAVE options that were set with \fBpwmd_setopt()\fP for you. It uses the specified callback function to retreive the passphrase.
1417 \fBNote:\fP
1418 .RS 4
1419 Pinentry is disabled when using this function.
1422 \fBParameters:\fP
1423 .RS 4
1424 \fIpwm\fP A handle. 
1426 \fIfunc\fP A callback function of type \fBpwmd_inquire_cb_t\fP which sets the passphrase to be sent. This acts as a normal \fBpwmd_inquire()\fP would. 
1428 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1431 \fBReturns:\fP
1432 .RS 4
1433 0 on success or an error code. 
1436 \fBSee also:\fP
1437 .RS 4
1438 \fBPWMD_OPTION_BASE64\fP 
1442 .SS "LIBPWMD_API gpg_error_t pwmd_setopt (\fBpwm_t\fP * pwm, \fBpwmd_option_t\fP opt,  ...)"
1444 Set handle options. See \fBpwmd_option_t\fP for option specific details.
1446 \fBParameters:\fP
1447 .RS 4
1448 \fIpwm\fP A handle. 
1450 \fIopt\fP The option and following value. 
1453 \fBReturns:\fP
1454 .RS 4
1455 0 on success or an error code. 
1459 .SS "LIBPWMD_API gpg_error_t pwmd_socket_type (\fBpwm_t\fP * pwm, \fBpwmd_socket_t\fP * type)"
1461 The type of connection a handle has. Useful when you want to know what kind of connection a handle has.
1463 \fBParameters:\fP
1464 .RS 4
1465 \fIpwm\fP A handle. 
1467 \fItype\fP The type of socket. 
1470 \fBReturns:\fP
1471 .RS 4
1472 0 on success or an error code. 
1475 \fBSee also:\fP
1476 .RS 4
1477 \fBpwmd_connect_url()\fP 
1481 .SS "LIBPWMD_API gpg_error_t pwmd_ssh_connect (\fBpwm_t\fP * pwm, const char * host, int port, const char * identity, const char * user, const char * known_hosts)"
1483 Establish a remote connection to a pwmd server. Connects to a pwmd server over an SSH channel.
1485 \fBParameters:\fP
1486 .RS 4
1487 \fIpwm\fP A handle. 
1489 \fIhost\fP The hostname to connect to or NULL to resume a connection previously started with \fBpwmd_get_hostkey()\fP. 
1491 \fIport\fP The port or -1 for the default of 22. 
1493 \fIidentity\fP The SSH identity file to use for authentication. This should specify the private key. The public key is assumed to be \fIidentity.pub\fP. 
1495 \fIuser\fP The username on the SSH server to login as. If NULL then invoking username will be used. 
1497 \fIknown_hosts\fP An OpenSSH known hosts formatted file containing public SSH server hashes which may be obtained with \fBpwmd_get_hostkey()\fP or via \fBpwmd_knownhost_cb_t\fP during a connection. If NULL, the default of \fI'~/.ssh/known_hosts'\fP will be used. 
1500 \fBReturns:\fP
1501 .RS 4
1502 0 on success or an error code. 
1505 \fBNote:\fP
1506 .RS 4
1507 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1510 \fBSee also:\fP
1511 .RS 4
1512 \fBpwmd_ssh_connect_async()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1516 .SS "LIBPWMD_API gpg_error_t pwmd_ssh_connect_async (\fBpwm_t\fP * pwm, const char * host, int port, const char * identity, const char * user, const char * known_hosts)"
1518 Establish a remote connection to a pwmd server (asynchronously). This is a variant of \fBpwmd_ssh_connect()\fP that will not block while doing DNS lookups or while connecting.
1520 \fBpwmd_process()\fP should be called until the command completes.
1522 \fBParameters:\fP
1523 .RS 4
1524 \fIpwm\fP A handle. 
1526 \fIhost\fP The hostname to connect to or NULL to resume a connection previously started with \fBpwmd_get_hostkey()\fP. 
1528 \fIport\fP The port or -1 for the default of 22. 
1530 \fIidentity\fP The SSH identity file to use for authentication. This should specify the private key. The public key is assumed to be \fIidentity.pub\fP. 
1532 \fIuser\fP The username on the SSH server to login as. If NULL, the invoking username will be used. 
1534 \fIknown_hosts\fP An OpenSSH known hosts formatted file containing public SSH server hashes which may be obtained with \fBpwmd_get_hostkey()\fP or via \fBpwmd_knownhost_cb_t\fP during a connection. If NULL, the default of \fI'~/.ssh/known_hosts'\fP will be used. 
1537 \fBReturns:\fP
1538 .RS 4
1539 0 on success or an error code. 
1542 \fBNote:\fP
1543 .RS 4
1544 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1547 \fBSee also:\fP
1548 .RS 4
1549 \fBpwmd_process()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1553 .SS "LIBPWMD_API char* pwmd_strdup (const char * str)"
1555 A wrapper around strdup(). Like strdup(), but lets libpwmd keep track of the pointer.
1557 \fBParameters:\fP
1558 .RS 4
1559 \fIstr\fP The string to duplicate. 
1562 \fBReturns:\fP
1563 .RS 4
1564 A newly allocated character pointer or NULL if there wasn't enough memory. 
1567 \fBSee also:\fP
1568 .RS 4
1569 strdup(3), \fBpwmd_free()\fP 
1573 .SS "LIBPWMD_API char* pwmd_strdup_printf (const char * fmt,  ...)"
1575 Duplicate a formatted string. Like \fBsprintf(3)\fP but returns an allocated string.
1577 \fBParameters:\fP
1578 .RS 4
1579 \fIfmt\fP The formatted string and any following arguments. 
1582 \fBReturns:\fP
1583 .RS 4
1584 A newly allocated character pointer or NULL if there wasn't enough memory. 
1587 \fBSee also:\fP
1588 .RS 4
1589 \fBpwmd_free()\fP 
1593 .SS "LIBPWMD_API const char* pwmd_strerror (gpg_error_t code)"
1595 Return a description of an error code. \fBParameters:\fP
1596 .RS 4
1597 \fIcode\fP The error code to describe. 
1600 \fBReturns:\fP
1601 .RS 4
1602 A character description of the error code. 
1605 \fBSee also:\fP
1606 .RS 4
1607 \fBpwmd_strerror_r()\fP 
1611 .SS "LIBPWMD_API int pwmd_strerror_r (gpg_error_t code, char * buf, size_t size)"
1613 Return a description of an error code (thread-safe). This is a thread-safe version of \fBpwmd_strerror()\fP.
1615 \fBParameters:\fP
1616 .RS 4
1617 \fIcode\fP The error code to describe. 
1619 \fIbuf\fP An allocated buffer to hold the error description. 
1621 \fIsize\fP The size of the allocated buffer \fIbuf\fP.
1624 \fBReturn values:\fP
1625 .RS 4
1626 \fI0\fP Success. 
1628 \fIERANGE\fP \fIsize\fP was not large enough to hold the entire description and \fIbuf\fP is set to the truncated error string. 
1632 .SS "LIBPWMD_API const char* pwmd_version ()"
1634 Returns this version of libpwmd. As a string. 
1636 \fBReturns:\fP
1637 .RS 4
1638 A string. 
1642 .SH "Author"
1643 .PP 
1644 Generated automatically by Doxygen for libpwmd from the source code.