sasl2_sys/
saslplug.rs

1// Copyright Materialize, Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License in the LICENSE file at the
6// root of this repository, or online at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! SASL plugin API.
17
18use libc::{c_char, c_int, c_uchar, c_uint, c_ulong, c_void};
19
20use super::hmac_md5::{HMAC_MD5_CTX, HMAC_MD5_STATE};
21use super::md5::MD5_CTX;
22use super::prop::{propctx, propval};
23use super::sasl::{
24    iovec, sasl_callback_t, sasl_calloc_t, sasl_channel_binding_t, sasl_conn_t, sasl_free_t,
25    sasl_getopt_t, sasl_http_request_t, sasl_interact_t, sasl_malloc_t, sasl_mutex_alloc_t,
26    sasl_mutex_free_t, sasl_mutex_lock_t, sasl_mutex_unlock_t, sasl_rand_t, sasl_realloc_t,
27    sasl_security_properties_t, sasl_ssf_t,
28};
29
30pub type sasl_callback_ft = Option<unsafe extern "C" fn() -> c_int>;
31
32pub type sasl_getcallback_t = Option<
33    unsafe extern "C" fn(
34        conn: *mut sasl_conn_t,
35        callbackid: c_ulong,
36        pproc: *mut sasl_callback_ft,
37        pcontext: *mut *mut c_void,
38    ) -> c_int,
39>;
40
41// Utility functions for plugins.
42
43pub const SASL_UTILS_VERSION: c_uint = 4;
44
45#[repr(C)]
46#[derive(Debug, Copy, Clone)]
47pub struct sasl_utils {
48    pub version: c_int,
49
50    pub conn: *mut sasl_conn_t,
51    pub rpool: *mut sasl_rand_t,
52    pub getopt_context: *mut c_void,
53
54    pub getopt: sasl_getopt_t,
55
56    pub malloc: sasl_malloc_t,
57    pub calloc: sasl_calloc_t,
58    pub realloc: sasl_realloc_t,
59    pub free: sasl_free_t,
60
61    pub mutex_alloc: sasl_mutex_alloc_t,
62    pub mutex_lock: sasl_mutex_lock_t,
63    pub mutex_unlock: sasl_mutex_unlock_t,
64    pub mutex_free: sasl_mutex_free_t,
65
66    pub MD5Init: Option<unsafe extern "C" fn(arg1: *mut MD5_CTX)>,
67    pub MD5Update:
68        Option<unsafe extern "C" fn(arg1: *mut MD5_CTX, text: *const c_uchar, len: c_uint)>,
69    pub MD5Final: Option<unsafe extern "C" fn(arg1: *mut c_uchar, arg2: *mut MD5_CTX)>,
70    pub hmac_md5: Option<
71        unsafe extern "C" fn(
72            text: *const c_uchar,
73            text_len: c_int,
74            key: *const c_uchar,
75            key_len: c_int,
76            arg1: *mut c_uchar,
77        ),
78    >,
79    pub hmac_md5_init:
80        Option<unsafe extern "C" fn(arg1: *mut HMAC_MD5_CTX, key: *const c_uchar, len: c_int)>,
81    pub hmac_md5_final: Option<unsafe extern "C" fn(arg1: *mut c_uchar, arg2: *mut HMAC_MD5_CTX)>,
82    pub hmac_md5_precalc:
83        Option<unsafe extern "C" fn(arg1: *mut HMAC_MD5_STATE, key: *const c_uchar, len: c_int)>,
84    pub hmac_md5_import:
85        Option<unsafe extern "C" fn(arg1: *mut HMAC_MD5_CTX, arg2: *mut HMAC_MD5_STATE)>,
86
87    pub mkchal: Option<
88        unsafe extern "C" fn(
89            conn: *mut sasl_conn_t,
90            buf: *mut c_char,
91            maxlen: c_uint,
92            hostflag: c_uint,
93        ) -> c_int,
94    >,
95    pub utf8verify: Option<unsafe extern "C" fn(str: *const c_char, len: c_uint) -> c_int>,
96    pub rand: Option<unsafe extern "C" fn(rpool: *mut sasl_rand_t, buf: *mut c_char, len: c_uint)>,
97    pub churn:
98        Option<unsafe extern "C" fn(rpool: *mut sasl_rand_t, data: *const c_char, len: c_uint)>,
99
100    pub checkpass: Option<
101        unsafe extern "C" fn(
102            conn: *mut sasl_conn_t,
103            user: *const c_char,
104            userlen: c_uint,
105            pass: *const c_char,
106            passlen: c_uint,
107        ) -> c_int,
108    >,
109
110    pub decode64: Option<
111        unsafe extern "C" fn(
112            in_: *const c_char,
113            inlen: c_uint,
114            out: *mut c_char,
115            outmax: c_uint,
116            outlen: *mut c_uint,
117        ) -> c_int,
118    >,
119    pub encode64: Option<
120        unsafe extern "C" fn(
121            in_: *const c_char,
122            inlen: c_uint,
123            out: *mut c_char,
124            outmax: c_uint,
125            outlen: *mut c_uint,
126        ) -> c_int,
127    >,
128
129    pub erasebuffer: Option<unsafe extern "C" fn(buf: *mut c_char, len: c_uint)>,
130
131    pub getprop: Option<
132        unsafe extern "C" fn(
133            conn: *mut sasl_conn_t,
134            propnum: c_int,
135            pvalue: *mut *const c_void,
136        ) -> c_int,
137    >,
138    pub setprop: Option<
139        unsafe extern "C" fn(conn: *mut sasl_conn_t, propnum: c_int, value: *const c_void) -> c_int,
140    >,
141
142    pub getcallback: sasl_getcallback_t,
143
144    pub log:
145        Option<unsafe extern "C" fn(conn: *mut sasl_conn_t, level: c_int, fmt: *const c_char, ...)>,
146
147    pub seterror: Option<
148        unsafe extern "C" fn(conn: *mut sasl_conn_t, flags: c_uint, fmt: *const c_char, ...),
149    >,
150
151    pub spare_fptr: Option<unsafe extern "C" fn() -> *mut c_int>,
152
153    pub prop_new: Option<unsafe extern "C" fn(estimate: c_uint) -> *mut propctx>,
154    pub prop_dup:
155        Option<unsafe extern "C" fn(src_ctx: *mut propctx, dst_ctx: *mut *mut propctx) -> c_int>,
156    pub prop_request:
157        Option<unsafe extern "C" fn(ctx: *mut propctx, names: *mut *const c_char) -> c_int>,
158    pub prop_get: Option<unsafe extern "C" fn(ctx: *mut propctx) -> *const propval>,
159    pub prop_getnames: Option<
160        unsafe extern "C" fn(
161            ctx: *mut propctx,
162            names: *mut *const c_char,
163            vals: *mut propval,
164        ) -> c_int,
165    >,
166    pub prop_clear: Option<unsafe extern "C" fn(ctx: *mut propctx, requests: c_int)>,
167    pub prop_dispose: Option<unsafe extern "C" fn(ctx: *mut *mut propctx)>,
168    pub prop_format: Option<
169        unsafe extern "C" fn(
170            ctx: *mut propctx,
171            sep: *const c_char,
172            seplen: c_int,
173            outbuf: *mut c_char,
174            outmax: c_uint,
175            outlen: *mut c_uint,
176        ) -> c_int,
177    >,
178    pub prop_set: Option<
179        unsafe extern "C" fn(
180            ctx: *mut propctx,
181            name: *const c_char,
182            value: *const c_char,
183            vallen: c_int,
184        ) -> c_int,
185    >,
186    pub prop_setvals: Option<
187        unsafe extern "C" fn(
188            ctx: *mut propctx,
189            name: *const c_char,
190            values: *mut *const c_char,
191        ) -> c_int,
192    >,
193    pub prop_erase: Option<unsafe extern "C" fn(ctx: *mut propctx, name: *const c_char)>,
194
195    pub auxprop_store: Option<
196        unsafe extern "C" fn(
197            conn: *mut sasl_conn_t,
198            ctx: *mut propctx,
199            user: *const c_char,
200        ) -> c_int,
201    >,
202
203    pub spare_fptr1: Option<unsafe extern "C" fn() -> c_int>,
204    pub spare_fptr2: Option<unsafe extern "C" fn() -> c_int>,
205}
206
207pub type sasl_utils_t = sasl_utils;
208
209#[repr(C)]
210#[derive(Copy, Clone)]
211pub struct sasl_out_params {
212    pub doneflag: c_uint,
213
214    pub user: *const c_char,
215    pub authid: *const c_char,
216
217    pub ulen: c_uint,
218    pub alen: c_uint,
219
220    pub maxoutbuf: c_uint,
221    pub mech_ssf: sasl_ssf_t,
222    pub encode_context: *mut c_void,
223    pub encode: Option<
224        unsafe extern "C" fn(
225            context: *mut c_void,
226            invec: *const iovec,
227            numiov: c_uint,
228            output: *mut *const c_char,
229            outputlen: *mut c_uint,
230        ) -> c_int,
231    >,
232    pub decode_context: *mut c_void,
233    pub decode: Option<
234        unsafe extern "C" fn(
235            context: *mut c_void,
236            input: *const c_char,
237            inputlen: c_uint,
238            output: *mut *const c_char,
239            outputlen: *mut c_uint,
240        ) -> c_int,
241    >,
242
243    pub client_creds: *mut c_void,
244
245    pub gss_peer_name: *const c_void,
246    pub gss_local_name: *const c_void,
247    pub cbindingname: *const c_char,
248    pub spare_fptr1: Option<unsafe extern "C" fn() -> c_int>,
249    pub spare_fptr2: Option<unsafe extern "C" fn() -> c_int>,
250    pub cbindingdisp: c_uint,
251    pub spare_int2: c_int,
252    pub spare_int3: c_int,
253    pub spare_int4: c_int,
254
255    pub param_version: c_int,
256}
257
258pub type sasl_out_params_t = sasl_out_params;
259
260pub type sasl_info_callback_stage_t = c_uint;
261
262pub const SASL_INFO_LIST_START: sasl_info_callback_stage_t = 0;
263pub const SASL_INFO_LIST_MECH: sasl_info_callback_stage_t = 1;
264pub const SASL_INFO_LIST_END: sasl_info_callback_stage_t = 2;
265
266// Channel binding.
267
268pub type sasl_cbinding_disp_t = c_uint;
269
270pub const SASL_CB_DISP_NONE: sasl_cbinding_disp_t = 0;
271pub const SASL_CB_DISP_WANT: sasl_cbinding_disp_t = 1;
272pub const SASL_CB_DISP_USED: sasl_cbinding_disp_t = 2;
273
274// Client mechanism functions.
275
276#[repr(C)]
277#[derive(Copy, Clone)]
278pub struct sasl_client_params {
279    pub service: *const c_char,
280    pub serverFQDN: *const c_char,
281    pub clientFQDN: *const c_char,
282    pub utils: *const sasl_utils_t,
283    pub prompt_supp: *const sasl_callback_t,
284    pub iplocalport: *const c_char,
285    pub ipremoteport: *const c_char,
286
287    pub servicelen: c_uint,
288    pub slen: c_uint,
289    pub clen: c_uint,
290    pub iploclen: c_uint,
291    pub ipremlen: c_uint,
292
293    pub props: sasl_security_properties_t,
294    pub external_ssf: sasl_ssf_t,
295
296    pub gss_creds: *const c_void,
297    pub cbinding: *const sasl_channel_binding_t,
298    pub http_request: *const sasl_http_request_t,
299    pub spare_ptr4: *mut c_void,
300
301    pub canon_user: Option<
302        unsafe extern "C" fn(
303            conn: *mut sasl_conn_t,
304            in_: *const c_char,
305            len: c_uint,
306            flags: c_uint,
307            oparams: *mut sasl_out_params_t,
308        ) -> c_int,
309    >,
310
311    pub spare_fptr1: Option<unsafe extern "C" fn() -> c_int>,
312
313    pub cbindingdisp: c_uint,
314    pub spare_int2: c_int,
315    pub spare_int3: c_int,
316
317    pub flags: c_uint,
318
319    pub param_version: c_int,
320}
321
322pub type sasl_client_params_t = sasl_client_params;
323
324pub const SASL_FEAT_WANT_CLIENT_FIRST: c_uint = 2;
325pub const SASL_FEAT_SERVER_FIRST: c_uint = 16;
326pub const SASL_FEAT_ALLOWS_PROXY: c_uint = 32;
327pub const SASL_FEAT_DONTUSE_USERPASSWD: c_uint = 128;
328pub const SASL_FEAT_GSS_FRAMING: c_uint = 256;
329pub const SASL_FEAT_CHANNEL_BINDING: c_uint = 2048;
330pub const SASL_FEAT_SUPPORTS_HTTP: c_uint = 4096;
331pub const SASL_FEAT_NEEDSERVERFQDN: c_uint = 1;
332
333#[repr(C)]
334#[derive(Debug, Copy, Clone)]
335pub struct sasl_client_plug {
336    pub mech_name: *const c_char,
337    pub max_ssf: sasl_ssf_t,
338    pub security_flags: c_uint,
339    pub features: c_uint,
340    pub required_prompts: *const c_ulong,
341    pub glob_context: *mut c_void,
342    pub mech_new: Option<
343        unsafe extern "C" fn(
344            glob_context: *mut c_void,
345            cparams: *mut sasl_client_params_t,
346            conn_context: *mut *mut c_void,
347        ) -> c_int,
348    >,
349    pub mech_step: Option<
350        unsafe extern "C" fn(
351            conn_context: *mut c_void,
352            cparams: *mut sasl_client_params_t,
353            serverin: *const c_char,
354            serverinlen: c_uint,
355            prompt_need: *mut *mut sasl_interact_t,
356            clientout: *mut *const c_char,
357            clientoutlen: *mut c_uint,
358            oparams: *mut sasl_out_params_t,
359        ) -> c_int,
360    >,
361    pub mech_dispose:
362        Option<unsafe extern "C" fn(conn_context: *mut c_void, utils: *const sasl_utils_t)>,
363    pub mech_free:
364        Option<unsafe extern "C" fn(glob_context: *mut c_void, utils: *const sasl_utils_t)>,
365    pub idle: Option<
366        unsafe extern "C" fn(
367            glob_context: *mut c_void,
368            conn_context: *mut c_void,
369            cparams: *mut sasl_client_params_t,
370        ) -> c_int,
371    >,
372    pub spare_fptr1: Option<unsafe extern "C" fn() -> c_int>,
373    pub spare_fptr2: Option<unsafe extern "C" fn() -> c_int>,
374}
375
376pub type sasl_client_plug_t = sasl_client_plug;
377
378pub const SASL_CLIENT_PLUG_VERSION: c_uint = 4;
379
380pub type sasl_client_plug_init_t = Option<
381    unsafe extern "C" fn(
382        utils: *const sasl_utils_t,
383        max_version: c_int,
384        out_version: *mut c_int,
385        pluglist: *mut *mut sasl_client_plug_t,
386        plugcount: *mut c_int,
387    ) -> c_int,
388>;
389
390extern "C" {
391    pub fn sasl_client_add_plugin(
392        plugname: *const c_char,
393        cplugfunc: sasl_client_plug_init_t,
394    ) -> c_int;
395}
396
397#[repr(C)]
398#[derive(Debug, Copy, Clone)]
399pub struct client_sasl_mechanism {
400    pub version: c_int,
401    pub plugname: *mut c_char,
402    pub plug: *const sasl_client_plug_t,
403}
404
405pub type client_sasl_mechanism_t = client_sasl_mechanism;
406
407pub type sasl_client_info_callback_t = Option<
408    unsafe extern "C" fn(
409        m: *mut client_sasl_mechanism_t,
410        stage: sasl_info_callback_stage_t,
411        rock: *mut c_void,
412    ),
413>;
414
415extern "C" {
416    pub fn sasl_client_plugin_info(
417        mech_list: *const c_char,
418        info_cb: sasl_client_info_callback_t,
419        info_cb_rock: *mut c_void,
420    ) -> c_int;
421}
422
423// Server functions.
424
425pub type sasl_logmsg_p =
426    Option<unsafe extern "C" fn(conn: *mut sasl_conn_t, fmt: *const c_char, ...)>;
427
428#[repr(C)]
429#[derive(Copy, Clone)]
430pub struct sasl_server_params {
431    pub service: *const c_char,
432    pub appname: *const c_char,
433    pub serverFQDN: *const c_char,
434    pub user_realm: *const c_char,
435    pub iplocalport: *const c_char,
436    pub ipremoteport: *const c_char,
437
438    pub servicelen: c_uint,
439    pub applen: c_uint,
440    pub slen: c_uint,
441    pub urlen: c_uint,
442    pub iploclen: c_uint,
443    pub ipremlen: c_uint,
444
445    pub log_level: c_int,
446
447    pub utils: *const sasl_utils_t,
448    pub callbacks: *const sasl_callback_t,
449
450    pub props: sasl_security_properties_t,
451    pub external_ssf: sasl_ssf_t,
452
453    pub transition: Option<
454        unsafe extern "C" fn(conn: *mut sasl_conn_t, pass: *const c_char, passlen: c_uint) -> c_int,
455    >,
456
457    pub canon_user: Option<
458        unsafe extern "C" fn(
459            conn: *mut sasl_conn_t,
460            user: *const c_char,
461            ulen: c_uint,
462            flags: c_uint,
463            oparams: *mut sasl_out_params_t,
464        ) -> c_int,
465    >,
466
467    pub propctx: *mut propctx,
468
469    pub gss_creds: *const c_void,
470    pub cbinding: *const sasl_channel_binding_t,
471    pub http_request: *const sasl_http_request_t,
472    pub spare_ptr4: *mut c_void,
473    pub spare_fptr1: Option<unsafe extern "C" fn() -> c_int>,
474    pub spare_fptr2: Option<unsafe extern "C" fn() -> c_int>,
475    pub spare_int1: c_int,
476    pub spare_int2: c_int,
477    pub spare_int3: c_int,
478
479    pub flags: c_uint,
480
481    pub param_version: c_int,
482}
483
484pub type sasl_server_params_t = sasl_server_params;
485
486pub const SASL_SET_REMOVE: c_uint = 1;
487
488pub const SASL_FEAT_SERVICE: c_uint = 512;
489pub const SASL_FEAT_GETSECRET: c_uint = 1024;
490
491#[repr(C)]
492#[derive(Debug, Copy, Clone)]
493pub struct sasl_server_plug {
494    pub mech_name: *const c_char,
495    pub max_ssf: sasl_ssf_t,
496    pub security_flags: c_uint,
497    pub features: c_uint,
498    pub glob_context: *mut c_void,
499    pub mech_new: Option<
500        unsafe extern "C" fn(
501            glob_context: *mut c_void,
502            sparams: *mut sasl_server_params_t,
503            challenge: *const c_char,
504            challen: c_uint,
505            conn_context: *mut *mut c_void,
506        ) -> c_int,
507    >,
508    pub mech_step: Option<
509        unsafe extern "C" fn(
510            conn_context: *mut c_void,
511            sparams: *mut sasl_server_params_t,
512            clientin: *const c_char,
513            clientinlen: c_uint,
514            serverout: *mut *const c_char,
515            serveroutlen: *mut c_uint,
516            oparams: *mut sasl_out_params_t,
517        ) -> c_int,
518    >,
519    pub mech_dispose:
520        Option<unsafe extern "C" fn(conn_context: *mut c_void, utils: *const sasl_utils_t)>,
521    pub mech_free:
522        Option<unsafe extern "C" fn(glob_context: *mut c_void, utils: *const sasl_utils_t)>,
523    pub setpass: Option<
524        unsafe extern "C" fn(
525            glob_context: *mut c_void,
526            sparams: *mut sasl_server_params_t,
527            user: *const c_char,
528            pass: *const c_char,
529            passlen: c_uint,
530            oldpass: *const c_char,
531            oldpasslen: c_uint,
532            flags: c_uint,
533        ) -> c_int,
534    >,
535    pub user_query: Option<
536        unsafe extern "C" fn(
537            glob_context: *mut c_void,
538            sparams: *mut sasl_server_params_t,
539            user: *const c_char,
540            maxmech: c_int,
541            mechlist: *mut *const c_char,
542        ) -> c_int,
543    >,
544    pub idle: Option<
545        unsafe extern "C" fn(
546            glob_context: *mut c_void,
547            conn_context: *mut c_void,
548            sparams: *mut sasl_server_params_t,
549        ) -> c_int,
550    >,
551    pub mech_avail: Option<
552        unsafe extern "C" fn(
553            glob_context: *mut c_void,
554            sparams: *mut sasl_server_params_t,
555            conn_context: *mut *mut c_void,
556        ) -> c_int,
557    >,
558    pub spare_fptr2: Option<unsafe extern "C" fn() -> c_int>,
559}
560
561pub type sasl_server_plug_t = sasl_server_plug;
562
563pub const SASL_SERVER_PLUG_VERSION: c_uint = 4;
564
565pub type sasl_server_plug_init_t = Option<
566    unsafe extern "C" fn(
567        utils: *const sasl_utils_t,
568        max_version: c_int,
569        out_version: *mut c_int,
570        pluglist: *mut *mut sasl_server_plug_t,
571        plugcount: *mut c_int,
572    ) -> c_int,
573>;
574
575extern "C" {
576    pub fn sasl_server_add_plugin(
577        plugname: *const c_char,
578        splugfunc: sasl_server_plug_init_t,
579    ) -> c_int;
580}
581
582#[repr(C)]
583#[derive(Debug, Copy, Clone)]
584pub struct server_sasl_mechanism {
585    pub version: c_int,
586    pub condition: c_int,
587    pub plugname: *mut c_char,
588    pub plug: *const sasl_server_plug_t,
589    pub f: *mut c_char,
590}
591
592pub type server_sasl_mechanism_t = server_sasl_mechanism;
593
594pub type sasl_server_info_callback_t = Option<
595    unsafe extern "C" fn(
596        m: *mut server_sasl_mechanism_t,
597        stage: sasl_info_callback_stage_t,
598        rock: *mut c_void,
599    ),
600>;
601
602extern "C" {
603    pub fn sasl_server_plugin_info(
604        mech_list: *const c_char,
605        info_cb: sasl_server_info_callback_t,
606        info_cb_rock: *mut c_void,
607    ) -> c_int;
608}
609
610// User canonicalization plugin.
611
612#[repr(C)]
613#[derive(Debug, Copy, Clone)]
614pub struct sasl_canonuser {
615    pub features: c_int,
616
617    pub spare_int1: c_int,
618
619    pub glob_context: *mut c_void,
620
621    pub name: *mut c_char,
622
623    pub canon_user_free:
624        Option<unsafe extern "C" fn(glob_context: *mut c_void, utils: *const sasl_utils_t)>,
625
626    pub canon_user_server: Option<
627        unsafe extern "C" fn(
628            glob_context: *mut c_void,
629            sparams: *mut sasl_server_params_t,
630            user: *const c_char,
631            len: c_uint,
632            flags: c_uint,
633            out: *mut c_char,
634            out_umax: c_uint,
635            out_ulen: *mut c_uint,
636        ) -> c_int,
637    >,
638
639    pub canon_user_client: Option<
640        unsafe extern "C" fn(
641            glob_context: *mut c_void,
642            cparams: *mut sasl_client_params_t,
643            user: *const c_char,
644            len: c_uint,
645            flags: c_uint,
646            out: *mut c_char,
647            out_max: c_uint,
648            out_len: *mut c_uint,
649        ) -> c_int,
650    >,
651
652    pub spare_fptr1: Option<unsafe extern "C" fn() -> c_int>,
653    pub spare_fptr2: Option<unsafe extern "C" fn() -> c_int>,
654    pub spare_fptr3: Option<unsafe extern "C" fn() -> c_int>,
655}
656
657pub type sasl_canonuser_plug_t = sasl_canonuser;
658
659pub const SASL_CANONUSER_PLUG_VERSION: c_uint = 5;
660
661pub type sasl_canonuser_init_t = Option<
662    unsafe extern "C" fn(
663        utils: *const sasl_utils_t,
664        max_version: c_int,
665        out_version: *mut c_int,
666        plug: *mut *mut sasl_canonuser_plug_t,
667        plugname: *const c_char,
668    ) -> c_int,
669>;
670
671extern "C" {
672    pub fn sasl_canonuser_add_plugin(
673        plugname: *const c_char,
674        canonuserfunc: sasl_canonuser_init_t,
675    ) -> c_int;
676}
677
678// Auxiliary property plugin.
679
680#[repr(C)]
681#[derive(Copy, Clone)]
682pub struct sasl_auxprop_plug {
683    pub features: c_int,
684
685    pub spare_int1: c_int,
686
687    pub glob_context: *mut c_void,
688
689    pub auxprop_free:
690        Option<unsafe extern "C" fn(glob_context: *mut c_void, utils: *const sasl_utils_t)>,
691
692    pub auxprop_lookup: Option<
693        unsafe extern "C" fn(
694            glob_context: *mut c_void,
695            sparams: *mut sasl_server_params_t,
696            flags: c_uint,
697            user: *const c_char,
698            ulen: c_uint,
699        ) -> c_int,
700    >,
701
702    pub name: *mut c_char,
703
704    pub auxprop_store: Option<
705        unsafe extern "C" fn(
706            glob_context: *mut c_void,
707            sparams: *mut sasl_server_params_t,
708            ctx: *mut propctx,
709            user: *const c_char,
710            ulen: c_uint,
711        ) -> c_int,
712    >,
713}
714
715pub type sasl_auxprop_plug_t = sasl_auxprop_plug;
716
717pub const SASL_AUXPROP_OVERRIDE: c_uint = 1;
718pub const SASL_AUXPROP_AUTHZID: c_uint = 2;
719
720pub const SASL_AUXPROP_VERIFY_AGAINST_HASH: c_uint = 16;
721
722pub const SASL_AUXPROP_PLUG_VERSION: c_uint = 8;
723
724pub type sasl_auxprop_init_t = Option<
725    unsafe extern "C" fn(
726        utils: *const sasl_utils_t,
727        max_version: c_int,
728        out_version: *mut c_int,
729        plug: *mut *mut sasl_auxprop_plug_t,
730        plugname: *const c_char,
731    ) -> c_int,
732>;
733
734extern "C" {
735    pub fn sasl_auxprop_add_plugin(
736        plugname: *const c_char,
737        auxpropfunc: sasl_auxprop_init_t,
738    ) -> c_int;
739}
740
741pub type auxprop_info_callback_t = Option<
742    unsafe extern "C" fn(
743        m: *mut sasl_auxprop_plug_t,
744        stage: sasl_info_callback_stage_t,
745        rock: *mut c_void,
746    ),
747>;
748
749extern "C" {
750    // Apparently missing in the libsasl2 shipped with macOS .
751    #[cfg(not(all(target_os = "macos", not(feature = "vendored"))))]
752    pub fn auxprop_plugin_info(
753        mech_list: *const c_char,
754        info_cb: auxprop_info_callback_t,
755        info_cb_rock: *mut c_void,
756    ) -> c_int;
757}