2 Copyright (C) 2006-2023 Ben Kibbey <bjk@luxsci.net>
4 This file is part of libpwmd.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License version 2.1 as published by the Free Software Foundation.
10 This library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
44 #define N_(msgid) dgettext("libpwmd", msgid)
46 #define N_(msgid) (msgid)
49 #define N_ARRAY(a) (sizeof(a)/sizeof(a[0]))
53 PWMD_IPV6
, PWMD_IPV4
, PWMD_IP_ANY
56 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
58 #define TCP_FLAG_DNS_FINISHED 0x01
65 struct addrinfo
*addrs
;
66 struct addrinfo
*addr
;
67 pthread_cond_t dns_cond
;
68 pthread_mutex_t dns_mutex
;
79 /* Borrowed from g10code. */
81 # define SOCKET2HANDLE(s) ((void *)(s))
82 # define HANDLE2SOCKET(h) ((uintptr_t)(h))
84 # define SOCKET2HANDLE(s) ((void *)(s))
85 # define HANDLE2SOCKET(h) ((unsigned int)(h))
87 # define SOCKET2HANDLE(s) (s)
88 # define HANDLE2SOCKET(h) (h)
91 #define OPT_LOCK_ON_OPEN 0x0001
92 #define OPT_SIGPIPE 0x0002
93 #define OPT_STATE_STATUS 0x0004
98 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
108 /* Options set with pwmd_setopt(). */
109 pwmd_read_cb_t read_cb
;
111 pwmd_write_cb_t write_cb
;
114 pwmd_ip_version_t prot
;
115 pwmd_knownhost_cb_t kh_cb
;
117 pwmd_passphrase_cb_t passphrase_cb
;
118 void *passphrase_data
;
119 int needs_passphrase
;
120 char *ssh_passphrase
;
129 pid_t pinentry_pid
; // for local pinentry timeouts
130 assuan_context_t pctx
;
135 char *pinentry_display
;
136 char *pinentry_lcctype
;
137 char *pinentry_lcmessages
;
138 char *pinentry_error
;
139 char *pinentry_prompt
;
141 int pinentry_tries
; // local pinentry
142 int pinentry_try
; // local pinentry
143 char *passphrase_hint
;
144 char *passphrase_info
;
146 int pinentry_timeout
;
147 int current_pinentry_timeout
;
148 int disable_pinentry
;
150 int pinentry_disabled
; // for sending the disable command
152 pwmd_status_cb_t status_func
;
154 pwmd_inquire_cb_t inquire_func
;
156 size_t inquire_total
;
158 size_t inquire_maxlen
;
160 size_t data_total
; // Used by the XFER status message
162 gpg_error_t (*_inquire_func
) (void *, const char *);
167 int override_inquire
;
169 unsigned version
; // of pwmd
172 gpg_error_t
_assuan_command (pwm_t
* pwm
, assuan_context_t ctx
,
173 char **result
, size_t * len
, const char *cmd
);
174 gpg_error_t
_connect_finalize (pwm_t
* pwm
);
175 #if defined(WITH_SSH) || defined(WITH_GNUTLS)
176 void free_tcp (pwm_t
*);
177 gpg_error_t
tcp_connect_common (pwm_t
* pwm
);