void *private_data;
};
-enum kdc_process_ret {
- KDC_PROCESS_OK=0,
- KDC_PROCESS_FAILED,
- KDC_PROCESS_PROXY};
+typedef enum kdc_code_e {
+ KDC_OK = 0,
+ KDC_ERROR,
+ KDC_PROXY_REQUEST
+} kdc_code;
-enum kdc_process_ret kpasswdd_process(struct kdc_server *kdc,
- TALLOC_CTX *mem_ctx,
- DATA_BLOB *input,
- DATA_BLOB *reply,
- struct tsocket_address *peer_addr,
- struct tsocket_address *my_addr,
- int datagram_reply);
+kdc_code kpasswdd_process(struct kdc_server *kdc,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *input,
+ DATA_BLOB *reply,
+ struct tsocket_address *peer_addr,
+ struct tsocket_address *my_addr,
+ int datagram_reply);
/* from hdb-samba4.c */
NTSTATUS hdb_samba4_create_kdc(struct samba_kdc_base_context *base_ctx,
return NT_STATUS_OK;
}
-typedef enum kdc_process_ret (*kdc_process_fn_t)(struct kdc_server *kdc,
- TALLOC_CTX *mem_ctx,
- DATA_BLOB *input,
- DATA_BLOB *reply,
- struct tsocket_address *peer_addr,
- struct tsocket_address *my_addr,
- int datagram);
+typedef kdc_code (*kdc_process_fn_t)(struct kdc_server *kdc,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *input,
+ DATA_BLOB *reply,
+ struct tsocket_address *peer_addr,
+ struct tsocket_address *my_addr,
+ int datagram);
/* hold information about one kdc socket */
struct kdc_socket {
calling conventions
*/
-static enum kdc_process_ret kdc_process(struct kdc_server *kdc,
- TALLOC_CTX *mem_ctx,
- DATA_BLOB *input,
- DATA_BLOB *reply,
- struct tsocket_address *peer_addr,
- struct tsocket_address *my_addr,
- int datagram_reply)
+static kdc_code kdc_process(struct kdc_server *kdc,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *input,
+ DATA_BLOB *reply,
+ struct tsocket_address *peer_addr,
+ struct tsocket_address *my_addr,
+ int datagram_reply)
{
int ret;
char *pa;
ret = tsocket_address_bsd_sockaddr(peer_addr, (struct sockaddr *) &ss,
sizeof(struct sockaddr_storage));
if (ret < 0) {
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
pa = tsocket_address_string(peer_addr, mem_ctx);
if (pa == NULL) {
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
DEBUG(10,("Received KDC packet of length %lu from %s\n",
datagram_reply);
if (ret == -1) {
*reply = data_blob(NULL, 0);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
if (ret == HDB_ERR_NOT_FOUND_HERE) {
*reply = data_blob(NULL, 0);
- return KDC_PROCESS_PROXY;
+ return KDC_PROXY_REQUEST;
}
if (k5_reply.length) {
} else {
*reply = data_blob(NULL, 0);
}
- return KDC_PROCESS_OK;
+ return KDC_OK;
}
static void kdc_tcp_call_proxy_done(struct tevent_req *subreq);
struct kdc_tcp_connection);
struct kdc_tcp_call *call;
NTSTATUS status;
- enum kdc_process_ret ret;
+ kdc_code ret;
call = talloc(kdc_conn, struct kdc_tcp_call);
if (call == NULL) {
kdc_conn->conn->remote_address,
kdc_conn->conn->local_address,
0 /* Stream */);
- if (ret == KDC_PROCESS_FAILED) {
+ if (ret == KDC_ERROR) {
kdc_tcp_terminate_connection(kdc_conn,
"kdc_tcp_call_loop: process function failed");
return;
}
- if (ret == KDC_PROCESS_PROXY) {
+ if (ret == KDC_PROXY_REQUEST) {
uint16_t port;
if (!kdc_conn->kdc_socket->kdc->am_rodc) {
uint8_t *buf;
ssize_t len;
int sys_errno;
- enum kdc_process_ret ret;
+ kdc_code ret;
call = talloc(sock, struct kdc_udp_call);
if (call == NULL) {
call->src,
sock->kdc_socket->local_address,
1 /* Datagram */);
- if (ret == KDC_PROCESS_FAILED) {
+ if (ret == KDC_ERROR) {
talloc_free(call);
goto done;
}
- if (ret == KDC_PROCESS_PROXY) {
+ if (ret == KDC_PROXY_REQUEST) {
uint16_t port;
if (!sock->kdc_socket->kdc->am_rodc) {
}
}
-enum kdc_process_ret kpasswdd_process(struct kdc_server *kdc,
- TALLOC_CTX *mem_ctx,
- DATA_BLOB *input,
- DATA_BLOB *reply,
- struct tsocket_address *peer_addr,
- struct tsocket_address *my_addr,
- int datagram_reply)
+kdc_code kpasswdd_process(struct kdc_server *kdc,
+ TALLOC_CTX *mem_ctx,
+ DATA_BLOB *input,
+ DATA_BLOB *reply,
+ struct tsocket_address *peer_addr,
+ struct tsocket_address *my_addr,
+ int datagram_reply)
{
bool ret;
const uint16_t header_len = 6;
char *keytab_name;
if (!tmp_ctx) {
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
if (kdc->am_rodc) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_PROXY;
+ return KDC_PROXY_REQUEST;
}
/* Be parinoid. We need to ensure we don't just let the
* caller lead us into a buffer overflow */
if (input->length <= header_len) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
len = RSVAL(input->data, 0);
if (input->length != len) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* There are two different versions of this protocol so far,
ap_req_len = RSVAL(input->data, 4);
if ((ap_req_len >= len) || (ap_req_len + header_len) >= len) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
krb_priv_len = len - ap_req_len;
if (!server_credentials) {
DEBUG(1, ("Failed to init server credentials\n"));
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* We want the credentials subsystem to use the krb5 context
&gensec_security);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* The kerberos PRIV packets include these addresses. MIT
nt_status = gensec_set_remote_address(gensec_security, peer_addr);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
#endif
nt_status = gensec_set_local_address(gensec_security, my_addr);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* We want the GENSEC wrap calls to generate PRIV tokens */
nt_status = gensec_start_mech_by_name(gensec_security, "krb5");
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* Accept the AP-REQ and generate teh AP-REP we need for the reply */
goto reply;
}
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* Extract the data from the KRB-PRIV half of the message */
goto reply;
}
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* Figure out something to do with it (probably changing a password...) */
if (!ret) {
/* Argh! */
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
/* And wrap up the reply: This ensures that the error message
goto reply;
}
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
reply:
*reply = data_blob_talloc(mem_ctx, NULL, krb_priv_rep.length + ap_rep.length + header_len);
if (!reply->data) {
talloc_free(tmp_ctx);
- return KDC_PROCESS_FAILED;
+ return KDC_ERROR;
}
RSSVAL(reply->data, 0, reply->length);
krb_priv_rep.length);
talloc_free(tmp_ctx);
- return KDC_PROCESS_OK;
+ return KDC_OK;
}