libssh2 IS thread safe. See Libss2 in multithread environment[1].
[libpwmd.git] / doc / libpwmd.3
blob001aceab657082eec0f3dc388e9d27bbefc36e4d
1 .TH "libpwmd.h" 3 "Tue Nov 16 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 "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 on IO operations (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 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:
21 .PP
22 .PP
23 .nf
24  command='socat UNIX-CONNECT:$HOME/.pwmd/socket -' <hash> ...
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   0x603"
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   3"
122 .ti -1c
123 .RI "#define \fBLIBPWMD_VERSION_STR\fP   '6.0.3-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 \fBEPWMD_NO_FILE\fP"
134 .ti -1c
135 .RI "#define \fBEPWMD_LIBXML_ERROR\fP"
137 .ti -1c
138 .RI "#define \fBEPWMD_FILE_MODIFIED\fP"
140 .ti -1c
141 .RI "#define \fBEPWMD_MAX\fP"
143 .in -1c
144 .SS "Typedefs"
146 .in +1c
147 .ti -1c
148 .RI "typedef struct pwm_s \fBpwm_t\fP"
150 .ti -1c
151 .RI "typedef gpg_error_t(* \fBpwmd_passphrase_cb_t\fP )(void *user, char **passphrase)"
153 .ti -1c
154 .RI "typedef int(* \fBpwmd_status_cb_t\fP )(void *user, const char *line)"
156 .ti -1c
157 .RI "typedef gpg_error_t(* \fBpwmd_inquire_cb_t\fP )(void *user, const char *cmd, gpg_error_t rc, char **data, size_t *len)"
159 .ti -1c
160 .RI "typedef gpg_error_t(* \fBpwmd_knownhost_cb_t\fP )(void *user, const char *host, const char *key, size_t len)"
162 .in -1c
163 .SS "Enumerations"
165 .in +1c
166 .ti -1c
167 .RI "enum \fBpwmd_async_t\fP { \fBASYNC_INIT\fP, \fBASYNC_PROCESS\fP, \fBASYNC_DONE\fP }"
169 .ti -1c
170 .RI "enum \fBpwmd_ip_version_t\fP { \fBPWMD_IP_ANY\fP, \fBPWMD_IPV4\fP, \fBPWMD_IPV6\fP }"
172 .ti -1c
173 .RI "enum \fBpwmd_socket_t\fP { \fBPWMD_SOCKET_LOCAL\fP, \fBPWMD_SOCKET_SSH\fP }"
175 .ti -1c
176 .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 }"
178 .ti -1c
179 .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 }"
181 .in -1c
182 .SS "Functions"
184 .in +1c
185 .ti -1c
186 .RI "LIBPWMD_API const char * \fBpwmd_version\fP ()"
188 .ti -1c
189 .RI "LIBPWMD_API gpg_error_t \fBpwmd_init\fP (void)"
191 .ti -1c
192 .RI "LIBPWMD_API \fBpwm_t\fP * \fBpwmd_new\fP (const char *name)"
194 .ti -1c
195 .RI "LIBPWMD_API gpg_error_t \fBpwmd_cancel\fP (\fBpwm_t\fP *pwm)"
197 .ti -1c
198 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect\fP (\fBpwm_t\fP *pwm, const char *path)"
200 .ti -1c
201 .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)"
203 .ti -1c
204 .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)"
206 .ti -1c
207 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect_url\fP (\fBpwm_t\fP *pwm, const char *url)"
209 .ti -1c
210 .RI "LIBPWMD_API gpg_error_t \fBpwmd_connect_url_async\fP (\fBpwm_t\fP *pwm, const char *url)"
212 .ti -1c
213 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_hostkey\fP (\fBpwm_t\fP *pwm, const char *host, int port, char **result)"
215 .ti -1c
216 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_hostkey_async\fP (\fBpwm_t\fP *pwm, const char *host, int port)"
218 .ti -1c
219 .RI "LIBPWMD_API gpg_error_t \fBpwmd_get_fds\fP (\fBpwm_t\fP *pwm, \fBpwmd_fd_t\fP *fds, int *n_fds)"
221 .ti -1c
222 .RI "LIBPWMD_API gpg_error_t \fBpwmd_pending_line\fP (\fBpwm_t\fP *pwm)"
224 .ti -1c
225 .RI "LIBPWMD_API gpg_error_t \fBpwmd_setopt\fP (\fBpwm_t\fP *pwm, \fBpwmd_option_t\fP opt,...)"
227 .ti -1c
228 .RI "LIBPWMD_API gpg_error_t \fBpwmd_getpin\fP (\fBpwm_t\fP *pwm, const char *filename, char **result, \fBpwmd_pinentry_t\fP which)"
230 .ti -1c
231 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open\fP (\fBpwm_t\fP *pwm, const char *filename)"
233 .ti -1c
234 .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)"
236 .ti -1c
237 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open2\fP (\fBpwm_t\fP *pwm, const char *filename)"
239 .ti -1c
240 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open_async2\fP (\fBpwm_t\fP *pwm, const char *filename)"
242 .ti -1c
243 .RI "LIBPWMD_API gpg_error_t \fBpwmd_open_async\fP (\fBpwm_t\fP *pwm, const char *filename)"
245 .ti -1c
246 .RI "LIBPWMD_API \fBpwmd_async_t\fP \fBpwmd_process\fP (\fBpwm_t\fP *pwm, gpg_error_t *rc, char **result)"
248 .ti -1c
249 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save\fP (\fBpwm_t\fP *pwm)"
251 .ti -1c
252 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_inquire\fP (\fBpwm_t\fP *pwm, \fBpwmd_inquire_cb_t\fP func, void *user)"
254 .ti -1c
255 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save2\fP (\fBpwm_t\fP *pwm)"
257 .ti -1c
258 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_async2\fP (\fBpwm_t\fP *pwm)"
260 .ti -1c
261 .RI "LIBPWMD_API gpg_error_t \fBpwmd_save_async\fP (\fBpwm_t\fP *pwm)"
263 .ti -1c
264 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd,...)"
266 .ti -1c
267 .RI "LIBPWMD_API gpg_error_t \fBpwmd_command_ap\fP (\fBpwm_t\fP *pwm, char **result, const char *cmd, va_list ap)"
269 .ti -1c
270 .RI "LIBPWMD_API gpg_error_t \fBpwmd_inquire\fP (\fBpwm_t\fP *pwm, const char *cmd, \fBpwmd_inquire_cb_t\fP func, void *user)"
272 .ti -1c
273 .RI "LIBPWMD_API gpg_error_t \fBpwmd_disconnect\fP (\fBpwm_t\fP *pwm)"
275 .ti -1c
276 .RI "LIBPWMD_API void \fBpwmd_close\fP (\fBpwm_t\fP *pwm)"
278 .ti -1c
279 .RI "LIBPWMD_API gpg_error_t \fBpwmd_socket_type\fP (\fBpwm_t\fP *pwm, \fBpwmd_socket_t\fP *type)"
281 .ti -1c
282 .RI "LIBPWMD_API void \fBpwmd_free\fP (void *ptr)"
284 .ti -1c
285 .RI "LIBPWMD_API void * \fBpwmd_malloc\fP (size_t size)"
287 .ti -1c
288 .RI "LIBPWMD_API void * \fBpwmd_calloc\fP (size_t nmemb, size_t size)"
290 .ti -1c
291 .RI "LIBPWMD_API void * \fBpwmd_realloc\fP (void *ptr, size_t size)"
293 .ti -1c
294 .RI "LIBPWMD_API char * \fBpwmd_strdup\fP (const char *str)"
296 .ti -1c
297 .RI "LIBPWMD_API char * \fBpwmd_strdup_printf\fP (const char *fmt,...)"
299 .ti -1c
300 .RI "LIBPWMD_API const char * \fBpwmd_strerror\fP (gpg_error_t code)"
302 .ti -1c
303 .RI "LIBPWMD_API int \fBpwmd_strerror_r\fP (gpg_error_t code, char *buf, size_t size)"
305 .in -1c
306 .SH "Constant Details"
307 .PP 
308 .SS "#define EPWMD_FILE_MODIFIED"
310 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. 
311 .SS "#define EPWMD_LIBXML_ERROR"
313 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. 
314 .SS "#define EPWMD_MAX"
316 libgpg-error error code offset. If you use your own libgpg-error codes then this should be the base of them. 
317 .SS "#define EPWMD_NO_FILE"
319 No data file has been opened. Some commands don't require an open data file but most do. 
320 .SS "#define LIBPWMD_VERSION   0x603"
322 Version information. The version of this library. 
323 .SS "#define LIBPWMD_VERSION_MAJOR   6"
325 Version information. The major release number of this library. 
326 .SS "#define LIBPWMD_VERSION_MINOR   0"
328 Version information. The minor release number of this library. 
329 .SS "#define LIBPWMD_VERSION_PATCH   3"
331 Version information. The patch level of this library. 
332 .SS "#define LIBPWMD_VERSION_STR   '6.0.3-git'"
334 Version information. A string representation of the version of this library. 
335 .SS "#define PWMD_FD_READABLE   0x01"
337 For use with \fBpwmd_get_fds()\fP. Set when the file descriptor is readable. 
338 .SS "#define PWMD_FD_WRITABLE   0x02"
340 For use with \fBpwmd_get_fds()\fP. Set when the file descriptor is writable. 
341 .SH "Typedef Details"
342 .PP 
343 .SS "\fBpwm_t\fP"
345 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. 
346 .SS "\fBpwmd_inquire_cb_t\fP"
348 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.
350 \fBParameters:\fP
351 .RS 4
352 \fIuser\fP The user data pointer passed to \fBpwmd_inquire()\fP. 
354 \fIcmd\fP The same as the \fIcmd\fP argument to \fBpwmd_inquire()\fP. 
356 \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. 
358 \fIdata\fP The next chunk of data to send or NULL. 
360 \fIlen\fP The length of \fIdata\fP or 0.
363 \fBReturn values:\fP
364 .RS 4
365 \fI0\fP There is more data to be sent. 
367 \fIGPG_ERR_EOF\fP No need to call this function again, the current \fIline\fP is the last to send. 
369 \fIcode\fP Any other error code which will terminate the INQUIRE.
372 \fBNote:\fP
373 .RS 4
374 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. 
378 .SS "\fBpwmd_knownhost_cb_t\fP"
380 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.
382 \fBParameters:\fP
383 .RS 4
384 \fIuser\fP User data which was set with \fBPWMD_OPTION_KNOWNHOST_DATA\fP. 
386 \fIhost\fP The hostname as passed to the connecting function. 
388 \fIkey\fP The raw host key. Note that this differs from the format returned from \fBpwmd_get_hostkey()\fP. 
390 \fIlen\fP The host key length. 
393 \fBReturn values:\fP
394 .RS 4
395 \fI0\fP Add the host key to the known hosts file. 
397 \fIGPG_ERR_NOT_CONFIRMED\fP Do not add the host key and abort the connection.
400 \fBNote:\fP
401 .RS 4
402 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.
405 \fBSee also:\fP
406 .RS 4
407 \fBSSH Details\fP 
411 .SS "\fBpwmd_passphrase_cb_t\fP"
413 Custom passphrase retrieval function. The value of the option \fBPWMD_OPTION_PASSPHRASE_CB\fP which is set with \fBpwmd_setopt()\fP.
415 \fBParameters:\fP
416 .RS 4
417 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_PASSPHRASE_DATA\fP. 
419 \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. 
422 \fBReturns:\fP
423 .RS 4
424 0 on success or an error code which will cause a command to fail. 
428 .SS "\fBpwmd_status_cb_t\fP"
430 Process status messages. The value of the option \fBPWMD_OPTION_STATUS_CB\fP which is set with \fBpwmd_setopt()\fP.
432 \fBParameters:\fP
433 .RS 4
434 \fIuser\fP A user data pointer which is set with \fBPWMD_OPTION_STATUS_DATA\fP. 
436 \fIline\fP The status message line received from the server. 
439 \fBReturns:\fP
440 .RS 4
441 0 on success or an error code which will cause a command to fail. 
445 .SH "Enumeration Details"
446 .PP 
447 .SS "enum \fBpwmd_async_t\fP"
449 Asynchronous return value. The return code of \fBpwmd_process()\fP which is used for all asynchronous commands. 
451 \fBEnumerator: \fP
452 .in +1c
454 \fB\fIASYNC_INIT \fP\fP
456 \fBFor internal use only.\fP
457 .RS 4
462 \fB\fIASYNC_PROCESS \fP\fP
463 \fBpwmd_process()\fP should be called again. 
465 \fB\fIASYNC_DONE \fP\fP
466 The command has completed. The result code should be checked for an error. 
467 .SS "enum \fBpwmd_ip_version_t\fP"
469 IP protocol version for remote SSH connections. The value of the option \fBPWMD_OPTION_IP_VERSION\fP which is set with \fBpwmd_setopt()\fP. 
471 \fBEnumerator: \fP
472 .in +1c
474 \fB\fIPWMD_IP_ANY \fP\fP
475 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. 
477 \fB\fIPWMD_IPV4 \fP\fP
478 Only try IPv4. 
480 \fB\fIPWMD_IPV6 \fP\fP
481 Only try IPv6. 
482 .SS "enum \fBpwmd_option_t\fP"
484 libpwmd options. Options are set with \fBpwmd_setopt()\fP.
486 \fBNote:\fP
487 .RS 4
488 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
493 \fBEnumerator: \fP
494 .in +1c
496 \fB\fIPWMD_OPTION_PASSPHRASE_CB \fP\fP
497 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.
499 \fBNote:\fP
500 .RS 4
501 An empty string as the passphrase is allowed. 
506 \fB\fIPWMD_OPTION_PASSPHRASE_DATA \fP\fP
507 User supplied data which is passed to the custom passphrase function. 
509 \fB\fIPWMD_OPTION_PASSPHRASE \fP\fP
510 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.
512 \fBNote:\fP
513 .RS 4
514 An empty string as the passphrase is allowed. 
519 \fB\fIPWMD_OPTION_PINENTRY_TRIES \fP\fP
520 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.
522 \fBNote:\fP
523 .RS 4
524 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. 
529 \fB\fIPWMD_OPTION_PINENTRY_PATH \fP\fP
530 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.
532 \fBSee also:\fP
533 .RS 4
534 \fBPinentry Details\fP 
539 \fB\fIPWMD_OPTION_PINENTRY_TTY \fP\fP
540 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.
542 \fBSee also:\fP
543 .RS 4
544 \fBPinentry Details\fP 
549 \fB\fIPWMD_OPTION_PINENTRY_TERM \fP\fP
550 A value which specifies the terminal type (e.g., vt100) that \fBpinentry(1)\fP will use when no X11 display is available.
552 \fBSee also:\fP
553 .RS 4
554 \fBPinentry Details\fP 
559 \fB\fIPWMD_OPTION_PINENTRY_DISPLAY \fP\fP
560 A value which specifies the X11 display that \fBpinentry(1)\fP will use.
562 \fBTodo\fP
563 .RS 4
564 X11 port forwarding so a remote pinentry can use the local display.
568 \fBSee also:\fP
569 .RS 4
570 \fBPinentry Details\fP 
575 \fB\fIPWMD_OPTION_PINENTRY_TITLE \fP\fP
576 A character string that \fBpinentry(1)\fP will use in it's dialog window. 
578 \fB\fIPWMD_OPTION_PINENTRY_PROMPT \fP\fP
579 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
581 \fB\fIPWMD_OPTION_PINENTRY_DESC \fP\fP
582 A character string that \fBpinentry(1)\fP will use in it's dialog window.  
584 \fB\fIPWMD_OPTION_PINENTRY_LC_CTYPE \fP\fP
585 For \fBpinentry(1)\fP localization. 
587 \fB\fIPWMD_OPTION_PINENTRY_LC_MESSAGES \fP\fP
588 For \fBpinentry(1)\fP localization.  
590 \fB\fIPWMD_OPTION_PINENTRY_TIMEOUT \fP\fP
591 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. 
593 \fB\fIPWMD_OPTION_STATUS_CB \fP\fP
594 A function of type \fBpwmd_status_cb_t\fP that will process status messages received from the pwmd server. 
596 \fB\fIPWMD_OPTION_STATUS_DATA \fP\fP
597 A user data pointer which is passed to the status message function. 
599 \fB\fIPWMD_OPTION_IP_VERSION \fP\fP
600 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.
602 \fBNote:\fP
603 .RS 4
604 This option must be set before a connection is made when not the default. 
609 \fB\fIPWMD_OPTION_KNOWNHOST_CB \fP\fP
610 A function to confirm an unknown host hash which wasn't found in the known hosts file.
612 \fBSee also:\fP
613 .RS 4
614 \fBSSH Details\fP 
619 \fB\fIPWMD_OPTION_KNOWNHOST_DATA \fP\fP
620 User supplied data which is passed to the known host function.
622 \fBSee also:\fP
623 .RS 4
624 \fBSSH Details\fP 
629 \fB\fIPWMD_OPTION_INQUIRE_TOTAL \fP\fP
630 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.
632 \fBNote:\fP
633 .RS 4
634 During the INQUIRE, PWMD_OPTION_STATUS_CB is called after every ASSUAN_LINELENGTH bytes have been successfully transferred.
636 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. 
641 \fB\fIPWMD_OPTION_LOCK_ON_OPEN \fP\fP
642 When set to 1, lock the file mutex after opening a file as if the LOCK command had been sent. 
644 \fB\fIPWMD_OPTION_ITERATIONS \fP\fP
645 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. 
647 \fB\fIPWMD_OPTION_CIPHER \fP\fP
648 A string specifying the cipher to use to encrypt with. See the pwmd(1) manual page for available ciphers. 
650 \fB\fIPWMD_OPTION_BASE64 \fP\fP
651 When 1, tell pwmd that the passphrase is Base64 encoded. pwmd will decode the passphrase before encryption and decryption. 
653 \fB\fIPWMD_OPTION_SSH_AGENT \fP\fP
654 Use ssh-agent to retrieve private key to authenticate. 
655 .SS "enum \fBpwmd_pinentry_t\fP"
657 Local pinentry commands and not pwmd pinentry. For use with \fBpwmd_getpin()\fP. 
659 \fBEnumerator: \fP
660 .in +1c
662 \fB\fIPWMD_PINENTRY_OPEN \fP\fP
663 When opening a file. 
665 \fB\fIPWMD_PINENTRY_OPEN_FAILED \fP\fP
666 When opening a file failed. 
668 \fB\fIPWMD_PINENTRY_SAVE \fP\fP
669 When saving a file. 
671 \fB\fIPWMD_PINENTRY_SAVE_CONFIRM \fP\fP
672 For passphrase confirmation. 
674 \fB\fIPWMD_PINENTRY_CONFIRM \fP\fP
675 For confirmation of a user-defined prompt. 
677 \fB\fIPWMD_PINENTRY_DEFAULT \fP\fP
678 For the default or user defined string set with \fBPWMD_OPTION_PINENTRY_DESC\fP. 
680 \fB\fIPWMD_PINENTRY_CLOSE \fP\fP
681 To terminate the pinentry process created with \fBpwmd_getpin()\fP. 
682 .SS "enum \fBpwmd_socket_t\fP"
684 The type of socket a handle is connected to. For use with \fBpwmd_socket_type()\fP. 
686 \fBEnumerator: \fP
687 .in +1c
689 \fB\fIPWMD_SOCKET_LOCAL \fP\fP
690 A local domain socket. 
692 \fB\fIPWMD_SOCKET_SSH \fP\fP
693 An SSH connection over a TCP socket. 
694 .SH "Function Details"
695 .PP 
696 .SS "LIBPWMD_API void* pwmd_calloc (size_t nmemb, size_t size)"
698 A wrapper around calloc(). Like calloc(), but lets libpwmd keep track of the pointer.
700 \fBParameters:\fP
701 .RS 4
702 \fInmemb\fP The number of elements to allocate. 
704 \fIsize\fP The number of bytes to allocate. 
707 \fBReturns:\fP
708 .RS 4
709 A newly allocated pointer or NULL if there wasn't enough memory. 
712 \fBSee also:\fP
713 .RS 4
714 calloc(3), \fBpwmd_free()\fP 
718 .SS "LIBPWMD_API gpg_error_t pwmd_cancel (\fBpwm_t\fP * pwm)"
720 Cancel the current transfer or command. Useful for multi-threaded applications. This only sets a flag in the specified handle. The cancellation is done at the next read or write operation of the socket file descriptor.
722 \fBParameters:\fP
723 .RS 4
724 \fIpwm\fP A handle. 
727 \fBReturns:\fP
728 .RS 4
729 0 on success or an error code. 
732 \fBSee also:\fP
733 .RS 4
734 \fBMultiple Threads\fP 
738 .SS "LIBPWMD_API void pwmd_close (\fBpwm_t\fP * pwm)"
740 Close a handle. This will close the connection to a pwmd server and free any resources associated with it.
742 \fBParameters:\fP
743 .RS 4
744 \fIpwm\fP A handle. 
747 \fBReturns:\fP
748 .RS 4
749 Nothing. 
752 \fBSee also:\fP
753 .RS 4
754 \fBpwmd_disconnect()\fP, \fBpwmd_new()\fP 
758 .SS "LIBPWMD_API gpg_error_t pwmd_command (\fBpwm_t\fP * pwm, char ** result, const char * cmd,  ...)"
760 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.
762 \fBParameters:\fP
763 .RS 4
764 \fIpwm\fP A handle. 
766 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. 
768 \fIcmd\fP The command to send and any following arguments. 
771 \fBReturns:\fP
772 .RS 4
773 0 on success or an error code.
776 \fBNote:\fP
777 .RS 4
778 Not all commands return a result. 
782 .SS "LIBPWMD_API gpg_error_t pwmd_command_ap (\fBpwm_t\fP * pwm, char ** result, const char * cmd, va_list ap)"
784 Send a command to the pwmd server. Like \fBpwmd_command()\fP but uses an argument pointer instead.
786 \fBParameters:\fP
787 .RS 4
788 \fIpwm\fP A handle. 
790 \fIresult\fP The result of the command when successful which must be freed with \fBpwmd_free()\fP. 
792 \fIcmd\fP The command to send. 
794 \fIap\fP The arguments to \fIcmd\fP. 
797 \fBReturns:\fP
798 .RS 4
799 0 on success or an error code.
802 \fBNote:\fP
803 .RS 4
804 Not all commands return a result. 
808 .SS "LIBPWMD_API gpg_error_t pwmd_connect (\fBpwm_t\fP * pwm, const char * path)"
810 Connect to a local pwmd server. Connects to a local unix domain socket.
812 \fBParameters:\fP
813 .RS 4
814 \fIpwm\fP A handle. 
816 \fIpath\fP The socket path to connect to. If NULL, then a default of \fI'~/.pwmd/socket'\fP will be used. 
819 \fBReturns:\fP
820 .RS 4
821 0 on success or an error code. 
824 \fBNote:\fP
825 .RS 4
826 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
829 \fBSee also:\fP
830 .RS 4
831 \fBpwmd_ssh_connect()\fP, \fBpwmd_ssh_connect_async()\fP, \fBpwmd_disconnect()\fP 
835 .SS "LIBPWMD_API gpg_error_t pwmd_connect_url (\fBpwm_t\fP * pwm, const char * url)"
837 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: 
840  file://[path/to/local/socket]
842  or
844  ssh[46]://[username@]hostname[:port][,identity,known_hosts]
849 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://.
851 \fBParameters:\fP
852 .RS 4
853 \fIpwm\fP A handle. 
855 \fIurl\fP The string to parse. 
858 \fBNote:\fP
859 .RS 4
860 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
863 \fBReturns:\fP
864 .RS 4
865 0 on success or an error code. 
868 \fBSee also:\fP
869 .RS 4
870 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
874 .SS "LIBPWMD_API gpg_error_t pwmd_connect_url_async (\fBpwm_t\fP * pwm, const char * url)"
876 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: 
879  file://[path/to/local/socket]
881  or
883  ssh[46]://[username@]hostname[:port][,identity,known_hosts]
888 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://.
890 \fBpwmd_process()\fP should be called until the command completes.
892 \fBParameters:\fP
893 .RS 4
894 \fIpwm\fP A handle. 
896 \fIurl\fP The string to parse. 
899 \fBNote:\fP
900 .RS 4
901 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
904 \fBReturns:\fP
905 .RS 4
906 0 on success or an error code. 
909 \fBSee also:\fP
910 .RS 4
911 \fBpwmd_socket_type()\fP, \fBpwmd_disconnect()\fP 
915 .SS "LIBPWMD_API gpg_error_t pwmd_disconnect (\fBpwm_t\fP * pwm)"
917 Close a connection to the pwmd server. This will close the connection but keep any previously set options for the specified handle.
919 \fBParameters:\fP
920 .RS 4
921 \fIpwm\fP A handle. 
924 \fBReturns:\fP
925 .RS 4
926 0 on success or an error code. 
929 \fBSee also:\fP
930 .RS 4
931 \fBpwmd_close()\fP 
935 .SS "LIBPWMD_API void pwmd_free (void * ptr)"
937 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.
939 The difference between the standard free() and this function is that this one will zero out the contents of the pointer before freeing it.
941 \fBParameters:\fP
942 .RS 4
943 \fIptr\fP The pointer to deallocate. 
946 \fBReturns:\fP
947 .RS 4
948 Nothing. 
951 \fBSee also:\fP
952 .RS 4
953 \fBpwmd_malloc()\fP, \fBpwmd_calloc()\fP, \fBpwmd_realloc()\fP, \fBpwmd_strdup()\fP, \fBpwmd_process()\fP, \fBpwmd_command()\fP 
957 .SS "LIBPWMD_API gpg_error_t pwmd_get_fds (\fBpwm_t\fP * pwm, \fBpwmd_fd_t\fP * fds, int * n_fds)"
959 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.
961 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.
963 \fBParameters:\fP
964 .RS 4
965 \fIpwm\fP A handle. 
967 \fIfds\fP Set to the file descriptor(s) of the associated handle. 
969 \fIn_fds\fP Initially the size of \fIfds\fP then updated to the number of available file descriptors which are stored in \fIfds\fP. 
972 \fBReturn values:\fP
973 .RS 4
974 \fI0\fP on success or an error code. 
976 \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. 
979 \fBSee also:\fP
980 .RS 4
981 \fBpwmd_process()\fP 
985 .SS "LIBPWMD_API gpg_error_t pwmd_get_hostkey (\fBpwm_t\fP * pwm, const char * host, int port, char ** result)"
987 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.
989 \fBParameters:\fP
990 .RS 4
991 \fIpwm\fP A handle. 
993 \fIhost\fP The hostname or IP to connect to. 
995 \fIport\fP The port or -1 for the default of 22. 
997 \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. 
1000 \fBReturns:\fP
1001 .RS 4
1002 0 on success or an error code.
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_async()\fP, \fBpwmd_ssh_connect()\fP, \fBSSH Details\fP 
1016 .SS "LIBPWMD_API gpg_error_t pwmd_get_hostkey_async (\fBpwm_t\fP * pwm, const char * host, int port)"
1018 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.
1020 \fBpwmd_process()\fP should be called until the command completes.
1022 \fBParameters:\fP
1023 .RS 4
1024 \fIpwm\fP A handle. 
1026 \fIhost\fP The hostname or IP to connect to. 
1028 \fIport\fP The port or -1 for the default of 22. 
1031 \fBReturns:\fP
1032 .RS 4
1033 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.
1036 \fBVersion:\fP
1037 .RS 4
1038 6.0.3 The connection is kept open but not verified after returning. It can be resumed from one of the SSH connection functions.
1041 \fBSee also:\fP
1042 .RS 4
1043 \fBpwmd_get_hostkey()\fP, \fBpwmd_ssh_connect_async()\fP, \fBpwmd_process()\fP, \fBSSH Details\fP 
1047 .SS "LIBPWMD_API gpg_error_t pwmd_getpin (\fBpwm_t\fP * pwm, const char * filename, char ** result, \fBpwmd_pinentry_t\fP which)"
1049 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.
1051 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.
1053 \fBParameters:\fP
1054 .RS 4
1055 \fIpwm\fP A handle. 
1057 \fIfilename\fP The filename to use in the pinentry dialog strings. 
1059 \fIresult\fP The entered value in the pinentry dialog which should be freed with \fBpwmd_free()\fP. 
1061 \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.
1064 \fBReturns:\fP
1065 .RS 4
1066 0 on success or an error. 
1070 .SS "LIBPWMD_API gpg_error_t pwmd_init (void)"
1072 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.
1074 \fBReturns:\fP
1075 .RS 4
1076 0 on success or an error code. 
1080 .SS "LIBPWMD_API gpg_error_t pwmd_inquire (\fBpwm_t\fP * pwm, const char * cmd, \fBpwmd_inquire_cb_t\fP func, void * user)"
1082 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.
1084 \fBParameters:\fP
1085 .RS 4
1086 \fIpwm\fP A handle. 
1088 \fIcmd\fP The \fBpwmd(1)\fP command to send including any options. 
1090 \fIfunc\fP A callback function of type \fBpwmd_inquire_cb_t\fP which sets the data to be sent. 
1092 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1095 \fBReturns:\fP
1096 .RS 4
1097 0 on success or an error code.
1100 \fBSee also:\fP
1101 .RS 4
1102 \fBpwmd_inquire_cb_t\fP 
1106 .SS "LIBPWMD_API void* pwmd_malloc (size_t size)"
1108 A wrapper around malloc. Like malloc(), but lets libpwmd keep track of the pointer.
1110 \fBParameters:\fP
1111 .RS 4
1112 \fIsize\fP The number of bytes to allocate. 
1115 \fBReturns:\fP
1116 .RS 4
1117 A newly allocated pointer or NULL if there wasn't enough memory. 
1120 \fBSee also:\fP
1121 .RS 4
1122 malloc(3), \fBpwmd_free()\fP 
1126 .SS "LIBPWMD_API \fBpwm_t\fP* pwmd_new (const char * name)"
1128 Creates a new handle. Creates a new handle for use with the other functions.
1130 \fBParameters:\fP
1131 .RS 4
1132 \fIname\fP If not NULL, the name of the application. The application name is sent to the pwmd server after successfully connecting.
1135 \fBReturns:\fP
1136 .RS 4
1137 a new handle or NULL if there was not enough memory. 
1141 .SS "LIBPWMD_API gpg_error_t pwmd_open (\fBpwm_t\fP * pwm, const char * filename)"
1143 Open a file on the pwmd server. This will send the OPEN command to the server.
1145 \fBParameters:\fP
1146 .RS 4
1147 \fIpwm\fP A handle. 
1149 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1152 \fBReturns:\fP
1153 .RS 4
1154 0 on success or an error code. 
1157 \fBSee also:\fP
1158 .RS 4
1159 \fBPinentry Details\fP 
1163 .SS "LIBPWMD_API gpg_error_t pwmd_open2 (\fBpwm_t\fP * pwm, const char * filename)"
1165 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.
1167 \fBNote:\fP
1168 .RS 4
1169 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.
1171 This pinentry method is not thread safe. It needs to set a couple of global variables for the pinentry timeout to work properly.
1174 \fBParameters:\fP
1175 .RS 4
1176 \fIpwm\fP A handle. 
1178 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1181 \fBReturns:\fP
1182 .RS 4
1183 0 on success or an error code. 
1186 \fBReturn values:\fP
1187 .RS 4
1188 \fIGPG_ERR_PIN_BLOCKED\fP Another handle is using the local pinentry. 
1191 \fBSee also:\fP
1192 .RS 4
1193 \fBPinentry Details\fP 
1197 .SS "LIBPWMD_API gpg_error_t pwmd_open_async (\fBpwm_t\fP * pwm, const char * filename)"
1199 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.
1201 \fBpwmd_process()\fP should be called until the command completes.
1203 \fBParameters:\fP
1204 .RS 4
1205 \fIpwm\fP A handle. 
1207 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1210 \fBReturns:\fP
1211 .RS 4
1212 0 on success or an error code. 
1215 \fBSee also:\fP
1216 .RS 4
1217 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1221 .SS "LIBPWMD_API gpg_error_t pwmd_open_async2 (\fBpwm_t\fP * pwm, const char * filename)"
1223 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.
1225 \fBpwmd_process()\fP should be called until the command completes.
1227 \fBNote:\fP
1228 .RS 4
1229 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.
1232 \fBParameters:\fP
1233 .RS 4
1234 \fIpwm\fP A handle. 
1236 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1239 \fBReturns:\fP
1240 .RS 4
1241 0 on success or an error code. 
1244 \fBSee also:\fP
1245 .RS 4
1246 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1250 .SS "LIBPWMD_API gpg_error_t pwmd_open_inquire (\fBpwm_t\fP * pwm, const char * filename, \fBpwmd_inquire_cb_t\fP func, void * user)"
1252 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.
1254 \fBNote:\fP
1255 .RS 4
1256 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.
1258 Pinentry is disabled when using this function.
1261 \fBParameters:\fP
1262 .RS 4
1263 \fIpwm\fP A handle. 
1265 \fIfilename\fP The filename to open. The \fIfilename\fP is not a full path but the data file only. 
1267 \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. 
1269 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1272 \fBReturns:\fP
1273 .RS 4
1274 0 on success or an error code. 
1277 \fBSee also:\fP
1278 .RS 4
1279 \fBPWMD_OPTION_BASE64\fP 
1283 .SS "LIBPWMD_API gpg_error_t pwmd_pending_line (\fBpwm_t\fP * pwm)"
1285 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.
1287 \fBParameters:\fP
1288 .RS 4
1289 \fIpwm\fP A handle. 
1292 \fBReturn values:\fP
1293 .RS 4
1294 \fI0\fP if there is a pending line. 
1296 \fIGPG_ERR_NO_DATA\fP if there is no pending line. 
1299 \fBSee also:\fP
1300 .RS 4
1301 \fBpwmd_process()\fP 
1305 .SS "LIBPWMD_API \fBpwmd_async_t\fP pwmd_process (\fBpwm_t\fP * pwm, gpg_error_t * rc, char ** result)"
1307 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.
1309 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.
1311 \fBParameters:\fP
1312 .RS 4
1313 \fIpwm\fP A handle. 
1315 \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. 
1317 \fIresult\fP Set to the result of the command when \fIrc\fP is 0. Note that not all commands return a result. 
1320 \fBReturn values:\fP
1321 .RS 4
1322 \fIASYNC_DONE\fP The command has completed. \fIrc\fP should be checked to determine if the command was successful or not. 
1324 \fIASYNC_PROCESS\fP The command is still running and this function should be called again. 
1327 \fBSee also:\fP
1328 .RS 4
1329 \fBpwmd_get_fds()\fP, \fBpwmd_pending_line()\fP 
1333 .SS "LIBPWMD_API void* pwmd_realloc (void * ptr, size_t size)"
1335 A wrapper around realloc(). Like realloc(), but lets libpwmd keep track of the pointer.
1337 \fBNote:\fP
1338 .RS 4
1339 This function will try and allocate the entire \fIsize\fP before freeing the original pointer and returning the new one.
1342 \fBParameters:\fP
1343 .RS 4
1344 \fIptr\fP The pointer to reallocate. 
1346 \fIsize\fP The new number of bytes to allocate. 
1349 \fBReturns:\fP
1350 .RS 4
1351 A newly allocated pointer or NULL if there wasn't enough memory. 
1354 \fBSee also:\fP
1355 .RS 4
1356 realloc(3), \fBpwmd_free()\fP 
1360 .SS "LIBPWMD_API gpg_error_t pwmd_save (\fBpwm_t\fP * pwm)"
1362 Save a file on the pwmd server. This will send the SAVE command.
1364 \fBParameters:\fP
1365 .RS 4
1366 \fIpwm\fP A handle. 
1369 \fBReturns:\fP
1370 .RS 4
1371 0 on success or an error code. 
1374 \fBSee also:\fP
1375 .RS 4
1376 \fBPinentry Details\fP 
1380 .SS "LIBPWMD_API gpg_error_t pwmd_save2 (\fBpwm_t\fP * pwm)"
1382 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.
1384 \fBParameters:\fP
1385 .RS 4
1386 \fIpwm\fP A handle. 
1389 \fBReturns:\fP
1390 .RS 4
1391 0 on success or an error code. 
1394 \fBSee also:\fP
1395 .RS 4
1396 \fBPinentry Details\fP 
1400 .SS "LIBPWMD_API gpg_error_t pwmd_save_async (\fBpwm_t\fP * pwm)"
1402 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.
1404 \fBpwmd_process()\fP should be called until the command completes.
1406 \fBParameters:\fP
1407 .RS 4
1408 \fIpwm\fP A handle. 
1411 \fBReturns:\fP
1412 .RS 4
1413 0 on success or an error code. 
1416 \fBSee also:\fP
1417 .RS 4
1418 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1422 .SS "LIBPWMD_API gpg_error_t pwmd_save_async2 (\fBpwm_t\fP * pwm)"
1424 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.
1426 \fBpwmd_process()\fP should be called until the command completes.
1428 \fBParameters:\fP
1429 .RS 4
1430 \fIpwm\fP A handle. 
1433 \fBReturns:\fP
1434 .RS 4
1435 0 on success or an error code. 
1438 \fBSee also:\fP
1439 .RS 4
1440 \fBpwmd_process()\fP, \fBPinentry Details\fP 
1444 .SS "LIBPWMD_API gpg_error_t pwmd_save_inquire (\fBpwm_t\fP * pwm, \fBpwmd_inquire_cb_t\fP func, void * user)"
1446 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.
1448 \fBNote:\fP
1449 .RS 4
1450 Pinentry is disabled when using this function.
1453 \fBParameters:\fP
1454 .RS 4
1455 \fIpwm\fP A handle. 
1457 \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. 
1459 \fIuser\fP A user data pointer passed to the callback function \fIfunc\fP. 
1462 \fBReturns:\fP
1463 .RS 4
1464 0 on success or an error code. 
1467 \fBSee also:\fP
1468 .RS 4
1469 \fBPWMD_OPTION_BASE64\fP 
1473 .SS "LIBPWMD_API gpg_error_t pwmd_setopt (\fBpwm_t\fP * pwm, \fBpwmd_option_t\fP opt,  ...)"
1475 Set handle options. See \fBpwmd_option_t\fP for option specific details.
1477 \fBParameters:\fP
1478 .RS 4
1479 \fIpwm\fP A handle. 
1481 \fIopt\fP The option and following value. 
1484 \fBReturns:\fP
1485 .RS 4
1486 0 on success or an error code. 
1490 .SS "LIBPWMD_API gpg_error_t pwmd_socket_type (\fBpwm_t\fP * pwm, \fBpwmd_socket_t\fP * type)"
1492 The type of connection a handle has. Useful when you want to know what kind of connection a handle has.
1494 \fBParameters:\fP
1495 .RS 4
1496 \fIpwm\fP A handle. 
1498 \fItype\fP The type of socket. 
1501 \fBReturns:\fP
1502 .RS 4
1503 0 on success or an error code. 
1506 \fBSee also:\fP
1507 .RS 4
1508 \fBpwmd_connect_url()\fP 
1512 .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)"
1514 Establish a remote connection to a pwmd server. Connects to a pwmd server over an SSH channel.
1516 \fBParameters:\fP
1517 .RS 4
1518 \fIpwm\fP A handle. 
1520 \fIhost\fP The hostname to connect to or NULL to resume a connection previously started with \fBpwmd_get_hostkey()\fP. 
1522 \fIport\fP The port or -1 for the default of 22. 
1524 \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. 
1526 \fIuser\fP The username on the SSH server to login as. If NULL then invoking username will be used. 
1528 \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. 
1531 \fBReturns:\fP
1532 .RS 4
1533 0 on success or an error code. 
1536 \fBNote:\fP
1537 .RS 4
1538 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1541 \fBSee also:\fP
1542 .RS 4
1543 \fBpwmd_ssh_connect_async()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1547 .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)"
1549 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.
1551 \fBpwmd_process()\fP should be called until the command completes.
1553 \fBParameters:\fP
1554 .RS 4
1555 \fIpwm\fP A handle. 
1557 \fIhost\fP The hostname to connect to or NULL to resume a connection previously started with \fBpwmd_get_hostkey()\fP. 
1559 \fIport\fP The port or -1 for the default of 22. 
1561 \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. 
1563 \fIuser\fP The username on the SSH server to login as. If NULL, the invoking username will be used. 
1565 \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. 
1568 \fBReturns:\fP
1569 .RS 4
1570 0 on success or an error code. 
1573 \fBNote:\fP
1574 .RS 4
1575 When the first character of a filename parameter is a tilde (~), it will be expanded to the home directory of the current user. 
1578 \fBSee also:\fP
1579 .RS 4
1580 \fBpwmd_process()\fP, \fBPWMD_OPTION_IP_VERSION\fP, \fBpwmd_disconnect()\fP, \fBSSH Details\fP 
1584 .SS "LIBPWMD_API char* pwmd_strdup (const char * str)"
1586 A wrapper around strdup(). Like strdup(), but lets libpwmd keep track of the pointer.
1588 \fBParameters:\fP
1589 .RS 4
1590 \fIstr\fP The string to duplicate. 
1593 \fBReturns:\fP
1594 .RS 4
1595 A newly allocated character pointer or NULL if there wasn't enough memory. 
1598 \fBSee also:\fP
1599 .RS 4
1600 strdup(3), \fBpwmd_free()\fP 
1604 .SS "LIBPWMD_API char* pwmd_strdup_printf (const char * fmt,  ...)"
1606 Duplicate a formatted string. Like \fBsprintf(3)\fP but returns an allocated string.
1608 \fBParameters:\fP
1609 .RS 4
1610 \fIfmt\fP The formatted string and any following arguments. 
1613 \fBReturns:\fP
1614 .RS 4
1615 A newly allocated character pointer or NULL if there wasn't enough memory. 
1618 \fBSee also:\fP
1619 .RS 4
1620 \fBpwmd_free()\fP 
1624 .SS "LIBPWMD_API const char* pwmd_strerror (gpg_error_t code)"
1626 Return a description of an error code. \fBParameters:\fP
1627 .RS 4
1628 \fIcode\fP The error code to describe. 
1631 \fBReturns:\fP
1632 .RS 4
1633 A character description of the error code. 
1636 \fBSee also:\fP
1637 .RS 4
1638 \fBpwmd_strerror_r()\fP 
1642 .SS "LIBPWMD_API int pwmd_strerror_r (gpg_error_t code, char * buf, size_t size)"
1644 Return a description of an error code (thread-safe). This is a thread-safe version of \fBpwmd_strerror()\fP.
1646 \fBParameters:\fP
1647 .RS 4
1648 \fIcode\fP The error code to describe. 
1650 \fIbuf\fP An allocated buffer to hold the error description. 
1652 \fIsize\fP The size of the allocated buffer \fIbuf\fP.
1655 \fBReturn values:\fP
1656 .RS 4
1657 \fI0\fP Success. 
1659 \fIERANGE\fP \fIsize\fP was not large enough to hold the entire description and \fIbuf\fP is set to the truncated error string. 
1663 .SS "LIBPWMD_API const char* pwmd_version ()"
1665 Returns this version of libpwmd. As a string. 
1667 \fBReturns:\fP
1668 .RS 4
1669 A string. 
1673 .SH "Author"
1674 .PP 
1675 Generated automatically by Doxygen for libpwmd from the source code.