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 "4 Jul 2007" "Password Manager Daemon Library" "Password Manager Daemon Library"
21 libpwmd \- pwmd client interface library
24 .B #include <libpwmd.h>
26 .BI "pwmd_error_t pwmd_init(void);"
27 .BI "pwm_t *pwmd_connect(const char " *socket ", gpg_error_t " *error ");"
28 .BI "int pwmd_get_password(pwm_t " *pwm ", gpg_error_t " *error ", const char " *filename ");"
29 .BI "pwmd_error_t pwmd_setopt(pwm_t " *pwm ", gpg_error_t " *error ", pwmd_option_t " opt ", ...);"
30 .BI "pwmd_error_t pwmd_open(pwm_t " *pwm ", gpg_error_t " *error ", const char " *filename ");"
31 .BI "pwmd_error_t pwmd_command(pwm_t " *pwm ", char " **result ", gpg_error_t " *error ", const char " *cmd ", " ... ");"
32 .BI "void pwmd_free_result(void " *result ");"
33 .BI "pwmd_error_t pwmd_save(pwm_t " *pwm ", gpg_error_t " *error ");"
34 .BI "void pwmd_close(pwm_t " *pwm ");"
35 .BI "const char *pwmd_strerror(gpg_error_t " error ");"
37 .BI "typedef int (*" pwmd_status_func ")(void *" data ", const char *" line ");"
38 .BI "typedef char *(*" pwmd_password_func ")(void *" data ");"
40 .BI "typedef struct {"
41 .BI " char " password[ASSUAN_LINELENGTH] ";"
42 .BI " gpg_error_t " error ";"
43 .BI "} " pwmd_password_t ";"
47 is an library making it easy for applications to use
51 .B "pwmd_error_t pwmd_init(void);"
52 Initializes libassuan and libgpg-error stuff. Be sure to call this before
53 using the other functions.
56 .B "pwm_t *pwmd_connect(const char " *socket ", gpg_error_t " *error ");"
57 \fBpwmd_connect\fP() connects to the specified \fIsocket\fP. If \fIsocket\fP
58 is NULL then a default of \fI~/.pwmd/socket\fP will be used. If there is an
59 error while connecting \fIerror\fP is set to the error code of the failed
60 function and NULL is returned. When successful a handle is returned for use in
61 the other library functions.
64 .B "int pwmd_get_password(pwm_t " *pwm ", gpg_error_t " *error ", const char " *filename ");"
65 This is a non-blocking
67 password retrieval function. When successful it returns a file descriptor that
69 can use to determine when a password can be read with
71 to open the file \fIfilename\fP.
73 should read a \fIpwmd_password_s\fP and check \fI.error\fP for an
74 error code returned by
76 If there is an error during
80 the function returns -1 and \fIerror\fP is set to the error code of the failed
81 function. If the file is cached on the server or the file is nonexistant, a
82 password is not needed and -2 is returned. After the password has been gotten,
83 call \fBpwmd_setopt\fP() to set the password and make sure
84 .B PWMD_OPTION_PINENTRY
85 is unset. Security note: it's up to the caller to clear the password; usually
90 .B "pwmd_error_t pwmd_setopt(pwm_t " *pwm ", gpg_error_t " *error ", pwmd_option_t " opt ", ...);"
91 \fBpwmd_setopt\fP() set the library option \fIopt\fP to the value of the next
92 argument where \fIopt\fP is one of the following:
95 .B PWMD_OPTION_PASSWORD_FUNC
96 Specifies a function to use to get a password. The next argument should be of
97 type \fBpwmd_password_func\fP. The function should return a \fIchar
98 *\fP string which is the password or NULL if there is an
101 .B PWMD_OPTION_PASSWORD_DATA
102 A user data pointer passed to the password function.
104 .B PWMD_OPTION_PINENTRY
107 to obtain the password when opening and saving a file on the server. The
108 following argument is an \fIint\fP and is \fI1\fP to enable
110 use, and \fI0\fP to use the password which is set with
111 \fBPWMD_OPTION_PASSWORD\fP.
113 .B PWMD_OPTION_PINENTRY_TTY
115 .B PWMD_OPTION_PINENTRY_TERM
117 .B PWMD_OPTION_PINENTRY_DISPLAY
120 command line options. The next argument should be of type \fIchar *\fP. If not
121 set, then the current DISPLAY, if set, or tty will be used.
123 .B PWMD_OPTION_PINENTRY_TITLE
125 .B PWMD_OPTION_PINENTRY_DESC
127 .B PWMD_OPTION_PINENTRY_PROMPT
128 Sets the strings used in the
131 The next argument is of type \fIchar *\fP. If not defined then a default will
134 .B PWMD_OPTION_PASSWORD
135 Sets the password to use for opening and saving a file when
136 \fBPWMD_OPTION_PINENTRY\fP is \fI0\fP. The following argument is the password
137 and is of type \fIchar *\fP.
139 .B PWMD_OPTION_STATUS_FUNC
141 .B PWMD_OPTION_STATUS_DATA
142 Function to be called when
144 sends a status message. This function should return \fB0\fP on success or a
145 \fBgpg_error_t\fP on failure. The data passed to the function can be set with
146 \fBPWMD_OPTION_STATUS_DATA\fP.
151 .B "pwmd_error_t pwmd_open(pwm_t " *pwm ", gpg_error_t " *error ", const char " *filename ");"
152 \fBpwmd_open\fP() opens the specified \fIfilename\fP on the server. The
153 password for the file is gotten from either
155 or the value set with \fBpwmd_setopt\fP(). \fBPWMD_ERROR\fP is returned on
156 error with \fIerror\fP set to the error code of the failed function.
157 Otherwise \fBPWMD_OK\fP is returned.
160 .B "pwmd_error_t pwmd_command(pwm_t " *pwm ", char " **result ", gpg_error_t " *error ", const char " *cmd ", " ... ");"
161 \fBpwmd_command\fP() sends a protocol command to the server. The function
162 returns \fBPWMD_OK\fP when successful and stores the result of the command
163 \fIcmd\fP to \fIresult\fP. The result should be free'd with
164 \fBpwmd_free_result\fP(). Protocol commands that don't have a result will set
165 \fIresult\fP to NULL. If an error occurs then \fBPWMD_ERROR\fP is returned and
166 \fIerror\fP is set to the error code.
169 .B "void pwmd_free_result(void " *result ");"
170 Deallocates the memory of \fBpwmd_command\fP() result. It is important to use
171 this function because
173 not only keeps track of all allocated memory used by other
175 functions, but also clears the memory contents for better security. Don't use
176 this to free your own allocated memory.
179 .B "pwmd_error_t pwmd_save(pwm_t " *pwm ", gpg_error_t " *error ");"
180 \fBpwmd_save\fP() saves the changes to the opened file. If not called before
181 disconnecting from the server then any changes will be lost. If an error
182 occurs then \fBPWMD_ERROR\fP is returned and \fIerror\fP is set to the error
183 code of the failed function. Otherwise \fBPWMD_OK\fP is returned.
186 .B "void pwmd_close(pwm_t " *pwm ");"
187 \fBpwmd_close\fP() closes the connection to the server and frees resources
188 used by the handle \fIpwm\fP.
191 .B "const char *pwmd_strerror(gpg_error_t " error ");"
192 \fBpwmd_strerror\fP() returns a string describing the error code
193 \fIerror\fP which was set from one of the above functions.
198 Default connecting socket.
200 .B @prefix@/lib/pkgconfig/libpwmd.pc
205 .B @prefix@/include/libpwmd.h
206 Installed location of header file.
209 Ben Kibbey <bjk@luxsci.net>
211 .URL "http://bjk.sourceforge.net/pwmd/" "PWMD Homepage" .