1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
3 Copyright (C) 2006-2009 Ben Kibbey <bjk@luxsci.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02110-1301 USA
26 #include <sys/socket.h>
35 #include <sys/types.h>
37 #include <sys/select.h>
39 #include <netinet/in.h>
40 #include <sys/socket.h>
52 #define DNS_USE_GETTIMEOFDAY_FOR_ID 1
54 #include <arpa/nameser.h>
57 GCRY_THREAD_OPTION_PTH_IMPL
;
70 #define N_(msgid) dgettext("libpwmd", msgid)
77 static int gelapsed
, gtimeout
;
78 static gpg_error_t
pinentry_command(pwm_t
*pwm
, char **result
, const char *cmd
);
79 static gpg_error_t global_error
;
82 const char *pwmd_strerror(gpg_error_t e
)
84 gpg_err_code_t code
= gpg_err_code(e
);
86 if (code
>= GPG_ERR_USER_1
&& code
< gpg_err_code(EPWMD_MAX
)) {
90 return N_("Unknown error");
92 return N_("No cache slots available");
94 return N_("Recursion loop");
96 return N_("No file is open");
98 return N_("General LibXML error");
100 return N_("File modified");
102 return N_("Access denied");
106 return gpg_strerror(e
);
109 gpg_error_t
pwmd_init()
111 static int initialized
;
117 gcry_control (GCRYCTL_SET_THREAD_CBS
, &gcry_threads_pth
);
123 bindtextdomain("libpwmd", LOCALEDIR
);
126 assuan_set_malloc_hooks(xmalloc
, xrealloc
, xfree
);
127 assuan_set_assuan_err_source(GPG_ERR_SOURCE_DEFAULT
);
132 static pwm_t
*_socket_connect_finalize(pwm_t
*pwm
, assuan_context_t ctx
)
135 int n
= assuan_get_active_fds(ctx
, 0, active
, sizeof(active
));
137 pwm
->fd
= n
<= 0 ? -1 : dup(active
[0]);
141 pwm
->pinentry_tries
= 3;
143 assuan_set_pointer(ctx
, pwm
);
148 static int read_hook(assuan_context_t ctx
, assuan_fd_t fd
, void *data
,
149 size_t len
, ssize_t
*ret
)
151 pwm_t
*pwm
= assuan_get_pointer(ctx
);
153 if (!pwm
|| !pwm
->tcp_conn
)
154 *ret
= read((int)fd
, data
, len
);
157 *ret
= libssh2_channel_read(pwm
->tcp_conn
->channel
, data
, len
);
158 } while (*ret
== LIBSSH2_ERROR_EAGAIN
);
161 return *ret
<= 0 ? 0 : 1;
164 static int write_hook(assuan_context_t ctx
, assuan_fd_t fd
, const void *data
,
165 size_t len
, ssize_t
*ret
)
167 pwm_t
*pwm
= assuan_get_pointer(ctx
);
169 if (!pwm
|| !pwm
->tcp_conn
)
170 *ret
= write((int)fd
, data
, len
);
173 *ret
= libssh2_channel_write(pwm
->tcp_conn
->channel
, data
, len
);
174 } while (*ret
== LIBSSH2_ERROR_EAGAIN
);
177 return *ret
<= 0 ? 0 : 1;
180 static void _ssh_deinit(pwmd_tcp_conn_t
*conn
);
181 static void free_tcp_conn(pwmd_tcp_conn_t
*conn
)
186 if (conn
->username
) {
187 xfree(conn
->username
);
188 conn
->username
= NULL
;
191 if (conn
->known_hosts
) {
192 xfree(conn
->known_hosts
);
193 conn
->known_hosts
= NULL
;
196 if (conn
->identity
) {
197 xfree(conn
->identity
);
198 conn
->identity
= NULL
;
201 if (conn
->identity_pub
) {
202 xfree(conn
->identity_pub
);
203 conn
->identity_pub
= NULL
;
212 xfree(conn
->hostkey
);
213 conn
->hostkey
= NULL
;
217 ares_destroy(conn
->chan
);
222 ares_free_hostent(conn
->he
);
237 static void _ssh_deinit(pwmd_tcp_conn_t
*conn
)
243 libssh2_channel_free(conn
->channel
);
246 libssh2_session_disconnect(conn
->session
, "Bye!");
247 libssh2_session_free(conn
->session
);
250 conn
->session
= NULL
;
251 conn
->channel
= NULL
;
255 static void _ssh_assuan_deinit(assuan_context_t ctx
)
257 pwm_t
*pwm
= assuan_get_pointer(ctx
);
259 _ssh_deinit(pwm
->tcp_conn
);
263 * Sets common options from both pwmd_tcp_connect() and
264 * pwmd_tcp_connect_async().
266 static gpg_error_t
init_tcp_conn(pwmd_tcp_conn_t
**dst
, const char *host
,
267 int port
, const char *identity
, const char *user
, const char *hosts
,
270 pwmd_tcp_conn_t
*conn
;
275 return GPG_ERR_INV_ARG
;
278 if (!host
|| !identity
|| !user
|| !hosts
)
279 return GPG_ERR_INV_ARG
;
282 conn
= xcalloc(1, sizeof(pwmd_tcp_conn_t
));
285 return gpg_error_from_errno(ENOMEM
);
287 conn
->port
= port
== -1 ? 22 : port
;
288 conn
->host
= xstrdup(host
);
291 rc
= gpg_error_from_errno(ENOMEM
);
296 conn
->identity
= xstrdup(identity
);
298 if (!conn
->identity
) {
299 rc
= gpg_error_from_errno(ENOMEM
);
303 conn
->identity_pub
= xmalloc(strlen(conn
->identity
)+5);
305 if (!conn
->identity_pub
) {
306 rc
= gpg_error_from_errno(ENOMEM
);
310 sprintf(conn
->identity_pub
, "%s.pub", conn
->identity
);
311 conn
->username
= xstrdup(user
);
313 if (!conn
->username
) {
314 rc
= gpg_error_from_errno(ENOMEM
);
318 conn
->known_hosts
= xstrdup(hosts
);
320 if (!conn
->known_hosts
) {
321 rc
= gpg_error_from_errno(ENOMEM
);
334 static gpg_error_t
do_connect(pwm_t
*pwm
, int prot
, void *addr
)
336 struct sockaddr_in their_addr
;
338 pwm
->tcp_conn
->fd
= socket(prot
, SOCK_STREAM
, 0);
340 if (pwm
->tcp_conn
->fd
== -1)
341 return gpg_error_from_syserror();
343 if (pwm
->tcp_conn
->async
)
344 fcntl(pwm
->tcp_conn
->fd
, F_SETFL
, O_NONBLOCK
);
346 pwm
->cmd
= ASYNC_CMD_CONNECT
;
347 their_addr
.sin_family
= prot
;
348 their_addr
.sin_port
= htons(pwm
->tcp_conn
->port
);
349 their_addr
.sin_addr
= *((struct in_addr
*)addr
);
350 memset(their_addr
.sin_zero
, '\0', sizeof their_addr
.sin_zero
);
353 if (pth_connect(pwm
->tcp_conn
->fd
, (struct sockaddr
*)&their_addr
,
354 sizeof(their_addr
)) == -1)
356 if (connect(pwm
->tcp_conn
->fd
, (struct sockaddr
*)&their_addr
,
357 sizeof(their_addr
)) == -1)
359 return gpg_error_from_syserror();
364 static gpg_error_t
ares_error_to_pwmd(int status
)
366 if (status
!= ARES_SUCCESS
)
367 warnx("%s", ares_strerror(status
));
373 return GPG_ERR_UNKNOWN_HOST
;
375 return GPG_ERR_EHOSTDOWN
;
377 return GPG_ERR_TIMEOUT
;
379 return gpg_error_from_errno(ENOMEM
);
380 case ARES_ECONNREFUSED
:
381 return GPG_ERR_ECONNREFUSED
;
384 return GPG_ERR_EHOSTUNREACH
;
390 static void dns_resolve_cb(void *arg
, int status
, int timeouts
,
391 unsigned char *abuf
, int alen
)
397 if (status
== ARES_EDESTRUCTION
)
400 if (status
!= ARES_SUCCESS
) {
401 pwm
->tcp_conn
->rc
= ares_error_to_pwmd(status
);
405 //FIXME localhost. works with ipv4. maybe local system config error
406 /* Check for an IPv6 address first. */
407 rc
= ares_parse_a_reply(abuf
, alen
, &he
, NULL
, NULL
);
409 if (rc
!= ARES_SUCCESS
) {
410 if (rc
!= ARES_ENODATA
) {
411 pwm
->tcp_conn
->rc
= ares_error_to_pwmd(status
);
415 rc
= ares_parse_aaaa_reply(abuf
, alen
, &he
, NULL
, NULL
);
417 if (rc
!= ARES_SUCCESS
) {
418 pwm
->tcp_conn
->rc
= ares_error_to_pwmd(status
);
423 pwm
->tcp_conn
->he
= he
;
424 pwm
->tcp_conn
->rc
= do_connect(pwm
, he
->h_addrtype
, he
->h_addr
);
427 pwm_t
*_do_pwmd_tcp_connect_async(const char *host
, int port
,
428 const char *identity
, const char *user
, const char *known_hosts
,
429 gpg_error_t
*rc
, pwmd_async_cmd_t which
)
431 pwmd_tcp_conn_t
*conn
;
434 *rc
= init_tcp_conn(&conn
, host
, port
, identity
, user
, known_hosts
,
435 which
== ASYNC_CMD_HOSTKEY
? 1 : 0);
440 if ((pwm
= (pwm_t
*)xcalloc(1, sizeof(pwm_t
))) == NULL
) {
441 *rc
= gpg_error_from_syserror();
447 pwm
->tcp_conn
= conn
;
448 pwm
->tcp_conn
->cmd
= which
;
450 if (pwm
->tcp_conn
->cmd
== ASYNC_CMD_HOSTKEY
)
451 pwm
->tcp_conn
->get_only
= 1;
453 pwm
->cmd
= ASYNC_CMD_DNS
;
454 pwm
->state
= ASYNC_PROCESS
;
455 ares_init(&pwm
->tcp_conn
->chan
);
456 ares_query(pwm
->tcp_conn
->chan
, pwm
->tcp_conn
->host
, ns_c_any
, ns_t_any
,
457 dns_resolve_cb
, pwm
);
461 pwm_t
*pwmd_tcp_connect_async(const char *host
, int port
, const char *identity
,
462 const char *user
, const char *known_hosts
, gpg_error_t
*rc
)
464 return _do_pwmd_tcp_connect_async(host
, port
, identity
, user
, known_hosts
,
465 rc
, ASYNC_CMD_CONNECT
);
468 void *_ssh_malloc(size_t size
, void **data
)
470 return xmalloc(size
);
473 void _ssh_free(void *ptr
, void **data
)
478 void *_ssh_realloc(void *ptr
, size_t size
, void **data
)
480 return xrealloc(ptr
, size
);
483 static char *to_hex(const char *str
, size_t slen
)
486 char *buf
= xmalloc(slen
*2+1);
491 for (i
= 0, buf
[0] = 0; i
< slen
; i
++) {
494 sprintf(tmp
, "%02x", (unsigned char)str
[i
]);
501 static int verify_host_key(pwm_t
*pwm
)
503 FILE *fp
= fopen(pwm
->tcp_conn
->known_hosts
, "r");
509 buf
= xmalloc(LINE_MAX
);
514 while ((p
= fgets(buf
, LINE_MAX
, fp
))) {
515 if (*p
== '#' || isspace(*p
))
518 if (p
[strlen(p
)-1] == '\n')
521 if (!strcmp(buf
, pwm
->tcp_conn
->hostkey
))
538 static gpg_error_t
authenticate_ssh(pwm_t
*pwm
)
540 const char *fp
= libssh2_hostkey_hash(pwm
->tcp_conn
->session
,
541 LIBSSH2_HOSTKEY_HASH_SHA1
);
544 pwm
->tcp_conn
->hostkey
= to_hex(fp
, 20);
546 if (!pwm
->tcp_conn
->hostkey
)
547 return gpg_error_from_errno(ENOMEM
);
549 if (pwm
->tcp_conn
->get_only
)
552 if (!fp
|| verify_host_key(pwm
))
553 return GPG_ERR_CHECKSUM
;
555 userauth
= libssh2_userauth_list(pwm
->tcp_conn
->session
,
556 pwm
->tcp_conn
->username
, strlen(pwm
->tcp_conn
->username
));
558 if (!userauth
|| !strstr(userauth
, "publickey"))
559 return GPG_ERR_BAD_PIN_METHOD
;
561 if (libssh2_userauth_publickey_fromfile(pwm
->tcp_conn
->session
,
562 pwm
->tcp_conn
->username
, pwm
->tcp_conn
->identity_pub
,
563 pwm
->tcp_conn
->identity
, NULL
))
564 return GPG_ERR_BAD_SECKEY
;
569 static pwm_t
*setup_context(pwm_t
*pwm
, gpg_error_t
*rc
)
571 assuan_context_t ctx
;
572 struct assuan_io_hooks io_hooks
= {read_hook
, write_hook
};
574 pwm
->tcp_conn
->session
= libssh2_session_init_ex(_ssh_malloc
, _ssh_free
,
577 if (!pwm
->tcp_conn
->session
) {
578 *rc
= gpg_error_from_errno(ENOMEM
);
582 if (libssh2_session_startup(pwm
->tcp_conn
->session
, pwm
->tcp_conn
->fd
)) {
583 *rc
= GPG_ERR_ASSUAN_SERVER_FAULT
;
587 *rc
= authenticate_ssh(pwm
);
592 /* pwmd_get_hostkey(). */
593 if (pwm
->tcp_conn
->get_only
) {
594 pwm
->result
= xstrdup(pwm
->tcp_conn
->hostkey
);
597 *rc
= gpg_error_from_errno(ENOMEM
);
604 pwm
->tcp_conn
->channel
= libssh2_channel_open_session(pwm
->tcp_conn
->session
);
606 if (!pwm
->tcp_conn
->channel
) {
607 *rc
= GPG_ERR_ASSUAN_SERVER_FAULT
;
611 if (libssh2_channel_shell(pwm
->tcp_conn
->channel
)) {
612 *rc
= GPG_ERR_ASSUAN_SERVER_FAULT
;
616 assuan_set_io_hooks(&io_hooks
);
617 *rc
= assuan_socket_connect_fd(&ctx
, pwm
->tcp_conn
->fd
, 0, pwm
);
622 assuan_set_finish_handler(ctx
, _ssh_assuan_deinit
);
623 return _socket_connect_finalize(pwm
, ctx
);
626 if (!pwm
->tcp_conn
->async
)
632 static pwm_t
*_do_pwmd_tcp_connect(const char *host
, int port
,
633 const char *identity
, const char *user
, const char *known_hosts
,
634 gpg_error_t
*rc
, int get
)
637 pwmd_tcp_conn_t
*conn
;
639 *rc
= init_tcp_conn(&conn
, host
, port
, identity
, user
, known_hosts
, get
);
644 if ((pwm
= (pwm_t
*)xcalloc(1, sizeof(pwm_t
))) == NULL
) {
645 *rc
= gpg_error_from_errno(ENOMEM
);
649 pwm
->tcp_conn
= conn
;
650 pwm
->tcp_conn
->get_only
= get
;
651 pwm
->cmd
= ASYNC_CMD_DNS
;
652 ares_init(&pwm
->tcp_conn
->chan
);
653 ares_query(pwm
->tcp_conn
->chan
, pwm
->tcp_conn
->host
, ns_c_any
, ns_t_any
,
654 dns_resolve_cb
, pwm
);
656 /* dns_resolve_cb() may have already been called. */
657 if (pwm
->tcp_conn
->rc
) {
658 *rc
= pwm
->tcp_conn
->rc
;
663 * Fake a blocking DNS lookup. libcares does a better job than
673 n
= ares_fds(pwm
->tcp_conn
->chan
, &rfds
, &wfds
);
674 ares_timeout(pwm
->tcp_conn
->chan
, NULL
, &tv
);
676 n
= pth_select(n
, &rfds
, &wfds
, NULL
, &tv
);
678 n
= select(n
, &rfds
, &wfds
, NULL
, &tv
);
682 *rc
= gpg_error_from_syserror();
686 *rc
= GPG_ERR_TIMEOUT
;
690 ares_process(pwm
->tcp_conn
->chan
, &rfds
, &wfds
);
692 if (pwm
->tcp_conn
->rc
)
694 } while (pwm
->cmd
== ASYNC_CMD_DNS
);
696 if (pwm
->tcp_conn
->rc
) {
697 *rc
= pwm
->tcp_conn
->rc
;
701 return setup_context(pwm
, rc
);
708 pwm_t
*pwmd_tcp_connect(const char *host
, int port
, const char *identity
,
709 const char *user
, const char *known_hosts
, gpg_error_t
*rc
)
711 return _do_pwmd_tcp_connect(host
, port
, identity
, user
, known_hosts
, rc
, 0);
714 /* Must free the result with pwmd_free_result(). */
715 char *pwmd_get_hostkey(const char *host
, int port
, gpg_error_t
*rc
)
720 pwm
= _do_pwmd_tcp_connect(host
, port
, NULL
, NULL
, NULL
, rc
, 1);
725 hostkey
= xstrdup(pwm
->tcp_conn
->hostkey
);
728 *rc
= gpg_error_from_errno(ENOMEM
);
734 pwm_t
*pwmd_get_hostkey_async(const char *host
, int port
, gpg_error_t
*rc
)
736 return _do_pwmd_tcp_connect_async(host
, port
, NULL
, NULL
, NULL
, rc
,
741 pwm_t
*pwmd_connect(const char *path
, gpg_error_t
*rc
)
744 char *socketpath
= NULL
;
746 assuan_context_t ctx
;
749 pw
= getpwuid(getuid());
750 socketpath
= (char *)xmalloc(strlen(pw
->pw_dir
) + strlen("/.pwmd/socket") + 1);
751 sprintf(socketpath
, "%s/.pwmd/socket", pw
->pw_dir
);
754 socketpath
= xstrdup(path
);
756 *rc
= assuan_socket_connect_ext(&ctx
, socketpath
, -1, 0);
762 if ((pwm
= (pwm_t
*)xcalloc(1, sizeof(pwm_t
))) == NULL
) {
763 *rc
= gpg_error_from_syserror();
767 return _socket_connect_finalize(pwm
, ctx
);
770 gpg_error_t
pwmd_pending_line(pwm_t
*pwm
, char **line
, size_t *len
)
773 return GPG_ERR_INV_ARG
;
775 if (assuan_pending_line(pwm
->ctx
))
776 return assuan_read_line(pwm
->ctx
, line
, len
);
778 return GPG_ERR_NO_DATA
;
781 void pwmd_close(pwm_t
*pwm
)
787 assuan_disconnect(pwm
->ctx
);
790 xfree(pwm
->password
);
801 if (pwm
->pinentry_tty
)
802 xfree(pwm
->pinentry_tty
);
804 if (pwm
->pinentry_display
)
805 xfree(pwm
->pinentry_display
);
807 if (pwm
->pinentry_term
)
808 xfree(pwm
->pinentry_term
);
811 xfree(pwm
->filename
);
818 free_tcp_conn(pwm
->tcp_conn
);
824 static int mem_realloc_cb(void *data
, const void *buffer
, size_t len
)
826 membuf_t
*mem
= (membuf_t
*)data
;
832 if ((p
= xrealloc(mem
->buf
, mem
->len
+ len
)) == NULL
)
836 memcpy((char *)mem
->buf
+ mem
->len
, buffer
, len
);
841 void pwmd_free_result(void *data
)
846 static int _inquire_cb(void *data
, const char *keyword
)
848 pwm_t
*pwm
= (pwm_t
*)data
;
850 int flags
= fcntl(pwm
->fd
, F_GETFL
);
852 /* Shouldn't get this far without a callback. */
853 if (!pwm
->inquire_func
)
854 return GPG_ERR_INV_ARG
;
857 * Since the socket file descriptor is probably set to non-blocking, set to
858 * blocking to prevent GPG_ERR_EAGAIN errors. This should be fixes when
859 * asynchronous INQUIRE is supported by either libassuan or a later
862 fcntl(pwm
->fd
, F_SETFL
, 0);
869 rc
= pwm
->inquire_func(pwm
->inquire_data
, keyword
, rc
, &result
, &len
);
870 rc
= gpg_err_code(rc
);
872 if (rc
== GPG_ERR_EOF
|| !rc
) {
873 if (len
<= 0 || !result
|| !*result
) {
878 arc
= assuan_send_data(pwm
->ctx
, result
, len
);
880 if (rc
== GPG_ERR_EOF
) {
891 fcntl(pwm
->fd
, F_SETFL
, flags
);
895 gpg_error_t
pwmd_finalize(pwm_t
*pwm
)
897 if (!pwm
|| pwm
->cmd
== ASYNC_CMD_NONE
|| pwm
->state
!= ASYNC_DONE
)
898 return GPG_ERR_INV_ARG
;
900 pwm
->state
= ASYNC_INIT
;
901 pwm
->cmd
= ASYNC_CMD_NONE
;
904 if (pwm
->cmd
== ASYNC_CMD_CONNECT
|| pwm
->cmd
== ASYNC_CMD_DNS
) {
905 gpg_error_t rc
= pwm
->tcp_conn
->rc
;
912 /* pwm is no longer a valid handle. */
921 return GPG_ERR_INV_ARG
;
925 pwm
->is_open_cmd
= 0;
930 static gpg_error_t
do_nb_command(pwm_t
*pwm
, const char *cmd
, const char *arg
)
934 size_t len
= strlen(cmd
) + 2;
936 len
+= arg
? strlen(arg
) : 0;
938 if (pwm
->state
!= ASYNC_INIT
)
939 return GPG_ERR_INV_STATE
;
941 buf
= (char *)xmalloc(len
);
944 rc
= gpg_error_from_errno(ENOMEM
);
948 snprintf(buf
, len
, "%s %s", cmd
, arg
? arg
: "");
949 rc
= assuan_write_line(pwm
->ctx
, buf
);
953 pwm
->state
= ASYNC_PROCESS
;
959 gpg_error_t
pwmd_open_async(pwm_t
*pwm
, const char *filename
)
961 if (!pwm
|| !filename
)
962 return GPG_ERR_INV_ARG
;
964 /* For pinentry retries. */
965 if (!pwm
->is_open_cmd
) {
967 xfree(pwm
->filename
);
969 pwm
->filename
= xstrdup(filename
);
972 pwm
->is_open_cmd
= 1;
973 return do_nb_command(pwm
, "OPEN", filename
);
976 gpg_error_t
pwmd_save_async(pwm_t
*pwm
)
979 return GPG_ERR_INV_ARG
;
981 return do_nb_command(pwm
, "SAVE", NULL
);
984 static gpg_error_t
parse_assuan_line(pwm_t
*pwm
)
990 rc
= assuan_read_line(pwm
->ctx
, &line
, &len
);
993 if (line
[0] == 'O' && line
[1] == 'K' &&
994 (line
[2] == 0 || line
[2] == ' ')) {
995 pwm
->state
= ASYNC_DONE
;
997 else if (line
[0] == '#') {
999 else if (line
[0] == 'S' && (line
[1] == 0 || line
[1] == ' ')) {
1000 if (pwm
->status_func
) {
1001 pwm
->status_func(pwm
->status_data
,
1002 line
[1] == 0 ? line
+1 : line
+2);
1005 else if (line
[0] == 'E' && line
[1] == 'R' && line
[2] == 'R' &&
1006 (line
[3] == 0 || line
[3] == ' ')) {
1009 pwm
->state
= ASYNC_DONE
;
1016 gpg_error_t
pwmd_get_result(pwm_t
*pwm
, const char **result
)
1018 if (!pwm
|| !result
)
1019 return GPG_ERR_INV_ARG
;
1021 if (pwm
->state
!= ASYNC_DONE
)
1022 return GPG_ERR_INV_STATE
;
1025 return GPG_ERR_NO_DATA
;
1027 *result
= pwm
->result
;
1031 pwmd_async_t
pwmd_process(pwm_t
*pwm
, gpg_error_t
*rc
)
1035 struct timeval tv
= {0, 0};
1040 *rc
= GPG_ERR_INV_ARG
;
1045 if (pwm
->cmd
== ASYNC_CMD_DNS
) {
1048 if (pwm
->tcp_conn
->rc
) {
1049 *rc
= pwm
->tcp_conn
->rc
;
1050 close(pwm
->tcp_conn
->fd
);
1051 pwm
->state
= ASYNC_DONE
;
1057 n
= ares_fds(pwm
->tcp_conn
->chan
, &rfds
, &wfds
);
1059 /* Shouldn't happen. */
1063 n
= select(n
, &rfds
, &wfds
, NULL
, &tv
);
1066 ares_process(pwm
->tcp_conn
->chan
, &rfds
, &wfds
);
1070 else if (pwm
->cmd
== ASYNC_CMD_CONNECT
) {
1071 if (pwm
->tcp_conn
->rc
== GPG_ERR_EINPROGRESS
) {
1073 socklen_t len
= sizeof(int);
1076 FD_SET(pwm
->tcp_conn
->fd
, &fds
);
1077 n
= select(pwm
->tcp_conn
->fd
+1, NULL
, &fds
, NULL
, &tv
);
1079 if (!n
|| !FD_ISSET(pwm
->tcp_conn
->fd
, &fds
))
1082 *rc
= gpg_error_from_syserror();
1083 close(pwm
->tcp_conn
->fd
);
1084 pwm
->state
= ASYNC_DONE
;
1088 ret
= getsockopt(pwm
->tcp_conn
->fd
, SOL_SOCKET
, SO_ERROR
, &n
, &len
);
1090 *rc
= ret
? gpg_error_from_syserror() : gpg_error_from_errno(n
);
1091 close(pwm
->tcp_conn
->fd
);
1092 pwm
->state
= ASYNC_DONE
;
1096 else if (pwm
->tcp_conn
->rc
) {
1097 *rc
= pwm
->tcp_conn
->rc
;
1098 close(pwm
->tcp_conn
->fd
);
1099 pwm
->state
= ASYNC_DONE
;
1103 fcntl(pwm
->tcp_conn
->fd
, F_SETFL
, 0);
1104 setup_context(pwm
, rc
);
1105 pwm
->state
= ASYNC_DONE
;
1111 *rc
= GPG_ERR_INV_ARG
;
1114 else if (pwm
->state
== ASYNC_DONE
)
1116 else if (pwm
->state
== ASYNC_INIT
) {
1117 *rc
= GPG_ERR_INV_STATE
;
1122 FD_SET(pwm
->fd
, &fds
);
1124 n
= pth_select(pwm
->fd
+1, &fds
, NULL
, NULL
, &tv
);
1126 n
= select(pwm
->fd
+1, &fds
, NULL
, NULL
, &tv
);
1130 if (FD_ISSET(pwm
->fd
, &fds
))
1131 *rc
= parse_assuan_line(pwm
);
1134 while (!*rc
&& assuan_pending_line(pwm
->ctx
))
1135 *rc
= parse_assuan_line(pwm
);
1137 if (pwm
->is_open_cmd
&& gpg_err_code(*rc
) == EPWMD_BADKEY
&&
1138 ++pwm
->ntries
< pwm
->pinentry_tries
) {
1139 pwm
->state
= ASYNC_INIT
;
1140 *rc
= pwmd_open_async(pwm
, pwm
->filename
);
1146 static gpg_error_t
assuan_command(pwm_t
*pwm
, assuan_context_t ctx
,
1147 char **result
, const char *cmd
)
1155 rc
= assuan_transact(ctx
, cmd
, mem_realloc_cb
, &data
, _inquire_cb
, pwm
,
1156 pwm
->status_func
, pwm
->status_data
);
1166 mem_realloc_cb(&data
, "", 1);
1167 *result
= (char *)data
.buf
;
1171 return gpg_err_code(rc
);
1174 gpg_error_t
pwmd_inquire(pwm_t
*pwm
, const char *cmd
, pwmd_inquire_fn fn
,
1177 if (!pwm
|| !cmd
|| !fn
)
1178 return GPG_ERR_INV_ARG
;
1180 pwm
->inquire_func
= fn
;
1181 pwm
->inquire_data
= data
;
1182 return assuan_command(pwm
, pwm
->ctx
, NULL
, cmd
);
1185 gpg_error_t
pwmd_terminate_pinentry(pwm_t
*pwm
)
1187 #ifndef WITH_PINENTRY
1188 return GPG_ERR_NOT_IMPLEMENTED
;
1190 if (!pwm
|| pwm
->pid
== -1)
1191 return GPG_ERR_INV_ARG
;
1193 if (kill(pwm
->pid
, 0) == 0) {
1194 if (kill(pwm
->pid
, SIGTERM
) == -1) {
1195 if (kill(pwm
->pid
, SIGKILL
) == -1)
1196 return gpg_error_from_errno(errno
);
1199 pwm
->pin_error
= GPG_ERR_TIMEOUT
;
1202 return gpg_error_from_errno(errno
);
1208 #ifdef WITH_PINENTRY
1209 static gpg_error_t
set_pinentry_strings(pwm_t
*pwm
, int which
)
1212 char tmp
[ASSUAN_LINELENGTH
];
1216 pwm
->title
= xstrdup(N_("LibPWMD"));
1219 pwm
->prompt
= xstrdup(N_("Passphrase:"));
1221 if (!pwm
->desc
&& !which
)
1222 pwm
->desc
= xstrdup(N_("Enter a passphrase."));
1225 snprintf(tmp
, sizeof(tmp
), "SETERROR %s", N_("Invalid passphrase, please try again."));
1228 else if (which
== 2) {
1229 snprintf(tmp
, sizeof(tmp
), "SETERROR %s", N_("Please type the passphrase again for confirmation."));
1233 buf
= (char *)xmalloc(strlen("SETERROR ") + strlen(pwm
->desc
) + 1);
1234 sprintf(buf
, "SETERROR %s", pwm
->desc
);
1237 error
= pinentry_command(pwm
, NULL
, buf
);
1243 buf
= (char *)xmalloc(strlen("SETPROMPT ") + strlen(pwm
->prompt
) + 1);
1244 sprintf(buf
, "SETPROMPT %s", pwm
->prompt
);
1245 error
= pinentry_command(pwm
, NULL
, buf
);
1251 buf
= (char *)xmalloc(strlen("SETDESC ") + strlen(pwm
->title
) + 1);
1252 sprintf(buf
, "SETDESC %s", pwm
->title
);
1253 error
= pinentry_command(pwm
, NULL
, buf
);
1258 static void update_pinentry_settings(pwm_t
*pwm
)
1262 struct passwd
*pw
= getpwuid(getuid());
1265 snprintf(buf
, sizeof(buf
), "%s/.pwmd/pinentry.conf", pw
->pw_dir
);
1267 if ((fp
= fopen(buf
, "r")) == NULL
)
1270 while ((p
= fgets(buf
, sizeof(buf
), fp
)) != NULL
) {
1271 char name
[32], val
[256];
1273 if (sscanf(p
, " %31[a-zA-Z] = %255s", name
, val
) != 2)
1276 if (strcasecmp(name
, "TTYNAME") == 0) {
1277 xfree(pwm
->pinentry_tty
);
1278 pwm
->pinentry_tty
= xstrdup(val
);
1280 else if (strcasecmp(name
, "TTYTYPE") == 0) {
1281 xfree(pwm
->pinentry_term
);
1282 pwm
->pinentry_term
= xstrdup(val
);
1284 else if (strcasecmp(name
, "DISPLAY") == 0) {
1285 xfree(pwm
->pinentry_display
);
1286 pwm
->pinentry_display
= xstrdup(val
);
1288 else if (strcasecmp(name
, "PATH") == 0) {
1289 xfree(pwm
->pinentry_path
);
1290 pwm
->pinentry_path
= xstrdup(val
);
1297 static gpg_error_t
launch_pinentry(pwm_t
*pwm
)
1300 assuan_context_t ctx
;
1301 int child_list
[] = {-1};
1302 char *display
= getenv("DISPLAY");
1303 const char *argv
[6];
1304 int have_display
= 0;
1307 update_pinentry_settings(pwm
);
1309 if (pwm
->pinentry_display
|| display
)
1312 tty
= pwm
->pinentry_tty
? pwm
->pinentry_tty
: ttyname(STDOUT_FILENO
);
1315 return gpg_error_from_errno(errno
);
1318 if (!have_display
&& !tty
)
1319 return GPG_ERR_ENOTTY
;
1321 argv
[0] = "pinentry";
1322 argv
[1] = have_display
? "--display" : "--ttyname";
1323 argv
[2] = have_display
? pwm
->pinentry_display
? pwm
->pinentry_display
: display
: tty
;
1326 if (!have_display
) {
1327 argv
[3] = "--ttytype";
1328 argv
[4] = pwm
->pinentry_term
? pwm
->pinentry_term
: getenv("TERM");
1332 rc
= assuan_pipe_connect(&ctx
, pwm
->pinentry_path
? pwm
->pinentry_path
: PINENTRY_PATH
, argv
, child_list
);
1337 pwm
->pid
= assuan_get_pid(ctx
);
1339 return set_pinentry_strings(pwm
, 0);
1342 static gpg_error_t
pinentry_command(pwm_t
*pwm
, char **result
, const char *cmd
)
1347 n
= launch_pinentry(pwm
);
1353 return assuan_command(pwm
, pwm
->pctx
, result
, cmd
);
1356 static void pinentry_disconnect(pwm_t
*pwm
)
1359 assuan_disconnect(pwm
->pctx
);
1366 * Only called from a child process.
1368 static void catchsig(int sig
)
1372 if (gelapsed
++ >= gtimeout
) {
1373 global_error
= pwmd_terminate_pinentry(gpwm
);
1376 global_error
= GPG_ERR_TIMEOUT
;
1389 * Borrowed from libassuan.
1391 static char *percent_escape(const char *atext
)
1393 const unsigned char *s
;
1394 int len
= strlen(atext
) * 3 + 1;
1395 char *buf
= (char *)xmalloc(len
), *p
= buf
;
1400 for (s
=(const unsigned char *)atext
; *s
; s
++) {
1402 sprintf (p
, "%%%02X", *s
);
1414 static gpg_error_t
send_command(pwm_t
*pwm
, char **result
, const char *cmd
)
1417 return GPG_ERR_INV_ARG
;
1419 return assuan_command(pwm
, pwm
->ctx
, result
, cmd
);
1422 gpg_error_t
pwmd_command_ap(pwm_t
*pwm
, char **result
, const char *cmd
,
1430 return GPG_ERR_INV_ARG
;
1433 * C99 allows the dst pointer to be null which will calculate the length
1434 * of the would-be result and return it.
1436 len
= vsnprintf(NULL
, 0, cmd
, ap
)+1;
1437 buf
= (char *)xmalloc(len
);
1438 len
= vsnprintf(buf
, len
, cmd
, ap
);
1439 error
= send_command(pwm
, result
, buf
);
1445 * Avoid sending the BYE command here. libassuan will close the file
1446 * descriptor and release the assuan context. Use pwmd_close() instead.
1448 gpg_error_t
pwmd_command(pwm_t
*pwm
, char **result
, const char *cmd
, ...)
1454 return GPG_ERR_INV_ARG
;
1458 error
= pwmd_command_ap(pwm
, result
, cmd
, ap
);
1463 #ifdef WITH_PINENTRY
1464 static gpg_error_t
do_getpin(pwm_t
*pwm
, char **result
)
1467 signal(SIGALRM
, catchsig
);
1472 return pinentry_command(pwm
, result
, "GETPIN");
1475 static gpg_error_t
getpin(pwm_t
*pwm
, char **result
, int *try_n
, int which
)
1477 int pin_try
= *try_n
;
1483 if (pin_try
== -1) {
1484 error
= set_pinentry_strings(pwm
, which
);
1487 pinentry_disconnect(pwm
);
1492 if (pwm
->pinentry_tries
-1 != pin_try
) {
1493 error
= set_pinentry_strings(pwm
, 1);
1496 pinentry_disconnect(pwm
);
1502 error
= do_getpin(pwm
, result
);
1505 * Since there was input cancel any timeout setting.
1510 if (error
== GPG_ERR_CANCELED
)
1511 return GPG_ERR_CANCELED
;
1513 if (pin_try
!= -1 && pin_try
--)
1517 pinentry_disconnect(pwm
);
1527 gpg_error_t
pwmd_open_nb_finalize(pwm_t
*pwm
, pwmd_nb_status_t
*pw
)
1531 #ifndef WITH_PINENTRY
1532 return GPG_ERR_NOT_IMPLEMENTED
;
1535 if (!pwm
|| !pw
|| !pw
->filename
[0])
1536 return GPG_ERR_INV_ARG
;
1546 xfree(pwm
->filename
);
1548 pwm
->filename
= xstrdup(pw
->filename
);
1549 memset(pw
, 0, sizeof(pwmd_nb_status_t
));
1553 memset(pw
, 0, sizeof(pwmd_nb_status_t
));
1557 static gpg_error_t
do_open_command(pwm_t
*pwm
, const char *filename
, char *password
)
1559 char buf
[ASSUAN_LINELENGTH
];
1561 char *result
= NULL
;
1563 snprintf(buf
, sizeof(buf
), "OPEN %s %s", filename
, password
? password
: "");
1564 error
= send_command(pwm
, &result
, buf
);
1565 memset(buf
, 0, sizeof(buf
));
1567 if (error
&& result
)
1573 static int do_pwmd_open(pwm_t
*pwm
, gpg_error_t
*error
, const char *filename
,
1574 int nb
, int timeout
)
1576 char *result
= NULL
;
1577 char *password
= NULL
;
1578 char path
[PATH_MAX
];
1579 #ifdef WITH_PINENTRY
1583 if (!pwm
|| !filename
|| !*filename
) {
1584 *error
= GPG_ERR_INV_ARG
;
1588 #ifdef WITH_PINENTRY
1589 pin_try
= pwm
->pinentry_tries
- 1;
1593 * Avoid calling pinentry if the password is cached on the server or if
1594 * this is a new file.
1596 *error
= pwmd_command(pwm
, &result
, "GETCONFIG data_directory");
1601 snprintf(path
, sizeof(path
), "%s/%s", result
, filename
);
1602 pwmd_free_result(result
);
1604 if (access(path
, R_OK
) == -1) {
1605 if (errno
== ENOENT
)
1609 *error
= pwmd_command(pwm
, &result
, "ISCACHED %s", filename
);
1611 if (*error
== EPWMD_CACHE_NOT_FOUND
) {
1612 if (pwm
->passfunc
) {
1613 password
= pwm
->passfunc(pwm
, pwm
->passdata
);
1617 #ifdef WITH_PINENTRY
1619 * Get the password from pinentry.
1621 if (pwm
->use_pinentry
) {
1623 * Nonblocking is wanted. fork() then return a file descriptor
1624 * that the client can use to read() from.
1629 pwmd_nb_status_t pw
;
1631 if (pipe(p
) == -1) {
1632 *error
= gpg_error_from_syserror();
1645 strncpy(pw
.filename
, filename
, sizeof(pw
.filename
));
1646 pw
.filename
[sizeof(pw
.filename
)-1] = 0;
1656 *error
= getpin(pwm
, &password
, &pin_try
, 0);
1661 pinentry_disconnect(pwm
);
1663 if (gtimeout
&& gelapsed
>= gtimeout
)
1664 *error
= GPG_ERR_TIMEOUT
;
1668 pth_write(p
[1], &pw
, sizeof(pw
));
1670 write(p
[1], &pw
, sizeof(pw
));
1677 * Don't count the time it takes to open the file
1678 * which may have many iterations.
1680 signal(SIGALRM
, SIG_DFL
);
1681 *error
= do_open_command(pwm
, filename
, password
);
1684 signal(SIGALRM
, catchsig
);
1686 if (pwm
->pctx
&& *error
== EPWMD_BADKEY
) {
1688 goto getpin_nb_again
;
1690 goto getpin_nb_fail
;
1693 pinentry_disconnect(pwm
);
1696 pth_write(p
[1], &pw
, sizeof(pw
));
1698 write(p
[1], &pw
, sizeof(pw
));
1704 *error
= gpg_error_from_syserror();
1720 * Not using pinentry and the file was not found
1723 password
= pwm
->password
;
1724 #ifdef WITH_PINENTRY
1732 *error
= do_open_command(pwm
, filename
, password
);
1735 * Keep the user defined password set with pwmd_setopt(). The password may
1736 * be needed later (pwmd_save()) depending on the pwmd file cache settings.
1738 if (!pwm
->passfunc
&& password
&& password
!= pwm
->password
)
1741 #ifdef WITH_PINENTRY
1742 if (*error
== EPWMD_BADKEY
) {
1743 if (pin_try
-- > 0 && !nb
) {
1744 *error
= pwmd_command(pwm
, &result
, "OPTION TITLE=%s",
1745 N_("Invalid passphrase, please try again."));
1754 pinentry_disconnect(pwm
);
1762 xfree(pwm
->filename
);
1764 pwm
->filename
= xstrdup(filename
);
1768 * The file is cached or the file is a new file.
1771 return *error
? -1 : -2;
1773 return *error
? 1 : 0;
1776 gpg_error_t
pwmd_open(pwm_t
*pwm
, const char *filename
)
1780 do_pwmd_open(pwm
, &error
, filename
, 0, 0);
1784 int pwmd_open_nb(pwm_t
*pwm
, gpg_error_t
*error
, const char *filename
,
1787 #ifndef WITH_PINENTRY
1788 *error
= GPG_ERR_NOT_IMPLEMENTED
;
1791 return do_pwmd_open(pwm
, error
, filename
, 1, timeout
);
1795 #ifdef WITH_PINENTRY
1796 static gpg_error_t
do_save_getpin(pwm_t
*pwm
, char **password
)
1800 char *result
= NULL
;
1804 error
= getpin(pwm
, &result
, &pin_try
, confirm
? 2 : 0);
1808 pinentry_disconnect(pwm
);
1821 if (strcmp(*password
, result
)) {
1824 pinentry_disconnect(pwm
);
1825 error
= EPWMD_BADKEY
;
1830 pinentry_disconnect(pwm
);
1835 static gpg_error_t
do_save_command(pwm_t
*pwm
, char *password
)
1837 char buf
[ASSUAN_LINELENGTH
];
1839 char *result
= NULL
;
1841 snprintf(buf
, sizeof(buf
), "SAVE %s", password
? password
: "");
1842 error
= send_command(pwm
, &result
, buf
);
1843 memset(&buf
, 0, sizeof(buf
));
1845 if (error
&& result
)
1851 gpg_error_t
pwmd_save_nb_finalize(pwm_t
*pwm
, pwmd_nb_status_t
*pw
)
1855 #ifndef WITH_PINENTRY
1856 return GPG_ERR_NOT_IMPLEMENTED
;
1859 if (!pwm
|| !pw
|| !pw
->filename
[0])
1860 return GPG_ERR_INV_ARG
;
1864 memset(pw
, 0, sizeof(pwmd_nb_status_t
));
1868 static int do_pwmd_save(pwm_t
*pwm
, gpg_error_t
*error
, int nb
)
1870 char *result
= NULL
;
1871 char *password
= NULL
;
1874 *error
= GPG_ERR_INV_ARG
;
1878 if (pwm
->use_pinentry
|| pwm
->passfunc
) {
1879 *error
= pwmd_command(pwm
, &result
, "ISCACHED %s", pwm
->filename
);
1881 if (*error
== EPWMD_CACHE_NOT_FOUND
) {
1882 #ifdef WITH_PINENTRY
1883 if (pwm
->use_pinentry
) {
1887 pwmd_nb_status_t pw
;
1889 if (pipe(p
) == -1) {
1890 *error
= gpg_error_from_syserror();
1903 strncpy(pw
.filename
, pwm
->filename
, sizeof(pw
.filename
));
1904 pw
.filename
[sizeof(pw
.filename
)-1] = 0;
1909 *error
= do_save_getpin(pwm
, &password
);
1910 } while (*error
== EPWMD_BADKEY
);
1914 pinentry_disconnect(pwm
);
1918 pth_write(p
[1], &pw
, sizeof(pw
));
1920 write(p
[1], &pw
, sizeof(pw
));
1926 *error
= do_save_command(pwm
, password
);
1927 pinentry_disconnect(pwm
);
1930 pth_write(p
[1], &pw
, sizeof(pw
));
1932 write(p
[1], &pw
, sizeof(pw
));
1938 *error
= gpg_error_from_syserror();
1951 *error
= do_save_getpin(pwm
, &password
);
1959 password
= (*pwm
->passfunc
)(pwm
, pwm
->passdata
);
1960 #ifdef WITH_PINENTRY
1970 password
= pwm
->password
;
1972 *error
= do_save_command(pwm
, password
);
1974 if (password
&& password
!= pwm
->password
)
1978 return *error
? -1 : -2;
1980 return *error
? 1 : 0;
1983 int pwmd_save_nb(pwm_t
*pwm
, gpg_error_t
*error
)
1985 #ifndef WITH_PINENTRY
1986 *error
= GPG_ERR_NOT_IMPLEMENTED
;
1989 return do_pwmd_save(pwm
, error
, 1);
1993 gpg_error_t
pwmd_save(pwm_t
*pwm
)
1997 do_pwmd_save(pwm
, &error
, 0);
2001 gpg_error_t
pwmd_setopt(pwm_t
*pwm
, pwmd_option_t opt
, ...)
2004 #ifdef WITH_PINENTRY
2005 int n
= va_arg(ap
, int);
2009 gpg_error_t error
= 0;
2012 return GPG_ERR_INV_ARG
;
2017 case PWMD_OPTION_STATUS_FUNC
:
2018 pwm
->status_func
= va_arg(ap
, pwmd_status_fn
);
2020 case PWMD_OPTION_STATUS_DATA
:
2021 pwm
->status_data
= va_arg(ap
, void *);
2023 case PWMD_OPTION_PASSWORD_FUNC
:
2024 pwm
->passfunc
= va_arg(ap
, pwmd_password_fn
);
2026 case PWMD_OPTION_PASSWORD_DATA
:
2027 pwm
->passdata
= va_arg(ap
, void *);
2029 case PWMD_OPTION_PASSWORD
:
2030 arg1
= va_arg(ap
, char *);
2033 xfree(pwm
->password
);
2035 pwm
->password
= xstrdup(arg1
);
2037 #ifdef WITH_PINENTRY
2038 case PWMD_OPTION_PINENTRY
:
2039 n
= va_arg(ap
, int);
2041 if (n
!= 0 && n
!= 1) {
2043 error
= GPG_ERR_INV_VALUE
;
2046 pwm
->use_pinentry
= n
;
2047 error
= pwmd_command(pwm
, &result
, "OPTION PINENTRY=%i",
2048 !pwm
->use_pinentry
);
2051 case PWMD_OPTION_PINENTRY_TRIES
:
2052 n
= va_arg(ap
, int);
2056 error
= GPG_ERR_INV_VALUE
;
2059 pwm
->pinentry_tries
= n
;
2061 case PWMD_OPTION_PINENTRY_PATH
:
2062 if (pwm
->pinentry_path
)
2063 xfree(pwm
->pinentry_path
);
2065 pwm
->pinentry_path
= xstrdup(va_arg(ap
, char *));
2067 case PWMD_OPTION_PINENTRY_TTY
:
2068 if (pwm
->pinentry_tty
)
2069 xfree(pwm
->pinentry_tty
);
2071 pwm
->pinentry_tty
= xstrdup(va_arg(ap
, char *));
2073 case PWMD_OPTION_PINENTRY_DISPLAY
:
2074 if (pwm
->pinentry_display
)
2075 xfree(pwm
->pinentry_display
);
2077 pwm
->pinentry_display
= xstrdup(va_arg(ap
, char *));
2079 case PWMD_OPTION_PINENTRY_TERM
:
2080 if (pwm
->pinentry_term
)
2081 xfree(pwm
->pinentry_term
);
2083 pwm
->pinentry_term
= xstrdup(va_arg(ap
, char *));
2085 case PWMD_OPTION_PINENTRY_TITLE
:
2088 pwm
->title
= percent_escape(va_arg(ap
, char *));
2090 case PWMD_OPTION_PINENTRY_PROMPT
:
2093 pwm
->prompt
= percent_escape(va_arg(ap
, char *));
2095 case PWMD_OPTION_PINENTRY_DESC
:
2098 pwm
->desc
= percent_escape(va_arg(ap
, char *));
2101 case PWMD_OPTION_PINENTRY
:
2102 case PWMD_OPTION_PINENTRY_TRIES
:
2103 case PWMD_OPTION_PINENTRY_PATH
:
2104 case PWMD_OPTION_PINENTRY_TTY
:
2105 case PWMD_OPTION_PINENTRY_DISPLAY
:
2106 case PWMD_OPTION_PINENTRY_TERM
:
2107 case PWMD_OPTION_PINENTRY_TITLE
:
2108 case PWMD_OPTION_PINENTRY_PROMPT
:
2109 case PWMD_OPTION_PINENTRY_DESC
:
2110 error
= GPG_ERR_NOT_IMPLEMENTED
;
2114 error
= GPG_ERR_NOT_IMPLEMENTED
;
2123 * Prevent requiring assuan.h when setting ctx. The ctx is really an
2124 * assuan_context_t *.
2126 gpg_error_t
pwmd_assuan_ctx(pwm_t
*pwm
, void *ctx
, int *fd
)
2129 return GPG_ERR_INV_ARG
;