Changeset 988 for vendor/current/source4/kdc/kdc.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/kdc/kdc.c
r740 r988 33 33 #include "param/param.h" 34 34 #include "kdc/kdc-glue.h" 35 #include "kdc/pac-glue.h" 35 36 #include "dsdb/samdb/samdb.h" 36 37 #include "auth/session.h" 38 #include "libds/common/roles.h" 39 40 NTSTATUS server_service_kdc_init(void); 37 41 38 42 extern struct krb5plugin_windc_ftable windc_plugin_table; 39 extern struct hdb_method hdb_samba4;40 43 41 44 static NTSTATUS kdc_proxy_unavailable_error(struct kdc_server *kdc, … … 616 619 struct kdc_udp_call *call = tevent_req_callback_data(subreq, 617 620 struct kdc_udp_call); 618 ssize_t ret;619 621 int sys_errno; 620 622 621 ret =tdgram_sendto_queue_recv(subreq, &sys_errno);623 tdgram_sendto_queue_recv(subreq, &sys_errno); 622 624 623 625 /* We don't care about errors */ … … 653 655 &kdc_socket->local_address); 654 656 if (ret != 0) { 655 status = map_nt_error_from_unix (errno);657 status = map_nt_error_from_unix_common(errno); 656 658 return status; 657 659 } … … 684 686 &kdc_udp_socket->dgram); 685 687 if (ret != 0) { 686 status = map_nt_error_from_unix (errno);688 status = map_nt_error_from_unix_common(errno); 687 689 DEBUG(0,("Failed to bind to %s:%u UDP - %s\n", 688 690 address, port, nt_errstr(status))); … … 728 730 } 729 731 730 num_interfaces = iface_ count(ifaces);732 num_interfaces = iface_list_count(ifaces); 731 733 732 734 /* if we are allowing incoming packets from any address, then 733 735 we need to bind to the wildcard address */ 734 736 if (!lpcfg_bind_interfaces_only(lp_ctx)) { 735 if (kdc_port) { 736 status = kdc_add_socket(kdc, model_ops, 737 "kdc", "0.0.0.0", kdc_port, 738 kdc_process, false); 739 NT_STATUS_NOT_OK_RETURN(status); 740 } 741 742 if (kpasswd_port) { 743 status = kdc_add_socket(kdc, model_ops, 744 "kpasswd", "0.0.0.0", kpasswd_port, 745 kpasswdd_process, false); 746 NT_STATUS_NOT_OK_RETURN(status); 737 int num_binds = 0; 738 char **wcard = iface_list_wildcard(kdc); 739 NT_STATUS_HAVE_NO_MEMORY(wcard); 740 for (i=0; wcard[i]; i++) { 741 if (kdc_port) { 742 status = kdc_add_socket(kdc, model_ops, 743 "kdc", wcard[i], kdc_port, 744 kdc_process, false); 745 if (NT_STATUS_IS_OK(status)) { 746 num_binds++; 747 } 748 } 749 750 if (kpasswd_port) { 751 status = kdc_add_socket(kdc, model_ops, 752 "kpasswd", wcard[i], kpasswd_port, 753 kpasswdd_process, false); 754 if (NT_STATUS_IS_OK(status)) { 755 num_binds++; 756 } 757 } 758 } 759 talloc_free(wcard); 760 if (num_binds == 0) { 761 return NT_STATUS_INVALID_PARAMETER_MIX; 747 762 } 748 763 done_wildcard = true; … … 750 765 751 766 for (i=0; i<num_interfaces; i++) { 752 const char *address = talloc_strdup(tmp_ctx, iface_ n_ip(ifaces, i));767 const char *address = talloc_strdup(tmp_ctx, iface_list_n_ip(ifaces, i)); 753 768 754 769 if (kdc_port) { … … 772 787 } 773 788 774 775 789 static NTSTATUS kdc_check_generic_kerberos(struct irpc_message *msg, 776 790 struct kdc_check_generic_kerberos *r) … … 781 795 struct kdc_server *kdc = talloc_get_type(msg->private_data, struct kdc_server); 782 796 enum ndr_err_code ndr_err; 783 krb5_enctype etype;784 797 int ret; 785 798 hdb_entry_ex ent; 786 799 krb5_principal principal; 787 krb5_keyblock keyblock;788 Key *key;789 800 790 801 /* There is no reply to this request */ … … 797 808 } 798 809 799 if (pac_validate.MessageType != 3) {810 if (pac_validate.MessageType != NETLOGON_GENERIC_KRB5_PAC_VALIDATE) { 800 811 /* We don't implement any other message types - such as certificate validation - yet */ 801 812 return NT_STATUS_INVALID_PARAMETER; … … 810 821 srv_sig = data_blob_const(pac_validate.ChecksumAndSignature.data, 811 822 pac_validate.ChecksumLength); 812 813 if (pac_validate.SignatureType == CKSUMTYPE_HMAC_MD5) {814 etype = ETYPE_ARCFOUR_HMAC_MD5;815 } else {816 ret = krb5_cksumtype_to_enctype(kdc->smb_krb5_context->krb5_context, pac_validate.SignatureType,817 &etype);818 if (ret != 0) {819 return NT_STATUS_LOGON_FAILURE;820 }821 }822 823 823 824 ret = krb5_make_principal(kdc->smb_krb5_context->krb5_context, &principal, … … 844 845 } 845 846 846 ret = hdb_enctype2key(kdc->smb_krb5_context->krb5_context, &ent.entry, etype, &key);847 848 if (ret != 0) {849 hdb_free_entry(kdc->smb_krb5_context->krb5_context, &ent);850 krb5_free_principal(kdc->smb_krb5_context->krb5_context, principal);851 return NT_STATUS_LOGON_FAILURE;852 }853 854 keyblock = key->key;855 856 847 kdc_sig.type = pac_validate.SignatureType; 857 848 kdc_sig.signature = data_blob_const(&pac_validate.ChecksumAndSignature.data[pac_validate.ChecksumLength], 858 849 pac_validate.SignatureLength); 859 ret = check_pac_checksum(msg, srv_sig, &kdc_sig, 860 kdc->smb_krb5_context->krb5_context, &keyblock);850 851 ret = kdc_check_pac(kdc->smb_krb5_context->krb5_context, srv_sig, &kdc_sig, &ent); 861 852 862 853 hdb_free_entry(kdc->smb_krb5_context->krb5_context, &ent); … … 889 880 task_server_terminate(task, "kdc: no KDC required in member server configuration", false); 890 881 return; 891 case ROLE_DOMAIN_CONTROLLER: 882 case ROLE_DOMAIN_PDC: 883 case ROLE_DOMAIN_BDC: 884 task_server_terminate(task, "Cannot start KDC as a 'classic Samba' DC", true); 885 return; 886 case ROLE_ACTIVE_DIRECTORY_DC: 892 887 /* Yes, we want a KDC */ 893 888 break; 894 889 } 895 890 896 load_interface s(task, lpcfg_interfaces(task->lp_ctx), &ifaces);897 898 if (iface_ count(ifaces) == 0) {891 load_interface_list(task, task->lp_ctx, &ifaces); 892 893 if (iface_list_count(ifaces) == 0) { 899 894 task_server_terminate(task, "kdc: no network interfaces configured", false); 900 895 return; … … 933 928 initialize_krb5_error_table(); 934 929 935 ret = smb_krb5_init_context(kdc, task-> event_ctx, task->lp_ctx, &kdc->smb_krb5_context);930 ret = smb_krb5_init_context(kdc, task->lp_ctx, &kdc->smb_krb5_context); 936 931 if (ret) { 937 932 DEBUG(1,("kdc_task_init: krb5_init_context failed (%s)\n", … … 950 945 } 951 946 952 kdc->config->logf = kdc->smb_krb5_context->logf;947 kdc->config->logf = (krb5_log_facility *)kdc->smb_krb5_context->pvt_log_data; 953 948 kdc->config->db = talloc(kdc, struct HDB *); 954 949 if (!kdc->config->db) { … … 957 952 } 958 953 kdc->config->num_db = 1; 954 955 /* 956 * This restores the behavior before 957 * commit 255e3e18e00f717d99f3bc57c8a8895ff624f3c3 958 * s4:heimdal: import lorikeet-heimdal-201107150856 959 * (commit 48936803fae4a2fb362c79365d31f420c917b85b) 960 * 961 * as_use_strongest_session_key,preauth_use_strongest_session_key 962 * and tgs_use_strongest_session_key are input to the 963 * _kdc_find_etype() function. The old bahavior is in 964 * the use_strongest_session_key=FALSE code path. 965 * (The only remaining difference in _kdc_find_etype() 966 * is the is_preauth parameter.) 967 * 968 * The old behavior in the _kdc_get_preferred_key() 969 * function is use_strongest_server_key=TRUE. 970 */ 971 kdc->config->as_use_strongest_session_key = false; 972 kdc->config->preauth_use_strongest_session_key = false; 973 kdc->config->tgs_use_strongest_session_key = false; 974 kdc->config->use_strongest_server_key = true; 959 975 960 976 /* Register hdb-samba4 hooks for use as a keytab */ … … 979 995 ret = krb5_plugin_register(kdc->smb_krb5_context->krb5_context, 980 996 PLUGIN_TYPE_DATA, "hdb", 981 &hdb_samba4 );997 &hdb_samba4_interface); 982 998 if(ret) { 983 999 task_server_terminate(task, "kdc: failed to register hdb plugin", true);
Note:
See TracChangeset
for help on using the changeset viewer.