+
+ /* User-specified GSSAPI library */
+ if (cfg->ssh_gss_custom.path[0] &&
+ (gsslib = dlopen(cfg->ssh_gss_custom.path, RTLD_LAZY)) != NULL)
+ gss_init(&list->libraries[list->nlibraries++], gsslib,
+ 3, dupprintf("Using GSSAPI from user-specified"
+ " library '%s'", cfg->ssh_gss_custom.path));
+
+ return list;
+}
+
+void ssh_gss_cleanup(struct ssh_gss_liblist *list)
+{
+ int i;
+
+ /*
+ * dlopen and dlclose are defined to employ reference counting
+ * in the case where the same library is repeatedly dlopened, so
+ * even in a multiple-sessions-per-process context it's safe to
+ * naively dlclose everything here without worrying about
+ * destroying it under the feet of another SSH instance still
+ * using it.
+ */
+ for (i = 0; i < list->nlibraries; i++) {
+ dlclose(list->libraries[i].handle);
+ if (list->libraries[i].id == 3) {
+ /* The 'custom' id involves a dynamically allocated message.
+ * Note that we must cast away the 'const' to free it. */
+ sfree((char *)list->libraries[i].gsslogmsg);
+ }
+ }
+ sfree(list->libraries);
+ sfree(list);