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.
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.
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
15 \\$2 \(laURL: \\$1 \(ra\\$3
17 .if \n[.g] .mso www.tmac
18 .TH LIBPWMD 3 "12 Jul 2007" "Password Manager Daemon Library" "Password Manager Daemon Library"
21 libpwmd \- pwmd client interface library
24 .B #include <libpwmd.h>
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 "void pwmd_free_result(void *" result ");"
34 .BI "gpg_error_t pwmd_save(pwm_t *" pwm ");"
35 .BI "int pwmd_save_nb(pwm_t *" pwm ", gpg_error_t *" error ");"
36 .BI "gpg_error_t pwmd_save_nb_finalize(pwm_t *" pwm ", pwmd_nb_status_t *" status ");"
37 .BI "gpg_error_t pwmd_terminate_pinentry(pwm_t *" pwm ");"
38 .BI "void pwmd_close(pwm_t *" pwm ");"
39 .BI "const char *pwmd_strerror(gpg_error_t " error ");"
41 .BI "typedef int (*" pwmd_status_fn ")(void *" data ", const char *" line ");"
42 .BI "typedef char *(*" pwmd_password_fn ")(pwm_t *" pwm ", void *" data ");"
46 is an library making it easy for applications to use
50 .BI "gpg_error_t pwmd_init(void);"
51 Initializes \fBlibpwmd\fP, \fBlibassuan\fP, \fBlibgpg-error\fP and
52 internationalization. Be sure to call this before using the other functions.
53 If your application uses
59 before calling this function.
62 .BI "pwm_t *pwmd_connect(const char *" socket ", gpg_error_t *" error ");"
63 Connects to the specified \fIsocket\fP. If \fIsocket\fP is NULL then a default
64 of \fI~/.pwmd/socket\fP will be used. If there is an error while connecting
65 \fIerror\fP is set to the error code of the failed function and NULL is
66 returned. When successful a handle is returned for use with the other library
70 .BI "gpg_error_t pwmd_setopt(pwm_t *" pwm ", pwmd_option_t " opt ", ...);"
71 Set the library option \fIopt\fP to the value of the next argument. Returns 0
72 on success or an error code. \fIopt\fP is one of the following:
75 .B PWMD_OPTION_PASSWORD_FUNC
76 Specifies a function to use to get a password. The next argument should be of
77 type \fIpwmd_password_fn\fP. The function should return a \fIchar
78 *\fP string which is the password or NULL if there is an
81 .B PWMD_OPTION_PASSWORD_DATA
82 A user data pointer passed to the password function.
84 .B PWMD_OPTION_PINENTRY
87 to obtain the password when opening and saving a file on the server. The
88 following argument is an \fIint\fP and is \fI1\fP to enable
90 use, and \fI0\fP to use the password which is set with
91 \fBPWMD_OPTION_PASSWORD\fP or \fBPWMD_OPTION_PASSWORD_FUNC\fP.
93 .B PWMD_OPTION_PINENTRY_TRIES
94 The next argument if type \fIint\fP specifies the number of invalid password
97 gives up. Only \fBpwmd_open\fP() and \fBpwmd_open_nb\fP() will use this
98 option. \fBpwmd_save\fP() and \fBpwmd_save_nb\fP() will continue to confirm a
99 password until either a match is entered or Cancel is selected.
101 .B PWMD_OPTION_PINENTRY_TTY
103 .B PWMD_OPTION_PINENTRY_TERM
105 .B PWMD_OPTION_PINENTRY_DISPLAY
108 command line options. The next argument should be of type \fIchar *\fP. If not
109 set, then the current DISPLAY, if set, or tty will be used.
112 If the file \fI~/.pwmd/env\fP exists then values for the above settings will
113 read from this file. The format of the file is one NAME=VALUE per line where
114 NAME is one of TTY, TERM or DISPLAY. The value for an existing setting will be
115 updated to the value contained in the file.
118 .B PWMD_OPTION_PINENTRY_TITLE
120 .B PWMD_OPTION_PINENTRY_DESC
122 .B PWMD_OPTION_PINENTRY_PROMPT
123 Sets the strings used in the
126 The next argument is of type \fIchar *\fP. If not defined then a default will
129 .B PWMD_OPTION_PASSWORD
130 Sets the password to use for opening and saving a file when
131 \fBPWMD_OPTION_PINENTRY\fP is \fI0\fP. The following argument is the password
132 and is of type \fIchar *\fP.
134 .B PWMD_OPTION_STATUS_FUNC
136 .B PWMD_OPTION_STATUS_DATA
137 Function to be called when
139 sends a status message. This function should return \fB0\fP on success or a
140 \fBgpg_error_t\fP on failure. The data passed to the function can be set with
141 \fBPWMD_OPTION_STATUS_DATA\fP. Status message lines are prefixed with a
142 keyword followed by a space then the message. Read the \fBlibassuan\fP
143 documentation for more information.
148 .BI "gpg_error_t pwmd_open(pwm_t *" pwm ", const char *" filename ");"
149 Opens the specified \fIfilename\fP on the server. The password for the file is
150 gotten from one of the methods specified with \fBpwmd_setopt\fP().
151 An error code is returned on error or \fB0\fP on success.
154 .BI "int pwmd_open_nb(pwm_t *" pwm ", gpg_error_t *" error ", const char *" filename ", int " timeout ");"
155 This is a nonblocking way of obtaining the password from
157 when opening a file on the server. When successful, it returns a file
162 should read a \fIpwmd_nb_status_t\fP and then call
163 \fBpwmd_open_nb_finalize\fP() to update the handle. If there is an error,
164 \fB-1\fP is returned and \fIerror\fP is set. If \fIfilename\fP is already
165 cached on the server or doesn't exist on the filesystem and the open
166 succeeded, \fB-2\fP is returned. The \fItimeout\fP argument is the number of
167 seconds until the pinentry process will terminate. If \fB0\fP, the default, no
168 timeout will be used. Note that \fBPWMD_OPTION_PINENTRY\fP must be set and
169 that if a timeout is specified then the child process will modify it's
170 \fBSIGALRM\fP handler.
173 .BI "gpg_error_t pwmd_open_nb_finalize(pwm_t *" pwm ", pwmd_nb_status_t *" status ");"
174 For use with \fBpwmd_open_nb\fP(); it updates the handle \fIpwm\fP and closes
175 the file descriptor. This should be called right after the successful
177 of \fIstatus\fP from the file descriptor returned by \fBpwmd_open_nb\fP(). If
178 there was a protocol or
180 error, an error code is returned. Otherwise \fB0\fP is returned.
183 .BI "gpg_error_t pwmd_command(pwm_t *" pwm ", char **" result ", const char *" cmd ", " ... ");"
184 Sends a protocol command to the server. The function returns \fB0\fP
185 when successful and stores the result of the command format string \fIcmd\fP
186 to \fIresult\fP. The result should be free'd with \fBpwmd_free_result\fP().
187 Protocol commands that don't have a result will set \fIresult\fP to NULL. If
188 an error occurs then an error code is returned. Note: the BYE protocol
189 command should not be sent here. Use \fBpwmd_close\fP() instead.
192 .BI "void pwmd_free_result(void *" result ");"
193 Deallocates the memory of \fBpwmd_command\fP() result. It is important to use
194 this function because
196 not only keeps track of all allocated memory used by other
198 functions, but also clears the memory contents for better security. Don't use
199 this to free your own allocated memory though.
202 .BI "gpg_error_t pwmd_save(pwm_t *" pwm ");"
203 Saves the changes to the file associated with the handle \fIpwm\fP. If not
204 called before \fBpwmd_close\fP() then any changes will be lost. If an error
205 occurs then an error code is returned. Otherwise \fB0\fP is returned.
208 .BI "int pwmd_save_nb(pwm_t *" pwm ", gpg_error_t *" error ");"
209 This is a nonblocking way of obtaining the password from
211 when saving an opened file. When successful, a file descriptor is returned
216 should read a \fIpwmd_nb_status_t\fP and then call
217 \fBpwmd_save_nb_finalize\fP() to update the handle. If there was an error,
218 \fB-1\fP is returned and \fIerror\fP is set. If the file is cached on the
219 server and the save succeeded, \fB-2\fP is returned. Note that
220 \fBPWMD_OPTION_PINENTRY\fP must be set.
223 .BI "gpg_error_t pwmd_save_nb_finalize(pwm_t *" pwm ", pwmd_nb_status_t *" status ");"
224 For use with \fBpwmd_save_nb\fP(); it updates the handle \fIpwm\fP and closes
225 the file descriptor. This should be called right after the successful
227 of \fIstatus\fP from the file descriptor returned by \fBpwmd_save_nb\fP(). If
228 there was a protocol or
230 error, an error code is returned. Otherwise \fB0\fP is returned.
233 .BI "gpg_error_t pwmd_terminate_pinentry(pwm_t *" pwm ");"
236 process associated with the handle \fIpwm\fP. This may be useful if your
237 application wants to use a timeout for password entry but doesn't use
238 \fBpwmd_open_nb\fP(). Returns \fB0\fP on success or an error code on failure.
241 .BI "void pwmd_close(pwm_t *" pwm ");"
242 Closes the server connection and free's resources used by the handle
246 .BI "const char *pwmd_strerror(gpg_error_t " error ");"
247 Returns a string describing the error code \fIerror\fP which was set from one
248 of the above functions.
253 Default connecting socket.
256 Optional file containing pinentry settings.
258 .B @prefix@/lib/pkgconfig/libpwmd.pc
263 .B @prefix@/include/libpwmd.h
264 Installed location of header file.
267 Ben Kibbey <bjk@luxsci.net>
269 .URL "http://bjk.sourceforge.net/pwmd/" "PWMD Homepage" .
276 And the \fBlibassuan\fP