pwmc: some progress indicator for non-blocking functions when DEBUG is
[libpwmd.git] / doc / libpwmd.3
blob02c8ce5202bc4c3b4bf111d32a2edabb89a41b5d
1 .TH "libpwmd.h" 3 "Fri Dec 31 2010" "Version 6.0.4" "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 "Multiple 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 .PP
13 There is a limitation that when compiled with \fBpth(3)\fP support SSH connections cannot make use of the \fBpth(3)\fP IO functions and therefore will block while waiting on IO operations in other threads (as of libssh2 1.2.8).
14 .SH "SSH Details"
15 .PP
16 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.
17 .PP
18 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.
19 .PP
20 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 \fIpublic_key\fP 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:
21 .PP
22 .PP
23 .nf
24  command='socat UNIX-CONNECT:$HOME/.pwmd/socket -' <public_key> ...
25 .fi
26 .PP
27 .PP
28 \fBNote:\fP
29 .RS 4
30 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).
31 .RE
32 .PP
33 \fBVersion:\fP
34 .RS 4
35 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.
36 .RE
37 .PP
38 \fBTodo\fP
39 .RS 4
40 X11 port forwarding so a remote pinentry can use the local display. 
41 .RE
42 .PP
43 .SH "Pinentry Details"
44 .PP
45 \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.
46 .PP
47 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.
48 .PP
49 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!).
50 .PP
51 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:
52 .PP
53 \fBParameters:\fP
54 .RS 4
55 \fIPATH\fP The full path to the location of the pinentry binary. 
56 .br
57 \fIDISPLAY\fP The X11 display to use. 
58 .br
59 \fITTYNAME\fP The full path to the tty that pinentry should prompt on. 
60 .br
61 \fITTYTYPE\fP The terminal type of the tty which is required if DISPLAY is not set.
62 .RE
63 .PP
64 \fBNote:\fP
65 .RS 4
66 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user.
67 .PP
68 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.
69 .PP
70 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.
71 .RE
72 .PP
73 \fBTodo\fP
74 .RS 4
75 X11 port forwarding so a remote pinentry can use the local display.
76 .RE
77 .PP
78 .PP
79 \fBSee also:\fP
80 .RS 4
81 \fBSSH Details\fP
82 .RE
83 .PP
84 .SH "Errors"
85 .PP
86 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.
87 .PP
88 \fBNote:\fP
89 .RS 4
90 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. 
91 .RE
92 .PP
94 .SH SYNOPSIS
95 .br
96 .PP
97 .SS "Data Structures"
99 .in +1c
100 .ti -1c
101 .RI "struct \fBpwmd_fd_t\fP"
103 .in -1c
104 .SS "Constants"
106 .in +1c
107 .ti -1c
108 .RI "#define \fBLIBPWMD_API\fP"
110 .ti -1c
111 .RI "#define \fBLIBPWMD_VERSION\fP   0x604"
113 .ti -1c
114 .RI "#define \fBLIBPWMD_VERSION_MAJOR\fP   6"
116 .ti -1c
117 .RI "#define \fBLIBPWMD_VERSION_MINOR\fP   0"
119 .ti -1c
120 .RI "#define \fBLIBPWMD_VERSION_PATCH\fP   4"
122 .ti -1c
123 .RI "#define \fBLIBPWMD_VERSION_STR\fP   '6.0.4-git'"
125 .ti -1c
126 .RI "#define \fBPWMD_FD_READABLE\fP   0x01"
128 .ti -1c
129 .RI "#define \fBPWMD_FD_WRITABLE\fP   0x02"
131 .ti -1c
132 .RI "#define \fBPWMD_FEATURE_PINENTRY\fP"
134 .ti -1c
135 .RI "#define \fBPWMD_FEATURE_CRACK\fP"
137 .ti -1c
138 .RI "#define \fBPWMD_FEATURE_SSH\fP"
140 .ti -1c
141 .RI "#define \fBEPWMD_NO_FILE\fP"
143 .ti -1c
144 .RI "#define \fBEPWMD_LIBXML_ERROR\fP"
146 .ti -1c
147 .RI "#define \fBEPWMD_FILE_MODIFIED\fP"
149 .ti -1c
150 .RI "#define \fBEPWMD_MAX\fP"
152 .in -1c
153 .SS "Typedefs"
155 .in +1c
156 .ti -1c
157 .RI "typedef struct pwm_s \fBpwm_t\fP"
159 .ti -1c
160 .RI "typedef gpg_error_t(* \fBpwmd_passphrase_cb_t\fP )(void *user, char **passphrase)"
162 .ti -1c
163 .RI "typedef int(* \fBpwmd_status_cb_t\fP )(void *user, const char *line)"
165 .ti -1c
166 .RI "typedef gpg_error_t(* \fBpwmd_inquire_cb_t\fP )(void *user, const char *cmd, gpg_error_t rc, char **data, size_t *len)"
168 .ti -1c
169 .RI "typedef gpg_error_t(* \fBpwmd_knownhost_cb_t\fP )(void *user, const char *host, const char *key, size_t len)"
171 .in -1c
172 .SS "Enumerations"
174 .in +1c
175 .ti -1c
176 .RI "enum \fBpwmd_async_t\fP { \fBASYNC_INIT\fP, \fBASYNC_PROCESS\fP, \fBASYNC_DONE\fP }"
178 .ti -1c
179 .RI "enum \fBpwmd_ip_version_t\fP { \fBPWMD_IP_ANY\fP, \fBPWMD_IPV4\fP, \fBPWMD_IPV6\fP }"
181 .ti -1c
182 .RI "enum \fBpwmd_socket_t\fP { \fBPWMD_SOCKET_LOCAL\fP, \fBPWMD_SOCKET_SSH\fP }"
184 .ti -1c
185 .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 }"
187 .ti -1c
188 .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, \fBPWMD_OPTION_SSH_AGENT\fP, \fBPWMD_OPTION_NO_PINENTRY\fP }"
190 .in -1c
191 .SS "Functions"
193 .in +1c
194 .ti -1c
195 .RI "LIBPWMD_API const char * \fBpwmd_version\fP ()"
197 .ti -1c
198 .RI "LIBPWMD_API unsigned int \fBpwmd_features\fP ()"
200 .ti -1c
201 .RI "LIBPWMD_API gpg_error_t \fBpwmd_init\fP (void)"
203 .ti -1c
204 .RI "LIBPWMD_API \fBpwm_t\fP * \fBpwmd_new\fP (const char *name)"
206 .ti -1c
207 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect\fP (\fBpwm_t\fP *pwm, const char *path)"
209 .ti -1c
210 .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)"
212 .ti -1c
213 .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)"
215 .ti -1c
216 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect_url\fP (\fBpwm_t\fP *pwm, const char *url)"
218 .ti -1c
219 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect_url_async\fP (\fBpwm_t\fP *pwm, const char *url)"
221 .ti -1c
222 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_hostkey\fP (\fBpwm_t\fP *pwm, const char *host, int port, char **result)"
224 .ti -1c
225 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_hostkey_async\fP (\fBpwm_t\fP *pwm, const char *host, int port)"
227 .ti -1c
228 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_fds\fP (\fBpwm_t\fP *pwm, \fBpwmd_fd_t\fP *fds, int *n_fds)"
230 .ti -1c
231 .RI "LIBPWMD_API gpg_error_t \fBpwmd_pending_line\fP (\fBpwm_t\fP *pwm)"
233 .ti -1c
234 .RI "LIBPWMD_API gpg_error_t \fBpwmd_setopt\fP (\fBpwm_t\fP *pwm, \fBpwmd_option_t\fP opt,...)"
236 .ti -1c
237 .RI "LIBPWMD_API gpg_error_t \fBpwmd_getpin\fP (\fBpwm_t\fP *pwm, const char *filename, char **result, \fBpwmd_pinentry_t\fP which)"
239 .ti -1c
240 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open\fP (\fBpwm_t\fP *pwm, const char *filename)"
242 .ti -1c
243 .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)"
245 .ti -1c
246 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open2\fP (\fBpwm_t\fP *pwm, const char *filename)"
248 .ti -1c
249 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open_async2\fP (\fBpwm_t\fP *pwm, const char *filename)"
251 .ti -1c
252 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open_async\fP (\fBpwm_t\fP *pwm, const char *filename)"
254 .ti -1c
255 .RI "LIBPWMD_API \fBpwmd_async_t\fP \fBpwmd_process\fP (\fBpwm_t\fP *pwm, gpg_error_t *rc, char **result)"
257 .ti -1c
258 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save\fP (\fBpwm_t\fP *pwm)"
260 .ti -1c
261 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_inquire\fP (\fBpwm_t\fP *pwm, \fBpwmd_inquire_cb_t\fP func, void *user)"
263 .ti -1c
264 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save2\fP (\fBpwm_t\fP *pwm)"
266 .ti -1c
267 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_async2\fP (\fBpwm_t\fP *pwm)"
269 .ti -1c
270 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_async\fP (\fBpwm_t\fP *pwm)"
272 .ti -1c
273 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd,...)"
275 .ti -1c
276 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command_ap\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd, va_list ap)"
278 .ti -1c
279 .RI "LIBPWMD_API gpg_error_t \fBpwmd_inquire\fP (\fBpwm_t\fP *pwm, const char *cmd, \fBpwmd_inquire_cb_t\fP func, void *user)"
281 .ti -1c
282 .RI "LIBPWMD_API gpg_error_t \fBpwmd_disconnect\fP (\fBpwm_t\fP *pwm)"
284 .ti -1c
285 .RI "LIBPWMD_API void \fBpwmd_close\fP (\fBpwm_t\fP *pwm)"
287 .ti -1c
288 .RI "LIBPWMD_API gpg_error_t \fBpwmd_socket_type\fP (\fBpwm_t\fP *pwm, \fBpwmd_socket_t\fP *type)"
290 .ti -1c
291 .RI "LIBPWMD_API void \fBpwmd_free\fP (void *ptr)"
293 .ti -1c
294 .RI "LIBPWMD_API void * \fBpwmd_malloc\fP (size_t size)"
296 .ti -1c
297 .RI "LIBPWMD_API void * \fBpwmd_calloc\fP (size_t nmemb, size_t size)"
299 .ti -1c
300 .RI "LIBPWMD_API void * \fBpwmd_realloc\fP (void *ptr, size_t size)"
302 .ti -1c
303 .RI "LIBPWMD_API char * \fBpwmd_strdup\fP (const char *str)"
305 .ti -1c
306 .RI "LIBPWMD_API char * \fBpwmd_strdup_printf\fP (const char *fmt,...)"
308 .ti -1c
309 .RI "LIBPWMD_API const char * \fBpwmd_strerror\fP (gpg_error_t code)"
311 .ti -1c
312 .RI "LIBPWMD_API int \fBpwmd_strerror_r\fP (gpg_error_t code, char *buf, size_t size)"
314 .in -1c
315 .SH "Constant Details"
316 .PP 
317 .SS "#define EPWMD_FILE_MODIFIED"
319 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. 
320 .SS "#define EPWMD_LIBXML_ERROR"
322 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. 
323 .SS "#define EPWMD_MAX"
325 libgpg-error error code offset. If you use your own libgpg-error codes then this should be the base of them. 
326 .SS "#define EPWMD_NO_FILE"
328 No data file has been opened. Some commands don't require an open data file but most do. 
329 .SS "#define LIBPWMD_VERSION   0x604"
331 Version information. The version of this library. 
332 .SS "#define LIBPWMD_VERSION_MAJOR   6"
334 Version information. The major release number of this library. 
335 .SS "#define LIBPWMD_VERSION_MINOR   0"
337 Version information. The minor release number of this library. 
338 .SS "#define LIBPWMD_VERSION_PATCH   4"
340 Version information. The patch level of this library. 
341 .SS "#define LIBPWMD_VERSION_STR   '6.0.4-git'"
343 Version information. A string representation of the version of this library. 
344 .SS "#define PWMD_FD_READABLE   0x01"
346 For use with \fBpwmd_get_fds()\fP. Set when the file descriptor is readable. 
347 .SS "#define PWMD_FD_WRITABLE   0x02"
349 For use with \fBpwmd_get_fds()\fP. Set when the file descriptor is writable. 
350 .SS "#define PWMD_FEATURE_CRACK"
352 Password quality checking. A password quality meter is shown when the pinentry supports it. 
353 .SS "#define PWMD_FEATURE_PINENTRY"
355 Pinentry support. This is for a local pinentry when calling \fBpwmd_open2()\fP and \fBpwmd_save2()\fP. 
356 .SS "#define PWMD_FEATURE_SSH"
358 Remote connections over an SSH channel. Refer to \fBSSH Details\fP for how to get this to work. 
359 .SH "Typedef Details"
360 .PP 
361 .SS "\fBpwm_t\fP"
363 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. 
364 .SS "\fBpwmd_inquire_cb_t\fP"
366 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.
368 \fBParameters:\fP
369 .RS 4
370 \fIuser\fP The user data pointer passed to \fBpwmd_inquire()\fP. 
372 \fIcmd\fP The same as the \fIcmd\fP argument to \fBpwmd_inquire()\fP. 
374 \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. 
376 \fIdata\fP The next chunk of data to send or NULL. 
378 \fIlen\fP The length of \fIdata\fP or 0.
381 \fBReturn values:\fP
382 .RS 4
383 \fI0\fP There is more data to be sent. 
385 \fIGPG_ERR_CANCELED\fP Cancel the current inquire. 
387 \fIGPG_ERR_EOF\fP No need to call this function again, the current \fIline\fP is the last to send. 
389 \fIcode\fP Any other error code which will terminate the INQUIRE.
392 \fBNote:\fP
393 .RS 4
394 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. 
398 .SS "\fBpwmd_knownhost_cb_t\fP"
400 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.
402 \fBParameters:\fP
403 .RS 4
404 \fIuser\fP User data which was set with \fBPWMD_OPTION_KNOWNHOST_DATA\fP. 
406 \fIhost\fP The hostname as passed to the connecting function. 
408 \fIkey\fP The raw host key. Note that this differs from the format returned from \fBpwmd_get_hostkey()\fP. 
410 \fIlen\fP The host key length. 
413 \fBReturn values:\fP
414 .RS 4
415 \fI0\fP Add the host key to the known hosts file. 
417 \fIGPG_ERR_NOT_CONFIRMED\fP Do not add the host key and abort the connection.
420 \fBNote:\fP
421 .RS 4
422 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.
425 \fBSee also:\fP
426 .RS 4
427 \fBSSH Details\fP 
431 .SS "\fBpwmd_passphrase_cb_t\fP"
433 Custom passphrase retrieval function. The value of the option \fBPWMD_OPTION_PASSPHRASE_CB\fP which is set with \fBpwmd_setopt()\fP.
435 \fBParameters:\fP
436 .RS 4
437 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_PASSPHRASE_DATA\fP. 
439 \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. 
442 \fBReturns:\fP
443 .RS 4
444 0 on success or an error code which will cause a command to fail. 
448 .SS "\fBpwmd_status_cb_t\fP"
450 Process status messages. The value of the option \fBPWMD_OPTION_STATUS_CB\fP which is set with \fBpwmd_setopt()\fP.
452 \fBParameters:\fP
453 .RS 4
454 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_STATUS_DATA\fP. 
456 \fIline\fP The status message line received from the server. 
459 \fBReturns:\fP
460 .RS 4
461 0 on success or an error code which will cause a command to fail. 
465 .SH "Enumeration Details"
466 .PP 
467 .SS "enum \fBpwmd_async_t\fP"
469 Asynchronous return value. The return code of \fBpwmd_process()\fP which is used for all asynchronous commands. 
471 \fBEnumerator: \fP
472 .in +1c
474 \fB\fIASYNC_INIT \fP\fP
476 \fBFor internal use only.\fP
477 .RS 4
482 \fB\fIASYNC_PROCESS \fP\fP
483 \fBpwmd_process()\fP should be called again. 
485 \fB\fIASYNC_DONE \fP\fP
486 The command has completed. The result code should be checked for an error. 
487 .SS "enum \fBpwmd_ip_version_t\fP"
489 IP protocol version for remote SSH connections. The value of the option \fBPWMD_OPTION_IP_VERSION\fP which is set with \fBpwmd_setopt()\fP. 
491 \fBEnumerator: \fP
492 .in +1c
494 \fB\fIPWMD_IP_ANY \fP\fP
495 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. 
497 \fB\fIPWMD_IPV4 \fP\fP
498 Only try IPv4. 
500 \fB\fIPWMD_IPV6 \fP\fP
501 Only try IPv6. 
502 .SS "enum \fBpwmd_option_t\fP"
504 libpwmd options. Options are set with \fBpwmd_setopt()\fP.
506 \fBNote:\fP
507 .RS 4
508 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
513 \fBEnumerator: \fP
514 .in +1c
516 \fB\fIPWMD_OPTION_PASSPHRASE_CB \fP\fP
517 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.
519 \fBNote:\fP
520 .RS 4
521 An empty string as the passphrase is allowed. 
526 \fB\fIPWMD_OPTION_PASSPHRASE_DATA \fP\fP
527 User supplied data which is passed to the custom passphrase function. 
529 \fB\fIPWMD_OPTION_PASSPHRASE \fP\fP
530 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.
532 \fBNote:\fP
533 .RS 4
534 An empty string as the passphrase is allowed. 
539 \fB\fIPWMD_OPTION_PINENTRY_TRIES \fP\fP
540 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.
542 \fBNote:\fP
543 .RS 4
544 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. 
549 \fB\fIPWMD_OPTION_PINENTRY_PATH \fP\fP
550 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.
552 \fBSee also:\fP
553 .RS 4
554 \fBPinentry Details\fP 
559 \fB\fIPWMD_OPTION_PINENTRY_TTY \fP\fP
560 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.
562 \fBSee also:\fP
563 .RS 4
564 \fBPinentry Details\fP 
569 \fB\fIPWMD_OPTION_PINENTRY_TERM \fP\fP
570 A value which specifies the terminal type (e.g., vt100) that \fBpinentry(1)\fP will use when no X11 display is available.
572 \fBSee also:\fP
573 .RS 4
574 \fBPinentry Details\fP 
579 \fB\fIPWMD_OPTION_PINENTRY_DISPLAY \fP\fP
580 A value which specifies the X11 display that \fBpinentry(1)\fP will use.
582 \fBTodo\fP
583 .RS 4
584 X11 port forwarding so a remote pinentry can use the local display.
588 \fBSee also:\fP
589 .RS 4
590 \fBPinentry Details\fP 
595 \fB\fIPWMD_OPTION_PINENTRY_TITLE \fP\fP
596 A character string that \fBpinentry(1)\fP will use in it's dialog window. 
598 \fB\fIPWMD_OPTION_PINENTRY_PROMPT \fP\fP
599 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
601 \fB\fIPWMD_OPTION_PINENTRY_DESC \fP\fP
602 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
604 \fB\fIPWMD_OPTION_PINENTRY_LC_CTYPE \fP\fP
605 For \fBpinentry(1)\fP localization. 
607 \fB\fIPWMD_OPTION_PINENTRY_LC_MESSAGES \fP\fP
608 For \fBpinentry(1)\fP localization.  
610 \fB\fIPWMD_OPTION_PINENTRY_TIMEOUT \fP\fP
611 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. 
613 \fB\fIPWMD_OPTION_STATUS_CB \fP\fP
614 A function of type \fBpwmd_status_cb_t\fP that will process status messages received from the pwmd server. 
616 \fB\fIPWMD_OPTION_STATUS_DATA \fP\fP
617 A user data pointer which is passed to the status message function. 
619 \fB\fIPWMD_OPTION_IP_VERSION \fP\fP
620 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.
622 \fBNote:\fP
623 .RS 4
624 This option must be set before a connection is made when not the default. 
629 \fB\fIPWMD_OPTION_KNOWNHOST_CB \fP\fP
630 A function to confirm an unknown host hash which wasn't found in the known hosts file.
632 \fBSee also:\fP
633 .RS 4
634 \fBSSH Details\fP 
639 \fB\fIPWMD_OPTION_KNOWNHOST_DATA \fP\fP
640 User supplied data which is passed to the known host function.
642 \fBSee also:\fP
643 .RS 4
644 \fBSSH Details\fP 
649 \fB\fIPWMD_OPTION_INQUIRE_TOTAL \fP\fP
650 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.
652 \fBNote:\fP
653 .RS 4
654 During the INQUIRE, PWMD_OPTION_STATUS_CB is called after every ASSUAN_LINELENGTH bytes have been successfully transferred.
656 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. 
661 \fB\fIPWMD_OPTION_LOCK_ON_OPEN \fP\fP
662 When set to 1, lock the file mutex after opening a file as if the LOCK command had been sent. 
664 \fB\fIPWMD_OPTION_ITERATIONS \fP\fP
665 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. 
667 \fB\fIPWMD_OPTION_CIPHER \fP\fP
668 A string specifying the cipher to use to encrypt with. See the pwmd(1) manual page for available ciphers. 
670 \fB\fIPWMD_OPTION_BASE64 \fP\fP
671 When 1, tell pwmd that the passphrase is Base64 encoded. pwmd will decode the passphrase before encryption and decryption. 
673 \fB\fIPWMD_OPTION_SSH_AGENT \fP\fP
674 Use ssh-agent to retrieve private key to authenticate. 
676 \fB\fIPWMD_OPTION_NO_PINENTRY \fP\fP
677 When 1, disable pinentry use. This will prevent pwmd and libpwmd from using a pinentry. 
678 .SS "enum \fBpwmd_pinentry_t\fP"
680 Local pinentry commands and not pwmd pinentry. For use with \fBpwmd_getpin()\fP. 
682 \fBEnumerator: \fP
683 .in +1c
685 \fB\fIPWMD_PINENTRY_OPEN \fP\fP
686 When opening a file. 
688 \fB\fIPWMD_PINENTRY_OPEN_FAILED \fP\fP
689 When opening a file failed. 
691 \fB\fIPWMD_PINENTRY_SAVE \fP\fP
692 When saving a file. 
694 \fB\fIPWMD_PINENTRY_SAVE_CONFIRM \fP\fP
695 For passphrase confirmation. 
697 \fB\fIPWMD_PINENTRY_CONFIRM \fP\fP
698 For confirmation of a user-defined prompt. 
700 \fB\fIPWMD_PINENTRY_DEFAULT \fP\fP
701 For the default or user defined string set with \fBPWMD_OPTION_PINENTRY_DESC\fP. 
703 \fB\fIPWMD_PINENTRY_CLOSE \fP\fP
704 To terminate the pinentry process created with \fBpwmd_getpin()\fP. 
705 .SS "enum \fBpwmd_socket_t\fP"
707 The type of socket a handle is connected to. For use with \fBpwmd_socket_type()\fP. 
709 \fBEnumerator: \fP
710 .in +1c
712 \fB\fIPWMD_SOCKET_LOCAL \fP\fP
713 A local domain socket. 
715 \fB\fIPWMD_SOCKET_SSH \fP\fP
716 An SSH connection over a TCP socket. 
717 .SH "Function Details"
718 .PP 
719 .SS "LIBPWMD_API void* pwmd_calloc (size_t nmemb, size_t size)"
721 A wrapper around calloc(). Like calloc(), but lets libpwmd keep track of the pointer.
723 \fBParameters:\fP
724 .RS 4
725 \fInmemb\fP The number of elements to allocate. 
727 \fIsize\fP The number of bytes to allocate. 
730 \fBReturns:\fP
731 .RS 4
732 A newly allocated pointer or NULL if there wasn't enough memory. 
735 \fBSee also:\fP
736 .RS 4
737 calloc(3), \fBpwmd_free()\fP 
741 .SS "LIBPWMD_API void pwmd_close (\fBpwm_t\fP * pwm)"
743 Close a handle. This will close the connection to a pwmd server and free any resources associated with it.
745 \fBParameters:\fP
746 .RS 4
747 \fIpwm\fP A handle. 
750 \fBReturns:\fP
751 .RS 4
752 Nothing. 
755 \fBSee also:\fP
756 .RS 4
757 \fBpwmd_disconnect()\fP, \fBpwmd_new()\fP 
761 .SS "LIBPWMD_API gpg_error_t pwmd_command (\fBpwm_t\fP * pwm, char ** result, const char * cmd,  ...)"
763 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.
765 \fBParameters:\fP
766 .RS 4
767 \fIpwm\fP A handle. 
769 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. 
771 \fIcmd\fP The command to send and any following arguments. 
774 \fBReturns:\fP
775 .RS 4
776 0 on success or an error code.
779 \fBNote:\fP
780 .RS 4
781 Not all commands return a result. 
785 .SS "LIBPWMD_API gpg_error_t pwmd_command_ap (\fBpwm_t\fP * pwm, char ** result, const char * cmd, va_list ap)"
787 Send a command to the pwmd server. Like \fBpwmd_command()\fP but uses an argument pointer instead.
789 \fBParameters:\fP
790 .RS 4
791 \fIpwm\fP A handle. 
793 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. 
795 \fIcmd\fP The command to send. 
797 \fIap\fP The arguments to \fIcmd\fP. 
800 \fBReturns:\fP
801 .RS 4
802 0 on success or an error code.
805 \fBNote:\fP
806 .RS 4
807 Not all commands return a result. 
811 .SS "LIBPWMD_API gpg_error_t pwmd_connect (\fBpwm_t\fP * pwm, const char * path)"
813 Connect to a local pwmd server. Connects to a local unix domain socket.
815 \fBParameters:\fP
816 .RS 4
817 \fIpwm\fP A handle. 
819 \fIpath\fP The socket path to connect to. If NULL, then a default of \fI'~/.pwmd/socket'\fP will be used. 
822 \fBReturns:\fP
823 .RS 4
824 0 on success or an error code. 
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 \fBSee also:\fP
833 .RS 4
834 \fBpwmd_ssh_connect()\fP, \fBpwmd_ssh_connect_async()\fP, \fBpwmd_disconnect()\fP 
838 .SS "LIBPWMD_API gpg_error_t pwmd_connect_url (\fBpwm_t\fP * pwm, const char * url)"
840 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: 
843  file://[path/to/local/socket]
845  or
847  ssh[46]://[username@]hostname[:port][,identity,known_hosts]
852 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://.
854 \fBParameters:\fP
855 .RS 4
856 \fIpwm\fP A handle. 
858 \fIurl\fP The string to parse. 
861 \fBNote:\fP
862 .RS 4
863 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
866 \fBReturns:\fP
867 .RS 4
868 0 on success or an error code. 
871 \fBSee also:\fP
872 .RS 4
873 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
877 .SS "LIBPWMD_API gpg_error_t pwmd_connect_url_async (\fBpwm_t\fP * pwm, const char * url)"
879 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: 
882  file://[path/to/local/socket]
884  or
886  ssh[46]://[username@]hostname[:port][,identity,known_hosts]
891 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://.
893 \fBpwmd_process()\fP should be called until the command completes.
895 \fBParameters:\fP
896 .RS 4
897 \fIpwm\fP A handle. 
899 \fIurl\fP The string to parse. 
902 \fBNote:\fP
903 .RS 4
904 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
907 \fBReturns:\fP
908 .RS 4
909 0 on success or an error code. 
912 \fBSee also:\fP
913 .RS 4
914 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
918 .SS "LIBPWMD_API gpg_error_t pwmd_disconnect (\fBpwm_t\fP * pwm)"
920 Close a connection to the pwmd server. This will close the connection but keep any previously set options for the specified handle.
922 \fBParameters:\fP
923 .RS 4
924 \fIpwm\fP A handle. 
927 \fBReturns:\fP
928 .RS 4
929 0 on success or an error code. 
932 \fBSee also:\fP
933 .RS 4
934 \fBpwmd_close()\fP 
938 .SS "LIBPWMD_API unsigned int pwmd_features ()"
940 libpwmd compile time features. Useful for clients to determine what features are compiled into libpwmd at runtime.
942 \fBReturns:\fP
943 .RS 4
944 A bitmask of features. 
948 .SS "LIBPWMD_API void pwmd_free (void * ptr)"
950 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.
952 The difference between the standard free() and this function is that this one will zero out the contents of the pointer before freeing it.
954 \fBParameters:\fP
955 .RS 4
956 \fIptr\fP The pointer to deallocate. 
959 \fBReturns:\fP
960 .RS 4
961 Nothing. 
964 \fBSee also:\fP
965 .RS 4
966 \fBpwmd_malloc()\fP, \fBpwmd_calloc()\fP, \fBpwmd_realloc()\fP, \fBpwmd_strdup()\fP, \fBpwmd_process()\fP, \fBpwmd_command()\fP 
970 .SS "LIBPWMD_API gpg_error_t pwmd_get_fds (\fBpwm_t\fP * pwm, \fBpwmd_fd_t\fP * fds, int * n_fds)"
972 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.
974 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.
976 \fBParameters:\fP
977 .RS 4
978 \fIpwm\fP A handle. 
980 \fIfds\fP Set to the file descriptor(s) of the associated handle. 
982 \fIn_fds\fP Initially the size of \fIfds\fP then updated to the number of available file descriptors which are stored in \fIfds\fP. 
985 \fBReturn values:\fP
986 .RS 4
987 \fI0\fP on success or an error code. 
989 \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. 
992 \fBSee also:\fP
993 .RS 4
994 \fBpwmd_process()\fP 
998 .SS "LIBPWMD_API gpg_error_t pwmd_get_hostkey (\fBpwm_t\fP * pwm, const char * host, int port, char ** result)"
1000 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.
1002 \fBParameters:\fP
1003 .RS 4
1004 \fIpwm\fP A handle. 
1006 \fIhost\fP The hostname or IP to connect to. 
1008 \fIport\fP The port or -1 for the default of 22. 
1010 \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. 
1013 \fBReturns:\fP
1014 .RS 4
1015 0 on success or an error code.
1018 \fBVersion:\fP
1019 .RS 4
1020 6.0.3 The connection is kept open but not verified after returning. It can be resumed from one of the SSH connection functions.
1023 \fBSee also:\fP
1024 .RS 4
1025 \fBpwmd_get_hostkey_async()\fP, \fBpwmd_ssh_connect()\fP, \fBSSH Details\fP 
1029 .SS "LIBPWMD_API gpg_error_t pwmd_get_hostkey_async (\fBpwm_t\fP * pwm, const char * host, int port)"
1031 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.
1033 \fBpwmd_process()\fP should be called until the command completes.
1035 \fBParameters:\fP
1036 .RS 4
1037 \fIpwm\fP A handle. 
1039 \fIhost\fP The hostname or IP to connect to. 
1041 \fIport\fP The port or -1 for the default of 22. 
1044 \fBReturns:\fP
1045 .RS 4
1046 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.
1049 \fBVersion:\fP
1050 .RS 4
1051 6.0.3 The connection is kept open but not verified after returning. It can be resumed from one of the SSH connection functions.
1054 \fBSee also:\fP
1055 .RS 4
1056 \fBpwmd_get_hostkey()\fP, \fBpwmd_ssh_connect_async()\fP, \fBpwmd_process()\fP, \fBSSH Details\fP 
1060 .SS "LIBPWMD_API gpg_error_t pwmd_getpin (\fBpwm_t\fP * pwm, const char * filename, char ** result, \fBpwmd_pinentry_t\fP which)"
1062 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.
1064 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.
1066 \fBParameters:\fP
1067 .RS 4
1068 \fIpwm\fP A handle. 
1070 \fIfilename\fP The filename to use in the pinentry dialog strings. 
1072 \fIresult\fP The entered value in the pinentry dialog which should be freed with \fBpwmd_free()\fP. 
1074 \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.
1077 \fBReturns:\fP
1078 .RS 4
1079 0 on success or an error. 
1083 .SS "LIBPWMD_API gpg_error_t pwmd_init (void)"
1085 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.
1087 \fBReturns:\fP
1088 .RS 4
1089 0 on success or an error code. 
1093 .SS "LIBPWMD_API gpg_error_t pwmd_inquire (\fBpwm_t\fP * pwm, const char * cmd, \fBpwmd_inquire_cb_t\fP func, void * user)"
1095 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.
1097 \fBParameters:\fP
1098 .RS 4
1099 \fIpwm\fP A handle. 
1101 \fIcmd\fP The \fBpwmd(1)\fP command to send including any options. 
1103 \fIfunc\fP A callback function of type \fBpwmd_inquire_cb_t\fP which sets the data to be sent. 
1105 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1108 \fBReturns:\fP
1109 .RS 4
1110 0 on success or an error code.
1113 \fBSee also:\fP
1114 .RS 4
1115 \fBpwmd_inquire_cb_t\fP 
1119 .SS "LIBPWMD_API void* pwmd_malloc (size_t size)"
1121 A wrapper around malloc. Like malloc(), but lets libpwmd keep track of the pointer.
1123 \fBParameters:\fP
1124 .RS 4
1125 \fIsize\fP The number of bytes to allocate. 
1128 \fBReturns:\fP
1129 .RS 4
1130 A newly allocated pointer or NULL if there wasn't enough memory. 
1133 \fBSee also:\fP
1134 .RS 4
1135 malloc(3), \fBpwmd_free()\fP 
1139 .SS "LIBPWMD_API \fBpwm_t\fP* pwmd_new (const char * name)"
1141 Creates a new handle. Creates a new handle for use with the other functions.
1143 \fBParameters:\fP
1144 .RS 4
1145 \fIname\fP If not NULL, the name of the application. The application name is sent to the pwmd server after successfully connecting.
1148 \fBReturns:\fP
1149 .RS 4
1150 a new handle or NULL if there was not enough memory. 
1154 .SS "LIBPWMD_API gpg_error_t pwmd_open (\fBpwm_t\fP * pwm, const char * filename)"
1156 Open a file on the pwmd server. This will send the OPEN command to the server.
1158 \fBParameters:\fP
1159 .RS 4
1160 \fIpwm\fP A handle. 
1162 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1165 \fBReturns:\fP
1166 .RS 4
1167 0 on success or an error code. 
1170 \fBSee also:\fP
1171 .RS 4
1172 \fBPinentry Details\fP 
1176 .SS "LIBPWMD_API gpg_error_t pwmd_open2 (\fBpwm_t\fP * pwm, const char * filename)"
1178 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.
1180 \fBNote:\fP
1181 .RS 4
1182 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.
1184 This pinentry method is not thread safe. It needs to set a couple of global variables for the pinentry timeout to work properly.
1187 \fBParameters:\fP
1188 .RS 4
1189 \fIpwm\fP A handle. 
1191 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1194 \fBReturns:\fP
1195 .RS 4
1196 0 on success or an error code. 
1199 \fBReturn values:\fP
1200 .RS 4
1201 \fIGPG_ERR_PIN_BLOCKED\fP Another handle is using the local pinentry. 
1204 \fBSee also:\fP
1205 .RS 4
1206 \fBPinentry Details\fP 
1210 .SS "LIBPWMD_API gpg_error_t pwmd_open_async (\fBpwm_t\fP * pwm, const char * filename)"
1212 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.
1214 \fBpwmd_process()\fP should be called until the command completes.
1216 \fBParameters:\fP
1217 .RS 4
1218 \fIpwm\fP A handle. 
1220 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1223 \fBReturns:\fP
1224 .RS 4
1225 0 on success or an error code. 
1228 \fBSee also:\fP
1229 .RS 4
1230 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1234 .SS "LIBPWMD_API gpg_error_t pwmd_open_async2 (\fBpwm_t\fP * pwm, const char * filename)"
1236 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.
1238 \fBpwmd_process()\fP should be called until the command completes.
1240 \fBNote:\fP
1241 .RS 4
1242 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.
1245 \fBParameters:\fP
1246 .RS 4
1247 \fIpwm\fP A handle. 
1249 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1252 \fBReturns:\fP
1253 .RS 4
1254 0 on success or an error code. 
1257 \fBSee also:\fP
1258 .RS 4
1259 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1263 .SS "LIBPWMD_API gpg_error_t pwmd_open_inquire (\fBpwm_t\fP * pwm, const char * filename, \fBpwmd_inquire_cb_t\fP func, void * user)"
1265 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.
1267 \fBNote:\fP
1268 .RS 4
1269 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.
1271 Pinentry is disabled when using this function.
1274 \fBParameters:\fP
1275 .RS 4
1276 \fIpwm\fP A handle. 
1278 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1280 \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. 
1282 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1285 \fBReturns:\fP
1286 .RS 4
1287 0 on success or an error code. 
1290 \fBSee also:\fP
1291 .RS 4
1292 \fBPWMD_OPTION_BASE64\fP 
1296 .SS "LIBPWMD_API gpg_error_t pwmd_pending_line (\fBpwm_t\fP * pwm)"
1298 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.
1300 \fBParameters:\fP
1301 .RS 4
1302 \fIpwm\fP A handle. 
1305 \fBReturn values:\fP
1306 .RS 4
1307 \fI0\fP if there is a pending line. 
1309 \fIGPG_ERR_NO_DATA\fP if there is no pending line. 
1312 \fBSee also:\fP
1313 .RS 4
1314 \fBpwmd_process()\fP 
1318 .SS "LIBPWMD_API \fBpwmd_async_t\fP pwmd_process (\fBpwm_t\fP * pwm, gpg_error_t * rc, char ** result)"
1320 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.
1322 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.
1324 \fBParameters:\fP
1325 .RS 4
1326 \fIpwm\fP A handle. 
1328 \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. 
1330 \fIresult\fP Set to the result of the command when \fIrc\fP is 0. Note that not all commands return a result. 
1333 \fBReturn values:\fP
1334 .RS 4
1335 \fIASYNC_DONE\fP The command has completed. \fIrc\fP should be checked to determine if the command was successful or not. 
1337 \fIASYNC_PROCESS\fP The command is still running and this function should be called again. 
1340 \fBSee also:\fP
1341 .RS 4
1342 \fBpwmd_get_fds()\fP, \fBpwmd_pending_line()\fP 
1346 .SS "LIBPWMD_API void* pwmd_realloc (void * ptr, size_t size)"
1348 A wrapper around realloc(). Like realloc(), but lets libpwmd keep track of the pointer.
1350 \fBNote:\fP
1351 .RS 4
1352 This function will try and allocate the entire \fIsize\fP before freeing the original pointer and returning the new one.
1355 \fBParameters:\fP
1356 .RS 4
1357 \fIptr\fP The pointer to reallocate. 
1359 \fIsize\fP The new number of bytes to allocate. 
1362 \fBReturns:\fP
1363 .RS 4
1364 A newly allocated pointer or NULL if there wasn't enough memory. 
1367 \fBSee also:\fP
1368 .RS 4
1369 realloc(3), \fBpwmd_free()\fP 
1373 .SS "LIBPWMD_API gpg_error_t pwmd_save (\fBpwm_t\fP * pwm)"
1375 Save a file on the pwmd server. This will send the SAVE command.
1377 \fBParameters:\fP
1378 .RS 4
1379 \fIpwm\fP A handle. 
1382 \fBReturns:\fP
1383 .RS 4
1384 0 on success or an error code. 
1387 \fBSee also:\fP
1388 .RS 4
1389 \fBPinentry Details\fP 
1393 .SS "LIBPWMD_API gpg_error_t pwmd_save2 (\fBpwm_t\fP * pwm)"
1395 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.
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 \fBPinentry Details\fP 
1413 .SS "LIBPWMD_API gpg_error_t pwmd_save_async (\fBpwm_t\fP * pwm)"
1415 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.
1417 \fBpwmd_process()\fP should be called until the command completes.
1419 \fBParameters:\fP
1420 .RS 4
1421 \fIpwm\fP A handle. 
1424 \fBReturns:\fP
1425 .RS 4
1426 0 on success or an error code. 
1429 \fBSee also:\fP
1430 .RS 4
1431 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1435 .SS "LIBPWMD_API gpg_error_t pwmd_save_async2 (\fBpwm_t\fP * pwm)"
1437 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.
1439 \fBpwmd_process()\fP should be called until the command completes.
1441 \fBParameters:\fP
1442 .RS 4
1443 \fIpwm\fP A handle. 
1446 \fBReturns:\fP
1447 .RS 4
1448 0 on success or an error code. 
1451 \fBSee also:\fP
1452 .RS 4
1453 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1457 .SS "LIBPWMD_API gpg_error_t pwmd_save_inquire (\fBpwm_t\fP * pwm, \fBpwmd_inquire_cb_t\fP func, void * user)"
1459 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.
1461 \fBNote:\fP
1462 .RS 4
1463 Pinentry is disabled when using this function.
1466 \fBParameters:\fP
1467 .RS 4
1468 \fIpwm\fP A handle. 
1470 \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. 
1472 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1475 \fBReturns:\fP
1476 .RS 4
1477 0 on success or an error code. 
1480 \fBSee also:\fP
1481 .RS 4
1482 \fBPWMD_OPTION_BASE64\fP 
1486 .SS "LIBPWMD_API gpg_error_t pwmd_setopt (\fBpwm_t\fP * pwm, \fBpwmd_option_t\fP opt,  ...)"
1488 Set handle options. See \fBpwmd_option_t\fP for option specific details.
1490 \fBParameters:\fP
1491 .RS 4
1492 \fIpwm\fP A handle. 
1494 \fIopt\fP The option and following value. 
1497 \fBReturns:\fP
1498 .RS 4
1499 0 on success or an error code. 
1503 .SS "LIBPWMD_API gpg_error_t pwmd_socket_type (\fBpwm_t\fP * pwm, \fBpwmd_socket_t\fP * type)"
1505 The type of connection a handle has. Useful when you want to know what kind of connection a handle has.
1507 \fBParameters:\fP
1508 .RS 4
1509 \fIpwm\fP A handle. 
1511 \fItype\fP The type of socket. 
1514 \fBReturns:\fP
1515 .RS 4
1516 0 on success or an error code. 
1519 \fBSee also:\fP
1520 .RS 4
1521 \fBpwmd_connect_url()\fP 
1525 .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)"
1527 Establish a remote connection to a pwmd server. Connects to a pwmd server over an SSH channel.
1529 \fBParameters:\fP
1530 .RS 4
1531 \fIpwm\fP A handle. 
1533 \fIhost\fP The hostname to connect to or NULL to resume a connection previously started with \fBpwmd_get_hostkey()\fP. 
1535 \fIport\fP The port or -1 for the default of 22. 
1537 \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. This parameter is not used if \fBPWMD_OPTION_SSH_AGENT\fP is set. 
1539 \fIuser\fP The username on the SSH server to login as. If NULL then invoking username will be used. 
1541 \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. 
1544 \fBReturns:\fP
1545 .RS 4
1546 0 on success or an error code. 
1549 \fBNote:\fP
1550 .RS 4
1551 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1554 \fBSee also:\fP
1555 .RS 4
1556 \fBpwmd_ssh_connect_async()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1560 .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)"
1562 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.
1564 \fBpwmd_process()\fP should be called until the command completes.
1566 \fBParameters:\fP
1567 .RS 4
1568 \fIpwm\fP A handle. 
1570 \fIhost\fP The hostname to connect to or NULL to resume a connection previously started with \fBpwmd_get_hostkey()\fP. 
1572 \fIport\fP The port or -1 for the default of 22. 
1574 \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. This parameter is not used if \fBPWMD_OPTION_SSH_AGENT\fP is set. 
1576 \fIuser\fP The username on the SSH server to login as. If NULL, the invoking username will be used. 
1578 \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. 
1581 \fBReturns:\fP
1582 .RS 4
1583 0 on success or an error code. 
1586 \fBNote:\fP
1587 .RS 4
1588 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1591 \fBSee also:\fP
1592 .RS 4
1593 \fBpwmd_process()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1597 .SS "LIBPWMD_API char* pwmd_strdup (const char * str)"
1599 A wrapper around strdup(). Like strdup(), but lets libpwmd keep track of the pointer.
1601 \fBParameters:\fP
1602 .RS 4
1603 \fIstr\fP The string to duplicate. 
1606 \fBReturns:\fP
1607 .RS 4
1608 A newly allocated character pointer or NULL if there wasn't enough memory. 
1611 \fBSee also:\fP
1612 .RS 4
1613 strdup(3), \fBpwmd_free()\fP 
1617 .SS "LIBPWMD_API char* pwmd_strdup_printf (const char * fmt,  ...)"
1619 Duplicate a formatted string. Like \fBsprintf(3)\fP but returns an allocated string.
1621 \fBParameters:\fP
1622 .RS 4
1623 \fIfmt\fP The formatted string and any following arguments. 
1626 \fBReturns:\fP
1627 .RS 4
1628 A newly allocated character pointer or NULL if there wasn't enough memory. 
1631 \fBSee also:\fP
1632 .RS 4
1633 \fBpwmd_free()\fP 
1637 .SS "LIBPWMD_API const char* pwmd_strerror (gpg_error_t code)"
1639 Return a description of an error code. \fBParameters:\fP
1640 .RS 4
1641 \fIcode\fP The error code to describe. 
1644 \fBReturns:\fP
1645 .RS 4
1646 A character description of the error code. 
1649 \fBSee also:\fP
1650 .RS 4
1651 \fBpwmd_strerror_r()\fP 
1655 .SS "LIBPWMD_API int pwmd_strerror_r (gpg_error_t code, char * buf, size_t size)"
1657 Return a description of an error code (thread-safe). This is a thread-safe version of \fBpwmd_strerror()\fP.
1659 \fBParameters:\fP
1660 .RS 4
1661 \fIcode\fP The error code to describe. 
1663 \fIbuf\fP An allocated buffer to hold the error description. 
1665 \fIsize\fP The size of the allocated buffer \fIbuf\fP.
1668 \fBReturn values:\fP
1669 .RS 4
1670 \fI0\fP Success. 
1672 \fIERANGE\fP \fIsize\fP was not large enough to hold the entire description and \fIbuf\fP is set to the truncated error string. 
1676 .SS "LIBPWMD_API const char* pwmd_version ()"
1678 Returns this version of libpwmd. As a string. 
1680 \fBReturns:\fP
1681 .RS 4
1682 A string. 
1686 .SH "Author"
1687 .PP 
1688 Generated automatically by Doxygen for libpwmd from the source code.