Make sure the STORE command has following data.
[libpwmd.git] / libpwmd.3.in
blob71e352ed8002c3ac80f6b9bfc73e0c6d70016c12
1 .\" This program is free software; you can redistribute it and/or modify
2 .\" it under the terms of the GNU General Public License as published by
3 .\" the Free Software Foundation; either version 2 of the License, or
4 .\" (at your option) any later version.
5 .\" 
6 .\" This program is distributed in the hope that it will be useful,
7 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
8 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 .\" GNU General Public License for more details.
10 .\" 
11 .\" You should have received a copy of the GNU General Public License
12 .\" along with this program; if not, write to the Free Software
13 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
14 .de URL
15 \\$2 \(laURL: \\$1 \(ra\\$3
17 .if \n[.g] .mso www.tmac
18 .TH LIBPWMD 3 "19 Nov 2007" "Password Manager Daemon Library" "Password Manager Daemon Library"
19 .SH NAME
21 libpwmd \- pwmd client interface library
22 .SH SYNOPSIS
23 .nf
24 .B #include <libpwmd.h>
25 .sp
26 .BI "gpg_error_t pwmd_init(void);"
27 .BI "pwm_t *pwmd_connect(const char *" socket ", gpg_error_t *" error ");"
28 .BI "gpg_error_t pwmd_setopt(pwm_t *" pwm ", pwmd_option_t " opt ", ...);"
29 .BI "gpg_error_t pwmd_open(pwm_t *" pwm ", const char *" filename ");"
30 .BI "int pwmd_open_nb(pwm_t *" pwm ", gpg_error_t *" error ", const char *" filename ", int " timeout ");"
31 .BI "gpg_error_t pwmd_open_nb_finalize(pwm_t *" pwm ", pwmd_nb_status_t *" status ");"
32 .BI "gpg_error_t pwmd_command(pwm_t *" pwm ", char **" result ", const char *" cmd ", " ... ");"
33 .BI "gpg_error_t pwmd_inquire(pwm_t *" pwm ", const char *" command ");"
34 .BI "gpg_error_t pwmd_inquire_process(pwm_t *" pwm ", const void *" buf ", size_t " len ");"
35 .BI "gpg_error_t pwmd_inquire_finish(pwm_t *" pwm ");"
36 .BI "void pwmd_free_result(void *" result ");"
37 .BI "gpg_error_t pwmd_save(pwm_t *" pwm ");"
38 .BI "int pwmd_save_nb(pwm_t *" pwm ", gpg_error_t *" error ");"
39 .BI "gpg_error_t pwmd_save_nb_finalize(pwm_t *" pwm ", pwmd_nb_status_t *" status ");"
40 .BI "gpg_error_t pwmd_terminate_pinentry(pwm_t *" pwm ");"
41 .BI "void pwmd_close(pwm_t *" pwm ");"
42 .BI "const char *pwmd_strerror(gpg_error_t " error ");"
44 .BI "typedef int (*" pwmd_status_fn ")(void *" data ", const char *" line ");"
45 .BI "typedef char *(*" pwmd_password_fn ")(pwm_t *" pwm ", void *" data ");"
46 .fi
47 .SH DESCRIPTION
48 .B libpwmd
49 is an library making it easy for applications to use
50 .BR pwmd (1).
52 .TP
53 .BI "gpg_error_t pwmd_init(void);"
54 Initializes \fBlibpwmd\fP, \fBlibassuan\fP, \fBlibgpg-error\fP and
55 internationalization. Be sure to call this before using the other functions.
56 If your application uses
57 .BR gettext(3)
58 be sure to call
59 .BR setlocale(3)
60 and
61 .BR textdomain(3)
62 before calling this function.
64 .TP
65 .BI "pwm_t *pwmd_connect(const char *" socket ", gpg_error_t *" error ");"
66 Connects to the specified \fIsocket\fP. If \fIsocket\fP is NULL then a default
67 of \fI~/.pwmd/socket\fP will be used. If there is an error while connecting
68 \fIerror\fP is set to the error code of the failed function and NULL is
69 returned. When successful a handle is returned for use with the other library
70 functions.
72 .TP
73 .BI "gpg_error_t pwmd_setopt(pwm_t *" pwm ", pwmd_option_t " opt ", ...);"
74 Set the library option \fIopt\fP to the value of the next argument. Returns 0
75 on success or an error code. \fIopt\fP is one of the following:
76 .RS
77 .TP
78 .B PWMD_OPTION_PASSWORD_FUNC
79 Specifies a function to use to get a password. The next argument should be of
80 type \fIpwmd_password_fn\fP. The function should return a \fIchar
81 *\fP string which is the password or NULL if there is an
82 error.
83 .TP
84 .B PWMD_OPTION_PASSWORD_DATA
85 A user data pointer passed to the password function.
86 .TP
87 .B PWMD_OPTION_PINENTRY
88 Whether to use 
89 .BR pinentry (1)
90 to obtain the password when opening and saving a file on the server. The
91 following argument is an \fIint\fP and is \fI1\fP to enable
92 .BR pinentry (1)
93 use, and \fI0\fP to use the password which is set with
94 \fBPWMD_OPTION_PASSWORD\fP or \fBPWMD_OPTION_PASSWORD_FUNC\fP.
95 .TP
96 .B PWMD_OPTION_PINENTRY_TRIES
97 The next argument if type \fIint\fP specifies the number of invalid password
98 tries before
99 .BR pinentry (1)
100 gives up. Only \fBpwmd_open\fP() and \fBpwmd_open_nb\fP() will use this
101 option. \fBpwmd_save\fP() and \fBpwmd_save_nb\fP() will continue to confirm a
102 password until either a match is entered or Cancel is selected.
104 .B PWMD_OPTION_PINENTRY_TTY
106 .B PWMD_OPTION_PINENTRY_TERM
108 .B PWMD_OPTION_PINENTRY_DISPLAY
109 Sets the
110 .BR pinentry (1)
111 command line options. The next argument should be of type \fIchar *\fP. If not
112 set, then the current DISPLAY, if set, or tty will be used.
115 If the file \fI~/.pwmd/env\fP exists then values for the above settings will
116 read from this file. The format of the file is one NAME=VALUE per line where
117 NAME is one of TTY, TERM or DISPLAY. The value for an existing setting will be
118 updated to the value contained in the file.
121 .B PWMD_OPTION_PINENTRY_TITLE
123 .B PWMD_OPTION_PINENTRY_DESC
125 .B PWMD_OPTION_PINENTRY_PROMPT
126 Sets the strings used in the 
127 .BR pinentry (1)
128 program.
129 The next argument is of type \fIchar *\fP. If not defined then a default will
130 be used.
132 .B PWMD_OPTION_PASSWORD
133 Sets the password to use for opening and saving a file when
134 \fBPWMD_OPTION_PINENTRY\fP is \fI0\fP. The following argument is the password
135 and is of type \fIchar *\fP.
137 .B PWMD_OPTION_STATUS_FUNC
139 .B PWMD_OPTION_STATUS_DATA
140 Function to be called when 
141 .BR pwmd (1)
142 sends a status message. This function should return \fB0\fP on success or a
143 \fBgpg_error_t\fP on failure. The data passed to the function can be set with
144 \fBPWMD_OPTION_STATUS_DATA\fP. Status message lines are prefixed with a
145 keyword followed by a space then the message. Read the \fBlibassuan\fP
146 documentation for more information. 
151 .BI "gpg_error_t pwmd_open(pwm_t *" pwm ", const char *" filename ");"
152 Opens the specified \fIfilename\fP on the server. The password for the file is
153 gotten from one of the methods specified with \fBpwmd_setopt\fP().
154 An error code is returned on error or \fB0\fP on success.
157 .BI "int pwmd_open_nb(pwm_t *" pwm ", gpg_error_t *" error ", const char *" filename ", int " timeout ");"
158 This is a nonblocking way of obtaining the password from
159 .BR pinentry (1)
160 when opening a file on the server. When successful, it returns a file
161 descriptor that
162 .BR select (2)
163 can use. When ready,
164 .BR read (2)
165 should read a \fIpwmd_nb_status_t\fP and then call
166 \fBpwmd_open_nb_finalize\fP() to update the handle. If there is an error,
167 \fB-1\fP is returned and \fIerror\fP is set. If \fIfilename\fP is already
168 cached on the server or doesn't exist on the filesystem and the open
169 succeeded, \fB-2\fP is returned. The \fItimeout\fP argument is the number of
170 seconds until the pinentry process will terminate. If \fB0\fP, the default, no
171 timeout will be used. Note that \fBPWMD_OPTION_PINENTRY\fP must be set and
172 that if a timeout is specified then the child process will modify it's
173 \fBSIGALRM\fP handler.
176 .BI "gpg_error_t pwmd_open_nb_finalize(pwm_t *" pwm ", pwmd_nb_status_t *" status ");"
177 For use with \fBpwmd_open_nb\fP(); it updates the handle \fIpwm\fP and closes
178 the file descriptor. This should be called right after the successful
179 .BR read (2)
180 of \fIstatus\fP from the file descriptor returned by \fBpwmd_open_nb\fP(). If
181 there was a protocol or
182 .BR pinentry (1)
183 error, an error code is returned. Otherwise \fB0\fP is returned.
186 .BI "gpg_error_t pwmd_command(pwm_t *" pwm ", char **" result ", const char *" cmd ", " ... ");"
187 Sends a protocol command to the server. The function returns \fB0\fP
188 when successful and stores the result of the command format string \fIcmd\fP
189 to \fIresult\fP. The result should be free'd with \fBpwmd_free_result\fP().
190 Protocol commands that don't have a result will set \fIresult\fP to NULL. If
191 an error occurs then an error code is returned. Note: the BYE protocol
192 command should not be sent here. Use \fBpwmd_close\fP() instead.
195 .BI "gpg_error_t pwmd_inquire(pwm_t *" pwm ", const char *" command ");"
196 For use with commands that use the libassuan INQUIRE protocol command (e.g.,
197 STORE). It initializes a data connection to the server using the inquire
198 \fIcommand\fP. Returns \fB0\fP on success or an error code. Note that these
199 inquire functions are less descriptive about errors and you'll probably have a
200 better error message in the pwmd logs.
203 .BI "gpg_error_t pwmd_inquire_process(pwm_t *" pwm ", const void *" buf ", size_t" len ");"
204 After calling \fBpwmd_inquire()\fP, call this function repeatedly until all of
205 your data has been sent. Returns \fB0\fP on success or an error code.
208 .BI "gpg_error_t pwmd_inquire_finish(pwm_t *" pwm ");"
209 After all data has been processed with \fBpwmd_inquire_process()\fP, call this
210 function to end the command. Returns \fB0\fP on success or an error code.
213 .BI "void pwmd_free_result(void *" result ");"
214 Deallocates the memory of \fBpwmd_command\fP() result. It is important to use
215 this function because
216 .B libpwmd
217 not only keeps track of all allocated memory used by other
218 .B libpwmd
219 functions, but also clears the memory contents for better security. Don't use
220 this to free your own allocated memory though.
223 .BI "gpg_error_t pwmd_save(pwm_t *" pwm ");"
224 Saves the changes to the file associated with the handle \fIpwm\fP. If not
225 called before \fBpwmd_close\fP() then any changes will be lost. If an error
226 occurs then an error code is returned. Otherwise \fB0\fP is returned.
229 .BI "int pwmd_save_nb(pwm_t *" pwm ", gpg_error_t *" error ");"
230 This is a nonblocking way of obtaining the password from
231 .BR pinentry (1)
232 when saving an opened file. When successful, a file descriptor is returned
233 that
234 .BR select (2)
235 can use. When ready
236 .BR read (2)
237 should read a \fIpwmd_nb_status_t\fP and then call
238 \fBpwmd_save_nb_finalize\fP() to update the handle. If there was an error,
239 \fB-1\fP is returned and \fIerror\fP is set. If the file is cached on the
240 server and the save succeeded, \fB-2\fP is returned. Note that
241 \fBPWMD_OPTION_PINENTRY\fP must be set.
244 .BI "gpg_error_t pwmd_save_nb_finalize(pwm_t *" pwm ", pwmd_nb_status_t *" status ");"
245 For use with \fBpwmd_save_nb\fP(); it updates the handle \fIpwm\fP and closes
246 the file descriptor. This should be called right after the successful
247 .BR read (2)
248 of \fIstatus\fP from the file descriptor returned by \fBpwmd_save_nb\fP(). If
249 there was a protocol or
250 .BR pinentry (1)
251 error, an error code is returned. Otherwise \fB0\fP is returned.
254 .BI "gpg_error_t pwmd_terminate_pinentry(pwm_t *" pwm ");"
255 Terminates a
256 .BR pinentry (1)
257 process associated with the handle \fIpwm\fP. This may be useful if your
258 application wants to use a timeout for password entry but doesn't use
259 \fBpwmd_open_nb\fP(). Returns \fB0\fP on success or an error code on failure.
262 .BI "void pwmd_close(pwm_t *" pwm ");"
263 Closes the server connection and free's resources used by the handle
264 \fIpwm\fP.
267 .BI "const char *pwmd_strerror(gpg_error_t " error ");"
268 Returns a string describing the error code \fIerror\fP which was set from one
269 of the above functions.
271 .SH FILES
273 .B ~/.pwmd/socket
274 Default connecting socket.
276 .B ~/.pwmd/env
277 Optional file containing pinentry settings.
279 .B @prefix@/lib/pkgconfig/libpwmd.pc
281 .BR pkg-config (1)
282 metadata file.
284 .B @prefix@/include/libpwmd.h
285 Installed location of header file.
287 .B @pinentry_path@
288 Default location of the
289 .BR pinentry (1)
290 binary.
292 .SH AUTHOR
293 Ben Kibbey <bjk@luxsci.net>
295 .URL "http://bjk.sourceforge.net/pwmd/" "PWMD Homepage" .
297 .SH "SEE ALSO"
298 .BR pwmd (1),
299 .BR pinentry (1),
300 .BR pkg-config (1)
302 And the \fBlibassuan\fP
303 .BR info (1)
304 documentation.