Changeset 740 for vendor/current/source4/libcli
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- Location:
- vendor/current/source4/libcli
- Files:
-
- 11 added
- 15 deleted
- 66 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/libcli/cliconnect.c
r414 r740 36 36 struct resolve_context *resolve_ctx, 37 37 struct smbcli_options *options, 38 struct smb_iconv_convenience *iconv_convenience,39 38 const char *socket_options) 40 39 { … … 47 46 if (sock == NULL) return false; 48 47 49 cli->transport = smbcli_transport_init(sock, cli, true, options, 50 iconv_convenience); 48 cli->transport = smbcli_transport_init(sock, cli, true, options); 51 49 if (!cli->transport) { 52 50 return false; … … 155 153 struct smbcli_options *options, 156 154 struct smbcli_session_options *session_options, 157 struct smb_iconv_convenience *iconv_convenience,158 155 struct gensec_settings *gensec_settings) 159 156 { … … 170 167 options, 171 168 session_options, 172 iconv_convenience,173 169 gensec_settings); 174 170 if (!NT_STATUS_IS_OK(status)) { … … 239 235 char *p; 240 236 241 *hostname = *sharename = NULL;242 243 237 if (strncmp(unc_name, "\\\\", 2) && 244 238 strncmp(unc_name, "//", 2)) { 245 239 return false; 246 240 } 241 242 *hostname = *sharename = NULL; 247 243 248 244 *hostname = talloc_strdup(mem_ctx, &unc_name[2]); -
vendor/current/source4/libcli/clideltree.c
r414 r740 42 42 n = strdup(name); 43 43 n[strlen(n)-1] = 0; 44 asprintf(&s, "%s%s", n, finfo->name); 44 if (asprintf(&s, "%s%s", n, finfo->name) < 0) { 45 free(n); 46 return; 47 } 45 48 46 49 if (finfo->attrib & FILE_ATTRIBUTE_READONLY) { … … 53 56 if (finfo->attrib & FILE_ATTRIBUTE_DIRECTORY) { 54 57 char *s2; 55 asprintf(&s2, "%s\\*", s); 58 if (asprintf(&s2, "%s\\*", s) < 0) { 59 free(s); 60 free(n); 61 return; 62 } 56 63 smbcli_unlink(dstate->tree, s2); 57 64 smbcli_list(dstate->tree, s2, … … 110 117 } 111 118 112 asprintf(&mask, "%s\\*", dname); 119 if (asprintf(&mask, "%s\\*", dname) < 0) { 120 return -1; 121 } 113 122 smbcli_unlink(dstate.tree, mask); 114 123 smbcli_list(dstate.tree, mask, -
vendor/current/source4/libcli/clifile.c
r414 r740 56 56 uint32_t unix_perms_to_wire(mode_t perms) 57 57 { 58 u int_t ret = 0;58 unsigned int ret = 0; 59 59 60 60 ret |= ((perms & S_IXOTH) ? UNIX_X_OTH : 0); … … 242 242 open_parms.ntcreatex.level = RAW_OPEN_NTCREATEX; 243 243 open_parms.ntcreatex.in.flags = CreatFlags; 244 open_parms.ntcreatex.in.root_fid = 0;244 open_parms.ntcreatex.in.root_fid.fnum = 0; 245 245 open_parms.ntcreatex.in.access_mask = DesiredAccess; 246 246 open_parms.ntcreatex.in.file_attr = FileAttributes; … … 272 272 { 273 273 union smb_open open_parms; 274 u int_t openfn=0;275 u int_t accessmode=0;274 unsigned int openfn=0; 275 unsigned int accessmode=0; 276 276 TALLOC_CTX *mem_ctx; 277 277 NTSTATUS status; -
vendor/current/source4/libcli/composite/composite.c
r414 r740 27 27 #include "libcli/smb2/smb2.h" 28 28 #include "libcli/composite/composite.h" 29 #include "lib/messaging/irpc.h"30 #include "librpc/rpc/dcerpc.h"31 29 #include "../libcli/nbt/libnbt.h" 32 30 … … 164 162 } 165 163 166 _PUBLIC_ void composite_continue_rpc(struct composite_context *ctx,167 struct rpc_request *new_req,168 void (*continuation)(struct rpc_request *),169 void *private_data)170 {171 if (composite_nomem(new_req, ctx)) return;172 new_req->async.callback = continuation;173 new_req->async.private_data = private_data;174 }175 176 _PUBLIC_ void composite_continue_irpc(struct composite_context *ctx,177 struct irpc_request *new_req,178 void (*continuation)(struct irpc_request *),179 void *private_data)180 {181 if (composite_nomem(new_req, ctx)) return;182 new_req->async.fn = continuation;183 new_req->async.private_data = private_data;184 }185 186 164 _PUBLIC_ void composite_continue_smb(struct composite_context *ctx, 187 165 struct smbcli_request *new_req, -
vendor/current/source4/libcli/composite/composite.h
r414 r740 68 68 }; 69 69 70 struct irpc_request;71 70 struct smbcli_request; 72 71 struct smb2_request; 73 struct rpc_request;74 72 struct nbt_name_request; 75 73 … … 80 78 void (*continuation)(struct composite_context *), 81 79 void *private_data); 82 void composite_continue_rpc(struct composite_context *ctx,83 struct rpc_request *new_req,84 void (*continuation)(struct rpc_request *),85 void *private_data);86 void composite_continue_irpc(struct composite_context *ctx,87 struct irpc_request *new_req,88 void (*continuation)(struct irpc_request *),89 void *private_data);90 80 void composite_continue_smb(struct composite_context *ctx, 91 81 struct smbcli_request *new_req, -
vendor/current/source4/libcli/dgram/browse.c
r414 r740 39 39 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); 40 40 41 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience,request,41 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, request, 42 42 (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet); 43 43 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 67 67 struct socket_address *dest; 68 68 69 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience,reply,69 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, reply, 70 70 (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet); 71 71 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 100 100 enum ndr_err_code ndr_err; 101 101 102 ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience,pkt,102 ndr_err = ndr_pull_struct_blob(&data, mem_ctx, pkt, 103 103 (ndr_pull_flags_fn_t)ndr_pull_nbt_browse_packet); 104 104 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { -
vendor/current/source4/libcli/dgram/dgramsocket.c
r414 r740 62 62 blob.length = nread; 63 63 64 DEBUG( 2,("Received dgram packet of length %d from %s:%d\n",64 DEBUG(5,("Received dgram packet of length %d from %s:%d\n", 65 65 (int)blob.length, src->addr, src->port)); 66 66 … … 72 72 73 73 /* parse the request */ 74 ndr_err = ndr_pull_struct_blob(&blob, packet, dgmsock->iconv_convenience,packet,74 ndr_err = ndr_pull_struct_blob(&blob, packet, packet, 75 75 (ndr_pull_flags_fn_t)ndr_pull_nbt_dgram_packet); 76 76 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 158 158 */ 159 159 struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx, 160 struct tevent_context *event_ctx, 161 struct smb_iconv_convenience *iconv_convenience) 160 struct tevent_context *event_ctx) 162 161 { 163 162 struct nbt_dgram_socket *dgmsock; … … 184 183 dgmsock->incoming.handler = NULL; 185 184 dgmsock->mailslot_handlers = NULL; 186 dgmsock->iconv_convenience = iconv_convenience;187 185 188 186 return dgmsock; … … 227 225 if (talloc_reference(req, dest) == NULL) goto failed; 228 226 229 ndr_err = ndr_push_struct_blob(&req->encoded, req, dgmsock->iconv_convenience,packet,227 ndr_err = ndr_push_struct_blob(&req->encoded, req, packet, 230 228 (ndr_push_flags_fn_t)ndr_push_nbt_dgram_packet); 231 229 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { -
vendor/current/source4/libcli/dgram/libdgram.h
r414 r740 20 20 */ 21 21 22 #include "../libcli/netlogon .h"22 #include "../libcli/netlogon/netlogon.h" 23 23 24 24 /* … … 41 41 struct socket_context *sock; 42 42 struct tevent_context *event_ctx; 43 struct smb_iconv_convenience *iconv_convenience;44 43 45 44 /* the fd event */ … … 94 93 void *private_data); 95 94 struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx, 96 struct tevent_context *event_ctx, 97 struct smb_iconv_convenience *); 95 struct tevent_context *event_ctx); 98 96 99 97 const char *dgram_mailslot_name(struct nbt_dgram_packet *packet); -
vendor/current/source4/libcli/dgram/mailslot.c
r414 r740 130 130 if (dgram_mailslot_find(dgmsock, name)) { 131 131 talloc_free(name); 132 return NULL;132 continue; 133 133 } 134 134 dgmslot = dgram_mailslot_listen(dgmsock, name, handler, private_data); -
vendor/current/source4/libcli/dgram/netlogon.c
r414 r740 41 41 TALLOC_CTX *tmp_ctx = talloc_new(dgmsock); 42 42 43 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, 44 dgmsock->iconv_convenience, 45 request, 43 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, request, 46 44 (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet); 47 45 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { … … 75 73 struct socket_address *dest; 76 74 77 status = push_nbt_netlogon_response(&blob, tmp_ctx, dgmsock->iconv_convenience, 78 reply); 75 status = push_nbt_netlogon_response(&blob, tmp_ctx, reply); 79 76 if (!NT_STATUS_IS_OK(status)) { 80 77 return status; … … 111 108 enum ndr_err_code ndr_err; 112 109 113 ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience,netlogon,114 110 ndr_err = ndr_pull_struct_blob(&data, mem_ctx, netlogon, 111 (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet); 115 112 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 116 113 NTSTATUS status = ndr_map_error2ntstatus(ndr_err); … … 136 133 DATA_BLOB data = dgram_mailslot_data(dgram); 137 134 138 status = pull_nbt_netlogon_response(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience,netlogon);135 status = pull_nbt_netlogon_response(&data, mem_ctx, netlogon); 139 136 if (!NT_STATUS_IS_OK(status)) { 140 137 return status; -
vendor/current/source4/libcli/ldap/ldap_bind.c
r414 r740 23 23 24 24 #include "includes.h" 25 #include "libcli/ldap/l dap.h"25 #include "libcli/ldap/libcli_ldap.h" 26 26 #include "libcli/ldap/ldap_proto.h" 27 27 #include "libcli/ldap/ldap_client.h" … … 226 226 status = gensec_client_start(conn, &conn->gensec, 227 227 conn->event.event_ctx, 228 lp _gensec_settings(conn, lp_ctx));228 lpcfg_gensec_settings(conn, lp_ctx)); 229 229 if (!NT_STATUS_IS_OK(status)) { 230 230 DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status))); … … 353 353 goto failed; 354 354 } 355 talloc_ steal(tmp_ctx, req);355 talloc_reparent(conn, tmp_ctx, req); 356 356 357 357 status = ldap_result_n(req, 0, &response); -
vendor/current/source4/libcli/ldap/ldap_client.c
r414 r740 28 28 #include "../lib/util/asn1.h" 29 29 #include "../lib/util/dlinklist.h" 30 #include "libcli/ldap/l dap.h"30 #include "libcli/ldap/libcli_ldap.h" 31 31 #include "libcli/ldap/ldap_proto.h" 32 32 #include "libcli/ldap/ldap_client.h" … … 339 339 * local host name as the target for gensec's 340 340 * DIGEST-MD5 mechanism */ 341 conn->host = talloc_asprintf(conn, "%s.%s", lp_netbios_name(conn->lp_ctx), lp_realm(conn->lp_ctx)); 341 conn->host = talloc_asprintf(conn, "%s.%s", 342 lpcfg_netbios_name(conn->lp_ctx), 343 lpcfg_dnsdomain(conn->lp_ctx)); 342 344 if (composite_nomem(conn->host, state->ctx)) { 343 345 return result; … … 374 376 375 377 ctx = socket_connect_multi_send(state, conn->host, 1, &conn->port, 376 lp _resolve_context(conn->lp_ctx), conn->event.event_ctx);378 lpcfg_resolve_context(conn->lp_ctx), conn->event.event_ctx); 377 379 if (ctx == NULL) goto failed; 378 380 … … 404 406 if (conn->ldaps) { 405 407 struct socket_context *tls_socket; 406 struct socket_context *tmp_socket; 407 char *cafile = lp_tls_cafile(conn->sock, conn->lp_ctx); 408 char *cafile = lpcfg_tls_cafile(conn->sock, conn->lp_ctx); 408 409 409 410 if (!cafile || !*cafile) { … … 499 500 conn->reconnect.max_retries = max_retries; 500 501 conn->reconnect.retries = 0; 501 conn->reconnect.previous = time (NULL);502 conn->reconnect.previous = time_mono(NULL); 502 503 } 503 504 } … … 507 508 { 508 509 NTSTATUS status; 509 time_t now = time (NULL);510 time_t now = time_mono(NULL); 510 511 511 512 /* do we have set up reconnect ? */ … … 565 566 566 567 /* 567 called on completion of a one-wayldap request568 */ 569 static void ldap_request_ complete(struct tevent_context *ev, struct tevent_timer *te,570 struct timeval t, void *private_data)568 called on completion of a failed ldap request 569 */ 570 static void ldap_request_failed_complete(struct tevent_context *ev, struct tevent_timer *te, 571 struct timeval t, void *private_data) 571 572 { 572 573 struct ldap_request *req = talloc_get_type(private_data, struct ldap_request); … … 577 578 578 579 /* 580 called on completion of a one-way ldap request 581 */ 582 static void ldap_request_oneway_complete(void *private_data) 583 { 584 struct ldap_request *req = talloc_get_type(private_data, struct ldap_request); 585 if (req->state == LDAP_REQUEST_PENDING) { 586 DLIST_REMOVE(req->conn->pending, req); 587 } 588 req->state = LDAP_REQUEST_DONE; 589 if (req->async.fn) { 590 req->async.fn(req); 591 } 592 } 593 /* 579 594 send a ldap message - async interface 580 595 */ … … 584 599 struct ldap_request *req; 585 600 NTSTATUS status = NT_STATUS_UNSUCCESSFUL; 601 packet_send_callback_fn_t send_callback = NULL; 586 602 587 603 req = talloc_zero(conn, struct ldap_request); … … 613 629 } 614 630 615 status = packet_send(conn->packet, req->data); 631 if (req->type == LDAP_TAG_AbandonRequest || 632 req->type == LDAP_TAG_UnbindRequest) { 633 send_callback = ldap_request_oneway_complete; 634 } 635 636 status = packet_send_callback(conn->packet, req->data, 637 send_callback, req); 616 638 if (!NT_STATUS_IS_OK(status)) { 617 639 goto failed; 618 }619 620 /* some requests don't expect a reply, so don't add those to the621 pending queue */622 if (req->type == LDAP_TAG_AbandonRequest ||623 req->type == LDAP_TAG_UnbindRequest) {624 req->status = NT_STATUS_OK;625 req->state = LDAP_REQUEST_DONE;626 /* we can't call the async callback now, as it isn't setup, so627 call it as next event */628 tevent_add_timer(conn->event.event_ctx, req, timeval_zero(),629 ldap_request_complete, req);630 return req;631 640 } 632 641 … … 645 654 req->state = LDAP_REQUEST_ERROR; 646 655 tevent_add_timer(conn->event.event_ctx, req, timeval_zero(), 647 ldap_request_ complete, req);656 ldap_request_failed_complete, req); 648 657 649 658 return req; -
vendor/current/source4/libcli/ldap/ldap_client.h
r414 r740 21 21 22 22 23 #include "libcli/ldap/l dap.h"23 #include "libcli/ldap/libcli_ldap.h" 24 24 25 25 enum ldap_request_state { LDAP_REQUEST_SEND=1, LDAP_REQUEST_PENDING=2, LDAP_REQUEST_DONE=3, LDAP_REQUEST_ERROR=4 }; -
vendor/current/source4/libcli/ldap/ldap_controls.c
r414 r740 22 22 #include "includes.h" 23 23 #include "../lib/util/asn1.h" 24 #include "libcli/ldap/ldap.h" 25 #include "lib/ldb/include/ldb.h" 24 #include "libcli/ldap/libcli_ldap.h" 26 25 #include "libcli/ldap/ldap_proto.h" 27 26 #include "dsdb/samdb/samdb.h" … … 215 214 } 216 215 217 if (!asn1_read_Integer(data, &(lsdfc->secinfo_flags))) {216 if (!asn1_read_Integer(data, (int *) &(lsdfc->secinfo_flags))) { 218 217 return false; 219 218 } … … 249 248 } 250 249 251 if (!asn1_read_Integer(data, &(lsoc->search_options))) {250 if (!asn1_read_Integer(data, (int *) &(lsoc->search_options))) { 252 251 return false; 253 252 } … … 424 423 425 424 *out = lac; 426 427 return true;428 }429 430 static bool decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void *_out)431 {432 if (in.length != 0) {433 return false;434 }435 436 return true;437 }438 439 static bool decode_notification_request(void *mem_ctx, DATA_BLOB in, void *_out)440 {441 if (in.length != 0) {442 return false;443 }444 445 return true;446 }447 448 static bool decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void *_out)449 {450 if (in.length != 0) {451 return false;452 }453 454 return true;455 }456 457 static bool decode_show_recycled_request(void *mem_ctx, DATA_BLOB in, void *_out)458 {459 if (in.length != 0) {460 return false;461 }462 463 return true;464 }465 466 static bool decode_show_deactivated_link_request(void *mem_ctx, DATA_BLOB in, void *_out)467 {468 if (in.length != 0) {469 return false;470 }471 472 return true;473 }474 475 static bool decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void *_out)476 {477 if (in.length != 0) {478 return false;479 }480 481 return true;482 }483 484 static bool decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void *_out)485 {486 if (in.length != 0) {487 return false;488 }489 425 490 426 return true; … … 947 883 talloc_free(data); 948 884 949 return true;950 }951 952 static bool encode_domain_scope_request(void *mem_ctx, void *in, DATA_BLOB *out)953 {954 if (in) {955 return false;956 }957 958 *out = data_blob(NULL, 0);959 return true;960 }961 962 static bool encode_notification_request(void *mem_ctx, void *in, DATA_BLOB *out)963 {964 if (in) {965 return false;966 }967 968 *out = data_blob(NULL, 0);969 return true;970 }971 972 static bool encode_show_deleted_request(void *mem_ctx, void *in, DATA_BLOB *out)973 {974 if (in) {975 return false;976 }977 978 *out = data_blob(NULL, 0);979 return true;980 }981 982 static bool encode_show_recycled_request(void *mem_ctx, void *in, DATA_BLOB *out)983 {984 if (in) {985 return false;986 }987 988 *out = data_blob(NULL, 0);989 return true;990 }991 992 static bool encode_show_deactivated_link_request(void *mem_ctx, void *in, DATA_BLOB *out)993 {994 if (in) {995 return false;996 }997 998 *out = data_blob(NULL, 0);999 return true;1000 }1001 1002 static bool encode_permissive_modify_request(void *mem_ctx, void *in, DATA_BLOB *out)1003 {1004 if (in) {1005 return false;1006 }1007 1008 *out = data_blob(NULL, 0);1009 return true;1010 }1011 1012 static bool encode_manageDSAIT_request(void *mem_ctx, void *in, DATA_BLOB *out)1013 {1014 if (in) {1015 return false;1016 }1017 1018 *out = data_blob(NULL, 0);1019 885 return true; 1020 886 } … … 1252 1118 } 1253 1119 1120 static bool encode_flag_request(void *mem_ctx, void *in, DATA_BLOB *out) 1121 { 1122 if (in) { 1123 return false; 1124 } 1125 1126 *out = data_blob(NULL, 0); 1127 return true; 1128 } 1129 1130 static bool decode_flag_request(void *mem_ctx, DATA_BLOB in, void *_out) 1131 { 1132 if (in.length != 0) { 1133 return false; 1134 } 1135 1136 return true; 1137 } 1138 1254 1139 static const struct ldap_control_handler ldap_known_controls[] = { 1255 { "1.2.840.113556.1.4.319", decode_paged_results_request, encode_paged_results_request }, 1256 { "1.2.840.113556.1.4.529", decode_extended_dn_request, encode_extended_dn_request }, 1257 { "1.2.840.113556.1.4.473", decode_server_sort_request, encode_server_sort_request }, 1258 { "1.2.840.113556.1.4.474", decode_server_sort_response, encode_server_sort_response }, 1259 { "1.2.840.113556.1.4.1504", decode_asq_control, encode_asq_control }, 1260 { "1.2.840.113556.1.4.841", decode_dirsync_request, encode_dirsync_request }, 1261 { "1.2.840.113556.1.4.528", decode_notification_request, encode_notification_request }, 1262 { "1.2.840.113556.1.4.417", decode_show_deleted_request, encode_show_deleted_request }, 1263 { "1.2.840.113556.1.4.2064", decode_show_recycled_request, encode_show_recycled_request }, 1264 { "1.2.840.113556.1.4.2065", decode_show_deactivated_link_request, encode_show_deactivated_link_request }, 1265 { "1.2.840.113556.1.4.1413", decode_permissive_modify_request, encode_permissive_modify_request }, 1266 { "1.2.840.113556.1.4.801", decode_sd_flags_request, encode_sd_flags_request }, 1267 { "1.2.840.113556.1.4.1339", decode_domain_scope_request, encode_domain_scope_request }, 1268 { "1.2.840.113556.1.4.1340", decode_search_options_request, encode_search_options_request }, 1269 { "2.16.840.1.113730.3.4.2", decode_manageDSAIT_request, encode_manageDSAIT_request }, 1270 { "2.16.840.1.113730.3.4.9", decode_vlv_request, encode_vlv_request }, 1271 { "2.16.840.1.113730.3.4.10", decode_vlv_response, encode_vlv_response }, 1140 { LDB_CONTROL_PAGED_RESULTS_OID, decode_paged_results_request, encode_paged_results_request }, 1141 { LDB_CONTROL_SD_FLAGS_OID, decode_sd_flags_request, encode_sd_flags_request }, 1142 { LDB_CONTROL_DOMAIN_SCOPE_OID, decode_flag_request, encode_flag_request }, 1143 { LDB_CONTROL_SEARCH_OPTIONS_OID, decode_search_options_request, encode_search_options_request }, 1144 { LDB_CONTROL_NOTIFICATION_OID, decode_flag_request, encode_flag_request }, 1145 { LDB_CONTROL_TREE_DELETE_OID, decode_flag_request, encode_flag_request }, 1146 { LDB_CONTROL_SHOW_DELETED_OID, decode_flag_request, encode_flag_request }, 1147 { LDB_CONTROL_SHOW_RECYCLED_OID, decode_flag_request, encode_flag_request }, 1148 { LDB_CONTROL_SHOW_DEACTIVATED_LINK_OID, decode_flag_request, encode_flag_request }, 1149 { LDB_CONTROL_EXTENDED_DN_OID, decode_extended_dn_request, encode_extended_dn_request }, 1150 { LDB_CONTROL_SERVER_SORT_OID, decode_server_sort_request, encode_server_sort_request }, 1151 { LDB_CONTROL_SORT_RESP_OID, decode_server_sort_response, encode_server_sort_response }, 1152 { LDB_CONTROL_ASQ_OID, decode_asq_control, encode_asq_control }, 1153 { LDB_CONTROL_DIRSYNC_OID, decode_dirsync_request, encode_dirsync_request }, 1154 { LDB_CONTROL_VLV_REQ_OID, decode_vlv_request, encode_vlv_request }, 1155 { LDB_CONTROL_VLV_RESP_OID, decode_vlv_response, encode_vlv_response }, 1156 { LDB_CONTROL_PERMISSIVE_MODIFY_OID, decode_flag_request, encode_flag_request }, 1157 { LDB_CONTROL_SERVER_LAZY_COMMIT, decode_flag_request, encode_flag_request }, 1158 { LDB_CONTROL_RODC_DCPROMO_OID, decode_flag_request, encode_flag_request }, 1159 { LDB_CONTROL_RELAX_OID, decode_flag_request, encode_flag_request }, 1160 { DSDB_OPENLDAP_DEREFERENCE_CONTROL, decode_openldap_dereference, encode_openldap_dereference }, 1161 1272 1162 /* DSDB_CONTROL_CURRENT_PARTITION_OID is internal only, and has no network representation */ 1273 { "1.3.6.1.4.1.7165.4.3.2", NULL, NULL }, 1163 { DSDB_CONTROL_CURRENT_PARTITION_OID, NULL, NULL }, 1164 /* DSDB_CONTROL_REPLICATED_UPDATE_OID is internal only, and has no network representation */ 1165 { DSDB_CONTROL_REPLICATED_UPDATE_OID, NULL, NULL }, 1166 /* DSDB_CONTROL_DN_STORAGE_FORMAT_OID is internal only, and has no network representation */ 1167 { DSDB_CONTROL_DN_STORAGE_FORMAT_OID, NULL, NULL }, 1168 /* LDB_CONTROL_RECALCULATE_SD_OID is internal only, and has no network representation */ 1169 { LDB_CONTROL_RECALCULATE_SD_OID, NULL, NULL }, 1170 /* LDB_CONTROL_REVEAL_INTERNALS is internal only, and has no network representation */ 1171 { LDB_CONTROL_REVEAL_INTERNALS, NULL, NULL }, 1172 /* LDB_CONTROL_AS_SYSTEM_OID is internal only, and has no network representation */ 1173 { LDB_CONTROL_AS_SYSTEM_OID, NULL, NULL }, 1174 /* DSDB_CONTROL_PASSWORD_CHANGE_STATUS_OID is internal only, and has no network representation */ 1175 { DSDB_CONTROL_PASSWORD_CHANGE_STATUS_OID, NULL, NULL }, 1176 /* DSDB_CONTROL_PASSWORD_HASH_VALUES_OID is internal only, and has no network representation */ 1177 { DSDB_CONTROL_PASSWORD_HASH_VALUES_OID, NULL, NULL }, 1178 /* DSDB_CONTROL_PASSWORD_CHANGE_OID is internal only, and has no network representation */ 1179 { DSDB_CONTROL_PASSWORD_CHANGE_OID, NULL, NULL }, 1180 /* DSDB_CONTROL_APPLY_LINKS is internal only, and has no network representation */ 1181 { DSDB_CONTROL_APPLY_LINKS, NULL, NULL }, 1182 /* DSDB_CONTROL_BYPASS_PASSWORD_HASH_OID is internal only, and has an empty network representation */ 1183 { DSDB_CONTROL_BYPASS_PASSWORD_HASH_OID, decode_flag_request, encode_flag_request }, 1184 /* LDB_CONTROL_BYPASS_OPERATIONAL_OID is internal only, and has no network representation */ 1185 { LDB_CONTROL_BYPASS_OPERATIONAL_OID, NULL, NULL }, 1186 /* DSDB_CONTROL_CHANGEREPLMETADATA_OID is internal only, and has no network representation */ 1187 { DSDB_CONTROL_CHANGEREPLMETADATA_OID, NULL, NULL }, 1188 /* LDB_CONTROL_PROVISION_OID is internal only, and has no network representation */ 1189 { LDB_CONTROL_PROVISION_OID, NULL, NULL }, 1274 1190 /* DSDB_EXTENDED_REPLICATED_OBJECTS_OID is internal only, and has no network representation */ 1275 { "1.3.6.1.4.1.7165.4.4.1", NULL, NULL }, 1276 { DSDB_OPENLDAP_DEREFERENCE_CONTROL, decode_openldap_dereference, encode_openldap_dereference}, 1191 { DSDB_EXTENDED_REPLICATED_OBJECTS_OID, NULL, NULL }, 1192 /* DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID is internal only, and has no network representation */ 1193 { DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID, NULL, NULL }, 1194 /* DSDB_EXTENDED_ALLOCATE_RID_POOL is internal only, and has no network representation */ 1195 { DSDB_EXTENDED_ALLOCATE_RID_POOL, NULL, NULL }, 1277 1196 { NULL, NULL, NULL } 1278 1197 }; -
vendor/current/source4/libcli/ldap/ldap_ildap.c
r414 r740 22 22 23 23 #include "includes.h" 24 #include "libcli/ldap/l dap.h"24 #include "libcli/ldap/libcli_ldap.h" 25 25 #include "libcli/ldap/ldap_client.h" 26 26 … … 74 74 75 75 req = ldap_request_send(conn, msg); 76 talloc_ steal(msg, req);76 talloc_reparent(conn, msg, req); 77 77 78 78 for (i=n=0;true;i++) { -
vendor/current/source4/libcli/rap/rap.h
r414 r740 1 /* 1 /* 2 2 Unix SMB/CIFS implementation. 3 RAP operations3 RAP client 4 4 Copyright (C) Volker Lendecke 2004 5 5 Copyright (C) Tim Potter 2005 6 Copyright (C) Jelmer Vernooij 2007 7 Copyright (C) Guenther Deschner 2010 8 6 9 This program is free software; you can redistribute it and/or modify 7 10 it under the terms of the GNU General Public License as published by 8 11 the Free Software Foundation; either version 3 of the License, or 9 12 (at your option) any later version. 10 13 11 14 This program is distributed in the hope that it will be useful, 12 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 17 GNU General Public License for more details. 15 18 16 19 You should have received a copy of the GNU General Public License 17 20 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 21 */ 19 22 20 #define RAP_WshareEnum 0 21 #define RAP_WshareGetInfo 1 22 #define RAP_WshareSetInfo 2 23 #define RAP_WshareAdd 3 24 #define RAP_WshareDel 4 25 #define RAP_NetShareCheck 5 26 #define RAP_WsessionEnum 6 27 #define RAP_WsessionGetInfo 7 28 #define RAP_WsessionDel 8 29 #define RAP_WconnectionEnum 9 30 #define RAP_WfileEnum 10 31 #define RAP_WfileGetInfo 11 32 #define RAP_WfileClose 12 33 #define RAP_WserverGetInfo 13 34 #define RAP_WserverSetInfo 14 35 #define RAP_WserverDiskEnum 15 36 #define RAP_WserverAdminCommand 16 37 #define RAP_NetAuditOpen 17 38 #define RAP_WauditClear 18 39 #define RAP_NetErrorLogOpen 19 40 #define RAP_WerrorLogClear 20 41 #define RAP_NetCharDevEnum 21 42 #define RAP_NetCharDevGetInfo 22 43 #define RAP_WCharDevControl 23 44 #define RAP_NetCharDevQEnum 24 45 #define RAP_NetCharDevQGetInfo 25 46 #define RAP_WCharDevQSetInfo 26 47 #define RAP_WCharDevQPurge 27 48 #define RAP_WCharDevQPurgeSelf 28 49 #define RAP_WMessageNameEnum 29 50 #define RAP_WMessageNameGetInfo 30 51 #define RAP_WMessageNameAdd 31 52 #define RAP_WMessageNameDel 32 53 #define RAP_WMessageNameFwd 33 54 #define RAP_WMessageNameUnFwd 34 55 #define RAP_WMessageBufferSend 35 56 #define RAP_WMessageFileSend 36 57 #define RAP_WMessageLogFileSet 37 58 #define RAP_WMessageLogFileGet 38 59 #define RAP_WServiceEnum 39 60 #define RAP_WServiceInstall 40 61 #define RAP_WServiceControl 41 62 #define RAP_WAccessEnum 42 63 #define RAP_WAccessGetInfo 43 64 #define RAP_WAccessSetInfo 44 65 #define RAP_WAccessAdd 45 66 #define RAP_WAccessDel 46 67 #define RAP_WGroupEnum 47 68 #define RAP_WGroupAdd 48 69 #define RAP_WGroupDel 49 70 #define RAP_WGroupAddUser 50 71 #define RAP_WGroupDelUser 51 72 #define RAP_WGroupGetUsers 52 73 #define RAP_WUserEnum 53 74 #define RAP_WUserAdd 54 75 #define RAP_WUserDel 55 76 #define RAP_WUserGetInfo 56 77 #define RAP_WUserSetInfo 57 78 #define RAP_WUserPasswordSet 58 79 #define RAP_WUserGetGroups 59 80 #define RAP_WWkstaSetUID 62 81 #define RAP_WWkstaGetInfo 63 82 #define RAP_WWkstaSetInfo 64 83 #define RAP_WUseEnum 65 84 #define RAP_WUseAdd 66 85 #define RAP_WUseDel 67 86 #define RAP_WUseGetInfo 68 87 #define RAP_WPrintQEnum 69 88 #define RAP_WPrintQGetInfo 70 89 #define RAP_WPrintQSetInfo 71 90 #define RAP_WPrintQAdd 72 91 #define RAP_WPrintQDel 73 92 #define RAP_WPrintQPause 74 93 #define RAP_WPrintQContinue 75 94 #define RAP_WPrintJobEnum 76 95 #define RAP_WPrintJobGetInfo 77 96 #define RAP_WPrintJobSetInfo_OLD 78 97 #define RAP_WPrintJobDel 81 98 #define RAP_WPrintJobPause 82 99 #define RAP_WPrintJobContinue 83 100 #define RAP_WPrintDestEnum 84 101 #define RAP_WPrintDestGetInfo 85 102 #define RAP_WPrintDestControl 86 103 #define RAP_WProfileSave 87 104 #define RAP_WProfileLoad 88 105 #define RAP_WStatisticsGet 89 106 #define RAP_WStatisticsClear 90 107 #define RAP_NetRemoteTOD 91 108 #define RAP_WNetBiosEnum 92 109 #define RAP_WNetBiosGetInfo 93 110 #define RAP_NetServerEnum 94 111 #define RAP_I_NetServerEnum 95 112 #define RAP_WServiceGetInfo 96 113 #define RAP_WPrintQPurge 103 114 #define RAP_NetServerEnum2 104 115 #define RAP_WAccessGetUserPerms 105 116 #define RAP_WGroupGetInfo 106 117 #define RAP_WGroupSetInfo 107 118 #define RAP_WGroupSetUsers 108 119 #define RAP_WUserSetGroups 109 120 #define RAP_WUserModalsGet 110 121 #define RAP_WUserModalsSet 111 122 #define RAP_WFileEnum2 112 123 #define RAP_WUserAdd2 113 124 #define RAP_WUserSetInfo2 114 125 #define RAP_WUserPasswordSet2 115 126 #define RAP_I_NetServerEnum2 116 127 #define RAP_WConfigGet2 117 128 #define RAP_WConfigGetAll2 118 129 #define RAP_WGetDCName 119 130 #define RAP_NetHandleGetInfo 120 131 #define RAP_NetHandleSetInfo 121 132 #define RAP_WStatisticsGet2 122 133 #define RAP_WBuildGetInfo 123 134 #define RAP_WFileGetInfo2 124 135 #define RAP_WFileClose2 125 136 #define RAP_WNetServerReqChallenge 126 137 #define RAP_WNetServerAuthenticate 127 138 #define RAP_WNetServerPasswordSet 128 139 #define RAP_WNetAccountDeltas 129 140 #define RAP_WNetAccountSync 130 141 #define RAP_WUserEnum2 131 142 #define RAP_WWkstaUserLogon 132 143 #define RAP_WWkstaUserLogoff 133 144 #define RAP_WLogonEnum 134 145 #define RAP_WErrorLogRead 135 146 #define RAP_NetPathType 136 147 #define RAP_NetPathCanonicalize 137 148 #define RAP_NetPathCompare 138 149 #define RAP_NetNameValidate 139 150 #define RAP_NetNameCanonicalize 140 151 #define RAP_NetNameCompare 141 152 #define RAP_WAuditRead 142 153 #define RAP_WPrintDestAdd 143 154 #define RAP_WPrintDestSetInfo 144 155 #define RAP_WPrintDestDel 145 156 #define RAP_WUserValidate2 146 157 #define RAP_WPrintJobSetInfo 147 158 #define RAP_TI_NetServerDiskEnum 148 159 #define RAP_TI_NetServerDiskGetInfo 149 160 #define RAP_TI_FTVerifyMirror 150 161 #define RAP_TI_FTAbortVerify 151 162 #define RAP_TI_FTGetInfo 152 163 #define RAP_TI_FTSetInfo 153 164 #define RAP_TI_FTLockDisk 154 165 #define RAP_TI_FTFixError 155 166 #define RAP_TI_FTAbortFix 156 167 #define RAP_TI_FTDiagnoseError 157 168 #define RAP_TI_FTGetDriveStats 158 169 #define RAP_TI_FTErrorGetInfo 160 170 #define RAP_NetAccessCheck 163 171 #define RAP_NetAlertRaise 164 172 #define RAP_NetAlertStart 165 173 #define RAP_NetAlertStop 166 174 #define RAP_NetAuditWrite 167 175 #define RAP_NetIRemoteAPI 168 176 #define RAP_NetServiceStatus 169 177 #define RAP_NetServerRegister 170 178 #define RAP_NetServerDeregister 171 179 #define RAP_NetSessionEntryMake 172 180 #define RAP_NetSessionEntryClear 173 181 #define RAP_NetSessionEntryGetInfo 174 182 #define RAP_NetSessionEntrySetInfo 175 183 #define RAP_NetConnectionEntryMake 176 184 #define RAP_NetConnectionEntryClear 177 185 #define RAP_NetConnectionEntrySetInfo 178 186 #define RAP_NetConnectionEntryGetInfo 179 187 #define RAP_NetFileEntryMake 180 188 #define RAP_NetFileEntryClear 181 189 #define RAP_NetFileEntrySetInfo 182 190 #define RAP_NetFileEntryGetInfo 183 191 #define RAP_AltSrvMessageBufferSend 184 192 #define RAP_AltSrvMessageFileSend 185 193 #define RAP_wI_NetRplWkstaEnum 186 194 #define RAP_wI_NetRplWkstaGetInfo 187 195 #define RAP_wI_NetRplWkstaSetInfo 188 196 #define RAP_wI_NetRplWkstaAdd 189 197 #define RAP_wI_NetRplWkstaDel 190 198 #define RAP_wI_NetRplProfileEnum 191 199 #define RAP_wI_NetRplProfileGetInfo 192 200 #define RAP_wI_NetRplProfileSetInfo 193 201 #define RAP_wI_NetRplProfileAdd 194 202 #define RAP_wI_NetRplProfileDel 195 203 #define RAP_wI_NetRplProfileClone 196 204 #define RAP_wI_NetRplBaseProfileEnum 197 205 #define RAP_WIServerSetInfo 201 206 #define RAP_WPrintDriverEnum 205 207 #define RAP_WPrintQProcessorEnum 206 208 #define RAP_WPrintPortEnum 207 209 #define RAP_WNetWriteUpdateLog 208 210 #define RAP_WNetAccountUpdate 209 211 #define RAP_WNetAccountConfirmUpdate 210 212 #define RAP_WConfigSet 211 213 #define RAP_WAccountsReplicate 212 214 #define RAP_SamOEMChgPasswordUser2_P 214 215 #define RAP_NetServerEnum3 215 216 #define RAP_WprintDriverGetInfo 250 217 #define RAP_WprintDriverSetInfo 251 218 #define RAP_WaliasAdd 252 219 #define RAP_WaliasDel 253 220 #define RAP_WaliasGetInfo 254 221 #define RAP_WaliasSetInfo 255 222 #define RAP_WaliasEnum 256 223 #define RAP_WuserGetLogonAsn 257 224 #define RAP_WuserSetLogonAsn 258 225 #define RAP_WuserGetAppSel 259 226 #define RAP_WuserSetAppSel 260 227 #define RAP_WappAdd 261 228 #define RAP_WappDel 262 229 #define RAP_WappGetInfo 263 230 #define RAP_WappSetInfo 264 231 #define RAP_WappEnum 265 232 #define RAP_WUserDCDBInit 266 233 #define RAP_WDASDAdd 267 234 #define RAP_WDASDDel 268 235 #define RAP_WDASDGetInfo 269 236 #define RAP_WDASDSetInfo 270 237 #define RAP_WDASDEnum 271 238 #define RAP_WDASDCheck 272 239 #define RAP_WDASDCtl 273 240 #define RAP_WuserRemoteLogonCheck 274 241 #define RAP_WUserPasswordSet3 275 242 #define RAP_WCreateRIPLMachine 276 243 #define RAP_WDeleteRIPLMachine 277 244 #define RAP_WGetRIPLMachineInfo 278 245 #define RAP_WSetRIPLMachineInfo 279 246 #define RAP_WEnumRIPLMachine 280 247 #define RAP_I_ShareAdd 281 248 #define RAP_AliasEnum 282 249 #define RAP_WaccessApply 283 250 #define RAP_WPrt16Query 284 251 #define RAP_WPrt16Set 285 252 #define RAP_WUserDel100 286 253 #define RAP_WUserRemoteLogonCheck2 287 254 #define RAP_WRemoteTODSet 294 255 #define RAP_WprintJobMoveAll 295 256 #define RAP_W16AppParmAdd 296 257 #define RAP_W16AppParmDel 297 258 #define RAP_W16AppParmGet 298 259 #define RAP_W16AppParmSet 299 260 #define RAP_W16RIPLMachineCreate 300 261 #define RAP_W16RIPLMachineGetInfo 301 262 #define RAP_W16RIPLMachineSetInfo 302 263 #define RAP_W16RIPLMachineEnum 303 264 #define RAP_W16RIPLMachineListParmEnum 304 265 #define RAP_W16RIPLMachClassGetInfo 305 266 #define RAP_W16RIPLMachClassEnum 306 267 #define RAP_W16RIPLMachClassCreate 307 268 #define RAP_W16RIPLMachClassSetInfo 308 269 #define RAP_W16RIPLMachClassDelete 309 270 #define RAP_W16RIPLMachClassLPEnum 310 271 #define RAP_W16RIPLMachineDelete 311 272 #define RAP_W16WSLevelGetInfo 312 273 #define RAP_WserverNameAdd 313 274 #define RAP_WserverNameDel 314 275 #define RAP_WserverNameEnum 315 276 #define RAP_I_WDASDEnum 316 277 #define RAP_WDASDEnumTerminate 317 278 #define RAP_WDASDSetInfo2 318 279 #define MAX_API 318 23 #define RAP_GOTO(call) do { \ 24 NTSTATUS _status; \ 25 _status = call; \ 26 if (!NT_STATUS_IS_OK(_status)) { \ 27 result = _status; \ 28 goto done; \ 29 } \ 30 } while (0) 280 31 281 struct rap_shareenum_info_0 { 282 char name[13]; 32 #define RAP_RETURN(call) do { \ 33 NTSTATUS _status; \ 34 _status = call; \ 35 if (!NT_STATUS_IS_OK(_status)) { \ 36 return _status; \ 37 } \ 38 } while (0) 39 40 #define NDR_GOTO(call) do { \ 41 enum ndr_err_code _ndr_err; \ 42 _ndr_err = call; \ 43 if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \ 44 result = ndr_map_error2ntstatus(_ndr_err); \ 45 goto done; \ 46 } \ 47 } while (0) 48 49 #define NDR_RETURN(call) do { \ 50 enum ndr_err_code _ndr_err; \ 51 _ndr_err = call; \ 52 if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \ 53 return ndr_map_error2ntstatus(_ndr_err); \ 54 } \ 55 } while (0) 56 57 struct rap_call { 58 uint16_t callno; 59 char *paramdesc; 60 const char *datadesc; 61 const char *auxdatadesc; 62 63 uint16_t status; 64 uint16_t convert; 65 66 uint16_t rcv_paramlen, rcv_datalen; 67 68 struct ndr_push *ndr_push_param; 69 struct ndr_push *ndr_push_data; 70 struct ndr_pull *ndr_pull_param; 71 struct ndr_pull *ndr_pull_data; 283 72 }; 284 73 285 struct rap_shareenum_info_1 { 286 char name[13]; 287 char pad; 288 uint16_t type; 289 char *comment; 290 }; 74 #define RAPNDR_FLAGS (LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM); 291 75 292 union rap_shareenum_info { 293 struct rap_shareenum_info_0 info0; 294 struct rap_shareenum_info_1 info1; 295 }; 296 297 struct rap_NetShareEnum { 298 struct { 299 uint16_t level; 300 uint16_t bufsize; 301 } in; 302 303 struct { 304 uint16_t status; 305 uint16_t convert; 306 uint16_t count; 307 uint16_t available; 308 union rap_shareenum_info *info; 309 } out; 310 }; 311 312 struct rap_server_info_0 { 313 char name[16]; 314 }; 315 316 struct rap_server_info_1 { 317 char name[16]; 318 uint8_t version_major; 319 uint8_t version_minor; 320 uint32_t servertype; 321 char *comment; 322 }; 323 324 union rap_server_info { 325 struct rap_server_info_0 info0; 326 struct rap_server_info_1 info1; 327 }; 328 329 struct rap_NetServerEnum2 { 330 struct { 331 uint16_t level; 332 uint16_t bufsize; 333 uint32_t servertype; 334 const char *domain; 335 } in; 336 337 struct { 338 uint16_t status; 339 uint16_t convert; 340 uint16_t count; 341 uint16_t available; 342 union rap_server_info *info; 343 } out; 344 }; 345 346 struct rap_WserverGetInfo { 347 struct { 348 uint16_t level; 349 uint16_t bufsize; 350 } in; 351 352 struct { 353 uint16_t status; 354 uint16_t convert; 355 uint16_t available; 356 union rap_server_info info; 357 } out; 358 }; 76 #include "../librpc/gen_ndr/rap.h" 77 #include "libcli/rap/proto.h" -
vendor/current/source4/libcli/raw/clisocket.c
r414 r740 81 81 state->socket_options = talloc_reference(state, socket_options); 82 82 83 if (!host_addr) { 84 host_addr = host_name; 85 } 86 83 87 ctx = socket_connect_multi_send(state, host_addr, 84 88 state->num_ports, state->ports, -
vendor/current/source4/libcli/raw/clitransport.c
r414 r740 76 76 TALLOC_CTX *parent_ctx, 77 77 bool primary, 78 struct smbcli_options *options, 79 struct smb_iconv_convenience *iconv_convenience) 78 struct smbcli_options *options) 80 79 { 81 80 struct smbcli_transport *transport; … … 92 91 transport->options = *options; 93 92 transport->negotiate.max_xmit = transport->options.max_xmit; 94 transport->iconv_convenience = iconv_convenience;95 93 96 94 /* setup the stream -> packet parser */ … … 173 171 if (!NT_STATUS_IS_OK(status)) goto failed; 174 172 175 status = nbt_name_to_blob(tmp_ctx, transport->iconv_convenience,&calling_blob, calling);173 status = nbt_name_to_blob(tmp_ctx, &calling_blob, calling); 176 174 if (!NT_STATUS_IS_OK(status)) goto failed; 177 175 178 status = nbt_name_to_blob(tmp_ctx, transport->iconv_convenience,&called_blob, called);176 status = nbt_name_to_blob(tmp_ctx, &called_blob, called); 179 177 if (!NT_STATUS_IS_OK(status)) goto failed; 180 178 -
vendor/current/source4/libcli/raw/clitree.c
r414 r740 180 180 struct smbcli_options *options, 181 181 struct smbcli_session_options *session_options, 182 struct smb_iconv_convenience *iconv_convenience,183 182 struct gensec_settings *gensec_settings) 184 183 { … … 206 205 io.in.options = *options; 207 206 io.in.session_options = *session_options; 208 io.in.iconv_convenience = iconv_convenience;209 207 210 208 status = smb_composite_connect(&io, parent_ctx, resolve_ctx, ev); -
vendor/current/source4/libcli/raw/interfaces.h
r414 r740 186 186 struct { 187 187 const char *path; 188 u int_t num_eas;188 unsigned int num_eas; 189 189 struct ea_struct *eas; 190 190 } in; … … 489 489 uint32_t attrib; 490 490 uint32_t ea_size; 491 u int_t num_eas;491 unsigned int num_eas; 492 492 struct ea_struct { 493 493 uint8_t flags; … … 517 517 uint32_t alignment_requirement; 518 518 uint32_t reparse_tag; 519 u int_t num_streams;519 unsigned int num_streams; 520 520 struct stream_struct { 521 521 uint64_t size; … … 579 579 struct { 580 580 union smb_handle_or_path file; 581 u int_t num_names;581 unsigned int num_names; 582 582 struct ea_name { 583 583 struct smb_wire_string name; … … 586 586 587 587 struct smb_ea_list { 588 u int_t num_eas;588 unsigned int num_eas; 589 589 struct ea_struct *eas; 590 590 } out; … … 733 733 } in; 734 734 struct stream_information { 735 u int_t num_streams;735 unsigned int num_streams; 736 736 struct stream_struct *streams; 737 737 } out; … … 994 994 struct { 995 995 union smb_handle_or_path file; 996 u int_t num_eas;996 unsigned int num_eas; 997 997 struct ea_struct *eas; 998 998 } in; … … 1357 1357 RAW_OPEN_NTTRANS_CREATE, 1358 1358 RAW_OPEN_OPENX_READX, 1359 RAW_OPEN_NTCREATEX_READX, 1359 1360 RAW_OPEN_SMB2 1360 1361 }; … … 1401 1402 file = &op->openxreadx.out.file; \ 1402 1403 break; \ 1404 case RAW_OPEN_NTCREATEX_READX: \ 1405 file = &op->ntcreatexreadx.out.file; \ 1406 break; \ 1403 1407 case RAW_OPEN_SMB2: \ 1404 1408 file = &op->smb2.out.file; \ … … 1415 1419 struct { 1416 1420 uint32_t flags; 1417 u int32_troot_fid;1421 union smb_handle root_fid; 1418 1422 uint32_t access_mask; 1419 1423 uint64_t alloc_size; … … 1436 1440 /* some optional parameters from the SMB2 varient */ 1437 1441 bool query_maximal_access; 1442 1443 /* private flags for internal use only */ 1444 uint8_t private_flags; 1438 1445 } in; 1439 1446 struct { … … 1471 1478 uint32_t timeout; 1472 1479 const char *fname; 1473 u int_t num_eas;1480 unsigned int num_eas; 1474 1481 struct ea_struct *eas; 1475 1482 } in; … … 1620 1627 } openxreadx; 1621 1628 1629 /* chained NTCreateX/ReadX interface */ 1630 struct { 1631 enum smb_open_level level; 1632 struct { 1633 uint32_t flags; 1634 union smb_handle root_fid; 1635 uint32_t access_mask; 1636 uint64_t alloc_size; 1637 uint32_t file_attr; 1638 uint32_t share_access; 1639 uint32_t open_disposition; 1640 uint32_t create_options; 1641 uint32_t impersonation; 1642 uint8_t security_flags; 1643 /* NOTE: fname can also be a pointer to a 1644 uint64_t file_id if create_options has the 1645 NTCREATEX_OPTIONS_OPEN_BY_FILE_ID flag set */ 1646 const char *fname; 1647 1648 /* readx part */ 1649 uint64_t offset; 1650 uint16_t mincnt; 1651 uint32_t maxcnt; 1652 uint16_t remaining; 1653 } in; 1654 struct { 1655 union smb_handle file; 1656 uint8_t oplock_level; 1657 uint32_t create_action; 1658 NTTIME create_time; 1659 NTTIME access_time; 1660 NTTIME write_time; 1661 NTTIME change_time; 1662 uint32_t attrib; 1663 uint64_t alloc_size; 1664 uint64_t size; 1665 uint16_t file_type; 1666 uint16_t ipc_state; 1667 uint8_t is_directory; 1668 1669 /* readx part */ 1670 uint8_t *data; 1671 uint16_t remaining; 1672 uint16_t compaction_mode; 1673 uint16_t nread; 1674 } out; 1675 } ntcreatexreadx; 1676 1622 1677 #define SMB2_CREATE_FLAG_REQUEST_OPLOCK 0x0100 1623 1678 #define SMB2_CREATE_FLAG_REQUEST_EXCLUSIVE_OPLOCK 0x0800 … … 1979 2034 /* uint16_t buffer_code; 0x30 */ 1980 2035 uint16_t lock_count; 1981 uint32_t reserved;2036 uint32_t lock_sequence; 1982 2037 /* struct smb2_handle handle; */ 1983 2038 struct smb2_lock_element { … … 2036 2091 union smb_handle file; 2037 2092 time_t write_time; 2038 #define SMB2_CLOSE_FLAGS_FULL_INFORMATION (1<<0)2039 2093 uint16_t flags; /* SMB2_CLOSE_FLAGS_* */ 2040 2094 } in; … … 2433 2487 2434 2488 /* the ea names are only used for RAW_SEARCH_EA_LIST */ 2435 u int_t num_names;2489 unsigned int num_names; 2436 2490 struct ea_name *ea_names; 2437 2491 } in; … … 2517 2571 2518 2572 /* the ea names are only used for RAW_SEARCH_EA_LIST */ 2519 u int_t num_names;2573 unsigned int num_names; 2520 2574 struct ea_name *ea_names; 2521 2575 } in; -
vendor/current/source4/libcli/raw/libcliraw.h
r414 r740 64 64 int server_zone; 65 65 time_t server_time; 66 uint_t readbraw_supported:1; 67 uint_t writebraw_supported:1; 66 unsigned int readbraw_supported:1; 67 unsigned int writebraw_supported:1; 68 unsigned int lockread_supported:1; 68 69 69 70 char *server_domain; … … 93 94 */ 94 95 struct smbcli_options { 95 u int_t use_oplocks:1;96 u int_t use_level2_oplocks:1;97 u int_t use_spnego:1;98 u int_t unicode:1;99 u int_t ntstatus_support:1;96 unsigned int use_oplocks:1; 97 unsigned int use_level2_oplocks:1; 98 unsigned int use_spnego:1; 99 unsigned int unicode:1; 100 unsigned int ntstatus_support:1; 100 101 int max_protocol; 101 102 uint32_t max_xmit; … … 122 123 /* is a readbraw pending? we need to handle that case 123 124 specially on receiving packets */ 124 u int_t readbraw_pending:1;125 unsigned int readbraw_pending:1; 125 126 126 127 /* an idle function - if this is defined then it will be … … 130 131 void (*func)(struct smbcli_transport *, void *); 131 132 void *private_data; 132 u int_t period;133 unsigned int period; 133 134 } idle; 134 135 … … 143 144 SOCKET_WRITE_ERROR, 144 145 SOCKET_READ_BAD_SIG} socket_error; 145 u int_t nbt_error;146 unsigned int nbt_error; 146 147 } e; 147 148 } error; … … 164 165 /* context of the stream -> packet parser */ 165 166 struct packet_context *packet; 166 167 /* iconv convenience */168 struct smb_iconv_convenience *iconv_convenience;169 167 }; 170 168 … … 193 191 194 192 struct smbcli_session_options { 195 u int_t lanman_auth:1;196 u int_t ntlmv2_auth:1;197 u int_t plaintext_auth:1;193 unsigned int lanman_auth:1; 194 unsigned int ntlmv2_auth:1; 195 unsigned int plaintext_auth:1; 198 196 } options; 199 197 … … 256 254 257 255 /* the sequence number of this packet - used for signing */ 258 u int_t seq_num;256 unsigned int seq_num; 259 257 260 258 /* list of ntcancel request for this requests */ … … 263 261 /* set if this is a one-way request, meaning we are not 264 262 expecting a reply from the server. */ 265 u int_t one_way_request:1;263 unsigned int one_way_request:1; 266 264 267 265 /* set this when the request should only increment the signing 268 266 counter by one */ 269 u int_t sign_single_increment:1;267 unsigned int sign_single_increment:1; 270 268 271 269 /* the caller wants to do the signing check */ -
vendor/current/source4/libcli/raw/rawacl.c
r414 r740 78 78 nt.out.data.length = IVAL(nt.out.params.data, 0); 79 79 80 ndr = ndr_pull_init_blob(&nt.out.data, mem_ctx , NULL);80 ndr = ndr_pull_init_blob(&nt.out.data, mem_ctx); 81 81 if (!ndr) { 82 82 return NT_STATUS_INVALID_PARAMETER; … … 136 136 nt.in.params.length = 8; 137 137 138 ndr = ndr_push_init_ctx(NULL , NULL);138 ndr = ndr_push_init_ctx(NULL); 139 139 if (!ndr) return NULL; 140 140 -
vendor/current/source4/libcli/raw/raweas.c
r414 r740 27 27 reasonable assumption 28 28 */ 29 size_t ea_list_size(u int_t num_eas, struct ea_struct *eas)30 { 31 u int_t total = 4;29 size_t ea_list_size(unsigned int num_eas, struct ea_struct *eas) 30 { 31 unsigned int total = 4; 32 32 int i; 33 33 for (i=0;i<num_eas;i++) { … … 40 40 work out how many bytes on the wire a ea name list will consume. 41 41 */ 42 static u int_t ea_name_list_size(uint_t num_names, struct ea_name *eas)43 { 44 u int_t total = 4;42 static unsigned int ea_name_list_size(unsigned int num_names, struct ea_name *eas) 43 { 44 unsigned int total = 4; 45 45 int i; 46 46 for (i=0;i<num_names;i++) { … … 55 55 reasonable assumption 56 56 */ 57 size_t ea_list_size_chained(u int_t num_eas, struct ea_struct *eas, unsigned alignment)58 { 59 u int_t total = 0;57 size_t ea_list_size_chained(unsigned int num_eas, struct ea_struct *eas, unsigned alignment) 58 { 59 unsigned int total = 0; 60 60 int i; 61 61 for (i=0;i<num_eas;i++) { 62 u int_t len = 8 + strlen(eas[i].name.s)+1 + eas[i].value.length;62 unsigned int len = 8 + strlen(eas[i].name.s)+1 + eas[i].value.length; 63 63 len = (len + (alignment-1)) & ~(alignment-1); 64 64 total += len; … … 71 71 of size ea_list_size() 72 72 */ 73 void ea_put_list(uint8_t *data, u int_t num_eas, struct ea_struct *eas)73 void ea_put_list(uint8_t *data, unsigned int num_eas, struct ea_struct *eas) 74 74 { 75 75 int i; … … 82 82 83 83 for (i=0;i<num_eas;i++) { 84 u int_t nlen = strlen(eas[i].name.s);84 unsigned int nlen = strlen(eas[i].name.s); 85 85 SCVAL(data, 0, eas[i].flags); 86 86 SCVAL(data, 1, nlen); … … 97 97 at least of size ea_list_size() 98 98 */ 99 void ea_put_list_chained(uint8_t *data, u int_t num_eas, struct ea_struct *eas,99 void ea_put_list_chained(uint8_t *data, unsigned int num_eas, struct ea_struct *eas, 100 100 unsigned alignment) 101 101 { … … 103 103 104 104 for (i=0;i<num_eas;i++) { 105 u int_t nlen = strlen(eas[i].name.s);105 unsigned int nlen = strlen(eas[i].name.s); 106 106 uint32_t len = 8+nlen+1+eas[i].value.length; 107 u int_t pad = ((len + (alignment-1)) & ~(alignment-1)) - len;107 unsigned int pad = ((len + (alignment-1)) & ~(alignment-1)) - len; 108 108 if (i == num_eas-1) { 109 109 SIVAL(data, 0, 0); … … 125 125 pull a ea_struct from a buffer. Return the number of bytes consumed 126 126 */ 127 u int_t ea_pull_struct(const DATA_BLOB *blob,127 unsigned int ea_pull_struct(const DATA_BLOB *blob, 128 128 TALLOC_CTX *mem_ctx, 129 129 struct ea_struct *ea) … … 165 165 NTSTATUS ea_pull_list(const DATA_BLOB *blob, 166 166 TALLOC_CTX *mem_ctx, 167 u int_t *num_eas, struct ea_struct **eas)167 unsigned int *num_eas, struct ea_struct **eas) 168 168 { 169 169 int n; … … 185 185 186 186 while (ofs < ea_size) { 187 u int_t len;187 unsigned int len; 188 188 DATA_BLOB blob2; 189 189 … … 214 214 NTSTATUS ea_pull_list_chained(const DATA_BLOB *blob, 215 215 TALLOC_CTX *mem_ctx, 216 u int_t *num_eas, struct ea_struct **eas)216 unsigned int *num_eas, struct ea_struct **eas) 217 217 { 218 218 int n; … … 229 229 230 230 while (ofs < blob->length) { 231 u int_t len;231 unsigned int len; 232 232 DATA_BLOB blob2; 233 233 uint32_t next_ofs = IVAL(blob->data, ofs); … … 262 262 pull a ea_name from a buffer. Return the number of bytes consumed 263 263 */ 264 static u int_t ea_pull_name(const DATA_BLOB *blob,264 static unsigned int ea_pull_name(const DATA_BLOB *blob, 265 265 TALLOC_CTX *mem_ctx, 266 266 struct ea_name *ea) … … 290 290 NTSTATUS ea_pull_name_list(const DATA_BLOB *blob, 291 291 TALLOC_CTX *mem_ctx, 292 u int_t *num_names, struct ea_name **ea_names)292 unsigned int *num_names, struct ea_name **ea_names) 293 293 { 294 294 int n; … … 310 310 311 311 while (ofs < ea_size) { 312 u int_t len;312 unsigned int len; 313 313 DATA_BLOB blob2; 314 314 … … 338 338 */ 339 339 bool ea_push_name_list(TALLOC_CTX *mem_ctx, 340 DATA_BLOB *data, u int_t num_names, struct ea_name *eas)340 DATA_BLOB *data, unsigned int num_names, struct ea_name *eas) 341 341 { 342 342 int i; … … 355 355 356 356 for (i=0;i<num_names;i++) { 357 u int_t nlen = strlen(eas[i].name.s);357 unsigned int nlen = strlen(eas[i].name.s); 358 358 SCVAL(data->data, off, nlen); 359 359 memcpy(data->data+off+1, eas[i].name.s, nlen+1); -
vendor/current/source4/libcli/raw/rawfile.c
r414 r740 349 349 if (parms->ntcreatex.in.sec_desc) { 350 350 enum ndr_err_code ndr_err; 351 ndr_err = ndr_push_struct_blob(&sd_blob, mem_ctx, NULL,351 ndr_err = ndr_push_struct_blob(&sd_blob, mem_ctx, 352 352 parms->ntcreatex.in.sec_desc, 353 353 (ndr_push_flags_fn_t)ndr_push_security_descriptor); … … 380 380 381 381 SIVAL(params, 0, parms->ntcreatex.in.flags); 382 SIVAL(params, 4, parms->ntcreatex.in.root_fid );382 SIVAL(params, 4, parms->ntcreatex.in.root_fid.fnum); 383 383 SIVAL(params, 8, parms->ntcreatex.in.access_mask); 384 384 SBVAL(params, 12, parms->ntcreatex.in.alloc_size); … … 565 565 SCVAL(req->out.vwv, VWV(2),0); /* padding */ 566 566 SIVAL(req->out.vwv, 7, parms->ntcreatex.in.flags); 567 SIVAL(req->out.vwv, 11, parms->ntcreatex.in.root_fid );567 SIVAL(req->out.vwv, 11, parms->ntcreatex.in.root_fid.fnum); 568 568 SIVAL(req->out.vwv, 15, parms->ntcreatex.in.access_mask); 569 569 SBVAL(req->out.vwv, 19, parms->ntcreatex.in.alloc_size); … … 617 617 } 618 618 break; 619 620 case RAW_OPEN_NTCREATEX_READX: 621 SETUP_REQUEST(SMBntcreateX, 24, 0); 622 SSVAL(req->out.vwv, VWV(0),SMB_CHAIN_NONE); 623 SSVAL(req->out.vwv, VWV(1),0); 624 SCVAL(req->out.vwv, VWV(2),0); /* padding */ 625 SIVAL(req->out.vwv, 7, parms->ntcreatexreadx.in.flags); 626 SIVAL(req->out.vwv, 11, parms->ntcreatexreadx.in.root_fid.fnum); 627 SIVAL(req->out.vwv, 15, parms->ntcreatexreadx.in.access_mask); 628 SBVAL(req->out.vwv, 19, parms->ntcreatexreadx.in.alloc_size); 629 SIVAL(req->out.vwv, 27, parms->ntcreatexreadx.in.file_attr); 630 SIVAL(req->out.vwv, 31, parms->ntcreatexreadx.in.share_access); 631 SIVAL(req->out.vwv, 35, parms->ntcreatexreadx.in.open_disposition); 632 SIVAL(req->out.vwv, 39, parms->ntcreatexreadx.in.create_options); 633 SIVAL(req->out.vwv, 43, parms->ntcreatexreadx.in.impersonation); 634 SCVAL(req->out.vwv, 47, parms->ntcreatexreadx.in.security_flags); 635 636 smbcli_req_append_string_len(req, parms->ntcreatexreadx.in.fname, STR_TERMINATE, &len); 637 SSVAL(req->out.vwv, 5, len); 638 639 if (tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES) { 640 bigoffset = true; 641 } 642 643 smbcli_chained_request_setup(req, SMBreadX, bigoffset ? 12 : 10, 0); 644 645 SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE); 646 SSVAL(req->out.vwv, VWV(1), 0); 647 SSVAL(req->out.vwv, VWV(2), 0); 648 SIVAL(req->out.vwv, VWV(3), parms->ntcreatexreadx.in.offset); 649 SSVAL(req->out.vwv, VWV(5), parms->ntcreatexreadx.in.maxcnt & 0xFFFF); 650 SSVAL(req->out.vwv, VWV(6), parms->ntcreatexreadx.in.mincnt); 651 SIVAL(req->out.vwv, VWV(7), parms->ntcreatexreadx.in.maxcnt >> 16); 652 SSVAL(req->out.vwv, VWV(9), parms->ntcreatexreadx.in.remaining); 653 if (bigoffset) { 654 SIVAL(req->out.vwv, VWV(10),parms->ntcreatexreadx.in.offset>>32); 655 } 656 break; 657 619 658 case RAW_OPEN_SMB2: 620 659 return NULL; … … 754 793 } 755 794 break; 795 796 case RAW_OPEN_NTCREATEX_READX: 797 SMBCLI_CHECK_MIN_WCT(req, 34); 798 parms->ntcreatexreadx.out.oplock_level = CVAL(req->in.vwv, 4); 799 parms->ntcreatexreadx.out.file.fnum = SVAL(req->in.vwv, 5); 800 parms->ntcreatexreadx.out.create_action = IVAL(req->in.vwv, 7); 801 parms->ntcreatexreadx.out.create_time = smbcli_pull_nttime(req->in.vwv, 11); 802 parms->ntcreatexreadx.out.access_time = smbcli_pull_nttime(req->in.vwv, 19); 803 parms->ntcreatexreadx.out.write_time = smbcli_pull_nttime(req->in.vwv, 27); 804 parms->ntcreatexreadx.out.change_time = smbcli_pull_nttime(req->in.vwv, 35); 805 parms->ntcreatexreadx.out.attrib = IVAL(req->in.vwv, 43); 806 parms->ntcreatexreadx.out.alloc_size = BVAL(req->in.vwv, 47); 807 parms->ntcreatexreadx.out.size = BVAL(req->in.vwv, 55); 808 parms->ntcreatexreadx.out.file_type = SVAL(req->in.vwv, 63); 809 parms->ntcreatexreadx.out.ipc_state = SVAL(req->in.vwv, 65); 810 parms->ntcreatexreadx.out.is_directory = CVAL(req->in.vwv, 67); 811 812 status = smbcli_chained_advance(req); 813 if (!NT_STATUS_IS_OK(status)) { 814 return status; 815 } 816 817 SMBCLI_CHECK_WCT(req, 12); 818 parms->ntcreatexreadx.out.remaining = SVAL(req->in.vwv, VWV(2)); 819 parms->ntcreatexreadx.out.compaction_mode = SVAL(req->in.vwv, VWV(3)); 820 parms->ntcreatexreadx.out.nread = SVAL(req->in.vwv, VWV(5)); 821 if (parms->ntcreatexreadx.out.nread > 822 MAX(parms->ntcreatexreadx.in.mincnt, parms->ntcreatexreadx.in.maxcnt) || 823 !smbcli_raw_pull_data(&req->in.bufinfo, req->in.hdr + SVAL(req->in.vwv, VWV(6)), 824 parms->ntcreatexreadx.out.nread, 825 parms->ntcreatexreadx.out.data)) { 826 req->status = NT_STATUS_BUFFER_TOO_SMALL; 827 } 828 break; 829 756 830 case RAW_OPEN_SMB2: 757 831 req->status = NT_STATUS_INTERNAL_ERROR; … … 845 919 case RAW_LOCK_LOCKX: { 846 920 struct smb_lock_entry *lockp; 847 u int_t lck_size = (parms->lockx.in.mode & LOCKING_ANDX_LARGE_FILES)? 20 : 10;848 u int_t lock_count = parms->lockx.in.ulock_cnt + parms->lockx.in.lock_cnt;921 unsigned int lck_size = (parms->lockx.in.mode & LOCKING_ANDX_LARGE_FILES)? 20 : 10; 922 unsigned int lock_count = parms->lockx.in.ulock_cnt + parms->lockx.in.lock_cnt; 849 923 int i; 850 924 -
vendor/current/source4/libcli/raw/rawfileinfo.c
r414 r740 48 48 49 49 while (blob.length - ofs >= 24) { 50 u int_t n = io->num_streams;50 unsigned int n = io->num_streams; 51 51 uint32_t nlen, len; 52 52 bool ret; … … 254 254 NT_STATUS_HAVE_NO_MEMORY(parms->query_secdesc.out.sd); 255 255 256 ndr_err = ndr_pull_struct_blob(blob, mem_ctx, NULL,257 258 256 ndr_err = ndr_pull_struct_blob(blob, mem_ctx, 257 parms->query_secdesc.out.sd, 258 (ndr_pull_flags_fn_t)ndr_pull_security_descriptor); 259 259 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 260 260 return ndr_map_error2ntstatus(ndr_err); -
vendor/current/source4/libcli/raw/rawfsinfo.c
r414 r740 160 160 { 161 161 NTSTATUS status = NT_STATUS_OK; 162 enum ndr_err_code ndr_err;163 162 int i; 164 163 … … 216 215 break; 217 216 218 case RAW_QFS_OBJECTID_INFORMATION: 217 case RAW_QFS_OBJECTID_INFORMATION: { 218 DATA_BLOB b2 = data_blob_const(blob.data, MIN(16, blob.length)); 219 219 QFS_CHECK_SIZE(64); 220 ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &fsinfo->objectid_information.out.guid, 221 (ndr_pull_flags_fn_t)ndr_pull_GUID); 222 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 223 status = ndr_map_error2ntstatus(ndr_err); 224 } 220 status = GUID_from_ndr_blob(&b2, &fsinfo->objectid_information.out.guid); 221 NT_STATUS_NOT_OK_RETURN(status); 225 222 for (i=0;i<6;i++) { 226 223 fsinfo->objectid_information.out.unknown[i] = BVAL(blob.data, 16 + i*8); 227 224 } 228 225 break; 226 } 229 227 230 228 default: -
vendor/current/source4/libcli/raw/rawnegotiate.c
r414 r740 153 153 transport->negotiate.writebraw_supported = true; 154 154 } 155 156 if (transport->negotiate.capabilities & CAP_LOCK_AND_READ) 157 transport->negotiate.lockread_supported = true; 155 158 } else if (transport->negotiate.protocol >= PROTOCOL_LANMAN1) { 156 159 SMBCLI_CHECK_WCT(req, 13); -
vendor/current/source4/libcli/raw/rawnotify.c
r414 r740 72 72 parms->nttrans.out.changes = NULL; 73 73 parms->nttrans.out.num_changes = 0; 74 74 75 75 /* count them */ 76 76 for (ofs=0; nt.out.params.length - ofs > 12; ) { 77 77 uint32_t next = IVAL(nt.out.params.data, ofs); 78 if (next % 4 != 0) 79 return NT_STATUS_INVALID_NETWORK_RESPONSE; 78 80 parms->nttrans.out.num_changes++; 79 81 if (next == 0 || … … 156 158 * but we want to keep it under oldreq->ntcancel 157 159 */ 158 if (!talloc_reference(oldreq, req)) { 159 talloc_free(req); 160 return NT_STATUS_NO_MEMORY; 161 } 160 req->do_not_free = true; 161 talloc_steal(oldreq, req); 162 162 163 163 smbcli_request_send(req); -
vendor/current/source4/libcli/raw/rawrequest.c
r414 r740 120 120 */ 121 121 struct smbcli_request *smbcli_request_setup_transport(struct smbcli_transport *transport, 122 uint8_t command, u int_t wct, uint_t buflen)122 uint8_t command, unsigned int wct, unsigned int buflen) 123 123 { 124 124 struct smbcli_request *req; … … 168 168 */ 169 169 struct smbcli_request *smbcli_request_setup_session(struct smbcli_session *session, 170 uint8_t command, u int_t wct, size_t buflen)170 uint8_t command, unsigned int wct, size_t buflen) 171 171 { 172 172 struct smbcli_request *req; … … 191 191 struct smbcli_request *smbcli_request_setup(struct smbcli_tree *tree, 192 192 uint8_t command, 193 u int_t wct, uint_t buflen)193 unsigned int wct, unsigned int buflen) 194 194 { 195 195 struct smbcli_request *req; … … 212 212 point at the same offset into the packet as before this call 213 213 */ 214 static void smbcli_req_grow_allocation(struct smbcli_request *req, u int_t new_size)214 static void smbcli_req_grow_allocation(struct smbcli_request *req, unsigned int new_size) 215 215 { 216 216 int delta; … … 253 253 point at the same offset into the packet as before this call 254 254 */ 255 static void smbcli_req_grow_data(struct smbcli_request *req, u int_t new_size)255 static void smbcli_req_grow_data(struct smbcli_request *req, unsigned int new_size) 256 256 { 257 257 int delta; … … 275 275 NTSTATUS smbcli_chained_request_setup(struct smbcli_request *req, 276 276 uint8_t command, 277 u int_t wct, size_t buflen)278 { 279 u int_t new_size = 1 + (wct*2) + 2 + buflen;277 unsigned int wct, size_t buflen) 278 { 279 unsigned int new_size = 1 + (wct*2) + 2 + buflen; 280 280 281 281 SSVAL(req->out.vwv, VWV(0), command); … … 372 372 an oplock break 373 373 */ 374 bool smbcli_handle_oplock_break(struct smbcli_transport *transport, u int_t len, const uint8_t *hdr, const uint8_t *vwv)374 bool smbcli_handle_oplock_break(struct smbcli_transport *transport, unsigned int len, const uint8_t *hdr, const uint8_t *vwv) 375 375 { 376 376 /* we must be very fussy about what we consider an oplock break to avoid … … 417 417 return the number of bytes added to the packet 418 418 */ 419 size_t smbcli_req_append_string(struct smbcli_request *req, const char *str, u int_t flags)419 size_t smbcli_req_append_string(struct smbcli_request *req, const char *str, unsigned int flags) 420 420 { 421 421 size_t len; … … 449 449 placed in the packet as a separate field 450 450 */ 451 size_t smbcli_req_append_string_len(struct smbcli_request *req, const char *str, u int_t flags, int *len)451 size_t smbcli_req_append_string_len(struct smbcli_request *req, const char *str, unsigned int flags, int *len) 452 452 { 453 453 int diff = 0; … … 490 490 if dest_len is -1 then no limit applies 491 491 */ 492 size_t smbcli_req_append_ascii4(struct smbcli_request *req, const char *str, u int_t flags)492 size_t smbcli_req_append_ascii4(struct smbcli_request *req, const char *str, unsigned int flags) 493 493 { 494 494 size_t size; … … 556 556 */ 557 557 static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ctx, 558 char **dest, const uint8_t *src, int byte_len, u int_t flags)558 char **dest, const uint8_t *src, int byte_len, unsigned int flags) 559 559 { 560 560 int src_len, src_len2, alignment=0; … … 610 610 */ 611 611 size_t smbcli_req_pull_ascii(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ctx, 612 char **dest, const uint8_t *src, int byte_len, u int_t flags)612 char **dest, const uint8_t *src, int byte_len, unsigned int flags) 613 613 { 614 614 int src_len, src_len2; … … 654 654 */ 655 655 size_t smbcli_req_pull_string(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ctx, 656 char **dest, const uint8_t *src, int byte_len, u int_t flags)656 char **dest, const uint8_t *src, int byte_len, unsigned int flags) 657 657 { 658 658 if (!(flags & STR_ASCII) && … … 752 752 size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, 753 753 const DATA_BLOB *blob, const char **dest, 754 const uint8_t *src, int byte_len, u int_t flags)754 const uint8_t *src, int byte_len, unsigned int flags) 755 755 { 756 756 int src_len, src_len2, alignment=0; … … 809 809 static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx, 810 810 const DATA_BLOB *blob, const char **dest, 811 const uint8_t *src, int byte_len, u int_t flags)811 const uint8_t *src, int byte_len, unsigned int flags) 812 812 { 813 813 int src_len, src_len2; … … 861 861 struct smb_wire_string *dest, 862 862 uint16_t len_offset, uint16_t str_offset, 863 u int_t flags)863 unsigned int flags) 864 864 { 865 865 int extra; … … 928 928 const char **dest, 929 929 uint16_t str_offset, 930 u int_t flags)930 unsigned int flags) 931 931 { 932 932 int extra = 0; … … 962 962 size_t smbcli_blob_append_string(struct smbcli_session *session, 963 963 TALLOC_CTX *mem_ctx, DATA_BLOB *blob, 964 const char *str, u int_t flags)964 const char *str, unsigned int flags) 965 965 { 966 966 size_t max_len; … … 992 992 bytes long 993 993 */ 994 enum ndr_err_code smbcli_pull_guid(void *base, uint16_t offset, 995 994 NTSTATUS smbcli_pull_guid(void *base, uint16_t offset, 995 struct GUID *guid) 996 996 { 997 997 DATA_BLOB blob; 998 TALLOC_CTX *tmp_ctx = talloc_new(NULL);999 enum ndr_err_code ndr_err;1000 998 1001 999 ZERO_STRUCTP(guid); … … 1003 1001 blob.data = offset + (uint8_t *)base; 1004 1002 blob.length = 16; 1005 ndr_err = ndr_pull_struct_blob(&blob, tmp_ctx, NULL, guid, 1006 (ndr_pull_flags_fn_t)ndr_pull_GUID); 1007 talloc_free(tmp_ctx); 1008 return ndr_err; 1003 1004 return GUID_from_ndr_blob(&blob, guid); 1009 1005 } 1010 1006 … … 1012 1008 push a guid onto the wire. The buffer must hold 16 bytes 1013 1009 */ 1014 enum ndr_err_code smbcli_push_guid(void *base, uint16_t offset, 1015 const struct GUID *guid) 1010 NTSTATUS smbcli_push_guid(void *base, uint16_t offset, const struct GUID *guid) 1016 1011 { 1017 1012 TALLOC_CTX *tmp_ctx = talloc_new(NULL); 1018 enum ndr_err_code ndr_err;1013 NTSTATUS status; 1019 1014 DATA_BLOB blob; 1020 ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, NULL, 1021 guid, (ndr_push_flags_fn_t)ndr_push_GUID); 1022 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || blob.length != 16) { 1015 status = GUID_to_ndr_blob(guid, tmp_ctx, &blob); 1016 if (!NT_STATUS_IS_OK(status)) { 1023 1017 talloc_free(tmp_ctx); 1024 return ndr_err;1018 return status; 1025 1019 } 1026 1020 memcpy(offset + (uint8_t *)base, blob.data, blob.length); 1027 1021 talloc_free(tmp_ctx); 1028 return ndr_err;1029 } 1022 return NT_STATUS_OK; 1023 } -
vendor/current/source4/libcli/raw/rawsearch.c
r414 r740 334 334 const DATA_BLOB *blob, 335 335 union smb_search_data *data, 336 u int_t *next_ofs,337 u int_t str_flags)338 { 339 u int_t len, blen;336 unsigned int *next_ofs, 337 unsigned int str_flags) 338 { 339 unsigned int len, blen; 340 340 341 341 if (blob->length < 4) { … … 488 488 union smb_search_data *data) 489 489 { 490 u int_t len, ofs;490 unsigned int len, ofs; 491 491 uint32_t ea_size; 492 492 DATA_BLOB eablob; … … 657 657 case RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO: 658 658 case RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO: { 659 u int_t str_flags = STR_UNICODE;659 unsigned int str_flags = STR_UNICODE; 660 660 if (!(tree->session->transport->negotiate.capabilities & CAP_UNICODE)) { 661 661 str_flags = STR_ASCII; … … 695 695 for (i=0; i < count; i++) { 696 696 union smb_search_data search_data; 697 u int_t len;697 unsigned int len; 698 698 699 699 len = parse_trans2_search(tree, mem_ctx, level, flags, &blob2, &search_data); -
vendor/current/source4/libcli/raw/rawsetfileinfo.c
r414 r740 34 34 DATA_BLOB *blob) 35 35 { 36 u int_t len;36 unsigned int len; 37 37 38 38 #define NEED_BLOB(n) do { \ … … 100 100 enum ndr_err_code ndr_err; 101 101 102 ndr_err = ndr_push_struct_blob(blob, mem_ctx, NULL, 103 parms->set_secdesc.in.sd, 102 ndr_err = ndr_push_struct_blob(blob, mem_ctx, parms->set_secdesc.in.sd, 104 103 (ndr_push_flags_fn_t)ndr_push_security_descriptor); 105 104 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { -
vendor/current/source4/libcli/raw/rawtrans.c
r414 r740 30 30 */ 31 31 static bool raw_trans_oob(struct smbcli_request *req, 32 u int_t offset, uint_t count)32 unsigned int offset, unsigned int count) 33 33 { 34 34 uint8_t *ptr; -
vendor/current/source4/libcli/raw/request.h
r414 r740 59 59 into the raw buffer */ 60 60 uint8_t *vwv; 61 u int_t wct;61 unsigned int wct; 62 62 63 63 /* the data buffer and size. data points into the raw buffer */ -
vendor/current/source4/libcli/raw/smb.h
r414 r740 179 179 NTCREATEX_OPTIONS_SYNC_ALERT | \ 180 180 NTCREATEX_OPTIONS_ASYNC_ALERT | \ 181 NTCREATEX_OPTIONS_OPFILTER | \182 181 0xFF000000) 183 182 184 183 /* 185 * We reuse some ignored flags for private use.184 * private_flags field in ntcreatex 186 185 * This values have different meaning for some ntvfs backends. 187 *188 * TODO: use values that are ignore for sure...189 186 */ 190 #define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x00010000 191 #define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x00020000 192 #define NTCREATEX_OPTIONS_PRIVATE_MASK (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS | \ 193 NTCREATEX_OPTIONS_PRIVATE_DENY_FCB) 187 #define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x0001 188 #define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x0002 189 194 190 195 191 /* ntcreatex impersonation field */ … … 371 367 372 368 373 /* Mapping of generic access rights for files to specific rights. */374 #define FILE_GENERIC_ALL (STANDARD_RIGHTS_REQUIRED_ACCESS| NT_ACCESS_SYNCHRONIZE_ACCESS|FILE_ALL_ACCESS)375 376 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ_ACCESS|FILE_READ_DATA|FILE_READ_ATTRIBUTES|\377 FILE_READ_EA|NT_ACCESS_SYNCHRONIZE_ACCESS)378 379 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE_ACCESS|FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|\380 FILE_WRITE_EA|FILE_APPEND_DATA|NT_ACCESS_SYNCHRONIZE_ACCESS)381 382 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE_ACCESS|FILE_READ_ATTRIBUTES|\383 FILE_EXECUTE|NT_ACCESS_SYNCHRONIZE_ACCESS)384 385 386 369 /* FileAttributes (search attributes) field */ 387 370 #define FILE_ATTRIBUTE_READONLY 0x0001 … … 465 448 (FILE_NOTIFY_CHANGE_FILE_NAME|FILE_NOTIFY_CHANGE_DIR_NAME) 466 449 450 #define FILE_NOTIFY_CHANGE_ALL \ 451 (FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | \ 452 FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_SIZE | \ 453 FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_LAST_ACCESS | \ 454 FILE_NOTIFY_CHANGE_CREATION | FILE_NOTIFY_CHANGE_EA | \ 455 FILE_NOTIFY_CHANGE_SECURITY | FILE_NOTIFY_CHANGE_STREAM_NAME | \ 456 FILE_NOTIFY_CHANGE_STREAM_SIZE | FILE_NOTIFY_CHANGE_STREAM_WRITE) 457 467 458 /* change notify action results */ 468 459 #define NOTIFY_ACTION_ADDED 1 … … 552 543 553 544 /* Lock types. */ 545 #define LOCKING_ANDX_EXCLUSIVE_LOCK 0x00 554 546 #define LOCKING_ANDX_SHARED_LOCK 0x01 555 547 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 -
vendor/current/source4/libcli/raw/smb_signing.c
r414 r740 133 133 } 134 134 135 bool check_signed_incoming_message(struct smb_request_buffer *in, DATA_BLOB *mac_key, u int_t seq_num)135 bool check_signed_incoming_message(struct smb_request_buffer *in, DATA_BLOB *mac_key, unsigned int seq_num) 136 136 { 137 137 bool good; -
vendor/current/source4/libcli/resolve/bcast.c
r414 r740 102 102 { 103 103 struct interface *ifaces; 104 load_interfaces(ctx, lp _interfaces(lp_ctx), &ifaces);105 return resolve_context_add_bcast_method(ctx, ifaces, lp _nbt_port(lp_ctx), lp_parm_int(lp_ctx, NULL, "nbt", "timeout", 1));104 load_interfaces(ctx, lpcfg_interfaces(lp_ctx), &ifaces); 105 return resolve_context_add_bcast_method(ctx, ifaces, lpcfg_nbt_port(lp_ctx), lpcfg_parm_int(lp_ctx, NULL, "nbt", "timeout", 1)); 106 106 } -
vendor/current/source4/libcli/resolve/dns_ex.c
r414 r740 68 68 69 69 kill(state->child, SIGTERM); 70 close(state->child_fd);71 70 if (waitpid(state->child, &status, WNOHANG) == 0) { 72 71 kill(state->child, SIGKILL); … … 94 93 bool do_srv = (state->flags & RESOLVE_NAME_FLAG_DNS_SRV); 95 94 95 if (strchr(state->name.name, '.') && state->name.name[strlen(state->name.name)-1] != '.') { 96 /* we are asking for a fully qualified name, but the 97 name doesn't end in a '.'. We need to prevent the 98 DNS library trying the search domains configured in 99 resolv.conf */ 100 state->name.name = talloc_strdup_append(discard_const_p(char, state->name.name), 101 "."); 102 } 103 96 104 /* this is the blocking call we are going to lots of trouble 97 105 to avoid in the parent */ … … 169 177 if (do_srv) { 170 178 /* we are only interested in SRV records */ 171 if (rr->type != rk_ns_ c_in) {179 if (rr->type != rk_ns_t_srv) { 172 180 continue; 173 181 } … … 209 217 } 210 218 211 /* we are only interested in SRVrecords */219 /* we are only interested in A records */ 212 220 if (rr->type != rk_ns_t_a) { 213 221 continue; … … 370 378 ret = -1; 371 379 } 372 close(state->child_fd);373 380 if (waitpid(state->child, &status, WNOHANG) == 0) { 374 381 kill(state->child, SIGKILL); … … 499 506 return c; 500 507 } 508 tevent_fd_set_auto_close(state->fde); 501 509 502 510 state->child = fork(); -
vendor/current/source4/libcli/resolve/nbtlist.c
r414 r740 164 164 } 165 165 166 state->nbtsock = nbt_name_socket_init(state, event_ctx, 167 global_iconv_convenience); 166 state->nbtsock = nbt_name_socket_init(state, event_ctx); 168 167 if (composite_nomem(state->nbtsock, c)) return c; 169 168 -
vendor/current/source4/libcli/resolve/resolve.c
r414 r740 28 28 #include "lib/socket/socket.h" 29 29 #include "../lib/util/dlinklist.h" 30 #include "lib/tsocket/tsocket.h" 31 #include "lib/util/util_net.h" 30 32 31 33 struct resolve_state { … … 138 140 struct composite_context *resolve_name_all_send(struct resolve_context *ctx, 139 141 TALLOC_CTX *mem_ctx, 140 uint32_t flags, 142 uint32_t flags, /* RESOLVE_NAME_FLAG_* */ 141 143 uint16_t port, 142 144 struct nbt_name *name, … … 146 148 struct resolve_state *state; 147 149 148 if ( ctx == NULL ||event_ctx == NULL) {150 if (event_ctx == NULL) { 149 151 return NULL; 150 152 } … … 222 224 } 223 225 226 struct composite_context *resolve_name_ex_send(struct resolve_context *ctx, 227 TALLOC_CTX *mem_ctx, 228 uint32_t flags, /* RESOLVE_NAME_FLAG_* */ 229 uint16_t port, 230 struct nbt_name *name, 231 struct tevent_context *event_ctx) 232 { 233 return resolve_name_all_send(ctx, mem_ctx, flags, port, name, event_ctx); 234 } 235 224 236 struct composite_context *resolve_name_send(struct resolve_context *ctx, 225 237 TALLOC_CTX *mem_ctx, … … 227 239 struct tevent_context *event_ctx) 228 240 { 229 return resolve_name_ all_send(ctx, mem_ctx, 0, 0, name, event_ctx);241 return resolve_name_ex_send(ctx, mem_ctx, 0, 0, name, event_ctx); 230 242 } 231 243 … … 240 252 241 253 if (NT_STATUS_IS_OK(status)) { 242 *reply_addr = talloc_steal(mem_ctx, addrs[0]->addr); 254 struct tsocket_address *t_addr = socket_address_to_tsocket_address(addrs, addrs[0]); 255 if (!t_addr) { 256 return NT_STATUS_NO_MEMORY; 257 } 258 259 *reply_addr = tsocket_address_inet_addr_string(t_addr, mem_ctx); 243 260 talloc_free(addrs); 261 if (!*reply_addr) { 262 return NT_STATUS_NO_MEMORY; 263 } 244 264 } 245 265 … … 248 268 249 269 /* 270 receive multiple responses from resolve_name_send() 271 */ 272 NTSTATUS resolve_name_multiple_recv(struct composite_context *c, 273 TALLOC_CTX *mem_ctx, 274 const char ***reply_addrs) 275 { 276 NTSTATUS status; 277 struct socket_address **addrs = NULL; 278 int i; 279 280 status = resolve_name_all_recv(c, mem_ctx, &addrs, NULL); 281 NT_STATUS_NOT_OK_RETURN(status); 282 283 /* count the addresses */ 284 for (i=0; addrs[i]; i++) ; 285 286 *reply_addrs = talloc_array(mem_ctx, const char *, i+1); 287 NT_STATUS_HAVE_NO_MEMORY(*reply_addrs); 288 289 for (i=0; addrs[i]; i++) { 290 struct tsocket_address *t_addr = socket_address_to_tsocket_address(addrs, addrs[i]); 291 NT_STATUS_HAVE_NO_MEMORY(t_addr); 292 293 (*reply_addrs)[i] = tsocket_address_inet_addr_string(t_addr, *reply_addrs); 294 NT_STATUS_HAVE_NO_MEMORY((*reply_addrs)[i]); 295 } 296 (*reply_addrs)[i] = NULL; 297 298 talloc_free(addrs); 299 300 return status; 301 } 302 303 /* 250 304 general name resolution - sync call 251 305 */ 306 NTSTATUS resolve_name_ex(struct resolve_context *ctx, 307 uint32_t flags, /* RESOLVE_NAME_FLAG_* */ 308 uint16_t port, 309 struct nbt_name *name, 310 TALLOC_CTX *mem_ctx, 311 const char **reply_addr, 312 struct tevent_context *ev) 313 { 314 struct composite_context *c = resolve_name_ex_send(ctx, mem_ctx, flags, port, name, ev); 315 return resolve_name_recv(c, mem_ctx, reply_addr); 316 } 317 318 319 /* 320 general name resolution - sync call 321 */ 252 322 NTSTATUS resolve_name(struct resolve_context *ctx, 253 struct nbt_name *name, 254 TALLOC_CTX *mem_ctx, 255 const char **reply_addr, 256 struct tevent_context *ev) 257 { 258 struct composite_context *c = resolve_name_send(ctx, mem_ctx, name, ev); 259 return resolve_name_recv(c, mem_ctx, reply_addr); 323 struct nbt_name *name, 324 TALLOC_CTX *mem_ctx, 325 const char **reply_addr, 326 struct tevent_context *ev) 327 { 328 return resolve_name_ex(ctx, 0, 0, name, mem_ctx, reply_addr, ev); 260 329 } 261 330 -
vendor/current/source4/libcli/resolve/resolve_lp.c
r414 r740 22 22 #include "param/param.h" 23 23 24 struct resolve_context *lp _resolve_context(struct loadparm_context *lp_ctx)24 struct resolve_context *lpcfg_resolve_context(struct loadparm_context *lp_ctx) 25 25 { 26 const char **methods = lp _name_resolve_order(lp_ctx);26 const char **methods = lpcfg_name_resolve_order(lp_ctx); 27 27 int i; 28 28 struct resolve_context *ret = resolve_context_init(lp_ctx); … … 36 36 } else if (!strcmp(methods[i], "bcast")) { 37 37 resolve_context_add_bcast_method_lp(ret, lp_ctx); 38 } else if (!strcmp(methods[i], "file")) { 39 resolve_context_add_file_method_lp(ret, lp_ctx); 38 40 } else if (!strcmp(methods[i], "host")) { 39 41 resolve_context_add_host_method(ret); -
vendor/current/source4/libcli/resolve/testsuite.c
r414 r740 25 25 #include "torture/torture.h" 26 26 #include "system/network.h" 27 #include "lib/util/util_net.h" 27 28 28 29 static bool test_async_resolve(struct torture_context *tctx) … … 82 83 struct torture_suite *torture_local_resolve(TALLOC_CTX *mem_ctx) 83 84 { 84 struct torture_suite *suite = torture_suite_create(mem_ctx, " RESOLVE");85 struct torture_suite *suite = torture_suite_create(mem_ctx, "resolve"); 85 86 86 87 torture_suite_add_simple_test(suite, "async", test_async_resolve); -
vendor/current/source4/libcli/resolve/wins.c
r414 r740 78 78 { 79 79 struct interface *ifaces; 80 load_interfaces(ctx, lp _interfaces(lp_ctx), &ifaces);81 return resolve_context_add_wins_method(ctx, lp _wins_server_list(lp_ctx), ifaces, lp_nbt_port(lp_ctx), lp_parm_int(lp_ctx, NULL, "nbt", "timeout", 1));80 load_interfaces(ctx, lpcfg_interfaces(lp_ctx), &ifaces); 81 return resolve_context_add_wins_method(ctx, lpcfg_wins_server_list(lp_ctx), ifaces, lpcfg_nbt_port(lp_ctx), lpcfg_parm_int(lp_ctx, NULL, "nbt", "timeout", 1)); 82 82 } -
vendor/current/source4/libcli/security/tests/sddl.c
r414 r740 73 73 "D:(A;;CC;;;BA)(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)(A;;RPLCLORC;;;AU)", 74 74 "D:(A;;GA;;;SY)", 75 "D:(A;;GA;;;RS)", 75 76 "D:(A;;RP;;;WD)(OA;;CR;1131f6aa-9c07-11d1-f79f-00c04fc2dcd2;;ED)(OA;;CR;1131f6ab-9c07-11d1-f79f-00c04fc2dcd2;;ED)(OA;;CR;1131f6ac-9c07-11d1-f79f-00c04fc2dcd2;;ED)(OA;;CR;1131f6aa-9c07-11d1-f79f-00c04fc2dcd2;;BA)(OA;;CR;1131f6ab-9c07-11d1-f79f-00c04fc2dcd2;;BA)(OA;;CR;1131f6ac-9c07-11d1-f79f-00c04fc2dcd2;;BA)(A;;RPLCLORC;;;AU)(A;;RPWPCRLCLOCCRCWDWOSW;;;DA)(A;CI;RPWPCRLCLOCCRCWDWOSDSW;;;BA)(A;;RPWPCRLCLOCCDCRCWDWOSDDTSW;;;SY)(A;CI;RPWPCRLCLOCCDCRCWDWOSDDTSW;;;EA)(A;CI;LC;;;RU)(OA;CIIO;RP;037088f8-0ae1-11d2-b422-00a0c968f939;bf967aba-0de6-11d0-a285-00aa003049e2;RU)(OA;CIIO;RP;59ba2f42-79a2-11d0-9020-00c04fc2d3cf;bf967aba-0de6-11d0-a285-00aa003049e2;RU)(OA;CIIO;RP;bc0ac240-79a9-11d0-9020-00c04fc2d4cf;bf967aba-0de6-11d0-a285-00aa003049e2;RU)(OA;CIIO;RP;4c164200-20c0-11d0-a768-00aa006e0529;bf967aba-0de6-11d0-a285-00aa003049e2;RU)(OA;CIIO;RP;5f202010-79a5-11d0-9020-00c04fc2d4cf;bf967aba-0de6-11d0-a285-00aa003049e2;RU)(OA;;RP;c7407360-20bf-11d0-a768-00aa006e0529;;RU)(OA;CIIO;RPLCLORC;;bf967a9c-0de6-11d0-a285-00aa003049e2;RU)(A;;RPRC;;;RU)(OA;CIIO;RPLCLORC;;bf967aba-0de6-11d0-a285-00aa003049e2;RU)(A;;LCRPLORC;;;ED)(OA;CIIO;RP;037088f8-0ae1-11d2-b422-00a0c968f939;4828CC14-1437-45bc-9B07-AD6F015E5F28;RU)(OA;CIIO;RP;59ba2f42-79a2-11d0-9020-00c04fc2d3cf;4828CC14-1437-45bc-9B07-AD6F015E5F28;RU)(OA;CIIO;RP;bc0ac240-79a9-11d0-9020-00c04fc2d4cf;4828CC14-1437-45bc-9B07-AD6F015E5F28;RU)(OA;CIIO;RP;4c164200-20c0-11d0-a768-00aa006e0529;4828CC14-1437-45bc-9B07-AD6F015E5F28;RU)(OA;CIIO;RP;5f202010-79a5-11d0-9020-00c04fc2d4cf;4828CC14-1437-45bc-9B07-AD6F015E5F28;RU)(OA;CIIO;RPLCLORC;;4828CC14-1437-45bc-9B07-AD6F015E5F28;RU)(OA;;RP;b8119fd0-04f6-4762-ab7a-4986c76b3f9a;;RU)(OA;;RP;b8119fd0-04f6-4762-ab7a-4986c76b3f9a;;AU)(OA;CIIO;RP;b7c69e6d-2cc7-11d2-854e-00a0c983f608;bf967aba-0de6-11d0-a285-00aa003049e2;ED)(OA;CIIO;RP;b7c69e6d-2cc7-11d2-854e-00a0c983f608;bf967a9c-0de6-11d0-a285-00aa003049e2;ED)(OA;CIIO;RP;b7c69e6d-2cc7-11d2-854e-00a0c983f608;bf967a86-0de6-11d0-a285-00aa003049e2;ED)(OA;;CR;1131f6ad-9c07-11d1-f79f-00c04fc2dcd2;;DD)(OA;;CR;1131f6ad-9c07-11d1-f79f-00c04fc2dcd2;;BA)(OA;;CR;e2a36dc9-ae17-47c3-b58b-be34c55ba633;;S-1-5-32-557)(OA;;CR;280f369c-67c7-438e-ae98-1d46f3c6f541;;AU)(OA;;CR;ccc2dc7d-a6ad-4a7a-8846-c04e3cc53501;;AU)(OA;;CR;05c74c5e-4deb-43b4-bd9f-86664c2a7fd5;;AU)S:(AU;SA;WDWOWP;;;WD)(AU;SA;CR;;;BA)(AU;SA;CR;;;DU)(OU;CISA;WP;f30e3bbe-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)(OU;CISA;WP;f30e3bbf-9ff0-11d1-b603-0000f80367c1;bf967aa5-0de6-11d0-a285-00aa003049e2;WD)", 76 77 "D:(A;;RPLCLORC;;;DA)(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;SY)(A;;RPLCLORC;;;AU)", … … 93 94 struct torture_suite *torture_local_sddl(TALLOC_CTX *mem_ctx) 94 95 { 95 struct torture_suite *suite = torture_suite_create(mem_ctx, " SDDL");96 struct torture_suite *suite = torture_suite_create(mem_ctx, "sddl"); 96 97 int i; 97 98 -
vendor/current/source4/libcli/smb2/cancel.c
r414 r740 54 54 SIVAL(c->out.hdr, SMB2_HDR_FLAGS, 0x00000002); 55 55 SSVAL(c->out.hdr, SMB2_HDR_CREDIT, 0x0030); 56 S IVAL(c->out.hdr, SMB2_HDR_PID, r->cancel.pending_id);56 SBVAL(c->out.hdr, SMB2_HDR_ASYNC_ID, r->cancel.async_id); 57 57 SBVAL(c->out.hdr, SMB2_HDR_MESSAGE_ID, c->seqnum); 58 58 if (r->session) { -
vendor/current/source4/libcli/smb2/create.c
r414 r740 132 132 enum ndr_err_code ndr_err; 133 133 DATA_BLOB sd_blob; 134 ndr_err = ndr_push_struct_blob(&sd_blob, req, NULL, 135 io->in.sec_desc, 134 ndr_err = ndr_push_struct_blob(&sd_blob, req, io->in.sec_desc, 136 135 (ndr_push_flags_fn_t)ndr_push_security_descriptor); 137 136 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { -
vendor/current/source4/libcli/smb2/find.c
r414 r740 96 96 */ 97 97 NTSTATUS smb2_find_level_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, 98 uint8_t level, u int_t *count,98 uint8_t level, unsigned int *count, 99 99 union smb_search_data **io) 100 100 { … … 103 103 DATA_BLOB b; 104 104 enum smb_search_data_level smb_level; 105 u int_t next_ofs=0;105 unsigned int next_ofs=0; 106 106 107 107 switch (level) { … … 172 172 NTSTATUS smb2_find_level(struct smb2_tree *tree, TALLOC_CTX *mem_ctx, 173 173 struct smb2_find *f, 174 u int_t *count, union smb_search_data **io)174 unsigned int *count, union smb_search_data **io) 175 175 { 176 176 struct smb2_request *req; -
vendor/current/source4/libcli/smb2/lock.c
r414 r740 40 40 41 41 SSVAL(req->out.body, 0x02, io->in.lock_count); 42 SIVAL(req->out.body, 0x04, io->in. reserved);42 SIVAL(req->out.body, 0x04, io->in.lock_sequence); 43 43 smb2_push_handle(req->out.body+0x08, &io->in.file.handle); 44 44 -
vendor/current/source4/libcli/smb2/negprot.c
r414 r740 35 35 struct smb2_request *req; 36 36 uint16_t size = 0x24 + io->in.dialect_count*2; 37 enum ndr_err_code ndr_err;38 37 int i; 38 NTSTATUS status; 39 39 40 40 req = smb2_request_init(transport, SMB2_OP_NEGPROT, size, false, 0); … … 47 47 SSVAL(req->out.body, 0x06, io->in.reserved); 48 48 SIVAL(req->out.body, 0x08, io->in.capabilities); 49 ndr_err= smbcli_push_guid(req->out.body, 0x0C, &io->in.client_guid);50 if (!N DR_ERR_CODE_IS_SUCCESS(ndr_err)) {49 status = smbcli_push_guid(req->out.body, 0x0C, &io->in.client_guid); 50 if (!NT_STATUS_IS_OK(status)) { 51 51 talloc_free(req); 52 52 return NULL; … … 69 69 { 70 70 NTSTATUS status; 71 enum ndr_err_code ndr_err;72 71 73 72 if (!smb2_request_receive(req) || … … 81 80 io->out.dialect_revision = SVAL(req->in.body, 0x04); 82 81 io->out.reserved = SVAL(req->in.body, 0x06); 83 ndr_err= smbcli_pull_guid(req->in.body, 0x08, &io->in.client_guid);84 if (!N DR_ERR_CODE_IS_SUCCESS(ndr_err)) {82 status = smbcli_pull_guid(req->in.body, 0x08, &io->in.client_guid); 83 if (!NT_STATUS_IS_OK(status)) { 85 84 smb2_request_destroy(req); 86 return NT_STATUS_INTERNAL_ERROR;85 return status; 87 86 } 88 87 io->out.capabilities = IVAL(req->in.body, 0x18); -
vendor/current/source4/libcli/smb2/request.c
r414 r740 176 176 177 177 SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, tree->session->uid); 178 SIVAL(req->out.hdr, SMB2_HDR_PID, tree->session->pid); 178 179 SIVAL(req->out.hdr, SMB2_HDR_TID, tree->tid); 179 180 req->session = tree->session; -
vendor/current/source4/libcli/smb2/session.c
r414 r740 27 27 #include "auth/gensec/gensec.h" 28 28 29 #include <unistd.h> 30 29 31 /** 30 32 initialise a smb2_session structure … … 46 48 session->transport = talloc_reference(session, transport); 47 49 } 50 51 session->pid = getpid(); 48 52 49 53 /* prepare a gensec context for later use */ -
vendor/current/source4/libcli/smb2/smb2.h
r414 r740 104 104 void (*func)(struct smb2_transport *, void *); 105 105 void *private_data; 106 u int_t period;106 unsigned int period; 107 107 } idle; 108 108 … … 146 146 struct gensec_security *gensec; 147 147 uint64_t uid; 148 uint32_t pid; 148 149 DATA_BLOB session_key; 149 150 bool signing_active; … … 167 168 /* each request is in one of 3 possible states */ 168 169 enum smb2_request_state state; 169 170 170 171 struct smb2_transport *transport; 171 172 struct smb2_session *session; … … 177 178 bool do_cancel; 178 179 bool can_cancel; 179 uint 32_t pending_id;180 uint64_t async_id; 180 181 } cancel; 181 182 … … 183 184 or code detecting error. */ 184 185 NTSTATUS status; 185 186 186 187 struct smb2_request_buffer in; 187 188 struct smb2_request_buffer out; -
vendor/current/source4/libcli/smb2/transport.c
r414 r740 303 303 NT_STATUS_EQUAL(req->status, STATUS_PENDING)) { 304 304 req->cancel.can_cancel = true; 305 req->cancel. pending_id = IVAL(hdr, SMB2_HDR_PID);305 req->cancel.async_id = BVAL(hdr, SMB2_HDR_ASYNC_ID); 306 306 for (i=0; i< req->cancel.do_cancel; i++) { 307 307 smb2_cancel(req); -
vendor/current/source4/libcli/smb2/util.c
r414 r740 26 26 #include "libcli/smb2/smb2_calls.h" 27 27 #include "libcli/smb_composite/smb_composite.h" 28 #include "librpc/gen_ndr/ndr_security.h" 28 29 29 30 /* … … 109 110 NTSTATUS status; 110 111 uint32_t total_deleted = 0; 111 u int_t count, i;112 unsigned int count, i; 112 113 union smb_search_data *list; 113 114 TALLOC_CTX *tmp_ctx = talloc_new(tree); … … 221 222 return total_deleted; 222 223 } 224 225 /* 226 check if two SMB2 file handles are the same 227 */ 228 bool smb2_util_handle_equal(const struct smb2_handle h1, 229 const struct smb2_handle h2) 230 { 231 return (h1.data[0] == h2.data[0]) && (h1.data[1] == h2.data[1]); 232 } -
vendor/current/source4/libcli/smb_composite/appendacl.c
r414 r740 255 255 256 256 state->io_open->ntcreatex.level = RAW_OPEN_NTCREATEX; 257 state->io_open->ntcreatex.in.root_fid = 0;257 state->io_open->ntcreatex.in.root_fid.fnum = 0; 258 258 state->io_open->ntcreatex.in.flags = 0; 259 259 state->io_open->ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; -
vendor/current/source4/libcli/smb_composite/connect.c
r414 r740 31 31 #include "librpc/gen_ndr/ndr_nbt.h" 32 32 #include "param/param.h" 33 #include "lib/util/util_net.h" 33 34 34 35 /* the stages of this call */ 35 enum connect_stage {CONNECT_RESOLVE, 36 CONNECT_SOCKET, 36 enum connect_stage {CONNECT_SOCKET, 37 37 CONNECT_SESSION_REQUEST, 38 38 CONNECT_NEGPROT, … … 324 324 /* the socket is up - we can initialise the smbcli transport layer */ 325 325 state->transport = smbcli_transport_init(state->sock, state, true, 326 &io->in.options , io->in.iconv_convenience);326 &io->in.options); 327 327 NT_STATUS_HAVE_NO_MEMORY(state->transport); 328 328 … … 363 363 364 364 /* 365 called when name resolution is finished366 */367 static NTSTATUS connect_resolve(struct composite_context *c,368 struct smb_composite_connect *io)369 {370 struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);371 NTSTATUS status;372 const char *address;373 374 status = resolve_name_recv(state->creq, state, &address);375 NT_STATUS_NOT_OK_RETURN(status);376 377 state->creq = smbcli_sock_connect_send(state, address,378 io->in.dest_ports,379 io->in.dest_host,380 NULL, c->event_ctx,381 io->in.socket_options);382 NT_STATUS_HAVE_NO_MEMORY(state->creq);383 384 state->stage = CONNECT_SOCKET;385 state->creq->async.private_data = c;386 state->creq->async.fn = composite_handler;387 388 return NT_STATUS_OK;389 }390 391 392 /*393 365 handle and dispatch state transitions 394 366 */ … … 398 370 399 371 switch (state->stage) { 400 case CONNECT_RESOLVE:401 c->status = connect_resolve(c, state->io);402 break;403 372 case CONNECT_SOCKET: 404 373 c->status = connect_socket(c, state->io); … … 462 431 struct composite_context *c; 463 432 struct connect_state *state; 464 struct nbt_name name;465 433 466 434 c = talloc_zero(mem_ctx, struct composite_context); … … 479 447 c->private_data = state; 480 448 481 state->stage = CONNECT_RESOLVE; 482 make_nbt_name_server(&name, io->in.dest_host); 483 state->creq = resolve_name_send(resolve_ctx, state, &name, c->event_ctx); 484 449 state->creq = smbcli_sock_connect_send(state, 450 NULL, 451 io->in.dest_ports, 452 io->in.dest_host, 453 resolve_ctx, c->event_ctx, 454 io->in.socket_options); 485 455 if (state->creq == NULL) goto failed; 456 457 state->stage = CONNECT_SOCKET; 486 458 state->creq->async.private_data = c; 487 459 state->creq->async.fn = composite_handler; -
vendor/current/source4/libcli/smb_composite/fetchfile.c
r414 r740 147 147 state->connect->in.workgroup = io->in.workgroup; 148 148 state->connect->in.gensec_settings = io->in.gensec_settings; 149 state->connect->in.iconv_convenience = io->in.iconv_convenience;150 149 151 150 state->connect->in.options = io->in.options; -
vendor/current/source4/libcli/smb_composite/fsinfo.c
r414 r740 154 154 state->connect->in.fallback_to_anonymous = false; 155 155 state->connect->in.workgroup = io->in.workgroup; 156 state->connect->in.iconv_convenience = io->in.iconv_convenience;157 156 state->connect->in.gensec_settings = io->in.gensec_settings; 158 157 -
vendor/current/source4/libcli/smb_composite/smb_composite.h
r414 r740 61 61 struct smbcli_session_options session_options; 62 62 struct resolve_context *resolve_ctx; 63 struct smb_iconv_convenience *iconv_convenience;64 63 struct gensec_settings *gensec_settings; 65 64 } in; … … 105 104 struct smbcli_options options; 106 105 struct smbcli_session_options session_options; 107 struct smb_iconv_convenience *iconv_convenience;108 106 struct gensec_settings *gensec_settings; 109 107 } in; … … 146 144 const char *workgroup; 147 145 enum smb_fsinfo_level level; 148 struct smb_iconv_convenience *iconv_convenience;149 146 struct gensec_settings *gensec_settings; 150 147 } in; … … 182 179 const char **hostnames; 183 180 const char **addresses; 184 int *ports; /* Either NULL for lp _smb_ports() per181 int *ports; /* Either NULL for lpcfg_smb_ports() per 185 182 * destination or a list of explicit ports */ 186 183 } in; -
vendor/current/source4/libcli/util/clilsa.c
r414 r740 80 80 lsa->ipc_tree->tid = tcon.tconx.out.tid; 81 81 82 lsa->pipe = dcerpc_pipe_init(lsa, cli->transport->socket->event.ctx, 83 cli->transport->iconv_convenience); 82 lsa->pipe = dcerpc_pipe_init(lsa, cli->transport->socket->event.ctx); 84 83 if (lsa->pipe == NULL) { 85 84 talloc_free(lsa); … … 120 119 r.out.handle = &lsa->handle; 121 120 122 status = dcerpc_lsa_OpenPolicy(lsa->pipe, lsa, &r); 123 if (!NT_STATUS_IS_OK(status)) { 124 talloc_free(lsa); 125 return status; 121 status = dcerpc_lsa_OpenPolicy_r(lsa->pipe->binding_handle, lsa, &r); 122 if (!NT_STATUS_IS_OK(status)) { 123 talloc_free(lsa); 124 return status; 125 } 126 127 if (!NT_STATUS_IS_OK(r.out.result)) { 128 talloc_free(lsa); 129 return r.out.result; 126 130 } 127 131 … … 151 155 r.out.rights = rights; 152 156 153 return dcerpc_lsa_EnumAccountRights(cli->lsa->pipe, mem_ctx, &r); 157 status = dcerpc_lsa_EnumAccountRights_r(cli->lsa->pipe->binding_handle, mem_ctx, &r); 158 if (!NT_STATUS_IS_OK(status)) { 159 return status; 160 } 161 162 return r.out.result; 154 163 } 155 164 … … 235 244 r.out.domains = &domains; 236 245 237 status = dcerpc_lsa_LookupSids(cli->lsa->pipe, mem_ctx2, &r); 238 if (!NT_STATUS_IS_OK(status)) { 239 talloc_free(mem_ctx2); 240 return status; 246 status = dcerpc_lsa_LookupSids_r(cli->lsa->pipe->binding_handle, mem_ctx2, &r); 247 if (!NT_STATUS_IS_OK(status)) { 248 talloc_free(mem_ctx2); 249 return status; 250 } 251 if (!NT_STATUS_IS_OK(r.out.result)) { 252 talloc_free(mem_ctx2); 253 return r.out.result; 241 254 } 242 255 if (names.count != 1) { … … 292 305 r.out.domains = &domains; 293 306 294 status = dcerpc_lsa_LookupNames(cli->lsa->pipe, mem_ctx2, &r); 295 if (!NT_STATUS_IS_OK(status)) { 296 talloc_free(mem_ctx2); 297 return status; 307 status = dcerpc_lsa_LookupNames_r(cli->lsa->pipe->binding_handle, mem_ctx2, &r); 308 if (!NT_STATUS_IS_OK(status)) { 309 talloc_free(mem_ctx2); 310 return status; 311 } 312 if (!NT_STATUS_IS_OK(r.out.result)) { 313 talloc_free(mem_ctx2); 314 return r.out.result; 298 315 } 299 316 if (sids.count != 1) { … … 333 350 r.in.rights = rights; 334 351 335 return dcerpc_lsa_AddAccountRights(cli->lsa->pipe, mem_ctx, &r); 352 status = dcerpc_lsa_AddAccountRights_r(cli->lsa->pipe->binding_handle, mem_ctx, &r); 353 if (!NT_STATUS_IS_OK(status)) { 354 return status; 355 } 356 357 return r.out.result; 336 358 } 337 359 … … 356 378 r.in.rights = rights; 357 379 358 return dcerpc_lsa_RemoveAccountRights(cli->lsa->pipe, mem_ctx, &r); 359 } 380 status = dcerpc_lsa_RemoveAccountRights_r(cli->lsa->pipe->binding_handle, mem_ctx, &r); 381 if (!NT_STATUS_IS_OK(status)) { 382 return status; 383 } 384 385 return r.out.result; 386 } -
vendor/current/source4/libcli/util/errormap.c
r414 r740 21 21 22 22 #include "includes.h" 23 #include "librpc/ndr/libndr.h"24 23 25 24 /* This map was extracted by the ERRMAPEXTRACT smbtorture command. … … 180 179 */ 181 180 {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, 181 {ERRSRV, ERRbaduid, NT_STATUS_USER_SESSION_DELETED}, 182 182 {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, 183 183 {ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, … … 1322 1322 #endif 1323 1323 #ifdef EDQUOT 1324 { EDQUOT, NT_STATUS_ QUOTA_EXCEEDED },1324 { EDQUOT, NT_STATUS_DISK_FULL }, /* Windows does NOT return NT_STATUS_QUOTA_EXCEEDED */ 1325 1325 #endif 1326 1326 #ifdef ENOTEMPTY … … 1383 1383 } 1384 1384 1385 NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err) 1385 /* Convert a Unix error code to WERROR */ 1386 WERROR unix_to_werror(int unix_error) 1386 1387 { 1387 switch (ndr_err) { 1388 case NDR_ERR_SUCCESS: 1389 return NT_STATUS_OK; 1390 case NDR_ERR_BUFSIZE: 1391 return NT_STATUS_BUFFER_TOO_SMALL; 1392 case NDR_ERR_TOKEN: 1393 return NT_STATUS_INTERNAL_ERROR; 1394 case NDR_ERR_ALLOC: 1395 return NT_STATUS_NO_MEMORY; 1396 case NDR_ERR_ARRAY_SIZE: 1397 return NT_STATUS_ARRAY_BOUNDS_EXCEEDED; 1398 case NDR_ERR_INVALID_POINTER: 1399 return NT_STATUS_INVALID_PARAMETER_MIX; 1400 case NDR_ERR_UNREAD_BYTES: 1401 return NT_STATUS_PORT_MESSAGE_TOO_LONG; 1402 default: 1403 break; 1404 } 1405 1406 /* we should map all error codes to different status codes */ 1407 return NT_STATUS_INVALID_PARAMETER; 1388 return ntstatus_to_werror(map_nt_error_from_unix(unix_error)); 1408 1389 } -
vendor/current/source4/libcli/util/nterr.c
r414 r740 1 /* 1 /* 2 2 * Unix SMB/CIFS implementation. 3 3 * RPC Pipe client / server routines 4 4 * Copyright (C) Luke Kenneth Casson Leighton 1997-2001. 5 * 5 * 6 6 * This program is free software; you can redistribute it and/or modify 7 7 * it under the terms of the GNU General Public License as published by 8 8 * the Free Software Foundation; either version 3 of the License, or 9 9 * (at your option) any later version. 10 * 10 * 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 * 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, see <http://www.gnu.org/licenses/>. … … 23 23 #include "../libcli/ldap/ldap_errors.h" 24 24 #undef strcasecmp 25 26 #if !defined(N_) 27 #define N_(string) string 28 #endif 25 29 26 30 typedef struct … … 544 548 { "NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE }, 545 549 { "NT_STATUS_DS_NO_MORE_RIDS", NT_STATUS_DS_NO_MORE_RIDS }, 546 { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES }, 550 { "NT_STATUS_NOT_A_REPARSE_POINT", NT_STATUS_NOT_A_REPARSE_POINT }, 551 { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES }, 547 552 { "NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED", NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED }, 548 553 { "NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX", NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX }, 554 { "NT_STATUS_RPC_UNKNOWN_IF", NT_STATUS_RPC_UNKNOWN_IF }, 555 { "NT_STATUS_RPC_CALL_FAILED", NT_STATUS_RPC_CALL_FAILED }, 556 { "NT_STATUS_RPC_PROTOCOL_ERROR", NT_STATUS_RPC_PROTOCOL_ERROR }, 557 { "NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE", NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE }, 558 { "NT_STATUS_RPC_CANNOT_SUPPORT", NT_STATUS_RPC_CANNOT_SUPPORT }, 559 { "NT_STATUS_RPC_SEC_PKG_ERROR", NT_STATUS_RPC_SEC_PKG_ERROR }, 560 { "NT_STATUS_RPC_SS_CONTEXT_MISMATCH", NT_STATUS_RPC_SS_CONTEXT_MISMATCH }, 561 { "NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE", NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE }, 562 { "NT_STATUS_RPC_BAD_STUB_DATA", NT_STATUS_RPC_BAD_STUB_DATA }, 563 { "NT_STATUS_RPC_INVALID_PIPE_OBJECT", NT_STATUS_RPC_INVALID_PIPE_OBJECT }, 564 { "NT_STATUS_RPC_INVALID_PIPE_OPERATION", NT_STATUS_RPC_INVALID_PIPE_OPERATION }, 565 { "NT_STATUS_RPC_WRONG_PIPE_VERSION", NT_STATUS_RPC_WRONG_PIPE_VERSION }, 566 { "NT_STATUS_RPC_PIPE_CLOSED", NT_STATUS_RPC_PIPE_CLOSED }, 567 { "NT_STATUS_RPC_PIPE_DISCIPLINE_ERROR", NT_STATUS_RPC_PIPE_DISCIPLINE_ERROR }, 568 { "NT_STATUS_RPC_PIPE_EMPTY", NT_STATUS_RPC_PIPE_EMPTY }, 549 569 { "NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED", NT_STATUS_CURRENT_DOMAIN_NOT_ALLOWED }, 550 570 { "NT_STATUS_OBJECTID_NOT_FOUND", NT_STATUS_OBJECTID_NOT_FOUND }, 551 571 { "NT_STATUS_DOWNGRADE_DETECTED", NT_STATUS_DOWNGRADE_DETECTED }, 572 { "NT_STATUS_NO_S4U_PROT_SUPPORT", NT_STATUS_NO_S4U_PROT_SUPPORT }, 573 { "NT_STATUS_CROSSREALM_DELEGATION_FAILURE", NT_STATUS_CROSSREALM_DELEGATION_FAILURE }, 552 574 { "NT_STATUS_INVALID_LOCK_RANGE", NT_STATUS_INVALID_LOCK_RANGE }, 553 575 { "NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS", NT_STATUS_ERROR_DS_OBJ_STRING_NAME_EXISTS }, … … 722 744 }; 723 745 746 /* These need sorting..... */ 747 724 748 static const nt_err_code_struct nt_err_desc[] = 725 749 { 726 { "Success", NT_STATUS_OK }, 727 { "Undetermined error", NT_STATUS_UNSUCCESSFUL }, 728 { "Access denied", NT_STATUS_ACCESS_DENIED }, 729 { "Account locked out", NT_STATUS_ACCOUNT_LOCKED_OUT }, 730 { "Must change password", NT_STATUS_PASSWORD_MUST_CHANGE }, 731 { "Password is too short", NT_STATUS_PWD_TOO_SHORT }, 732 { "Password is too recent", NT_STATUS_PWD_TOO_RECENT }, 733 { "Password history conflict", NT_STATUS_PWD_HISTORY_CONFLICT }, 734 { "No logon servers", NT_STATUS_NO_LOGON_SERVERS }, 735 { "Improperly formed account name", NT_STATUS_INVALID_ACCOUNT_NAME }, 736 { "User exists", NT_STATUS_USER_EXISTS }, 737 { "No such user", NT_STATUS_NO_SUCH_USER }, 738 { "Group exists", NT_STATUS_GROUP_EXISTS }, 739 { "No such group", NT_STATUS_NO_SUCH_GROUP }, 740 { "Member not in group", NT_STATUS_MEMBER_NOT_IN_GROUP }, 741 { "Wrong Password", NT_STATUS_WRONG_PASSWORD }, 742 { "Ill formed password", NT_STATUS_ILL_FORMED_PASSWORD }, 743 { "Password restriction", NT_STATUS_PASSWORD_RESTRICTION }, 744 { "Logon failure", NT_STATUS_LOGON_FAILURE }, 745 { "Account restriction", NT_STATUS_ACCOUNT_RESTRICTION }, 746 { "Invalid logon hours", NT_STATUS_INVALID_LOGON_HOURS }, 747 { "Invalid workstation", NT_STATUS_INVALID_WORKSTATION }, 748 { "Password expired", NT_STATUS_PASSWORD_EXPIRED }, 749 { "Account disabled", NT_STATUS_ACCOUNT_DISABLED }, 750 { "Unexpected information received", NT_STATUS_INVALID_PARAMETER }, 751 { "Memory allocation error", NT_STATUS_NO_MEMORY }, 752 { "No domain controllers located", NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND }, 753 { "Account locked out", NT_STATUS_ACCOUNT_LOCKED_OUT }, 754 { "Named pipe not available", NT_STATUS_PIPE_NOT_AVAILABLE }, 755 { "Not implemented", NT_STATUS_NOT_IMPLEMENTED }, 756 { "Invalid information class", NT_STATUS_INVALID_INFO_CLASS }, 757 { "Information length mismatch", NT_STATUS_INFO_LENGTH_MISMATCH }, 758 { "Access violation", NT_STATUS_ACCESS_VIOLATION }, 759 { "Invalid handle", NT_STATUS_INVALID_HANDLE }, 760 { "Invalid parameter", NT_STATUS_INVALID_PARAMETER }, 761 { "No memory", NT_STATUS_NO_MEMORY }, 762 { "Buffer too small", NT_STATUS_BUFFER_TOO_SMALL }, 763 { "Revision mismatch", NT_STATUS_REVISION_MISMATCH }, 764 { "No logon servers", NT_STATUS_NO_LOGON_SERVERS }, 765 { "No such logon session", NT_STATUS_NO_SUCH_LOGON_SESSION }, 766 { "No such privilege", NT_STATUS_NO_SUCH_PRIVILEGE }, 767 { "Procedure not found", NT_STATUS_PROCEDURE_NOT_FOUND }, 768 { "Server disabled", NT_STATUS_SERVER_DISABLED }, 769 { "Invalid pipe state", NT_STATUS_INVALID_PIPE_STATE }, 770 { "Named pipe busy", NT_STATUS_PIPE_BUSY }, 771 { "Illegal function", NT_STATUS_ILLEGAL_FUNCTION }, 772 { "Named pipe dicconnected", NT_STATUS_PIPE_DISCONNECTED }, 773 { "Named pipe closing", NT_STATUS_PIPE_CLOSING }, 774 { "Remote host not listening", NT_STATUS_REMOTE_NOT_LISTENING }, 775 { "Duplicate name on network", NT_STATUS_DUPLICATE_NAME }, 776 { "Print queue is full", NT_STATUS_PRINT_QUEUE_FULL }, 777 { "No print spool space available", NT_STATUS_NO_SPOOL_SPACE }, 778 { "Too many names", NT_STATUS_TOO_MANY_NAMES }, 779 { "Too many sessions", NT_STATUS_TOO_MANY_SESSIONS }, 780 { "Invalid server state", NT_STATUS_INVALID_SERVER_STATE }, 781 { "Invalid domain state", NT_STATUS_INVALID_DOMAIN_STATE }, 782 { "Invalid domain role", NT_STATUS_INVALID_DOMAIN_ROLE }, 783 { "No such domain", NT_STATUS_NO_SUCH_DOMAIN }, 784 { "Domain exists", NT_STATUS_DOMAIN_EXISTS }, 785 { "Domain limit exceeded", NT_STATUS_DOMAIN_LIMIT_EXCEEDED }, 786 { "Bad logon session state", NT_STATUS_BAD_LOGON_SESSION_STATE }, 787 { "Logon session collision", NT_STATUS_LOGON_SESSION_COLLISION }, 788 { "Invalid logon type", NT_STATUS_INVALID_LOGON_TYPE }, 789 { "Cancelled", NT_STATUS_CANCELLED }, 790 { "Invalid computer name", NT_STATUS_INVALID_COMPUTER_NAME }, 791 { "Logon server conflict", NT_STATUS_LOGON_SERVER_CONFLICT }, 792 { "Time difference at domain controller", NT_STATUS_TIME_DIFFERENCE_AT_DC }, 793 { "Pipe broken", NT_STATUS_PIPE_BROKEN }, 794 { "Registry corrupt", NT_STATUS_REGISTRY_CORRUPT }, 795 { "Too many secrets", NT_STATUS_TOO_MANY_SECRETS }, 796 { "Too many SIDs", NT_STATUS_TOO_MANY_SIDS }, 797 { "Lanmanager cross encryption required", NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED }, 798 { "Log file full", NT_STATUS_LOG_FILE_FULL }, 799 { "No trusted LSA secret", NT_STATUS_NO_TRUST_LSA_SECRET }, 800 { "No trusted SAM account", NT_STATUS_NO_TRUST_SAM_ACCOUNT }, 801 { "Trusted domain failure", NT_STATUS_TRUSTED_DOMAIN_FAILURE }, 802 { "Trust relationship failure", NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE }, 803 { "Trust failure", NT_STATUS_TRUST_FAILURE }, 804 { "Netlogon service not started", NT_STATUS_NETLOGON_NOT_STARTED }, 805 { "Account expired", NT_STATUS_ACCOUNT_EXPIRED }, 806 { "Network credential conflict", NT_STATUS_NETWORK_CREDENTIAL_CONFLICT }, 807 { "Remote session limit", NT_STATUS_REMOTE_SESSION_LIMIT }, 808 { "No logon interdomain trust account", NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT }, 809 { "No logon workstation trust account", NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT }, 810 { "No logon server trust account", NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT }, 811 { "Domain trust inconsistent", NT_STATUS_DOMAIN_TRUST_INCONSISTENT }, 812 { "No user session key available", NT_STATUS_NO_USER_SESSION_KEY }, 813 { "User session deleted", NT_STATUS_USER_SESSION_DELETED }, 814 { "Insufficient server resources", NT_STATUS_INSUFF_SERVER_RESOURCES }, 815 { "Insufficient logon information", NT_STATUS_INSUFFICIENT_LOGON_INFO }, 816 817 { "License quota exceeded", NT_STATUS_LICENSE_QUOTA_EXCEEDED }, 750 { N_("Success"), NT_STATUS_OK }, 751 { N_("Undetermined error"), NT_STATUS_UNSUCCESSFUL }, 752 { N_("Access denied"), NT_STATUS_ACCESS_DENIED }, 753 { N_("Account locked out"), NT_STATUS_ACCOUNT_LOCKED_OUT }, 754 { N_("Must change password"), NT_STATUS_PASSWORD_MUST_CHANGE }, 755 { N_("Password is too short"), NT_STATUS_PWD_TOO_SHORT }, 756 { N_("Password is too recent"), NT_STATUS_PWD_TOO_RECENT }, 757 { N_("Password history conflict"), NT_STATUS_PWD_HISTORY_CONFLICT }, 758 { N_("No logon servers"), NT_STATUS_NO_LOGON_SERVERS }, 759 { N_("Improperly formed account name"), NT_STATUS_INVALID_ACCOUNT_NAME }, 760 { N_("User exists"), NT_STATUS_USER_EXISTS }, 761 { N_("No such user"), NT_STATUS_NO_SUCH_USER }, 762 { N_("Group exists"), NT_STATUS_GROUP_EXISTS }, 763 { N_("No such group"), NT_STATUS_NO_SUCH_GROUP }, 764 { N_("Member not in group"), NT_STATUS_MEMBER_NOT_IN_GROUP }, 765 { N_("Wrong Password"), NT_STATUS_WRONG_PASSWORD }, 766 { N_("Ill formed password"), NT_STATUS_ILL_FORMED_PASSWORD }, 767 { N_("Password restriction"), NT_STATUS_PASSWORD_RESTRICTION }, 768 { N_("Logon failure"), NT_STATUS_LOGON_FAILURE }, 769 { N_("Account restriction"), NT_STATUS_ACCOUNT_RESTRICTION }, 770 { N_("Invalid logon hours"), NT_STATUS_INVALID_LOGON_HOURS }, 771 { N_("Invalid workstation"), NT_STATUS_INVALID_WORKSTATION }, 772 { N_("Password expired"), NT_STATUS_PASSWORD_EXPIRED }, 773 { N_("Account disabled"), NT_STATUS_ACCOUNT_DISABLED }, 774 { N_("Unexpected information received"), NT_STATUS_INVALID_PARAMETER }, 775 { N_("Memory allocation error"), NT_STATUS_NO_MEMORY }, 776 { N_("No domain controllers located"), NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND }, 777 { N_("Account locked out"), NT_STATUS_ACCOUNT_LOCKED_OUT }, 778 { N_("Named pipe not available"), NT_STATUS_PIPE_NOT_AVAILABLE }, 779 { N_("Not implemented"), NT_STATUS_NOT_IMPLEMENTED }, 780 { N_("Invalid information class"), NT_STATUS_INVALID_INFO_CLASS }, 781 { N_("Information length mismatch"), NT_STATUS_INFO_LENGTH_MISMATCH }, 782 { N_("Access violation"), NT_STATUS_ACCESS_VIOLATION }, 783 { N_("Invalid handle"), NT_STATUS_INVALID_HANDLE }, 784 { N_("Invalid parameter"), NT_STATUS_INVALID_PARAMETER }, 785 { N_("No memory"), NT_STATUS_NO_MEMORY }, 786 { N_("Buffer too small"), NT_STATUS_BUFFER_TOO_SMALL }, 787 { N_("Revision mismatch"), NT_STATUS_REVISION_MISMATCH }, 788 { N_("No logon servers"), NT_STATUS_NO_LOGON_SERVERS }, 789 { N_("No such logon session"), NT_STATUS_NO_SUCH_LOGON_SESSION }, 790 { N_("No such privilege"), NT_STATUS_NO_SUCH_PRIVILEGE }, 791 { N_("Procedure not found"), NT_STATUS_PROCEDURE_NOT_FOUND }, 792 { N_("Server disabled"), NT_STATUS_SERVER_DISABLED }, 793 { N_("Invalid pipe state"), NT_STATUS_INVALID_PIPE_STATE }, 794 { N_("Named pipe busy"), NT_STATUS_PIPE_BUSY }, 795 { N_("Illegal function"), NT_STATUS_ILLEGAL_FUNCTION }, 796 { N_("Named pipe disconnected"), NT_STATUS_PIPE_DISCONNECTED }, 797 { N_("Named pipe closing"), NT_STATUS_PIPE_CLOSING }, 798 { N_("Remote host not listening"), NT_STATUS_REMOTE_NOT_LISTENING }, 799 { N_("Duplicate name on network"), NT_STATUS_DUPLICATE_NAME }, 800 { N_("Print queue is full"), NT_STATUS_PRINT_QUEUE_FULL }, 801 { N_("No print spool space available"), NT_STATUS_NO_SPOOL_SPACE }, 802 { N_("The network name cannot be found"), NT_STATUS_BAD_NETWORK_NAME }, 803 { N_("The connection was refused"), NT_STATUS_CONNECTION_REFUSED }, 804 { N_("Too many names"), NT_STATUS_TOO_MANY_NAMES }, 805 { N_("Too many sessions"), NT_STATUS_TOO_MANY_SESSIONS }, 806 { N_("Invalid server state"), NT_STATUS_INVALID_SERVER_STATE }, 807 { N_("Invalid domain state"), NT_STATUS_INVALID_DOMAIN_STATE }, 808 { N_("Invalid domain role"), NT_STATUS_INVALID_DOMAIN_ROLE }, 809 { N_("No such domain"), NT_STATUS_NO_SUCH_DOMAIN }, 810 { N_("Domain exists"), NT_STATUS_DOMAIN_EXISTS }, 811 { N_("Domain limit exceeded"), NT_STATUS_DOMAIN_LIMIT_EXCEEDED }, 812 { N_("Bad logon session state"), NT_STATUS_BAD_LOGON_SESSION_STATE }, 813 { N_("Logon session collision"), NT_STATUS_LOGON_SESSION_COLLISION }, 814 { N_("Invalid logon type"), NT_STATUS_INVALID_LOGON_TYPE }, 815 { N_("Cancelled"), NT_STATUS_CANCELLED }, 816 { N_("Invalid computer name"), NT_STATUS_INVALID_COMPUTER_NAME }, 817 { N_("Logon server conflict"), NT_STATUS_LOGON_SERVER_CONFLICT }, 818 { N_("Time difference at domain controller"), NT_STATUS_TIME_DIFFERENCE_AT_DC }, 819 { N_("Pipe broken"), NT_STATUS_PIPE_BROKEN }, 820 { N_("Registry corrupt"), NT_STATUS_REGISTRY_CORRUPT }, 821 { N_("Too many secrets"), NT_STATUS_TOO_MANY_SECRETS }, 822 { N_("Too many SIDs"), NT_STATUS_TOO_MANY_SIDS }, 823 { N_("Lanmanager cross encryption required"), NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED }, 824 { N_("Log file full"), NT_STATUS_LOG_FILE_FULL }, 825 { N_("No trusted LSA secret"), NT_STATUS_NO_TRUST_LSA_SECRET }, 826 { N_("No trusted SAM account"), NT_STATUS_NO_TRUST_SAM_ACCOUNT }, 827 { N_("Trusted domain failure"), NT_STATUS_TRUSTED_DOMAIN_FAILURE }, 828 { N_("Trust relationship failure"), NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE }, 829 { N_("Trust failure"), NT_STATUS_TRUST_FAILURE }, 830 { N_("Netlogon service not started"), NT_STATUS_NETLOGON_NOT_STARTED }, 831 { N_("Account expired"), NT_STATUS_ACCOUNT_EXPIRED }, 832 { N_("Network credential conflict"), NT_STATUS_NETWORK_CREDENTIAL_CONFLICT }, 833 { N_("Remote session limit"), NT_STATUS_REMOTE_SESSION_LIMIT }, 834 { N_("No logon interdomain trust account"), NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT }, 835 { N_("No logon workstation trust account"), NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT }, 836 { N_("No logon server trust account"), NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT }, 837 { N_("Domain trust inconsistent"), NT_STATUS_DOMAIN_TRUST_INCONSISTENT }, 838 { N_("No user session key available"), NT_STATUS_NO_USER_SESSION_KEY }, 839 { N_("User session deleted"), NT_STATUS_USER_SESSION_DELETED }, 840 { N_("Insufficient server resources"), NT_STATUS_INSUFF_SERVER_RESOURCES }, 841 { N_("Insufficient logon information"), NT_STATUS_INSUFFICIENT_LOGON_INFO }, 842 843 { N_("License quota exceeded"), NT_STATUS_LICENSE_QUOTA_EXCEEDED }, 844 { N_("No more files"), STATUS_NO_MORE_FILES }, 818 845 819 846 { NULL, NT_STATUS(0) } … … 821 848 822 849 /***************************************************************************** 823 returns an NT error message. not amazingly helpful, but better than a number.850 Returns an NT error message. not amazingly helpful, but better than a number. 824 851 *****************************************************************************/ 852 825 853 const char *nt_errstr(NTSTATUS nt_code) 826 854 { 827 828 855 static char msg[40]; 856 int idx = 0; 829 857 830 858 while (nt_errs[idx].nt_errstr != NULL) { 831 if (NT_STATUS_V(nt_errs[idx].nt_errcode) == 832 833 859 if (NT_STATUS_V(nt_errs[idx].nt_errcode) == 860 NT_STATUS_V(nt_code)) { 861 return nt_errs[idx].nt_errstr; 834 862 } 835 863 idx++; … … 843 871 slprintf(msg, sizeof(msg), "NT code 0x%08x", NT_STATUS_V(nt_code)); 844 872 845 873 return msg; 846 874 } 847 875 … … 849 877 Print friendler version fo NT error code 850 878 ***********************************************************************/ 879 851 880 const char *get_friendly_nt_error_msg(NTSTATUS nt_code) 852 881 { 853 882 int idx = 0; 854 883 855 884 while (nt_err_desc[idx].nt_errstr != NULL) { 856 885 if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) { 857 886 return nt_err_desc[idx].nt_errstr; 858 887 } 859 888 idx++; 860 889 } 861 890 862 891 /* fall back to NT_STATUS_XXX string */ 892 863 893 return nt_errstr(nt_code); 864 894 } 865 895 866 896 /***************************************************************************** 867 returns an NT_STATUS constant as a string for inclusion in autogen C code897 Returns an NT_STATUS constant as a string for inclusion in autogen C code. 868 898 *****************************************************************************/ 899 869 900 const char *get_nt_error_c_code(NTSTATUS nt_code) 870 901 { 871 872 902 static char out[40]; 903 int idx = 0; 873 904 874 905 while (nt_errs[idx].nt_errstr != NULL) { 875 if (NT_STATUS_V(nt_errs[idx].nt_errcode) == 876 877 906 if (NT_STATUS_V(nt_errs[idx].nt_errcode) == 907 NT_STATUS_V(nt_code)) { 908 return nt_errs[idx].nt_errstr; 878 909 } 879 910 idx++; … … 882 913 slprintf(out, sizeof(out), "NT_STATUS(0x%08x)", NT_STATUS_V(nt_code)); 883 914 884 915 return out; 885 916 } 886 917 887 918 /***************************************************************************** 888 returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)919 Returns the NT_STATUS constant matching the string supplied (as an NTSTATUS) 889 920 *****************************************************************************/ 921 890 922 NTSTATUS nt_status_string_to_code(const char *nt_status_str) 891 923 { 892 924 int idx = 0; 893 925 894 926 while (nt_errs[idx].nt_errstr != NULL) { 895 927 if (strcasecmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) { 896 928 return nt_errs[idx].nt_errcode; 897 929 } 898 930 idx++; … … 900 932 return NT_STATUS_UNSUCCESSFUL; 901 933 } 934 935 /** 936 * Squash an NT_STATUS in line with security requirements. 937 * In an attempt to avoid giving the whole game away when users 938 * are authenticating, NT replaces both NT_STATUS_NO_SUCH_USER and 939 * NT_STATUS_WRONG_PASSWORD with NT_STATUS_LOGON_FAILURE in certain situations 940 * (session setups in particular). 941 * 942 * @param nt_status NTSTATUS input for squashing. 943 * @return the 'squashed' nt_status 944 **/ 945 946 NTSTATUS nt_status_squash(NTSTATUS nt_status) 947 { 948 if NT_STATUS_IS_OK(nt_status) { 949 return nt_status; 950 } else if NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER) { 951 /* Match WinXP and don't give the game away */ 952 return NT_STATUS_LOGON_FAILURE; 953 954 } else if NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD) { 955 /* Match WinXP and don't give the game away */ 956 return NT_STATUS_LOGON_FAILURE; 957 } else { 958 return nt_status; 959 } 960 } -
vendor/current/source4/libcli/util/pyerrors.h
r414 r740 25 25 #define PyErr_FromNTSTATUS(status) Py_BuildValue("(i,s)", NT_STATUS_V(status), discard_const_p(char, get_friendly_nt_error_msg(status))) 26 26 27 #define PyErr_FromString(str) Py_BuildValue("(s)", discard_const_p(char, str)) 28 27 29 #define PyErr_SetWERROR(err) \ 28 30 PyErr_SetObject(PyExc_RuntimeError, PyErr_FromWERROR(err)) -
vendor/current/source4/libcli/wbclient/wbclient.c
r414 r740 21 21 22 22 #include "includes.h" 23 #include <tevent.h> 23 24 #include "libcli/wbclient/wbclient.h" 24 25 /**26 * Get the server_id of the winbind task.27 *28 * \param[in] msg_ctx message context to use29 * \param[in] mem_ctx talloc context to use30 * \param[out] ids array of server_id structs containing the winbind id31 * \return NT_STATUS_OK on success, NT_STATUS_INTERNAL_ERROR on failure32 */33 static NTSTATUS get_server_id(struct messaging_context *msg_ctx,34 TALLOC_CTX *mem_ctx, struct server_id **ids)35 {36 *ids = irpc_servers_byname(msg_ctx, mem_ctx, "winbind_server");37 if (*ids == NULL || (*ids)[0].id == 0) {38 DEBUG(0, ("Geting the winbind server ID failed.\n"));39 return NT_STATUS_INTERNAL_ERROR;40 }41 return NT_STATUS_OK;42 }43 25 44 26 /** … … 54 36 { 55 37 struct wbc_context *ctx; 56 NTSTATUS status;57 38 58 39 ctx = talloc(mem_ctx, struct wbc_context); 59 40 if (ctx == NULL) return NULL; 60 41 61 status = get_server_id(msg_ctx, mem_ctx, &ctx->ids); 62 if (!NT_STATUS_IS_OK(status)) { 42 ctx->event_ctx = event_ctx; 43 44 ctx->irpc_handle = irpc_binding_handle_by_name(ctx, msg_ctx, 45 "winbind_server", 46 &ndr_table_winbind); 47 if (ctx->irpc_handle == NULL) { 63 48 talloc_free(ctx); 64 49 return NULL; 65 50 } 66 67 ctx->msg_ctx = msg_ctx;68 ctx->event_ctx = event_ctx;69 51 70 52 return ctx; … … 74 56 struct composite_context *ctx; 75 57 struct winbind_get_idmap *req; 76 struct irpc_request *irpc_req; 77 struct id_mapping *ids; 58 struct id_map *ids; 78 59 }; 79 60 80 static void sids_to_xids_recv_ids(struct irpc_request *req);61 static void sids_to_xids_recv_ids(struct tevent_req *subreq); 81 62 82 63 struct composite_context *wbc_sids_to_xids_send(struct wbc_context *wbc_ctx, 83 64 TALLOC_CTX *mem_ctx, 84 65 uint32_t count, 85 struct id_map ping*ids)66 struct id_map *ids) 86 67 { 87 68 struct composite_context *ctx; 88 69 struct wbc_idmap_state *state; 70 struct tevent_req *subreq; 89 71 90 72 DEBUG(5, ("wbc_sids_to_xids called\n")); … … 105 87 state->ctx = ctx; 106 88 107 state->irpc_req = IRPC_CALL_SEND(wbc_ctx->msg_ctx, wbc_ctx->ids[0], 108 winbind, WINBIND_GET_IDMAP, state->req, 109 state); 110 if (composite_nomem(state->irpc_req, ctx)) return ctx; 89 subreq = dcerpc_winbind_get_idmap_r_send(state, 90 wbc_ctx->event_ctx, 91 wbc_ctx->irpc_handle, 92 state->req); 93 if (composite_nomem(subreq, ctx)) return ctx; 111 94 112 composite_continue_irpc(ctx, state->irpc_req, sids_to_xids_recv_ids,113 state); 95 tevent_req_set_callback(subreq, sids_to_xids_recv_ids, state); 96 114 97 return ctx; 115 98 } 116 99 117 static void sids_to_xids_recv_ids(struct irpc_request *req)100 static void sids_to_xids_recv_ids(struct tevent_req *subreq) 118 101 { 119 struct wbc_idmap_state *state = talloc_get_type_abort(120 req->async.private_data,121 102 struct wbc_idmap_state *state = 103 tevent_req_callback_data(subreq, 104 struct wbc_idmap_state); 122 105 123 state->ctx->status = irpc_call_recv(state->irpc_req); 106 state->ctx->status = dcerpc_winbind_get_idmap_r_recv(subreq, state); 107 TALLOC_FREE(subreq); 124 108 if (!composite_is_ok(state->ctx)) return; 125 109 … … 129 113 130 114 NTSTATUS wbc_sids_to_xids_recv(struct composite_context *ctx, 131 struct id_map ping**ids)115 struct id_map **ids) 132 116 { 133 117 NTSTATUS status = composite_wait(ctx); … … 143 127 } 144 128 145 static void xids_to_sids_recv_ids(struct irpc_request *req);129 static void xids_to_sids_recv_ids(struct tevent_req *subreq); 146 130 147 131 struct composite_context *wbc_xids_to_sids_send(struct wbc_context *wbc_ctx, 148 132 TALLOC_CTX *mem_ctx, 149 133 uint32_t count, 150 struct id_map ping*ids)134 struct id_map *ids) 151 135 { 152 136 struct composite_context *ctx; 153 137 struct wbc_idmap_state *state; 138 struct tevent_req *subreq; 154 139 155 140 DEBUG(5, ("wbc_xids_to_sids called\n")); … … 170 155 state->ctx = ctx; 171 156 172 state->irpc_req = IRPC_CALL_SEND(wbc_ctx->msg_ctx, wbc_ctx->ids[0], 173 winbind, WINBIND_GET_IDMAP, state->req, 174 state); 175 if (composite_nomem(state->irpc_req, ctx)) return ctx; 157 subreq = dcerpc_winbind_get_idmap_r_send(state, 158 wbc_ctx->event_ctx, 159 wbc_ctx->irpc_handle, 160 state->req); 161 if (composite_nomem(subreq, ctx)) return ctx; 176 162 177 composite_continue_irpc(ctx, state->irpc_req, xids_to_sids_recv_ids, 178 state); 163 tevent_req_set_callback(subreq, xids_to_sids_recv_ids, state); 179 164 180 165 return ctx; 181 166 } 182 167 183 static void xids_to_sids_recv_ids(struct irpc_request *req)168 static void xids_to_sids_recv_ids(struct tevent_req *subreq) 184 169 { 185 struct wbc_idmap_state *state = talloc_get_type_abort(186 req->async.private_data,187 170 struct wbc_idmap_state *state = 171 tevent_req_callback_data(subreq, 172 struct wbc_idmap_state); 188 173 189 state->ctx->status = irpc_call_recv(state->irpc_req); 174 state->ctx->status = dcerpc_winbind_get_idmap_r_recv(subreq, state); 175 TALLOC_FREE(subreq); 190 176 if (!composite_is_ok(state->ctx)) return; 191 177 … … 195 181 196 182 NTSTATUS wbc_xids_to_sids_recv(struct composite_context *ctx, 197 struct id_map ping**ids)183 struct id_map **ids) 198 184 { 199 185 NTSTATUS status = composite_wait(ctx); -
vendor/current/source4/libcli/wbclient/wbclient.h
r414 r740 21 21 #include "lib/messaging/irpc.h" 22 22 #include "libcli/composite/composite.h" 23 #include "librpc/gen_ndr/ndr_winbind .h"23 #include "librpc/gen_ndr/ndr_winbind_c.h" 24 24 25 25 struct wbc_context { 26 struct messaging_context *msg_ctx;27 26 struct tevent_context *event_ctx; 28 struct server_id *ids;27 struct dcerpc_binding_handle *irpc_handle; 29 28 }; 30 29 … … 36 35 TALLOC_CTX *mem_ctx, 37 36 uint32_t count, 38 struct id_map ping*ids);37 struct id_map *ids); 39 38 40 39 NTSTATUS wbc_sids_to_xids_recv(struct composite_context *ctx, 41 struct id_map ping**ids);40 struct id_map **ids); 42 41 43 42 struct composite_context *wbc_xids_to_sids_send(struct wbc_context *wbc_ctx, 44 43 TALLOC_CTX *mem_ctx, 45 44 uint32_t count, 46 struct id_map ping*ids);45 struct id_map *ids); 47 46 48 47 NTSTATUS wbc_xids_to_sids_recv(struct composite_context *ctx, 49 struct id_map ping**ids);48 struct id_map **ids); 50 49 -
vendor/current/source4/libcli/wrepl/winsrepl.c
r414 r740 5 5 6 6 Copyright (C) Andrew Tridgell 2005 7 Copyright (C) Stefan Metzmacher 2005-2010 7 8 8 9 This program is free software; you can redistribute it and/or modify … … 23 24 #include "lib/events/events.h" 24 25 #include "../lib/util/dlinklist.h" 25 #include "lib/socket/socket.h"26 26 #include "libcli/wrepl/winsrepl.h" 27 27 #include "librpc/gen_ndr/ndr_winsrepl.h" 28 28 #include "lib/stream/packet.h" 29 #include "libcli/composite/composite.h"30 29 #include "system/network.h" 31 30 #include "lib/socket/netif.h" 32 31 #include "param/param.h" 33 34 static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, NTSTATUS status); 35 36 /* 37 mark all pending requests as dead - called when a socket error happens 38 */ 39 static void wrepl_socket_dead(struct wrepl_socket *wrepl_socket, NTSTATUS status) 40 { 41 wrepl_socket->dead = true; 42 43 if (wrepl_socket->packet) { 44 packet_recv_disable(wrepl_socket->packet); 45 packet_set_fde(wrepl_socket->packet, NULL); 46 packet_set_socket(wrepl_socket->packet, NULL); 47 } 48 49 if (wrepl_socket->event.fde) { 50 talloc_free(wrepl_socket->event.fde); 51 wrepl_socket->event.fde = NULL; 52 } 53 54 if (wrepl_socket->sock) { 55 talloc_free(wrepl_socket->sock); 56 wrepl_socket->sock = NULL; 57 } 58 59 if (NT_STATUS_EQUAL(NT_STATUS_UNSUCCESSFUL, status)) { 60 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; 61 } 62 while (wrepl_socket->recv_queue) { 63 struct wrepl_request *req = wrepl_socket->recv_queue; 64 DLIST_REMOVE(wrepl_socket->recv_queue, req); 65 wrepl_request_finished(req, status); 66 } 67 68 talloc_set_destructor(wrepl_socket, NULL); 69 if (wrepl_socket->free_skipped) { 70 talloc_free(wrepl_socket); 71 } 72 } 73 74 static void wrepl_request_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, 75 struct timeval t, void *ptr) 76 { 77 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request); 78 wrepl_socket_dead(req->wrepl_socket, NT_STATUS_IO_TIMEOUT); 79 } 80 81 /* 82 handle recv events 83 */ 84 static NTSTATUS wrepl_finish_recv(void *private_data, DATA_BLOB packet_blob_in) 85 { 86 struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, struct wrepl_socket); 87 struct wrepl_request *req = wrepl_socket->recv_queue; 88 DATA_BLOB blob; 89 enum ndr_err_code ndr_err; 90 91 if (!req) { 92 DEBUG(1,("Received unexpected WINS packet of length %u!\n", 93 (unsigned)packet_blob_in.length)); 94 return NT_STATUS_INVALID_NETWORK_RESPONSE; 95 } 96 97 req->packet = talloc(req, struct wrepl_packet); 98 NT_STATUS_HAVE_NO_MEMORY(req->packet); 99 100 blob.data = packet_blob_in.data + 4; 101 blob.length = packet_blob_in.length - 4; 102 103 /* we have a full request - parse it */ 104 ndr_err = ndr_pull_struct_blob(&blob, req->packet, wrepl_socket->iconv_convenience, req->packet, 105 (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet); 106 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 107 NTSTATUS status = ndr_map_error2ntstatus(ndr_err); 108 wrepl_request_finished(req, status); 109 return NT_STATUS_OK; 110 } 111 112 if (DEBUGLVL(10)) { 113 DEBUG(10,("Received WINS packet of length %u\n", 114 (unsigned)packet_blob_in.length)); 115 NDR_PRINT_DEBUG(wrepl_packet, req->packet); 116 } 117 118 wrepl_request_finished(req, NT_STATUS_OK); 119 return NT_STATUS_OK; 120 } 121 122 /* 123 handler for winrepl events 124 */ 125 static void wrepl_handler(struct tevent_context *ev, struct tevent_fd *fde, 126 uint16_t flags, void *private_data) 127 { 128 struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, 129 struct wrepl_socket); 130 if (flags & EVENT_FD_READ) { 131 packet_recv(wrepl_socket->packet); 132 return; 133 } 134 if (flags & EVENT_FD_WRITE) { 135 packet_queue_run(wrepl_socket->packet); 136 } 137 } 138 139 static void wrepl_error(void *private_data, NTSTATUS status) 140 { 141 struct wrepl_socket *wrepl_socket = talloc_get_type(private_data, 142 struct wrepl_socket); 143 wrepl_socket_dead(wrepl_socket, status); 144 } 145 146 147 /* 148 destroy a wrepl_socket destructor 149 */ 150 static int wrepl_socket_destructor(struct wrepl_socket *sock) 151 { 152 if (sock->dead) { 153 sock->free_skipped = true; 154 return -1; 155 } 156 wrepl_socket_dead(sock, NT_STATUS_LOCAL_DISCONNECT); 157 return 0; 32 #include "lib/util/tevent_ntstatus.h" 33 #include "lib/tsocket/tsocket.h" 34 #include "libcli/util/tstream.h" 35 36 /* 37 main context structure for the wins replication client library 38 */ 39 struct wrepl_socket { 40 struct { 41 struct tevent_context *ctx; 42 } event; 43 44 /* the default timeout for requests, 0 means no timeout */ 45 #define WREPL_SOCKET_REQUEST_TIMEOUT (60) 46 uint32_t request_timeout; 47 48 struct tevent_queue *request_queue; 49 50 struct tstream_context *stream; 51 }; 52 53 bool wrepl_socket_is_connected(struct wrepl_socket *wrepl_sock) 54 { 55 if (!wrepl_sock) { 56 return false; 57 } 58 59 if (!wrepl_sock->stream) { 60 return false; 61 } 62 63 return true; 158 64 } 159 65 … … 162 68 operations will use that event context 163 69 */ 164 struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx, 165 struct tevent_context *event_ctx, 166 struct smb_iconv_convenience *iconv_convenience) 70 struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx, 71 struct tevent_context *event_ctx) 167 72 { 168 73 struct wrepl_socket *wrepl_socket; 169 NTSTATUS status;170 74 171 75 wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket); 172 if (!wrepl_socket) return NULL; 76 if (!wrepl_socket) { 77 return NULL; 78 } 173 79 174 80 wrepl_socket->event.ctx = event_ctx; 175 if (!wrepl_socket->event.ctx) goto failed; 176 177 wrepl_socket->iconv_convenience = iconv_convenience; 178 179 status = socket_create("ip", SOCKET_TYPE_STREAM, &wrepl_socket->sock, 0); 180 if (!NT_STATUS_IS_OK(status)) goto failed; 181 182 talloc_steal(wrepl_socket, wrepl_socket->sock); 81 if (!wrepl_socket->event.ctx) { 82 goto failed; 83 } 84 85 wrepl_socket->request_queue = tevent_queue_create(wrepl_socket, 86 "wrepl request queue"); 87 if (wrepl_socket->request_queue == NULL) { 88 goto failed; 89 } 183 90 184 91 wrepl_socket->request_timeout = WREPL_SOCKET_REQUEST_TIMEOUT; 185 186 talloc_set_destructor(wrepl_socket, wrepl_socket_destructor);187 92 188 93 return wrepl_socket; … … 196 101 initialise a wrepl_socket from an already existing connection 197 102 */ 198 struct wrepl_socket *wrepl_socket_merge(TALLOC_CTX *mem_ctx, 199 struct tevent_context *event_ctx, 200 struct socket_context *sock, 201 struct packet_context *pack) 202 { 203 struct wrepl_socket *wrepl_socket; 204 205 wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket); 206 if (wrepl_socket == NULL) goto failed; 207 208 wrepl_socket->event.ctx = event_ctx; 209 if (wrepl_socket->event.ctx == NULL) goto failed; 210 211 wrepl_socket->sock = sock; 212 talloc_steal(wrepl_socket, wrepl_socket->sock); 213 214 215 wrepl_socket->request_timeout = WREPL_SOCKET_REQUEST_TIMEOUT; 216 217 wrepl_socket->event.fde = event_add_fd(wrepl_socket->event.ctx, wrepl_socket, 218 socket_get_fd(wrepl_socket->sock), 219 EVENT_FD_READ, 220 wrepl_handler, wrepl_socket); 221 if (wrepl_socket->event.fde == NULL) { 222 goto failed; 223 } 224 225 wrepl_socket->packet = pack; 226 talloc_steal(wrepl_socket, wrepl_socket->packet); 227 packet_set_private(wrepl_socket->packet, wrepl_socket); 228 packet_set_socket(wrepl_socket->packet, wrepl_socket->sock); 229 packet_set_callback(wrepl_socket->packet, wrepl_finish_recv); 230 packet_set_full_request(wrepl_socket->packet, packet_full_request_u32); 231 packet_set_error_handler(wrepl_socket->packet, wrepl_error); 232 packet_set_event_context(wrepl_socket->packet, wrepl_socket->event.ctx); 233 packet_set_fde(wrepl_socket->packet, wrepl_socket->event.fde); 234 packet_set_serialise(wrepl_socket->packet); 235 236 talloc_set_destructor(wrepl_socket, wrepl_socket_destructor); 237 238 return wrepl_socket; 239 240 failed: 241 talloc_free(wrepl_socket); 242 return NULL; 243 } 244 245 /* 246 destroy a wrepl_request 247 */ 248 static int wrepl_request_destructor(struct wrepl_request *req) 249 { 250 if (req->state == WREPL_REQUEST_RECV) { 251 DLIST_REMOVE(req->wrepl_socket->recv_queue, req); 252 } 253 req->state = WREPL_REQUEST_ERROR; 254 return 0; 255 } 256 257 /* 258 wait for a request to complete 259 */ 260 static NTSTATUS wrepl_request_wait(struct wrepl_request *req) 261 { 262 NT_STATUS_HAVE_NO_MEMORY(req); 263 while (req->state < WREPL_REQUEST_DONE) { 264 event_loop_once(req->wrepl_socket->event.ctx); 265 } 266 return req->status; 103 NTSTATUS wrepl_socket_donate_stream(struct wrepl_socket *wrepl_socket, 104 struct tstream_context **stream) 105 { 106 if (wrepl_socket->stream) { 107 return NT_STATUS_CONNECTION_ACTIVE; 108 } 109 110 wrepl_socket->stream = talloc_move(wrepl_socket, stream); 111 return NT_STATUS_OK; 112 } 113 114 /* 115 initialise a wrepl_socket from an already existing connection 116 */ 117 NTSTATUS wrepl_socket_split_stream(struct wrepl_socket *wrepl_socket, 118 TALLOC_CTX *mem_ctx, 119 struct tstream_context **stream) 120 { 121 size_t num_requests; 122 123 if (!wrepl_socket->stream) { 124 return NT_STATUS_CONNECTION_INVALID; 125 } 126 127 num_requests = tevent_queue_length(wrepl_socket->request_queue); 128 if (num_requests > 0) { 129 return NT_STATUS_CONNECTION_IN_USE; 130 } 131 132 *stream = talloc_move(wrepl_socket, &wrepl_socket->stream); 133 return NT_STATUS_OK; 134 } 135 136 const char *wrepl_best_ip(struct loadparm_context *lp_ctx, const char *peer_ip) 137 { 138 struct interface *ifaces; 139 load_interfaces(lp_ctx, lpcfg_interfaces(lp_ctx), &ifaces); 140 return iface_best_ip(ifaces, peer_ip); 267 141 } 268 142 269 143 struct wrepl_connect_state { 270 struct composite_context *result; 271 struct wrepl_socket *wrepl_socket; 272 struct composite_context *creq; 144 struct { 145 struct wrepl_socket *wrepl_socket; 146 struct tevent_context *ev; 147 } caller; 148 struct tsocket_address *local_address; 149 struct tsocket_address *remote_address; 150 struct tstream_context *stream; 273 151 }; 274 152 275 /* 276 handler for winrepl connection completion 277 */ 278 static void wrepl_connect_handler(struct composite_context *creq) 279 { 280 struct wrepl_connect_state *state = talloc_get_type(creq->async.private_data, 153 static void wrepl_connect_trigger(struct tevent_req *req, 154 void *private_date); 155 156 struct tevent_req *wrepl_connect_send(TALLOC_CTX *mem_ctx, 157 struct tevent_context *ev, 158 struct wrepl_socket *wrepl_socket, 159 const char *our_ip, const char *peer_ip) 160 { 161 struct tevent_req *req; 162 struct wrepl_connect_state *state; 163 int ret; 164 bool ok; 165 166 req = tevent_req_create(mem_ctx, &state, 167 struct wrepl_connect_state); 168 if (req == NULL) { 169 return NULL; 170 } 171 172 state->caller.wrepl_socket = wrepl_socket; 173 state->caller.ev = ev; 174 175 if (wrepl_socket->stream) { 176 tevent_req_nterror(req, NT_STATUS_CONNECTION_ACTIVE); 177 return tevent_req_post(req, ev); 178 } 179 180 ret = tsocket_address_inet_from_strings(state, "ipv4", 181 our_ip, 0, 182 &state->local_address); 183 if (ret != 0) { 184 NTSTATUS status = map_nt_error_from_unix(errno); 185 tevent_req_nterror(req, status); 186 return tevent_req_post(req, ev); 187 } 188 189 ret = tsocket_address_inet_from_strings(state, "ipv4", 190 peer_ip, WINS_REPLICATION_PORT, 191 &state->remote_address); 192 if (ret != 0) { 193 NTSTATUS status = map_nt_error_from_unix(errno); 194 tevent_req_nterror(req, status); 195 return tevent_req_post(req, ev); 196 } 197 198 ok = tevent_queue_add(wrepl_socket->request_queue, 199 ev, 200 req, 201 wrepl_connect_trigger, 202 NULL); 203 if (!ok) { 204 tevent_req_nomem(NULL, req); 205 return tevent_req_post(req, ev); 206 } 207 208 if (wrepl_socket->request_timeout > 0) { 209 struct timeval endtime; 210 endtime = tevent_timeval_current_ofs(wrepl_socket->request_timeout, 0); 211 ok = tevent_req_set_endtime(req, ev, endtime); 212 if (!ok) { 213 return tevent_req_post(req, ev); 214 } 215 } 216 217 return req; 218 } 219 220 static void wrepl_connect_done(struct tevent_req *subreq); 221 222 static void wrepl_connect_trigger(struct tevent_req *req, 223 void *private_date) 224 { 225 struct wrepl_connect_state *state = tevent_req_data(req, 281 226 struct wrepl_connect_state); 282 struct wrepl_socket *wrepl_socket = state->wrepl_socket; 283 struct composite_context *result = state->result; 284 285 result->status = socket_connect_recv(state->creq); 286 if (!composite_is_ok(result)) return; 287 288 wrepl_socket->event.fde = event_add_fd(wrepl_socket->event.ctx, wrepl_socket, 289 socket_get_fd(wrepl_socket->sock), 290 EVENT_FD_READ, 291 wrepl_handler, wrepl_socket); 292 if (composite_nomem(wrepl_socket->event.fde, result)) return; 293 294 /* setup the stream -> packet parser */ 295 wrepl_socket->packet = packet_init(wrepl_socket); 296 if (composite_nomem(wrepl_socket->packet, result)) return; 297 packet_set_private(wrepl_socket->packet, wrepl_socket); 298 packet_set_socket(wrepl_socket->packet, wrepl_socket->sock); 299 packet_set_callback(wrepl_socket->packet, wrepl_finish_recv); 300 packet_set_full_request(wrepl_socket->packet, packet_full_request_u32); 301 packet_set_error_handler(wrepl_socket->packet, wrepl_error); 302 packet_set_event_context(wrepl_socket->packet, wrepl_socket->event.ctx); 303 packet_set_fde(wrepl_socket->packet, wrepl_socket->event.fde); 304 packet_set_serialise(wrepl_socket->packet); 305 306 composite_done(result); 307 } 308 309 const char *wrepl_best_ip(struct loadparm_context *lp_ctx, const char *peer_ip) 310 { 311 struct interface *ifaces; 312 load_interfaces(lp_ctx, lp_interfaces(lp_ctx), &ifaces); 313 return iface_best_ip(ifaces, peer_ip); 314 } 315 316 317 /* 318 connect a wrepl_socket to a WINS server 319 */ 320 struct composite_context *wrepl_connect_send(struct wrepl_socket *wrepl_socket, 321 const char *our_ip, const char *peer_ip) 322 { 323 struct composite_context *result; 324 struct wrepl_connect_state *state; 325 struct socket_address *peer, *us; 326 327 result = talloc_zero(wrepl_socket, struct composite_context); 328 if (!result) return NULL; 329 330 result->state = COMPOSITE_STATE_IN_PROGRESS; 331 result->event_ctx = wrepl_socket->event.ctx; 332 333 state = talloc_zero(result, struct wrepl_connect_state); 334 if (composite_nomem(state, result)) return result; 335 result->private_data = state; 336 state->result = result; 337 state->wrepl_socket = wrepl_socket; 338 339 us = socket_address_from_strings(state, wrepl_socket->sock->backend_name, 340 our_ip, 0); 341 if (composite_nomem(us, result)) return result; 342 343 peer = socket_address_from_strings(state, wrepl_socket->sock->backend_name, 344 peer_ip, WINS_REPLICATION_PORT); 345 if (composite_nomem(peer, result)) return result; 346 347 state->creq = socket_connect_send(wrepl_socket->sock, us, peer, 348 0, wrepl_socket->event.ctx); 349 composite_continue(result, state->creq, wrepl_connect_handler, state); 350 return result; 227 struct tevent_req *subreq; 228 229 subreq = tstream_inet_tcp_connect_send(state, 230 state->caller.ev, 231 state->local_address, 232 state->remote_address); 233 if (tevent_req_nomem(subreq, req)) { 234 return; 235 } 236 tevent_req_set_callback(subreq, wrepl_connect_done, req); 237 238 return; 239 } 240 241 static void wrepl_connect_done(struct tevent_req *subreq) 242 { 243 struct tevent_req *req = tevent_req_callback_data(subreq, 244 struct tevent_req); 245 struct wrepl_connect_state *state = tevent_req_data(req, 246 struct wrepl_connect_state); 247 int ret; 248 int sys_errno; 249 250 ret = tstream_inet_tcp_connect_recv(subreq, &sys_errno, 251 state, &state->stream, NULL); 252 if (ret != 0) { 253 NTSTATUS status = map_nt_error_from_unix(sys_errno); 254 tevent_req_nterror(req, status); 255 return; 256 } 257 258 tevent_req_done(req); 351 259 } 352 260 … … 354 262 connect a wrepl_socket to a WINS server - recv side 355 263 */ 356 NTSTATUS wrepl_connect_recv(struct composite_context *result)357 { 358 struct wrepl_connect_state *state = t alloc_get_type(result->private_data,264 NTSTATUS wrepl_connect_recv(struct tevent_req *req) 265 { 266 struct wrepl_connect_state *state = tevent_req_data(req, 359 267 struct wrepl_connect_state); 360 struct wrepl_socket *wrepl_socket = state->wrepl_socket; 361 NTSTATUS status = composite_wait(result); 362 363 if (!NT_STATUS_IS_OK(status)) { 364 wrepl_socket_dead(wrepl_socket, status); 365 } 366 367 talloc_free(result); 368 return status; 268 struct wrepl_socket *wrepl_socket = state->caller.wrepl_socket; 269 NTSTATUS status; 270 271 if (tevent_req_is_nterror(req, &status)) { 272 tevent_req_received(req); 273 return status; 274 } 275 276 wrepl_socket->stream = talloc_move(wrepl_socket, &state->stream); 277 278 tevent_req_received(req); 279 return NT_STATUS_OK; 369 280 } 370 281 … … 375 286 const char *our_ip, const char *peer_ip) 376 287 { 377 struct composite_context *c_req = wrepl_connect_send(wrepl_socket, our_ip, peer_ip); 378 return wrepl_connect_recv(c_req); 379 } 380 381 /* 382 callback from wrepl_request_trigger() 383 */ 384 static void wrepl_request_trigger_handler(struct tevent_context *ev, struct tevent_timer *te, 385 struct timeval t, void *ptr) 386 { 387 struct wrepl_request *req = talloc_get_type(ptr, struct wrepl_request); 388 if (req->async.fn) { 389 req->async.fn(req); 390 } 391 } 392 393 /* 394 trigger an immediate event on a wrepl_request 395 the return value should only be used in wrepl_request_send() 396 this is the only place where req->trigger is true 397 */ 398 static struct wrepl_request *wrepl_request_finished(struct wrepl_request *req, NTSTATUS status) 399 { 400 struct tevent_timer *te; 401 402 if (req->state == WREPL_REQUEST_RECV) { 403 DLIST_REMOVE(req->wrepl_socket->recv_queue, req); 404 } 405 406 if (!NT_STATUS_IS_OK(status)) { 407 req->state = WREPL_REQUEST_ERROR; 408 } else { 409 req->state = WREPL_REQUEST_DONE; 410 } 411 412 req->status = status; 413 414 if (req->trigger) { 415 req->trigger = false; 416 /* a zero timeout means immediate */ 417 te = event_add_timed(req->wrepl_socket->event.ctx, 418 req, timeval_zero(), 419 wrepl_request_trigger_handler, req); 420 if (!te) { 421 talloc_free(req); 422 return NULL; 423 } 424 return req; 425 } 426 427 if (req->async.fn) { 428 req->async.fn(req); 429 } 430 return NULL; 431 } 432 433 struct wrepl_send_ctrl_state { 288 struct tevent_req *subreq; 289 bool ok; 290 NTSTATUS status; 291 292 subreq = wrepl_connect_send(wrepl_socket, wrepl_socket->event.ctx, 293 wrepl_socket, our_ip, peer_ip); 294 NT_STATUS_HAVE_NO_MEMORY(subreq); 295 296 ok = tevent_req_poll(subreq, wrepl_socket->event.ctx); 297 if (!ok) { 298 TALLOC_FREE(subreq); 299 return NT_STATUS_INTERNAL_ERROR; 300 } 301 302 status = wrepl_connect_recv(subreq); 303 TALLOC_FREE(subreq); 304 NT_STATUS_NOT_OK_RETURN(status); 305 306 return NT_STATUS_OK; 307 } 308 309 struct wrepl_request_state { 310 struct { 311 struct wrepl_socket *wrepl_socket; 312 struct tevent_context *ev; 313 } caller; 434 314 struct wrepl_send_ctrl ctrl; 435 struct wrepl_request *req; 436 struct wrepl_socket *wrepl_sock; 315 struct { 316 struct wrepl_wrap wrap; 317 DATA_BLOB blob; 318 struct iovec iov; 319 } req; 320 bool one_way; 321 struct { 322 DATA_BLOB blob; 323 struct wrepl_packet *packet; 324 } rep; 437 325 }; 438 326 439 static int wrepl_send_ctrl_destructor(struct wrepl_send_ctrl_state *s) 440 { 441 struct wrepl_request *req = s->wrepl_sock->recv_queue; 442 443 /* check if the request is still in WREPL_STATE_RECV, 444 * we need this here because the caller has may called 445 * talloc_free(req) and wrepl_send_ctrl_state isn't 446 * a talloc child of the request, so our s->req pointer 447 * is maybe invalid! 448 */ 449 for (; req; req = req->next) { 450 if (req == s->req) break; 451 } 452 if (!req) return 0; 453 454 /* here, we need to make sure the async request handler is called 455 * later in the next event_loop and now now 456 */ 457 req->trigger = true; 458 wrepl_request_finished(req, NT_STATUS_OK); 459 460 if (s->ctrl.disconnect_after_send) { 461 wrepl_socket_dead(s->wrepl_sock, NT_STATUS_LOCAL_DISCONNECT); 462 } 463 464 return 0; 465 } 466 467 /* 468 send a generic wins replication request 469 */ 470 struct wrepl_request *wrepl_request_send(struct wrepl_socket *wrepl_socket, 471 struct wrepl_packet *packet, 472 struct wrepl_send_ctrl *ctrl) 473 { 474 struct wrepl_request *req; 475 struct wrepl_wrap wrap; 476 DATA_BLOB blob; 327 static void wrepl_request_trigger(struct tevent_req *req, 328 void *private_data); 329 330 struct tevent_req *wrepl_request_send(TALLOC_CTX *mem_ctx, 331 struct tevent_context *ev, 332 struct wrepl_socket *wrepl_socket, 333 const struct wrepl_packet *packet, 334 const struct wrepl_send_ctrl *ctrl) 335 { 336 struct tevent_req *req; 337 struct wrepl_request_state *state; 477 338 NTSTATUS status; 478 339 enum ndr_err_code ndr_err; 479 480 req = talloc_zero(wrepl_socket, struct wrepl_request); 481 if (!req) return NULL; 482 req->wrepl_socket = wrepl_socket; 483 req->state = WREPL_REQUEST_RECV; 484 req->trigger = true; 485 486 DLIST_ADD_END(wrepl_socket->recv_queue, req, struct wrepl_request *); 487 talloc_set_destructor(req, wrepl_request_destructor); 488 489 if (wrepl_socket->dead) { 490 return wrepl_request_finished(req, NT_STATUS_INVALID_CONNECTION); 491 } 492 493 wrap.packet = *packet; 494 ndr_err = ndr_push_struct_blob(&blob, req, wrepl_socket->iconv_convenience, &wrap, 340 bool ok; 341 342 if (wrepl_socket->event.ctx != ev) { 343 /* TODO: remove wrepl_socket->event.ctx !!! */ 344 smb_panic("wrepl_associate_stop_send event context mismatch!"); 345 return NULL; 346 } 347 348 req = tevent_req_create(mem_ctx, &state, 349 struct wrepl_request_state); 350 if (req == NULL) { 351 return NULL; 352 } 353 354 state->caller.wrepl_socket = wrepl_socket; 355 state->caller.ev = ev; 356 357 if (ctrl) { 358 state->ctrl = *ctrl; 359 } 360 361 if (wrepl_socket->stream == NULL) { 362 tevent_req_nterror(req, NT_STATUS_INVALID_CONNECTION); 363 return tevent_req_post(req, ev); 364 } 365 366 state->req.wrap.packet = *packet; 367 ndr_err = ndr_push_struct_blob(&state->req.blob, state, 368 &state->req.wrap, 495 369 (ndr_push_flags_fn_t)ndr_push_wrepl_wrap); 496 370 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 497 371 status = ndr_map_error2ntstatus(ndr_err); 498 return wrepl_request_finished(req, status); 372 tevent_req_nterror(req, status); 373 return tevent_req_post(req, ev); 374 } 375 376 state->req.iov.iov_base = (char *) state->req.blob.data; 377 state->req.iov.iov_len = state->req.blob.length; 378 379 ok = tevent_queue_add(wrepl_socket->request_queue, 380 ev, 381 req, 382 wrepl_request_trigger, 383 NULL); 384 if (!ok) { 385 tevent_req_nomem(NULL, req); 386 return tevent_req_post(req, ev); 387 } 388 389 if (wrepl_socket->request_timeout > 0) { 390 struct timeval endtime; 391 endtime = tevent_timeval_current_ofs(wrepl_socket->request_timeout, 0); 392 ok = tevent_req_set_endtime(req, ev, endtime); 393 if (!ok) { 394 return tevent_req_post(req, ev); 395 } 396 } 397 398 return req; 399 } 400 401 static void wrepl_request_writev_done(struct tevent_req *subreq); 402 403 static void wrepl_request_trigger(struct tevent_req *req, 404 void *private_data) 405 { 406 struct wrepl_request_state *state = tevent_req_data(req, 407 struct wrepl_request_state); 408 struct tevent_req *subreq; 409 410 if (state->caller.wrepl_socket->stream == NULL) { 411 tevent_req_nterror(req, NT_STATUS_INVALID_CONNECTION); 412 return; 499 413 } 500 414 501 415 if (DEBUGLVL(10)) { 502 DEBUG(10,("Sending WINS packet of length %u\n", 503 (unsigned)blob.length)); 504 NDR_PRINT_DEBUG(wrepl_packet, &wrap.packet); 505 } 506 507 if (wrepl_socket->request_timeout > 0) { 508 req->te = event_add_timed(wrepl_socket->event.ctx, req, 509 timeval_current_ofs(wrepl_socket->request_timeout, 0), 510 wrepl_request_timeout_handler, req); 511 if (!req->te) return wrepl_request_finished(req, NT_STATUS_NO_MEMORY); 512 } 513 514 if (ctrl && (ctrl->send_only || ctrl->disconnect_after_send)) { 515 struct wrepl_send_ctrl_state *s = talloc(blob.data, struct wrepl_send_ctrl_state); 516 if (!s) return wrepl_request_finished(req, NT_STATUS_NO_MEMORY); 517 s->ctrl = *ctrl; 518 s->req = req; 519 s->wrepl_sock = wrepl_socket; 520 talloc_set_destructor(s, wrepl_send_ctrl_destructor); 521 } 522 523 status = packet_send(wrepl_socket->packet, blob); 416 DEBUG(10,("Sending WINS packet of length %u\n", 417 (unsigned)state->req.blob.length)); 418 NDR_PRINT_DEBUG(wrepl_packet, &state->req.wrap.packet); 419 } 420 421 subreq = tstream_writev_send(state, 422 state->caller.ev, 423 state->caller.wrepl_socket->stream, 424 &state->req.iov, 1); 425 if (tevent_req_nomem(subreq, req)) { 426 return; 427 } 428 tevent_req_set_callback(subreq, wrepl_request_writev_done, req); 429 } 430 431 static void wrepl_request_disconnect_done(struct tevent_req *subreq); 432 static void wrepl_request_read_pdu_done(struct tevent_req *subreq); 433 434 static void wrepl_request_writev_done(struct tevent_req *subreq) 435 { 436 struct tevent_req *req = tevent_req_callback_data(subreq, 437 struct tevent_req); 438 struct wrepl_request_state *state = tevent_req_data(req, 439 struct wrepl_request_state); 440 int ret; 441 int sys_errno; 442 443 ret = tstream_writev_recv(subreq, &sys_errno); 444 TALLOC_FREE(subreq); 445 if (ret == -1) { 446 NTSTATUS status = map_nt_error_from_unix(sys_errno); 447 TALLOC_FREE(state->caller.wrepl_socket->stream); 448 tevent_req_nterror(req, status); 449 return; 450 } 451 452 if (state->caller.wrepl_socket->stream == NULL) { 453 tevent_req_nterror(req, NT_STATUS_INVALID_CONNECTION); 454 return; 455 } 456 457 if (state->ctrl.disconnect_after_send) { 458 subreq = tstream_disconnect_send(state, 459 state->caller.ev, 460 state->caller.wrepl_socket->stream); 461 if (tevent_req_nomem(subreq, req)) { 462 return; 463 } 464 tevent_req_set_callback(subreq, wrepl_request_disconnect_done, req); 465 return; 466 } 467 468 if (state->ctrl.send_only) { 469 tevent_req_done(req); 470 return; 471 } 472 473 subreq = tstream_read_pdu_blob_send(state, 474 state->caller.ev, 475 state->caller.wrepl_socket->stream, 476 4, /* initial_read_size */ 477 packet_full_request_u32, 478 NULL); 479 if (tevent_req_nomem(subreq, req)) { 480 return; 481 } 482 tevent_req_set_callback(subreq, wrepl_request_read_pdu_done, req); 483 } 484 485 static void wrepl_request_disconnect_done(struct tevent_req *subreq) 486 { 487 struct tevent_req *req = tevent_req_callback_data(subreq, 488 struct tevent_req); 489 struct wrepl_request_state *state = tevent_req_data(req, 490 struct wrepl_request_state); 491 int ret; 492 int sys_errno; 493 494 ret = tstream_disconnect_recv(subreq, &sys_errno); 495 TALLOC_FREE(subreq); 496 if (ret == -1) { 497 NTSTATUS status = map_nt_error_from_unix(sys_errno); 498 TALLOC_FREE(state->caller.wrepl_socket->stream); 499 tevent_req_nterror(req, status); 500 return; 501 } 502 503 DEBUG(10,("WINS connection disconnected\n")); 504 TALLOC_FREE(state->caller.wrepl_socket->stream); 505 506 tevent_req_done(req); 507 } 508 509 static void wrepl_request_read_pdu_done(struct tevent_req *subreq) 510 { 511 struct tevent_req *req = tevent_req_callback_data(subreq, 512 struct tevent_req); 513 struct wrepl_request_state *state = tevent_req_data(req, 514 struct wrepl_request_state); 515 NTSTATUS status; 516 DATA_BLOB blob; 517 enum ndr_err_code ndr_err; 518 519 status = tstream_read_pdu_blob_recv(subreq, state, &state->rep.blob); 524 520 if (!NT_STATUS_IS_OK(status)) { 525 return wrepl_request_finished(req, status); 526 } 527 528 req->trigger = false; 529 return req; 530 } 531 532 /* 533 receive a generic WINS replication reply 534 */ 535 NTSTATUS wrepl_request_recv(struct wrepl_request *req, 521 TALLOC_FREE(state->caller.wrepl_socket->stream); 522 tevent_req_nterror(req, status); 523 return; 524 } 525 526 state->rep.packet = talloc(state, struct wrepl_packet); 527 if (tevent_req_nomem(state->rep.packet, req)) { 528 return; 529 } 530 531 blob.data = state->rep.blob.data + 4; 532 blob.length = state->rep.blob.length - 4; 533 534 /* we have a full request - parse it */ 535 ndr_err = ndr_pull_struct_blob(&blob, 536 state->rep.packet, 537 state->rep.packet, 538 (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet); 539 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { 540 status = ndr_map_error2ntstatus(ndr_err); 541 tevent_req_nterror(req, status); 542 return; 543 } 544 545 if (DEBUGLVL(10)) { 546 DEBUG(10,("Received WINS packet of length %u\n", 547 (unsigned)state->rep.blob.length)); 548 NDR_PRINT_DEBUG(wrepl_packet, state->rep.packet); 549 } 550 551 tevent_req_done(req); 552 } 553 554 NTSTATUS wrepl_request_recv(struct tevent_req *req, 536 555 TALLOC_CTX *mem_ctx, 537 556 struct wrepl_packet **packet) 538 557 { 539 NTSTATUS status = wrepl_request_wait(req); 540 if (NT_STATUS_IS_OK(status) && packet) { 541 *packet = talloc_steal(mem_ctx, req->packet); 542 } 543 talloc_free(req); 544 return status; 558 struct wrepl_request_state *state = tevent_req_data(req, 559 struct wrepl_request_state); 560 NTSTATUS status; 561 562 if (tevent_req_is_nterror(req, &status)) { 563 TALLOC_FREE(state->caller.wrepl_socket->stream); 564 tevent_req_received(req); 565 return status; 566 } 567 568 if (packet) { 569 *packet = talloc_move(mem_ctx, &state->rep.packet); 570 } 571 572 tevent_req_received(req); 573 return NT_STATUS_OK; 545 574 } 546 575 … … 550 579 NTSTATUS wrepl_request(struct wrepl_socket *wrepl_socket, 551 580 TALLOC_CTX *mem_ctx, 552 struct wrepl_packet *req_packet,581 const struct wrepl_packet *req_packet, 553 582 struct wrepl_packet **reply_packet) 554 583 { 555 struct wrepl_request *req = wrepl_request_send(wrepl_socket, req_packet, NULL); 556 return wrepl_request_recv(req, mem_ctx, reply_packet); 557 } 558 559 560 /* 561 setup an association - send 562 */ 563 struct wrepl_request *wrepl_associate_send(struct wrepl_socket *wrepl_socket, 564 struct wrepl_associate *io) 565 { 566 struct wrepl_packet *packet; 567 struct wrepl_request *req; 568 569 packet = talloc_zero(wrepl_socket, struct wrepl_packet); 570 if (packet == NULL) return NULL; 571 572 packet->opcode = WREPL_OPCODE_BITS; 573 packet->mess_type = WREPL_START_ASSOCIATION; 574 packet->message.start.minor_version = 2; 575 packet->message.start.major_version = 5; 584 struct tevent_req *subreq; 585 bool ok; 586 NTSTATUS status; 587 588 subreq = wrepl_request_send(mem_ctx, wrepl_socket->event.ctx, 589 wrepl_socket, req_packet, NULL); 590 NT_STATUS_HAVE_NO_MEMORY(subreq); 591 592 ok = tevent_req_poll(subreq, wrepl_socket->event.ctx); 593 if (!ok) { 594 TALLOC_FREE(subreq); 595 return NT_STATUS_INTERNAL_ERROR; 596 } 597 598 status = wrepl_request_recv(subreq, mem_ctx, reply_packet); 599 TALLOC_FREE(subreq); 600 NT_STATUS_NOT_OK_RETURN(status); 601 602 return NT_STATUS_OK; 603 } 604 605 606 struct wrepl_associate_state { 607 struct wrepl_packet packet; 608 uint32_t assoc_ctx; 609 uint16_t major_version; 610 }; 611 612 static void wrepl_associate_done(struct tevent_req *subreq); 613 614 struct tevent_req *wrepl_associate_send(TALLOC_CTX *mem_ctx, 615 struct tevent_context *ev, 616 struct wrepl_socket *wrepl_socket, 617 const struct wrepl_associate *io) 618 { 619 struct tevent_req *req; 620 struct wrepl_associate_state *state; 621 struct tevent_req *subreq; 622 623 if (wrepl_socket->event.ctx != ev) { 624 /* TODO: remove wrepl_socket->event.ctx !!! */ 625 smb_panic("wrepl_associate_send event context mismatch!"); 626 return NULL; 627 } 628 629 req = tevent_req_create(mem_ctx, &state, 630 struct wrepl_associate_state); 631 if (req == NULL) { 632 return NULL; 633 }; 634 635 state->packet.opcode = WREPL_OPCODE_BITS; 636 state->packet.mess_type = WREPL_START_ASSOCIATION; 637 state->packet.message.start.minor_version = 2; 638 state->packet.message.start.major_version = 5; 576 639 577 640 /* … … 583 646 * and that would break nt4 <-> samba replication 584 647 */ 585 packet->padding = data_blob_talloc(packet, NULL, 21); 586 if (packet->padding.data == NULL) { 587 talloc_free(packet); 588 return NULL; 589 } 590 memset(packet->padding.data, 0, packet->padding.length); 591 592 req = wrepl_request_send(wrepl_socket, packet, NULL); 593 594 talloc_free(packet); 595 596 return req; 648 state->packet.padding = data_blob_talloc(state, NULL, 21); 649 if (tevent_req_nomem(state->packet.padding.data, req)) { 650 return tevent_req_post(req, ev); 651 } 652 memset(state->packet.padding.data, 0, state->packet.padding.length); 653 654 subreq = wrepl_request_send(state, ev, wrepl_socket, &state->packet, NULL); 655 if (tevent_req_nomem(subreq, req)) { 656 return tevent_req_post(req, ev); 657 } 658 tevent_req_set_callback(subreq, wrepl_associate_done, req); 659 660 return req; 661 } 662 663 static void wrepl_associate_done(struct tevent_req *subreq) 664 { 665 struct tevent_req *req = tevent_req_callback_data(subreq, 666 struct tevent_req); 667 struct wrepl_associate_state *state = tevent_req_data(req, 668 struct wrepl_associate_state); 669 NTSTATUS status; 670 struct wrepl_packet *packet; 671 672 status = wrepl_request_recv(subreq, state, &packet); 673 TALLOC_FREE(subreq); 674 if (!NT_STATUS_IS_OK(status)) { 675 tevent_req_nterror(req, status); 676 return; 677 } 678 679 if (packet->mess_type != WREPL_START_ASSOCIATION_REPLY) { 680 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); 681 return; 682 } 683 684 state->assoc_ctx = packet->message.start_reply.assoc_ctx; 685 state->major_version = packet->message.start_reply.major_version; 686 687 tevent_req_done(req); 597 688 } 598 689 … … 600 691 setup an association - recv 601 692 */ 602 NTSTATUS wrepl_associate_recv(struct wrepl_request*req,693 NTSTATUS wrepl_associate_recv(struct tevent_req *req, 603 694 struct wrepl_associate *io) 604 695 { 605 struct wrepl_packet *packet=NULL; 606 NTSTATUS status; 607 status = wrepl_request_recv(req, req->wrepl_socket, &packet); 608 NT_STATUS_NOT_OK_RETURN(status); 609 if (packet->mess_type != WREPL_START_ASSOCIATION_REPLY) { 610 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; 611 } 612 if (NT_STATUS_IS_OK(status)) { 613 io->out.assoc_ctx = packet->message.start_reply.assoc_ctx; 614 io->out.major_version = packet->message.start_reply.major_version; 615 } 616 talloc_free(packet); 617 return status; 696 struct wrepl_associate_state *state = tevent_req_data(req, 697 struct wrepl_associate_state); 698 NTSTATUS status; 699 700 if (tevent_req_is_nterror(req, &status)) { 701 tevent_req_received(req); 702 return status; 703 } 704 705 io->out.assoc_ctx = state->assoc_ctx; 706 io->out.major_version = state->major_version; 707 708 tevent_req_received(req); 709 return NT_STATUS_OK; 618 710 } 619 711 … … 624 716 struct wrepl_associate *io) 625 717 { 626 struct wrepl_request *req = wrepl_associate_send(wrepl_socket, io); 627 return wrepl_associate_recv(req, io); 628 } 629 630 631 /* 632 stop an association - send 633 */ 634 struct wrepl_request *wrepl_associate_stop_send(struct wrepl_socket *wrepl_socket, 635 struct wrepl_associate_stop *io) 636 { 637 struct wrepl_packet *packet; 638 struct wrepl_request *req; 718 struct tevent_req *subreq; 719 bool ok; 720 NTSTATUS status; 721 722 subreq = wrepl_associate_send(wrepl_socket, wrepl_socket->event.ctx, 723 wrepl_socket, io); 724 NT_STATUS_HAVE_NO_MEMORY(subreq); 725 726 ok = tevent_req_poll(subreq, wrepl_socket->event.ctx); 727 if (!ok) { 728 TALLOC_FREE(subreq); 729 return NT_STATUS_INTERNAL_ERROR; 730 } 731 732 status = wrepl_associate_recv(subreq, io); 733 TALLOC_FREE(subreq); 734 NT_STATUS_NOT_OK_RETURN(status); 735 736 return NT_STATUS_OK; 737 } 738 739 struct wrepl_associate_stop_state { 740 struct wrepl_packet packet; 639 741 struct wrepl_send_ctrl ctrl; 640 641 packet = talloc_zero(wrepl_socket, struct wrepl_packet); 642 if (packet == NULL) return NULL; 643 644 packet->opcode = WREPL_OPCODE_BITS; 645 packet->assoc_ctx = io->in.assoc_ctx; 646 packet->mess_type = WREPL_STOP_ASSOCIATION; 647 packet->message.stop.reason = io->in.reason; 648 649 ZERO_STRUCT(ctrl); 742 }; 743 744 static void wrepl_associate_stop_done(struct tevent_req *subreq); 745 746 struct tevent_req *wrepl_associate_stop_send(TALLOC_CTX *mem_ctx, 747 struct tevent_context *ev, 748 struct wrepl_socket *wrepl_socket, 749 const struct wrepl_associate_stop *io) 750 { 751 struct tevent_req *req; 752 struct wrepl_associate_stop_state *state; 753 struct tevent_req *subreq; 754 755 if (wrepl_socket->event.ctx != ev) { 756 /* TODO: remove wrepl_socket->event.ctx !!! */ 757 smb_panic("wrepl_associate_stop_send event context mismatch!"); 758 return NULL; 759 } 760 761 req = tevent_req_create(mem_ctx, &state, 762 struct wrepl_associate_stop_state); 763 if (req == NULL) { 764 return NULL; 765 }; 766 767 state->packet.opcode = WREPL_OPCODE_BITS; 768 state->packet.assoc_ctx = io->in.assoc_ctx; 769 state->packet.mess_type = WREPL_STOP_ASSOCIATION; 770 state->packet.message.stop.reason = io->in.reason; 771 650 772 if (io->in.reason == 0) { 651 ctrl.send_only = true; 652 ctrl.disconnect_after_send = true; 653 } 654 655 req = wrepl_request_send(wrepl_socket, packet, &ctrl); 656 657 talloc_free(packet); 658 659 return req; 773 state->ctrl.send_only = true; 774 state->ctrl.disconnect_after_send = true; 775 } 776 777 subreq = wrepl_request_send(state, ev, wrepl_socket, &state->packet, &state->ctrl); 778 if (tevent_req_nomem(subreq, req)) { 779 return tevent_req_post(req, ev); 780 } 781 tevent_req_set_callback(subreq, wrepl_associate_stop_done, req); 782 783 return req; 784 } 785 786 static void wrepl_associate_stop_done(struct tevent_req *subreq) 787 { 788 struct tevent_req *req = tevent_req_callback_data(subreq, 789 struct tevent_req); 790 struct wrepl_associate_stop_state *state = tevent_req_data(req, 791 struct wrepl_associate_stop_state); 792 NTSTATUS status; 793 794 /* currently we don't care about a possible response */ 795 status = wrepl_request_recv(subreq, state, NULL); 796 TALLOC_FREE(subreq); 797 if (!NT_STATUS_IS_OK(status)) { 798 tevent_req_nterror(req, status); 799 return; 800 } 801 802 tevent_req_done(req); 660 803 } 661 804 … … 663 806 stop an association - recv 664 807 */ 665 NTSTATUS wrepl_associate_stop_recv(struct wrepl_request*req,808 NTSTATUS wrepl_associate_stop_recv(struct tevent_req *req, 666 809 struct wrepl_associate_stop *io) 667 810 { 668 struct wrepl_packet *packet=NULL; 669 NTSTATUS status; 670 status = wrepl_request_recv(req, req->wrepl_socket, &packet); 671 NT_STATUS_NOT_OK_RETURN(status); 672 talloc_free(packet); 673 return status; 811 NTSTATUS status; 812 813 if (tevent_req_is_nterror(req, &status)) { 814 tevent_req_received(req); 815 return status; 816 } 817 818 tevent_req_received(req); 819 return NT_STATUS_OK; 674 820 } 675 821 … … 680 826 struct wrepl_associate_stop *io) 681 827 { 682 struct wrepl_request *req = wrepl_associate_stop_send(wrepl_socket, io); 683 return wrepl_associate_stop_recv(req, io); 684 } 685 686 /* 687 fetch the partner tables - send 688 */ 689 struct wrepl_request *wrepl_pull_table_send(struct wrepl_socket *wrepl_socket, 690 struct wrepl_pull_table *io) 691 { 828 struct tevent_req *subreq; 829 bool ok; 830 NTSTATUS status; 831 832 subreq = wrepl_associate_stop_send(wrepl_socket, wrepl_socket->event.ctx, 833 wrepl_socket, io); 834 NT_STATUS_HAVE_NO_MEMORY(subreq); 835 836 ok = tevent_req_poll(subreq, wrepl_socket->event.ctx); 837 if (!ok) { 838 TALLOC_FREE(subreq); 839 return NT_STATUS_INTERNAL_ERROR; 840 } 841 842 status = wrepl_associate_stop_recv(subreq, io); 843 TALLOC_FREE(subreq); 844 NT_STATUS_NOT_OK_RETURN(status); 845 846 return NT_STATUS_OK; 847 } 848 849 struct wrepl_pull_table_state { 850 struct wrepl_packet packet; 851 uint32_t num_partners; 852 struct wrepl_wins_owner *partners; 853 }; 854 855 static void wrepl_pull_table_done(struct tevent_req *subreq); 856 857 struct tevent_req *wrepl_pull_table_send(TALLOC_CTX *mem_ctx, 858 struct tevent_context *ev, 859 struct wrepl_socket *wrepl_socket, 860 const struct wrepl_pull_table *io) 861 { 862 struct tevent_req *req; 863 struct wrepl_pull_table_state *state; 864 struct tevent_req *subreq; 865 866 if (wrepl_socket->event.ctx != ev) { 867 /* TODO: remove wrepl_socket->event.ctx !!! */ 868 smb_panic("wrepl_pull_table_send event context mismatch!"); 869 return NULL; 870 } 871 872 req = tevent_req_create(mem_ctx, &state, 873 struct wrepl_pull_table_state); 874 if (req == NULL) { 875 return NULL; 876 }; 877 878 state->packet.opcode = WREPL_OPCODE_BITS; 879 state->packet.assoc_ctx = io->in.assoc_ctx; 880 state->packet.mess_type = WREPL_REPLICATION; 881 state->packet.message.replication.command = WREPL_REPL_TABLE_QUERY; 882 883 subreq = wrepl_request_send(state, ev, wrepl_socket, &state->packet, NULL); 884 if (tevent_req_nomem(subreq, req)) { 885 return tevent_req_post(req, ev); 886 } 887 tevent_req_set_callback(subreq, wrepl_pull_table_done, req); 888 889 return req; 890 } 891 892 static void wrepl_pull_table_done(struct tevent_req *subreq) 893 { 894 struct tevent_req *req = tevent_req_callback_data(subreq, 895 struct tevent_req); 896 struct wrepl_pull_table_state *state = tevent_req_data(req, 897 struct wrepl_pull_table_state); 898 NTSTATUS status; 692 899 struct wrepl_packet *packet; 693 struct wrepl_request *req; 694 695 packet = talloc_zero(wrepl_socket, struct wrepl_packet); 696 if (packet == NULL) return NULL; 697 698 packet->opcode = WREPL_OPCODE_BITS; 699 packet->assoc_ctx = io->in.assoc_ctx; 700 packet->mess_type = WREPL_REPLICATION; 701 packet->message.replication.command = WREPL_REPL_TABLE_QUERY; 702 703 req = wrepl_request_send(wrepl_socket, packet, NULL); 704 705 talloc_free(packet); 706 707 return req; 708 } 709 900 struct wrepl_table *table; 901 902 status = wrepl_request_recv(subreq, state, &packet); 903 TALLOC_FREE(subreq); 904 if (!NT_STATUS_IS_OK(status)) { 905 tevent_req_nterror(req, status); 906 return; 907 } 908 909 if (packet->mess_type != WREPL_REPLICATION) { 910 tevent_req_nterror(req, NT_STATUS_NETWORK_ACCESS_DENIED); 911 return; 912 } 913 914 if (packet->message.replication.command != WREPL_REPL_TABLE_REPLY) { 915 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); 916 return; 917 } 918 919 table = &packet->message.replication.info.table; 920 921 state->num_partners = table->partner_count; 922 state->partners = talloc_move(state, &table->partners); 923 924 tevent_req_done(req); 925 } 710 926 711 927 /* 712 928 fetch the partner tables - recv 713 929 */ 714 NTSTATUS wrepl_pull_table_recv(struct wrepl_request*req,930 NTSTATUS wrepl_pull_table_recv(struct tevent_req *req, 715 931 TALLOC_CTX *mem_ctx, 716 932 struct wrepl_pull_table *io) 717 933 { 718 struct wrepl_packet *packet=NULL; 719 NTSTATUS status; 720 struct wrepl_table *table; 721 int i; 722 723 status = wrepl_request_recv(req, req->wrepl_socket, &packet); 724 NT_STATUS_NOT_OK_RETURN(status); 725 if (packet->mess_type != WREPL_REPLICATION) { 726 status = NT_STATUS_NETWORK_ACCESS_DENIED; 727 } else if (packet->message.replication.command != WREPL_REPL_TABLE_REPLY) { 728 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; 729 } 730 if (!NT_STATUS_IS_OK(status)) goto failed; 731 732 table = &packet->message.replication.info.table; 733 io->out.num_partners = table->partner_count; 734 io->out.partners = talloc_steal(mem_ctx, table->partners); 735 for (i=0;i<io->out.num_partners;i++) { 736 talloc_steal(io->out.partners, io->out.partners[i].address); 737 } 738 739 failed: 740 talloc_free(packet); 741 return status; 742 } 743 934 struct wrepl_pull_table_state *state = tevent_req_data(req, 935 struct wrepl_pull_table_state); 936 NTSTATUS status; 937 938 if (tevent_req_is_nterror(req, &status)) { 939 tevent_req_received(req); 940 return status; 941 } 942 943 io->out.num_partners = state->num_partners; 944 io->out.partners = talloc_move(mem_ctx, &state->partners); 945 946 tevent_req_received(req); 947 return NT_STATUS_OK; 948 } 744 949 745 950 /* … … 750 955 struct wrepl_pull_table *io) 751 956 { 752 struct wrepl_request *req = wrepl_pull_table_send(wrepl_socket, io); 753 return wrepl_pull_table_recv(req, mem_ctx, io); 754 } 755 756 757 /* 758 fetch the names for a WINS partner - send 759 */ 760 struct wrepl_request *wrepl_pull_names_send(struct wrepl_socket *wrepl_socket, 761 struct wrepl_pull_names *io) 762 { 957 struct tevent_req *subreq; 958 bool ok; 959 NTSTATUS status; 960 961 subreq = wrepl_pull_table_send(mem_ctx, wrepl_socket->event.ctx, 962 wrepl_socket, io); 963 NT_STATUS_HAVE_NO_MEMORY(subreq); 964 965 ok = tevent_req_poll(subreq, wrepl_socket->event.ctx); 966 if (!ok) { 967 TALLOC_FREE(subreq); 968 return NT_STATUS_INTERNAL_ERROR; 969 } 970 971 status = wrepl_pull_table_recv(subreq, mem_ctx, io); 972 TALLOC_FREE(subreq); 973 NT_STATUS_NOT_OK_RETURN(status); 974 975 return NT_STATUS_OK; 976 } 977 978 979 struct wrepl_pull_names_state { 980 struct { 981 const struct wrepl_pull_names *io; 982 } caller; 983 struct wrepl_packet packet; 984 uint32_t num_names; 985 struct wrepl_name *names; 986 }; 987 988 static void wrepl_pull_names_done(struct tevent_req *subreq); 989 990 struct tevent_req *wrepl_pull_names_send(TALLOC_CTX *mem_ctx, 991 struct tevent_context *ev, 992 struct wrepl_socket *wrepl_socket, 993 const struct wrepl_pull_names *io) 994 { 995 struct tevent_req *req; 996 struct wrepl_pull_names_state *state; 997 struct tevent_req *subreq; 998 999 if (wrepl_socket->event.ctx != ev) { 1000 /* TODO: remove wrepl_socket->event.ctx !!! */ 1001 smb_panic("wrepl_pull_names_send event context mismatch!"); 1002 return NULL; 1003 } 1004 1005 req = tevent_req_create(mem_ctx, &state, 1006 struct wrepl_pull_names_state); 1007 if (req == NULL) { 1008 return NULL; 1009 }; 1010 state->caller.io = io; 1011 1012 state->packet.opcode = WREPL_OPCODE_BITS; 1013 state->packet.assoc_ctx = io->in.assoc_ctx; 1014 state->packet.mess_type = WREPL_REPLICATION; 1015 state->packet.message.replication.command = WREPL_REPL_SEND_REQUEST; 1016 state->packet.message.replication.info.owner = io->in.partner; 1017 1018 subreq = wrepl_request_send(state, ev, wrepl_socket, &state->packet, NULL); 1019 if (tevent_req_nomem(subreq, req)) { 1020 return tevent_req_post(req, ev); 1021 } 1022 tevent_req_set_callback(subreq, wrepl_pull_names_done, req); 1023 1024 return req; 1025 } 1026 1027 static void wrepl_pull_names_done(struct tevent_req *subreq) 1028 { 1029 struct tevent_req *req = tevent_req_callback_data(subreq, 1030 struct tevent_req); 1031 struct wrepl_pull_names_state *state = tevent_req_data(req, 1032 struct wrepl_pull_names_state); 1033 NTSTATUS status; 763 1034 struct wrepl_packet *packet; 764 struct wrepl_request *req; 765 766 packet = talloc_zero(wrepl_socket, struct wrepl_packet); 767 if (packet == NULL) return NULL; 768 769 packet->opcode = WREPL_OPCODE_BITS; 770 packet->assoc_ctx = io->in.assoc_ctx; 771 packet->mess_type = WREPL_REPLICATION; 772 packet->message.replication.command = WREPL_REPL_SEND_REQUEST; 773 packet->message.replication.info.owner = io->in.partner; 774 775 req = wrepl_request_send(wrepl_socket, packet, NULL); 776 777 talloc_free(packet); 778 779 return req; 780 } 781 782 /* 783 fetch the names for a WINS partner - recv 784 */ 785 NTSTATUS wrepl_pull_names_recv(struct wrepl_request *req, 786 TALLOC_CTX *mem_ctx, 787 struct wrepl_pull_names *io) 788 { 789 struct wrepl_packet *packet=NULL; 790 NTSTATUS status; 791 int i; 792 793 status = wrepl_request_recv(req, req->wrepl_socket, &packet); 794 NT_STATUS_NOT_OK_RETURN(status); 795 if (packet->mess_type != WREPL_REPLICATION || 796 packet->message.replication.command != WREPL_REPL_SEND_REPLY) { 797 status = NT_STATUS_UNEXPECTED_NETWORK_ERROR; 798 } 799 if (!NT_STATUS_IS_OK(status)) goto failed; 800 801 io->out.num_names = packet->message.replication.info.reply.num_names; 802 803 io->out.names = talloc_array(packet, struct wrepl_name, io->out.num_names); 804 if (io->out.names == NULL) goto nomem; 1035 uint32_t i; 1036 1037 status = wrepl_request_recv(subreq, state, &packet); 1038 TALLOC_FREE(subreq); 1039 if (!NT_STATUS_IS_OK(status)) { 1040 tevent_req_nterror(req, status); 1041 return; 1042 } 1043 1044 if (packet->mess_type != WREPL_REPLICATION) { 1045 tevent_req_nterror(req, NT_STATUS_NETWORK_ACCESS_DENIED); 1046 return; 1047 } 1048 1049 if (packet->message.replication.command != WREPL_REPL_SEND_REPLY) { 1050 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); 1051 return; 1052 } 1053 1054 state->num_names = packet->message.replication.info.reply.num_names; 1055 1056 state->names = talloc_array(state, struct wrepl_name, state->num_names); 1057 if (tevent_req_nomem(state->names, req)) { 1058 return; 1059 } 805 1060 806 1061 /* convert the list of names and addresses to a sane format */ 807 for (i=0; i<io->out.num_names;i++) {1062 for (i=0; i < state->num_names; i++) { 808 1063 struct wrepl_wins_name *wname = &packet->message.replication.info.reply.names[i]; 809 struct wrepl_name *name = & io->out.names[i];1064 struct wrepl_name *name = &state->names[i]; 810 1065 811 1066 name->name = *wname->name; 812 talloc_steal( io->out.names, wname->name);1067 talloc_steal(state->names, wname->name); 813 1068 name->type = WREPL_NAME_TYPE(wname->flags); 814 1069 name->state = WREPL_NAME_STATE(wname->flags); … … 817 1072 name->raw_flags = wname->flags; 818 1073 name->version_id= wname->id; 819 name->owner = talloc_strdup(io->out.names, io->in.partner.address); 820 if (name->owner == NULL) goto nomem; 1074 name->owner = talloc_strdup(state->names, 1075 state->caller.io->in.partner.address); 1076 if (tevent_req_nomem(name->owner, req)) { 1077 return; 1078 } 821 1079 822 1080 /* trying to save 1 or 2 bytes on the wire isn't a good idea */ 823 1081 if (wname->flags & 2) { 824 int j;1082 uint32_t j; 825 1083 826 1084 name->num_addresses = wname->addresses.addresses.num_ips; 827 name->addresses = talloc_array( io->out.names,828 struct wrepl_address, 1085 name->addresses = talloc_array(state->names, 1086 struct wrepl_address, 829 1087 name->num_addresses); 830 if (name->addresses == NULL) goto nomem; 1088 if (tevent_req_nomem(name->addresses, req)) { 1089 return; 1090 } 1091 831 1092 for (j=0;j<name->num_addresses;j++) { 832 name->addresses[j].owner = 833 talloc_ steal(name->addresses,834 1093 name->addresses[j].owner = 1094 talloc_move(name->addresses, 1095 &wname->addresses.addresses.ips[j].owner); 835 1096 name->addresses[j].address = 836 talloc_ steal(name->addresses,837 1097 talloc_move(name->addresses, 1098 &wname->addresses.addresses.ips[j].ip); 838 1099 } 839 1100 } else { 840 1101 name->num_addresses = 1; 841 name->addresses = talloc(io->out.names, struct wrepl_address); 842 if (name->addresses == NULL) goto nomem; 843 name->addresses[0].owner = talloc_strdup(name->addresses,io->in.partner.address); 844 if (name->addresses[0].owner == NULL) goto nomem; 845 name->addresses[0].address = talloc_steal(name->addresses, 846 wname->addresses.ip); 1102 name->addresses = talloc_array(state->names, 1103 struct wrepl_address, 1104 name->num_addresses); 1105 if (tevent_req_nomem(name->addresses, req)) { 1106 return; 1107 } 1108 1109 name->addresses[0].owner = talloc_strdup(name->addresses, name->owner); 1110 if (tevent_req_nomem(name->addresses[0].owner, req)) { 1111 return; 1112 } 1113 name->addresses[0].address = talloc_move(name->addresses, 1114 &wname->addresses.ip); 847 1115 } 848 1116 } 849 1117 850 talloc_steal(mem_ctx, io->out.names); 851 talloc_free(packet); 852 return NT_STATUS_OK; 853 nomem: 854 status = NT_STATUS_NO_MEMORY; 855 failed: 856 talloc_free(packet); 857 return status; 1118 tevent_req_done(req); 1119 } 1120 1121 /* 1122 fetch the names for a WINS partner - recv 1123 */ 1124 NTSTATUS wrepl_pull_names_recv(struct tevent_req *req, 1125 TALLOC_CTX *mem_ctx, 1126 struct wrepl_pull_names *io) 1127 { 1128 struct wrepl_pull_names_state *state = tevent_req_data(req, 1129 struct wrepl_pull_names_state); 1130 NTSTATUS status; 1131 1132 if (tevent_req_is_nterror(req, &status)) { 1133 tevent_req_received(req); 1134 return status; 1135 } 1136 1137 io->out.num_names = state->num_names; 1138 io->out.names = talloc_move(mem_ctx, &state->names); 1139 1140 tevent_req_received(req); 1141 return NT_STATUS_OK; 858 1142 } 859 1143 … … 867 1151 struct wrepl_pull_names *io) 868 1152 { 869 struct wrepl_request *req = wrepl_pull_names_send(wrepl_socket, io); 870 return wrepl_pull_names_recv(req, mem_ctx, io); 871 } 1153 struct tevent_req *subreq; 1154 bool ok; 1155 NTSTATUS status; 1156 1157 subreq = wrepl_pull_names_send(mem_ctx, wrepl_socket->event.ctx, 1158 wrepl_socket, io); 1159 NT_STATUS_HAVE_NO_MEMORY(subreq); 1160 1161 ok = tevent_req_poll(subreq, wrepl_socket->event.ctx); 1162 if (!ok) { 1163 TALLOC_FREE(subreq); 1164 return NT_STATUS_INTERNAL_ERROR; 1165 } 1166 1167 status = wrepl_pull_names_recv(subreq, mem_ctx, io); 1168 TALLOC_FREE(subreq); 1169 NT_STATUS_NOT_OK_RETURN(status); 1170 1171 return NT_STATUS_OK; 1172 } -
vendor/current/source4/libcli/wrepl/winsrepl.h
r414 r740 5 5 6 6 Copyright (C) Andrew Tridgell 2005 7 Copyright (C) Stefan Metzmacher 2005-2010 7 8 8 9 This program is free software; you can redistribute it and/or modify … … 23 24 #include "librpc/gen_ndr/winsrepl.h" 24 25 25 /* 26 main context structure for the wins replication client library 27 */ 28 struct wrepl_socket { 29 struct socket_context *sock; 30 struct packet_context *packet; 31 32 struct { 33 struct tevent_context *ctx; 34 struct tevent_fd *fde; 35 } event; 36 37 /* a queue of replies waiting to be received */ 38 struct wrepl_request *recv_queue; 39 40 /* the default timeout for requests, 0 means no timeout */ 41 #define WREPL_SOCKET_REQUEST_TIMEOUT (60) 42 uint32_t request_timeout; 43 44 /* counter for request timeouts, after 2 timeouts the socket is marked as dead */ 45 uint32_t timeout_count; 46 47 /* remember is the socket is dead */ 48 bool dead; 49 50 /* remember if we need to free the wrepl_socket at the end of wrepl_socket_dead() */ 51 bool free_skipped; 52 53 struct smb_iconv_convenience *iconv_convenience; 54 }; 26 struct wrepl_request; 27 struct wrepl_socket; 55 28 56 29 struct wrepl_send_ctrl { … … 58 31 bool disconnect_after_send; 59 32 }; 60 61 enum wrepl_request_state {62 WREPL_REQUEST_INIT = 0,63 WREPL_REQUEST_RECV = 1,64 WREPL_REQUEST_DONE = 2,65 WREPL_REQUEST_ERROR = 366 };67 68 /*69 a WINS replication request70 */71 struct wrepl_request {72 struct wrepl_request *next, *prev;73 struct wrepl_socket *wrepl_socket;74 75 enum wrepl_request_state state;76 bool trigger;77 NTSTATUS status;78 79 struct tevent_timer *te;80 81 struct wrepl_packet *packet;82 83 struct {84 void (*fn)(struct wrepl_request *);85 void *private_data;86 } async;87 };88 89 33 90 34 /* … … 130 74 (is_static ? WREPL_FLAGS_IS_STATIC : 0)) 131 75 76 struct wrepl_address { 77 const char *owner; 78 const char *address; 79 }; 80 81 struct wrepl_name { 82 struct nbt_name name; 83 enum wrepl_name_type type; 84 enum wrepl_name_state state; 85 enum wrepl_name_node node; 86 bool is_static; 87 uint32_t raw_flags; 88 uint64_t version_id; 89 const char *owner; 90 uint32_t num_addresses; 91 struct wrepl_address *addresses; 92 }; 93 132 94 /* 133 95 a full pull replication … … 140 102 struct { 141 103 uint32_t num_names; 142 struct wrepl_name { 143 struct nbt_name name; 144 enum wrepl_name_type type; 145 enum wrepl_name_state state; 146 enum wrepl_name_node node; 147 bool is_static; 148 uint32_t raw_flags; 149 uint64_t version_id; 150 const char *owner; 151 uint32_t num_addresses; 152 struct wrepl_address { 153 const char *owner; 154 const char *address; 155 } *addresses; 156 } *names; 104 struct wrepl_name *names; 157 105 } out; 158 106 }; 159 107 160 struct resolve_context;108 struct tstream_context; 161 109 162 110 #include "libcli/wrepl/winsrepl_proto.h"
Note:
See TracChangeset
for help on using the changeset viewer.