msg = krb5_get_error_message(context, code);
if (msg) {
strlcpy(buffer, msg, KRB5_STRERROR_BUFSIZE);
-#ifdef HAVE_KRB5_FREE_ERROR_MESSAGE
+# ifdef HAVE_KRB5_FREE_ERROR_MESSAGE
krb5_free_error_message(context, msg);
-#elif defined(HAVE_KRB5_FREE_ERROR_STRING)
+# elif defined(HAVE_KRB5_FREE_ERROR_STRING)
{
char *free;
memcpy(&free, &msg, sizeof(free));
krb5_free_error_string(context, free);
}
-#else
-# error "No way to free error strings, missing krb5_free_error_message() and krb5_free_error_string()"
-#endif
+# else
+# error "No way to free error strings, missing krb5_free_error_message() and krb5_free_error_string()"
+# endif
} else {
strlcpy(buffer, "Unknown error", KRB5_STRERROR_BUFSIZE);
}
static int _mod_conn_free(rlm_krb5_handle_t *conn) {
krb5_free_context(conn->context);
- if (conn->keytab) {
- krb5_kt_close(conn->context, conn->keytab);
- }
+ if (conn->keytab) krb5_kt_close(conn->context, conn->keytab);
#ifdef HEIMDAL_KRB5
- if (conn->ccache) {
- krb5_cc_destroy(conn->context, conn->ccache);
- }
+ if (conn->ccache) krb5_cc_destroy(conn->context, conn->ccache);
#endif
return 0;
krb5_verify_opt_set_keytab(&conn->options, conn->keytab);
krb5_verify_opt_set_secure(&conn->options, true);
- if (inst->service) {
- krb5_verify_opt_set_service(&conn->options, inst->service);
- }
+ if (inst->service) krb5_verify_opt_set_service(&conn->options, inst->service);
#else
krb5_verify_init_creds_opt_set_ap_req_nofail(inst->vic_options, true);
#endif
#ifndef HEIMDAL_KRB5
talloc_free(inst->vic_options);
- if (inst->gic_options) {
- krb5_get_init_creds_opt_free(inst->context, inst->gic_options);
- }
-
- if (inst->server) {
- krb5_free_principal(inst->context, inst->server);
- }
+ if (inst->gic_options) krb5_get_init_creds_opt_free(inst->context, inst->gic_options);
+ if (inst->server) krb5_free_principal(inst->context, inst->server);
#endif
/* Don't free hostname, it's just a pointer into service_princ */
talloc_free(inst->service);
- if (inst->context) {
- krb5_free_context(inst->context);
- }
+ if (inst->context) krb5_free_context(inst->context);
#ifdef KRB5_IS_THREAD_SAFE
fr_connection_pool_free(inst->pool);
#endif
}
inst->xlat_name = cf_section_name2(conf);
- if (!inst->xlat_name) {
- inst->xlat_name = cf_section_name1(conf);
- }
+ if (!inst->xlat_name) inst->xlat_name = cf_section_name1(conf);
ret = krb5_init_context(&inst->context);
if (ret) {
}
#ifdef HEIMDAL_KRB5
- if (inst->hostname) {
- DEBUG("rlm_krb5 (%s): Ignoring hostname component of service principal \"%s\", not "
- "needed/supported by Heimdal", inst->xlat_name, inst->hostname);
- }
+ if (inst->hostname) DEBUG("rlm_krb5 (%s): Ignoring hostname component of service principal \"%s\", not "
+ "needed/supported by Heimdal", inst->xlat_name, inst->hostname);
#else
/*
krb5_principal client;
-#ifdef KRB5_IS_THREAD_SAFE
+# ifdef KRB5_IS_THREAD_SAFE
conn = fr_connection_get(inst->pool);
if (!conn) return RLM_MODULE_FAIL;
-#else
+# else
conn = inst->conn;
-#endif
+# endif
/*
* Zero out local storage
krb5_free_principal(conn->context, client);
}
-#ifdef KRB5_IS_THREAD_SAFE
+# ifdef KRB5_IS_THREAD_SAFE
fr_connection_release(inst->pool, conn);
-#endif
+# endif
return rcode;
}
rad_assert(inst->context);
-#ifdef KRB5_IS_THREAD_SAFE
+# ifdef KRB5_IS_THREAD_SAFE
conn = fr_connection_get(inst->pool);
if (!conn) return RLM_MODULE_FAIL;
-#else
+# else
conn = inst->conn;
-#endif
+# endif
/*
* Zero out local storage
RDEBUG("Attempting to authenticate against service principal");
ret = krb5_verify_init_creds(conn->context, &init_creds, inst->server, conn->keytab, NULL, inst->vic_options);
- if (ret) {
- rcode = krb5_process_error(request, conn, ret);
- }
+ if (ret) rcode = krb5_process_error(request, conn, ret);
cleanup:
- if (client) {
- krb5_free_principal(conn->context, client);
- }
+ if (client) krb5_free_principal(conn->context, client);
krb5_free_cred_contents(conn->context, &init_creds);
-#ifdef KRB5_IS_THREAD_SAFE
+# ifdef KRB5_IS_THREAD_SAFE
fr_connection_release(inst->pool, conn);
-#endif
+# endif
return rcode;
}