7 /* Unix code to set up the GSSAPI library list. */
9 struct ssh_gss_library ssh_gss_libraries
[3];
10 int n_ssh_gss_libraries
= 0;
11 static int initialised
= FALSE
;
13 const int ngsslibs
= 3;
14 const char *const gsslibnames
[3] = {
15 "libgssapi (Heimdal)",
16 "libgssapi_krb5 (MIT Kerberos)",
19 const struct keyval gsslibkeywords
[] = {
21 { "libgssapi_krb5", 1 },
28 * Run-time binding against a choice of GSSAPI implementations. We
29 * try loading several libraries, and produce an entry in
30 * ssh_gss_libraries[] for each one.
33 static void gss_init(struct ssh_gss_library
*lib
, void *dlhandle
,
34 int id
, const char *msg
)
39 #define BIND_GSS_FN(name) \
40 lib->u.gssapi.name = (t_gss_##name) dlsym(dlhandle, "gss_" #name)
42 BIND_GSS_FN(delete_sec_context
);
43 BIND_GSS_FN(display_status
);
45 BIND_GSS_FN(import_name
);
46 BIND_GSS_FN(init_sec_context
);
47 BIND_GSS_FN(release_buffer
);
48 BIND_GSS_FN(release_cred
);
49 BIND_GSS_FN(release_name
);
53 ssh_gssapi_bind_fns(lib
);
56 /* Dynamically load gssapi libs. */
57 void ssh_gss_init(void)
61 if (initialised
) return;
64 /* Heimdal's GSSAPI Library */
65 if ((gsslib
= dlopen("libgssapi.so.2", RTLD_LAZY
)) != NULL
)
66 gss_init(&ssh_gss_libraries
[n_ssh_gss_libraries
++], gsslib
,
67 0, "Using GSSAPI from libgssapi.so.2");
69 /* MIT Kerberos's GSSAPI Library */
70 if ((gsslib
= dlopen("libgssapi_krb5.so.2", RTLD_LAZY
)) != NULL
)
71 gss_init(&ssh_gss_libraries
[n_ssh_gss_libraries
++], gsslib
,
72 1, "Using GSSAPI from libgssapi_krb5.so.2");
74 /* Sun's GSSAPI Library */
75 if ((gsslib
= dlopen("libgss.so.1", RTLD_LAZY
)) != NULL
)
76 gss_init(&ssh_gss_libraries
[n_ssh_gss_libraries
++], gsslib
,
77 2, "Using GSSAPI from libgss.so.1");
83 * Link-time binding against GSSAPI. Here we just construct a single
84 * library structure containing pointers to the functions we linked
88 #include <gssapi/gssapi.h>
90 /* Dynamically load gssapi libs. */
91 void ssh_gss_init(void)
93 if (initialised
) return;
96 n_ssh_gss_libraries
= 1;
97 ssh_gss_libraries
[0].gsslogmsg
= "Using statically linked GSSAPI";
99 #define BIND_GSS_FN(name) \
100 ssh_gss_libraries[0].u.gssapi.name = (t_gss_##name) gss_##name
102 BIND_GSS_FN(delete_sec_context
);
103 BIND_GSS_FN(display_status
);
104 BIND_GSS_FN(get_mic
);
105 BIND_GSS_FN(import_name
);
106 BIND_GSS_FN(init_sec_context
);
107 BIND_GSS_FN(release_buffer
);
108 BIND_GSS_FN(release_cred
);
109 BIND_GSS_FN(release_name
);
113 ssh_gssapi_bind_fns(&ssh_gss_libraries
[0]);
116 #endif /* NO_LIBDL */
118 #endif /* NO_GSSAPI */