Changeset 988 for vendor/current/source4/ldap_server
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- Location:
- vendor/current/source4/ldap_server
- Files:
-
- 31 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/ldap_server/ldap_backend.c
r740 r988 24 24 #include "auth/credentials/credentials.h" 25 25 #include "auth/gensec/gensec.h" 26 #include "auth/gensec/gensec_internal.h" /* TODO: remove this */ 26 27 #include "param/param.h" 27 28 #include "smbd/service_stream.h" … … 170 171 171 172 *errstring = talloc_asprintf(mem_ctx, "%08X: %s", W_ERROR_V(err), 172 ldb_strerror(ldb_err)); 173 if (add_err_string != NULL) { 174 *errstring = talloc_asprintf(mem_ctx, "%s - %s", *errstring, 175 add_err_string); 176 } 177 173 add_err_string != NULL ? add_err_string : ldb_strerror(ldb_err)); 174 178 175 /* result is 1:1 for now */ 179 176 return ldb_err; … … 196 193 if (conn->server_credentials) { 197 194 char **sasl_mechs = NULL; 198 struct gensec_security_ops **backends = gensec_security_all();199 struct gensec_security_ops **ops195 const struct gensec_security_ops * const *backends = gensec_security_all(); 196 const struct gensec_security_ops **ops 200 197 = gensec_use_kerberos_mechs(conn, backends, conn->server_credentials); 201 198 unsigned int i, j = 0; … … 230 227 } 231 228 229 ldb_set_opaque(conn->ldb, "remoteAddress", 230 conn->connection->remote_address); 231 232 232 return NT_STATUS_OK; 233 233 } … … 256 256 void ldapsrv_queue_reply(struct ldapsrv_call *call, struct ldapsrv_reply *reply) 257 257 { 258 DLIST_ADD_END(call->replies, reply , struct ldapsrv_reply *);258 DLIST_ADD_END(call->replies, reply); 259 259 } 260 260 … … 286 286 const struct ldb_message *message, 287 287 struct ldb_control **controls, 288 void *context)288 struct ldb_result *res) 289 289 { 290 290 struct ldb_context *ldb = call->conn->ldb; … … 300 300 message, 301 301 controls, 302 context,302 res, 303 303 ldb_modify_default_callback, 304 304 NULL); 305 305 306 306 if (ret != LDB_SUCCESS) return ret; 307 308 if (call->conn->global_catalog) { 309 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port"); 310 } 311 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL); 307 312 308 313 ret = ldb_transaction_start(ldb); … … 337 342 const struct ldb_message *message, 338 343 struct ldb_control **controls, 339 void *context)344 struct ldb_result *res) 340 345 { 341 346 struct ldb_context *ldb = call->conn->ldb; … … 351 356 message, 352 357 controls, 353 context,358 res, 354 359 ldb_modify_default_callback, 355 360 NULL); … … 358 363 return ret; 359 364 } 365 366 if (call->conn->global_catalog) { 367 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port"); 368 } 369 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL); 360 370 361 371 ret = ldb_transaction_start(ldb); … … 390 400 struct ldb_dn *dn, 391 401 struct ldb_control **controls, 392 void *context)402 struct ldb_result *res) 393 403 { 394 404 struct ldb_context *ldb = call->conn->ldb; … … 399 409 dn, 400 410 controls, 401 context,411 res, 402 412 ldb_modify_default_callback, 403 413 NULL); 404 414 405 415 if (ret != LDB_SUCCESS) return ret; 416 417 if (call->conn->global_catalog) { 418 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port"); 419 } 420 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL); 406 421 407 422 ret = ldb_transaction_start(ldb); … … 436 451 struct ldb_dn *newdn, 437 452 struct ldb_control **controls, 438 void *context)453 struct ldb_result *res) 439 454 { 440 455 struct ldb_context *ldb = call->conn->ldb; … … 445 460 olddn, 446 461 newdn, 447 NULL,448 context,462 controls, 463 res, 449 464 ldb_modify_default_callback, 450 465 NULL); 451 466 452 467 if (ret != LDB_SUCCESS) return ret; 468 469 if (call->conn->global_catalog) { 470 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port"); 471 } 472 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL); 453 473 454 474 ret = ldb_transaction_start(ldb); … … 583 603 ldb_request_add_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID, false, search_options); 584 604 } 605 } else { 606 ldb_request_add_control(lreq, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL); 585 607 } 586 608 … … 1145 1167 unsigned int i; 1146 1168 struct ldap_message *msg = call->request; 1169 struct ldb_context *samdb = call->conn->ldb; 1170 NTSTATUS status; 1171 time_t *lastts; 1147 1172 /* Check for undecoded critical extensions */ 1148 1173 for (i=0; msg->controls && msg->controls[i]; i++) { … … 1163 1188 return ldapsrv_SearchRequest(call); 1164 1189 case LDAP_TAG_ModifyRequest: 1165 return ldapsrv_ModifyRequest(call); 1190 status = ldapsrv_ModifyRequest(call); 1191 break; 1166 1192 case LDAP_TAG_AddRequest: 1167 return ldapsrv_AddRequest(call); 1193 status = ldapsrv_AddRequest(call); 1194 break; 1168 1195 case LDAP_TAG_DelRequest: 1169 1196 return ldapsrv_DelRequest(call); … … 1179 1206 return ldapsrv_unwilling(call, LDAP_PROTOCOL_ERROR); 1180 1207 } 1181 } 1208 1209 if (NT_STATUS_IS_OK(status)) { 1210 lastts = (time_t *)ldb_get_opaque(samdb, DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME); 1211 if (lastts && !*lastts) { 1212 DEBUG(10, ("Schema update now was requested, " 1213 "fullfilling the request ts = %d\n", 1214 (int)*lastts)); 1215 /* 1216 * Just requesting the schema will do the trick 1217 * as the delay for reload is experied, we will have a reload 1218 * from the schema as expected as we are not yet in a transaction! 1219 */ 1220 dsdb_get_schema(samdb, NULL); 1221 *lastts = time(NULL); 1222 ldb_set_opaque(samdb, DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME, lastts); 1223 } 1224 } 1225 return status; 1226 } -
vendor/current/source4/ldap_server/ldap_bind.c
r740 r988 46 46 DEBUG(10, ("BindSimple dn: %s\n",req->dn)); 47 47 48 reply = ldapsrv_init_reply(call, LDAP_TAG_BindResponse); 49 if (!reply) { 50 return NT_STATUS_NO_MEMORY; 51 } 52 53 if (req->dn != NULL && 54 strlen(req->dn) != 0 && 55 call->conn->require_strong_auth > LDAP_SERVER_REQUIRE_STRONG_AUTH_NO && 56 call->conn->sockets.active != call->conn->sockets.tls) 57 { 58 status = NT_STATUS_NETWORK_ACCESS_DENIED; 59 result = LDAP_STRONG_AUTH_REQUIRED; 60 errstr = talloc_asprintf(reply, 61 "BindSimple: Transport encryption required."); 62 goto do_reply; 63 } 64 48 65 status = crack_auto_name_to_nt4_name(call, call->conn->connection->event.ctx, call->conn->lp_ctx, req->dn, &nt4_domain, &nt4_account); 49 66 if (NT_STATUS_IS_OK(status)) { … … 59 76 } 60 77 61 reply = ldapsrv_init_reply(call, LDAP_TAG_BindResponse);62 if (!reply) {63 return NT_STATUS_NO_MEMORY;64 }65 66 78 if (NT_STATUS_IS_OK(status)) { 67 79 result = LDAP_SUCCESS; … … 69 81 70 82 talloc_unlink(call->conn, call->conn->session_info); 71 call->conn->session_info = session_info; 72 talloc_steal(call->conn, session_info); 83 call->conn->session_info = talloc_steal(call->conn, session_info); 73 84 74 85 /* don't leak the old LDB */ … … 88 99 } 89 100 101 do_reply: 90 102 resp = &reply->msg->r.BindResponse; 91 103 resp->response.resultcode = result; … … 183 195 gensec_want_feature(conn->gensec, GENSEC_FEATURE_SEAL); 184 196 gensec_want_feature(conn->gensec, GENSEC_FEATURE_ASYNC_REPLIES); 197 gensec_want_feature(conn->gensec, GENSEC_FEATURE_LDAP_STYLE); 185 198 186 199 status = gensec_start_mech_by_sasl_name(conn->gensec, req->creds.SASL.mechanism); … … 204 217 } 205 218 206 status = gensec_update (conn->gensec, reply,207 219 status = gensec_update_ev(conn->gensec, reply, conn->connection->event.ctx, 220 input, &output); 208 221 209 222 /* Windows 2000 mmc doesn't like secblob == NULL and reports a decoding error */ … … 219 232 errstr = NULL; 220 233 } else if (NT_STATUS_IS_OK(status)) { 221 struct auth_session_info *old_session_info=NULL;222 234 struct ldapsrv_sasl_postprocess_context *context = NULL; 223 235 … … 264 276 } 265 277 } 278 } else { 279 switch (call->conn->require_strong_auth) { 280 case LDAP_SERVER_REQUIRE_STRONG_AUTH_NO: 281 break; 282 case LDAP_SERVER_REQUIRE_STRONG_AUTH_ALLOW_SASL_OVER_TLS: 283 if (call->conn->sockets.active == call->conn->sockets.tls) { 284 break; 285 } 286 status = NT_STATUS_NETWORK_ACCESS_DENIED; 287 result = LDAP_STRONG_AUTH_REQUIRED; 288 errstr = talloc_asprintf(reply, 289 "SASL:[%s]: not allowed if TLS is used.", 290 req->creds.SASL.mechanism); 291 break; 292 case LDAP_SERVER_REQUIRE_STRONG_AUTH_YES: 293 status = NT_STATUS_NETWORK_ACCESS_DENIED; 294 result = LDAP_STRONG_AUTH_REQUIRED; 295 errstr = talloc_asprintf(reply, 296 "SASL:[%s]: Sign or Seal are required.", 297 req->creds.SASL.mechanism); 298 break; 299 } 266 300 } 267 301 268 302 if (result != LDAP_SUCCESS) { 269 conn->session_info = old_session_info;270 303 } else if (!NT_STATUS_IS_OK(status)) { 271 conn->session_info = old_session_info;272 304 result = LDAP_OPERATIONS_ERROR; 273 305 errstr = talloc_asprintf(reply, … … 275 307 req->creds.SASL.mechanism, nt_errstr(status)); 276 308 } else { 309 struct auth_session_info *old_session_info=NULL; 277 310 278 311 old_session_info = conn->session_info; 279 312 conn->session_info = NULL; 280 status = gensec_session_info(conn->gensec, &conn->session_info);313 status = gensec_session_info(conn->gensec, conn, &conn->session_info); 281 314 if (!NT_STATUS_IS_OK(status)) { 282 315 conn->session_info = old_session_info; … … 287 320 } else { 288 321 talloc_unlink(conn, old_session_info); 289 talloc_steal(conn, conn->session_info);290 322 291 323 /* don't leak the old LDB */ -
vendor/current/source4/ldap_server/ldap_extended.c
r740 r988 83 83 TALLOC_FREE(subreq); 84 84 if (ret == -1) { 85 NTSTATUS status = map_nt_error_from_unix (sys_errno);85 NTSTATUS status = map_nt_error_from_unix_common(sys_errno); 86 86 87 87 DEBUG(1,("ldapsrv_starttls_postprocess_done: accept_tls_loop: " … … 186 186 */ 187 187 status = extended_ops[i].fn(call, reply, &error_str); 188 NT_STATUS_IS_OK_RETURN(status); 188 if (NT_STATUS_IS_OK(status)) { 189 return status; 190 } 189 191 190 192 if (NT_STATUS_IS_LDAP(status)) { -
vendor/current/source4/ldap_server/ldap_server.c
r740 r988 47 47 #include "../lib/util/tevent_ntstatus.h" 48 48 #include "../libcli/util/tstream.h" 49 #include "libds/common/roles.h" 49 50 50 51 static void ldapsrv_terminate_connection_done(struct tevent_req *subreq); … … 100 101 tevent_req_callback_data(subreq, 101 102 struct ldapsrv_connection); 102 int ret;103 103 int sys_errno; 104 104 105 ret =tstream_disconnect_recv(subreq, &sys_errno);105 tstream_disconnect_recv(subreq, &sys_errno); 106 106 TALLOC_FREE(subreq); 107 107 … … 219 219 220 220 s = sscanf((const char *)el->values[i].data, "%255[^=]=%d", policy_name, &policy_value); 221 if ( ret!= 2 || policy_value == 0)221 if (s != 2 || policy_value == 0) 222 222 continue; 223 224 223 if (strcasecmp("InitRecvTimeout", policy_name) == 0) { 225 224 conn->limits.initial_timeout = policy_value; … … 335 334 conn->session_info = session_info; 336 335 336 conn->sockets.active = conn->sockets.raw; 337 338 if (conn->is_privileged) { 339 conn->require_strong_auth = LDAP_SERVER_REQUIRE_STRONG_AUTH_NO; 340 } else { 341 conn->require_strong_auth = lpcfg_ldap_server_require_strong_auth(conn->lp_ctx); 342 } 343 337 344 if (!NT_STATUS_IS_OK(ldapsrv_backend_Init(conn))) { 338 345 ldapsrv_terminate_connection(conn, "backend Init failed"); … … 345 352 /* register the server */ 346 353 irpc_add_name(c->msg_ctx, "ldap_server"); 347 348 conn->sockets.active = conn->sockets.raw;349 354 350 355 if (port != 636 && port != 3269) { … … 709 714 ldapsrv_process_call_trigger, NULL); 710 715 if (!ok) { 711 tevent_req_ nomem(NULL,req);716 tevent_req_oom(req); 712 717 return tevent_req_post(req, ev); 713 718 } … … 816 821 status = stream_setup_socket(task, task->event_ctx, lp_ctx, 817 822 model_ops, &ldap_stream_nonpriv_ops, 818 "ip v4", address, &port,823 "ip", address, &port, 819 824 lpcfg_socket_options(lp_ctx), 820 825 ldap_service); … … 831 836 model_ops, 832 837 &ldap_stream_nonpriv_ops, 833 "ip v4", address, &port,838 "ip", address, &port, 834 839 lpcfg_socket_options(lp_ctx), 835 840 ldap_service); … … 853 858 model_ops, 854 859 &ldap_stream_nonpriv_ops, 855 "ip v4", address, &port,860 "ip", address, &port, 856 861 lpcfg_socket_options(lp_ctx), 857 862 ldap_service); … … 867 872 model_ops, 868 873 &ldap_stream_nonpriv_ops, 869 "ip v4", address, &port,874 "ip", address, &port, 870 875 lpcfg_socket_options(lp_ctx), 871 876 ldap_service); … … 908 913 false); 909 914 return; 910 case ROLE_ DOMAIN_CONTROLLER:915 case ROLE_ACTIVE_DIRECTORY_DC: 911 916 /* Yes, we want an LDAP server */ 912 917 break; … … 937 942 lpcfg_tls_crlfile(ldap_service, task->lp_ctx), 938 943 lpcfg_tls_dhpfile(ldap_service, task->lp_ctx), 944 lpcfg_tls_priority(task->lp_ctx), 939 945 &ldap_service->tls_params); 940 946 if (!NT_STATUS_IS_OK(status)) { 941 DEBUG(0,("ldapsrv failed tstream_tls_pa tams_server - %s\n",947 DEBUG(0,("ldapsrv failed tstream_tls_params_server - %s\n", 942 948 nt_errstr(status))); 943 949 goto failed; … … 952 958 int i; 953 959 954 load_interface s(task, lpcfg_interfaces(task->lp_ctx), &ifaces);955 num_interfaces = iface_ count(ifaces);960 load_interface_list(task, task->lp_ctx, &ifaces); 961 num_interfaces = iface_list_count(ifaces); 956 962 957 963 /* We have been given an interfaces line, and been … … 960 966 */ 961 967 for(i = 0; i < num_interfaces; i++) { 962 const char *address = iface_ n_ip(ifaces, i);968 const char *address = iface_list_n_ip(ifaces, i); 963 969 status = add_socket(task, task->lp_ctx, model_ops, address, ldap_service); 964 970 if (!NT_STATUS_IS_OK(status)) goto failed; 965 971 } 966 972 } else { 967 status = add_socket(task, task->lp_ctx, model_ops, 968 lpcfg_socket_address(task->lp_ctx), ldap_service); 969 if (!NT_STATUS_IS_OK(status)) goto failed; 970 } 971 972 ldapi_path = private_path(ldap_service, task->lp_ctx, "ldapi"); 973 char **wcard; 974 int i; 975 int num_binds = 0; 976 wcard = iface_list_wildcard(task); 977 if (wcard == NULL) { 978 DEBUG(0,("No wildcard addresses available\n")); 979 goto failed; 980 } 981 for (i=0; wcard[i]; i++) { 982 status = add_socket(task, task->lp_ctx, model_ops, wcard[i], ldap_service); 983 if (NT_STATUS_IS_OK(status)) { 984 num_binds++; 985 } 986 } 987 talloc_free(wcard); 988 if (num_binds == 0) { 989 goto failed; 990 } 991 } 992 993 ldapi_path = lpcfg_private_path(ldap_service, task->lp_ctx, "ldapi"); 973 994 if (!ldapi_path) { 974 995 goto failed; … … 987 1008 988 1009 #ifdef WITH_LDAPI_PRIV_SOCKET 989 priv_dir = private_path(ldap_service, task->lp_ctx, "ldap_priv");1010 priv_dir = lpcfg_private_path(ldap_service, task->lp_ctx, "ldap_priv"); 990 1011 if (priv_dir == NULL) { 991 1012 goto failed; … … 995 1016 * is of the correct permissions 996 1017 */ 997 if (!directory_create_or_exist(priv_dir, geteuid(),0750)) {1018 if (!directory_create_or_exist(priv_dir, 0750)) { 998 1019 task_server_terminate(task, "Cannot create ldap " 999 1020 "privileged ldapi directory", true); … … 1018 1039 1019 1040 #endif 1041 1042 /* register the server */ 1043 irpc_add_name(task->msg_ctx, "ldap_server"); 1020 1044 return; 1021 1045 -
vendor/current/source4/ldap_server/ldap_server.h
r740 r988 23 23 #include "lib/stream/packet.h" 24 24 #include "system/network.h" 25 #include "lib/param/loadparm.h" 25 26 26 27 struct ldapsrv_connection { … … 43 44 bool global_catalog; 44 45 bool is_privileged; 46 enum ldap_server_require_strong_auth require_strong_auth; 45 47 46 48 struct { -
vendor/current/source4/ldap_server/wscript_build
r740 r988 7 7 subsystem='service', 8 8 init_function='server_service_ldap_init', 9 deps=' credentials cli-ldap samdb process_model gensec samba-hostconfig samba_server_gensec',9 deps='samba-credentials cli-ldap samdb process_model gensec samba-hostconfig samba_server_gensec', 10 10 internal_module=False, 11 enabled=bld.AD_DC_BUILD_IS_ENABLED() 11 12 ) 12 13
Note:
See TracChangeset
for help on using the changeset viewer.