int /* R: -1 on failure, else 0 */ auth_krb4_init ( /* PARAMETERS */ void /* no parameters */ /* END PARAMETERS */ ) { #ifdef AUTH_KRB4 /* VARIABLES */ int rc; /* return code holder */ char *configname = 0; /* END VARIABLES */ if (mech_option) configname = mech_option; else if (access(SASLAUTHD_CONF_FILE_DEFAULT, F_OK) == 0) configname = SASLAUTHD_CONF_FILE_DEFAULT; if (configname) { char complaint[1024]; config = cfile_read(configname, complaint, sizeof(complaint)); if (!config) { syslog(LOG_ERR, "auth_krb4_init %s", complaint); return -1; } } if (config) { srvtabname = cfile_getstring(config, "krb4_srvtab", srvtabname); verify_principal = cfile_getstring(config, "krb4_verify_principal", verify_principal); } if (krbtf_init() == -1) { syslog(LOG_ERR, "auth_krb4_init krbtf_init failed"); return -1; } rc = krb_get_lrealm(default_realm, 1); if (rc) { syslog(LOG_ERR, "auth_krb4: krb_get_lrealm: %s", krb_get_err_text(rc)); return -1; } if (gethostname(myhostname, sizeof(myhostname)) < 0) { syslog(LOG_ERR, "auth_krb4: gethoanem(): %m"); return -1; } myhostname[sizeof(myhostname) - 1] = '\0'; return 0; #else /* ! AUTH_KRB4 */ return -1; #endif /* ! AUTH_KRB4 */ }
int /* R: -1 on failure, else 0 */ auth_krb5_init ( /* PARAMETERS */ void /* no parameters */ /* END PARAMETERS */ ) { #ifdef AUTH_KRB5 int rc; char *configname = 0; if (krbtf_init() == -1) { syslog(LOG_ERR, "auth_krb5_init krbtf_init failed"); return -1; } if (mech_option) configname = mech_option; else if (access(SASLAUTHD_CONF_FILE_DEFAULT, F_OK) == 0) configname = SASLAUTHD_CONF_FILE_DEFAULT; if (configname) { char complaint[1024]; if (!(config = cfile_read(configname, complaint, (int)sizeof (complaint)))) { syslog(LOG_ERR, "auth_krb5_init %s", complaint); return -1; } } if (config) { keytabname = cfile_getstring(config, "krb5_keytab", keytabname); verify_principal = cfile_getstring(config, "krb5_verify_principal", verify_principal); } return 0; #else return -1; #endif }
int auth_httpform_init ( /* PARAMETERS */ void /* no parameters */ /* END PARAMETERS */ ) { /* VARIABLES */ int rc; char *configname = NULL; struct addrinfo hints; /* END VARIABLES */ /* name of config file may be given with -O option */ if (mech_option) configname = mech_option; else if (access(SASLAUTHD_CONF_FILE_DEFAULT, F_OK) == 0) configname = SASLAUTHD_CONF_FILE_DEFAULT; /* open and read config file */ if (configname) { char complaint[1024]; if (!(config = cfile_read(configname, complaint, sizeof (complaint)))) { syslog(LOG_ERR, "auth_httpform_init %s", complaint); return -1; } } if (config) { r_host = cfile_getstring(config, "httpform_host", r_host); r_port = cfile_getstring(config, "httpform_port", r_port); r_uri = cfile_getstring(config, "httpform_uri", r_uri); formdata = cfile_getstring(config, "httpform_data", formdata); } if (formdata == NULL || r_uri == NULL) { syslog(LOG_ERR, "auth_httpform_init formdata and uri must be specified"); return -1; } /* lookup the host/port - taken from auth_rimap */ if (ai) freeaddrinfo(ai); memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; if ((rc = getaddrinfo(r_host, r_port, &hints, &ai)) != 0) { syslog(LOG_ERR, "auth_httpform_init: getaddrinfo %s/%s: %s", r_host, r_port, gai_strerror(rc)); return -1; } /* Make sure we have AF_INET or AF_INET6 addresses. */ if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) { syslog(LOG_ERR, "auth_httpform_init: no IP address info for %s", ai->ai_canonname ? ai->ai_canonname : r_host); freeaddrinfo(ai); ai = NULL; return -1; } return 0; }