Changeset 745 for trunk/server/source3/libsmb/clifsinfo.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libsmb/clifsinfo.c
r414 r745 4 4 Copyright (C) Stefan (metze) Metzmacher 2003 5 5 Copyright (C) Jeremy Allison 2007 6 6 7 7 This program is free software; you can redistribute it and/or modify 8 8 it under the terms of the GNU General Public License as published by 9 9 the Free Software Foundation; either version 3 of the License, or 10 10 (at your option) any later version. 11 11 12 12 This program is distributed in the hope that it will be useful, 13 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 GNU General Public License for more details. 16 16 17 17 You should have received a copy of the GNU General Public License 18 18 along with this program. If not, see <http://www.gnu.org/licenses/>. … … 20 20 21 21 #include "includes.h" 22 #include "libsmb/libsmb.h" 22 23 #include "../libcli/auth/spnego.h" 24 #include "../libcli/auth/ntlmssp.h" 25 #include "../lib/util/tevent_ntstatus.h" 26 #include "async_smb.h" 27 #include "smb_crypt.h" 28 #include "trans2.h" 23 29 24 30 /**************************************************************************** … … 27 33 28 34 struct cli_unix_extensions_version_state { 35 struct cli_state *cli; 29 36 uint16_t setup[1]; 30 37 uint8_t param[2]; … … 47 54 return NULL; 48 55 } 56 state->cli = cli; 49 57 SSVAL(state->setup, 0, TRANSACT2_QFSINFO); 50 58 SSVAL(state->param, 0, SMB_QUERY_CIFS_UNIX_INFO); … … 72 80 NTSTATUS status; 73 81 74 status = cli_trans_recv(subreq, state, NULL, NULL, NULL, NULL,75 &data, &num_data);82 status = cli_trans_recv(subreq, state, NULL, NULL, 0, NULL, 83 NULL, 0, NULL, &data, 12, &num_data); 76 84 TALLOC_FREE(subreq); 77 85 if (!NT_STATUS_IS_OK(status)) { 78 86 tevent_req_nterror(req, status); 79 return;80 }81 if (num_data < 12) {82 tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);83 87 return; 84 88 } … … 108 112 *pcaplow = state->caplow; 109 113 *pcaphigh = state->caphigh; 114 state->cli->server_posix_capabilities = *pcaplow; 110 115 return NT_STATUS_OK; 111 116 } … … 147 152 status = cli_unix_extensions_version_recv(req, pmajor, pminor, pcaplow, 148 153 pcaphigh); 149 if (NT_STATUS_IS_OK(status)) {150 cli->posix_capabilities = *pcaplow;151 }152 154 fail: 153 155 TALLOC_FREE(frame); … … 162 164 ****************************************************************************/ 163 165 164 bool cli_set_unix_extensions_capabilities(struct cli_state *cli, uint16 major, uint16 minor, 165 uint32 caplow, uint32 caphigh) 166 { 167 bool ret = False; 168 uint16 setup; 169 char param[4]; 170 char data[12]; 171 char *rparam=NULL, *rdata=NULL; 172 unsigned int rparam_count=0, rdata_count=0; 173 174 setup = TRANSACT2_SETFSINFO; 175 176 SSVAL(param,0,0); 177 SSVAL(param,2,SMB_SET_CIFS_UNIX_INFO); 178 179 SSVAL(data,0,major); 180 SSVAL(data,2,minor); 181 SIVAL(data,4,caplow); 182 SIVAL(data,8,caphigh); 183 184 if (!cli_send_trans(cli, SMBtrans2, 185 NULL, 186 0, 0, 187 &setup, 1, 0, 188 param, 4, 0, 189 data, 12, 560)) { 190 goto cleanup; 191 } 192 193 if (!cli_receive_trans(cli, SMBtrans2, 194 &rparam, &rparam_count, 195 &rdata, &rdata_count)) { 196 goto cleanup; 197 } 198 199 if (cli_is_error(cli)) { 200 ret = False; 201 goto cleanup; 202 } else { 203 ret = True; 204 } 205 206 cleanup: 207 SAFE_FREE(rparam); 208 SAFE_FREE(rdata); 209 210 return ret; 211 } 212 213 bool cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr) 214 { 215 bool ret = False; 216 uint16 setup; 217 char param[2]; 218 char *rparam=NULL, *rdata=NULL; 219 unsigned int rparam_count=0, rdata_count=0; 220 221 if (!cli||!fs_attr) 222 smb_panic("cli_get_fs_attr_info() called with NULL Pionter!"); 223 224 setup = TRANSACT2_QFSINFO; 225 226 SSVAL(param,0,SMB_QUERY_FS_ATTRIBUTE_INFO); 227 228 if (!cli_send_trans(cli, SMBtrans2, 229 NULL, 230 0, 0, 231 &setup, 1, 0, 232 param, 2, 0, 233 NULL, 0, 560)) { 234 goto cleanup; 235 } 236 237 if (!cli_receive_trans(cli, SMBtrans2, 238 &rparam, &rparam_count, 239 &rdata, &rdata_count)) { 240 goto cleanup; 241 } 242 243 if (cli_is_error(cli)) { 244 ret = False; 245 goto cleanup; 246 } else { 247 ret = True; 248 } 249 250 if (rdata_count < 12) { 251 goto cleanup; 252 } 253 254 *fs_attr = IVAL(rdata,0); 166 struct cli_set_unix_extensions_capabilities_state { 167 struct cli_state *cli; 168 uint16_t setup[1]; 169 uint8_t param[4]; 170 uint8_t data[12]; 171 }; 172 173 static void cli_set_unix_extensions_capabilities_done( 174 struct tevent_req *subreq); 175 176 struct tevent_req *cli_set_unix_extensions_capabilities_send( 177 TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct cli_state *cli, 178 uint16_t major, uint16_t minor, uint32_t caplow, uint32_t caphigh) 179 { 180 struct tevent_req *req, *subreq; 181 struct cli_set_unix_extensions_capabilities_state *state; 182 183 req = tevent_req_create( 184 mem_ctx, &state, 185 struct cli_set_unix_extensions_capabilities_state); 186 if (req == NULL) { 187 return NULL; 188 } 189 190 state->cli = cli; 191 SSVAL(state->setup+0, 0, TRANSACT2_SETFSINFO); 192 193 SSVAL(state->param, 0, 0); 194 SSVAL(state->param, 2, SMB_SET_CIFS_UNIX_INFO); 195 196 SSVAL(state->data, 0, major); 197 SSVAL(state->data, 2, minor); 198 SIVAL(state->data, 4, caplow); 199 SIVAL(state->data, 8, caphigh); 200 201 subreq = cli_trans_send(state, ev, cli, SMBtrans2, 202 NULL, 0, 0, 0, 203 state->setup, 1, 0, 204 state->param, 4, 0, 205 state->data, 12, 560); 206 if (tevent_req_nomem(subreq, req)) { 207 return tevent_req_post(req, ev); 208 } 209 tevent_req_set_callback( 210 subreq, cli_set_unix_extensions_capabilities_done, req); 211 return req; 212 } 213 214 static void cli_set_unix_extensions_capabilities_done( 215 struct tevent_req *subreq) 216 { 217 struct tevent_req *req = tevent_req_callback_data( 218 subreq, struct tevent_req); 219 struct cli_set_unix_extensions_capabilities_state *state = tevent_req_data( 220 req, struct cli_set_unix_extensions_capabilities_state); 221 222 NTSTATUS status = cli_trans_recv(subreq, NULL, NULL, NULL, 0, NULL, 223 NULL, 0, NULL, NULL, 0, NULL); 224 if (NT_STATUS_IS_OK(status)) { 225 state->cli->requested_posix_capabilities = IVAL(state->data, 4); 226 } 227 tevent_req_simple_finish_ntstatus(subreq, status); 228 } 229 230 NTSTATUS cli_set_unix_extensions_capabilities_recv(struct tevent_req *req) 231 { 232 return tevent_req_simple_recv_ntstatus(req); 233 } 234 235 NTSTATUS cli_set_unix_extensions_capabilities(struct cli_state *cli, 236 uint16 major, uint16 minor, 237 uint32 caplow, uint32 caphigh) 238 { 239 struct tevent_context *ev; 240 struct tevent_req *req; 241 NTSTATUS status = NT_STATUS_NO_MEMORY; 242 243 if (cli_has_async_calls(cli)) { 244 return NT_STATUS_INVALID_PARAMETER; 245 } 246 ev = tevent_context_init(talloc_tos()); 247 if (ev == NULL) { 248 goto fail; 249 } 250 req = cli_set_unix_extensions_capabilities_send( 251 ev, ev, cli, major, minor, caplow, caphigh); 252 if (req == NULL) { 253 goto fail; 254 } 255 if (!tevent_req_poll_ntstatus(req, ev, &status)) { 256 goto fail; 257 } 258 status = cli_set_unix_extensions_capabilities_recv(req); 259 fail: 260 TALLOC_FREE(ev); 261 if (!NT_STATUS_IS_OK(status)) { 262 cli_set_error(cli, status); 263 } 264 return status; 265 } 266 267 struct cli_get_fs_attr_info_state { 268 uint16_t setup[1]; 269 uint8_t param[2]; 270 uint32_t fs_attr; 271 }; 272 273 static void cli_get_fs_attr_info_done(struct tevent_req *subreq); 274 275 struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx, 276 struct tevent_context *ev, 277 struct cli_state *cli) 278 { 279 struct tevent_req *subreq, *req; 280 struct cli_get_fs_attr_info_state *state; 281 282 req = tevent_req_create(mem_ctx, &state, 283 struct cli_get_fs_attr_info_state); 284 if (req == NULL) { 285 return NULL; 286 } 287 SSVAL(state->setup+0, 0, TRANSACT2_QFSINFO); 288 SSVAL(state->param+0, 0, SMB_QUERY_FS_ATTRIBUTE_INFO); 289 290 subreq = cli_trans_send(state, ev, cli, SMBtrans2, 291 NULL, 0, 0, 0, 292 state->setup, 1, 0, 293 state->param, 2, 0, 294 NULL, 0, 560); 295 if (tevent_req_nomem(subreq, req)) { 296 return tevent_req_post(req, ev); 297 } 298 tevent_req_set_callback(subreq, cli_get_fs_attr_info_done, req); 299 return req; 300 } 301 302 static void cli_get_fs_attr_info_done(struct tevent_req *subreq) 303 { 304 struct tevent_req *req = tevent_req_callback_data( 305 subreq, struct tevent_req); 306 struct cli_get_fs_attr_info_state *state = tevent_req_data( 307 req, struct cli_get_fs_attr_info_state); 308 uint8_t *data; 309 uint32_t num_data; 310 NTSTATUS status; 311 312 status = cli_trans_recv(subreq, talloc_tos(), NULL, NULL, 0, NULL, 313 NULL, 0, NULL, &data, 12, &num_data); 314 TALLOC_FREE(subreq); 315 if (!NT_STATUS_IS_OK(status)) { 316 tevent_req_nterror(req, status); 317 return; 318 } 319 state->fs_attr = IVAL(data, 0); 320 TALLOC_FREE(data); 321 tevent_req_done(req); 322 } 323 324 NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr) 325 { 326 struct cli_get_fs_attr_info_state *state = tevent_req_data( 327 req, struct cli_get_fs_attr_info_state); 328 NTSTATUS status; 329 330 if (tevent_req_is_nterror(req, &status)) { 331 return status; 332 } 333 *fs_attr = state->fs_attr; 334 return NT_STATUS_OK; 335 } 336 337 NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr) 338 { 339 struct tevent_context *ev; 340 struct tevent_req *req; 341 NTSTATUS status = NT_STATUS_NO_MEMORY; 342 343 if (cli_has_async_calls(cli)) { 344 return NT_STATUS_INVALID_PARAMETER; 345 } 346 ev = tevent_context_init(talloc_tos()); 347 if (ev == NULL) { 348 goto fail; 349 } 350 req = cli_get_fs_attr_info_send(ev, ev, cli); 351 if (req == NULL) { 352 goto fail; 353 } 354 if (!tevent_req_poll_ntstatus(req, ev, &status)) { 355 goto fail; 356 } 357 status = cli_get_fs_attr_info_recv(req, fs_attr); 358 fail: 359 TALLOC_FREE(ev); 360 if (!NT_STATUS_IS_OK(status)) { 361 cli_set_error(cli, status); 362 } 363 return status; 364 } 365 366 NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, 367 uint32 *pserial_number, time_t *pdate) 368 { 369 NTSTATUS status; 370 uint16 setup[1]; 371 uint8_t param[2]; 372 uint8_t *rdata; 373 uint32_t rdata_count; 374 unsigned int nlen; 375 376 SSVAL(setup, 0, TRANSACT2_QFSINFO); 377 SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO); 378 379 status = cli_trans(talloc_tos(), cli, SMBtrans2, 380 NULL, 0, 0, 0, 381 setup, 1, 0, 382 param, 2, 0, 383 NULL, 0, 560, 384 NULL, 385 NULL, 0, NULL, 386 NULL, 0, NULL, 387 &rdata, 10, &rdata_count); 388 if (!NT_STATUS_IS_OK(status)) { 389 return status; 390 } 391 392 if (pdate) { 393 struct timespec ts; 394 ts = interpret_long_date((char *)rdata); 395 *pdate = ts.tv_sec; 396 } 397 if (pserial_number) { 398 *pserial_number = IVAL(rdata,8); 399 } 400 nlen = IVAL(rdata,12); 401 clistr_pull(cli->inbuf, volume_name, rdata + 18, sizeof(fstring), 402 nlen, STR_UNICODE); 255 403 256 404 /* todo: but not yet needed … … 258 406 */ 259 407 260 cleanup: 261 SAFE_FREE(rparam); 262 SAFE_FREE(rdata); 263 264 return ret; 265 } 266 267 bool cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number) 268 { 269 bool ret = False; 270 uint16 setup; 271 char param[2]; 272 char *rparam=NULL, *rdata=NULL; 273 unsigned int rparam_count=0, rdata_count=0; 274 unsigned char nlen; 275 276 setup = TRANSACT2_QFSINFO; 277 278 SSVAL(param,0,SMB_INFO_VOLUME); 279 280 if (!cli_send_trans(cli, SMBtrans2, 281 NULL, 282 0, 0, 283 &setup, 1, 0, 284 param, 2, 0, 285 NULL, 0, 560)) { 286 goto cleanup; 287 } 288 289 if (!cli_receive_trans(cli, SMBtrans2, 290 &rparam, &rparam_count, 291 &rdata, &rdata_count)) { 292 goto cleanup; 293 } 294 295 if (cli_is_error(cli)) { 296 ret = False; 297 goto cleanup; 298 } else { 299 ret = True; 300 } 301 302 if (rdata_count < 5) { 303 goto cleanup; 304 } 305 306 if (pserial_number) { 307 *pserial_number = IVAL(rdata,0); 308 } 309 nlen = CVAL(rdata,l2_vol_cch); 310 clistr_pull(cli->inbuf, volume_name, rdata + l2_vol_szVolLabel, 311 sizeof(fstring), nlen, STR_NOALIGN); 312 313 /* todo: but not yet needed 314 * return the other stuff 315 */ 316 317 cleanup: 318 SAFE_FREE(rparam); 319 SAFE_FREE(rdata); 320 321 return ret; 322 } 323 324 bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate) 325 { 326 bool ret = False; 327 uint16 setup; 328 char param[2]; 329 char *rparam=NULL, *rdata=NULL; 330 unsigned int rparam_count=0, rdata_count=0; 331 unsigned int nlen; 332 333 setup = TRANSACT2_QFSINFO; 334 335 SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO); 336 337 if (!cli_send_trans(cli, SMBtrans2, 338 NULL, 339 0, 0, 340 &setup, 1, 0, 341 param, 2, 0, 342 NULL, 0, 560)) { 343 goto cleanup; 344 } 345 346 if (!cli_receive_trans(cli, SMBtrans2, 347 &rparam, &rparam_count, 348 &rdata, &rdata_count)) { 349 goto cleanup; 350 } 351 352 if (cli_is_error(cli)) { 353 ret = False; 354 goto cleanup; 355 } else { 356 ret = True; 357 } 358 359 if (rdata_count < 19) { 360 goto cleanup; 361 } 362 363 if (pdate) { 364 struct timespec ts; 365 ts = interpret_long_date(rdata); 366 *pdate = ts.tv_sec; 367 } 368 if (pserial_number) { 369 *pserial_number = IVAL(rdata,8); 370 } 371 nlen = IVAL(rdata,12); 372 clistr_pull(cli->inbuf, volume_name, rdata + 18, sizeof(fstring), 373 nlen, STR_UNICODE); 374 375 /* todo: but not yet needed 376 * return the other stuff 377 */ 378 379 cleanup: 380 SAFE_FREE(rparam); 381 SAFE_FREE(rdata); 382 383 return ret; 384 } 385 386 bool cli_get_fs_full_size_info(struct cli_state *cli, 387 uint64_t *total_allocation_units, 388 uint64_t *caller_allocation_units, 389 uint64_t *actual_allocation_units, 390 uint64_t *sectors_per_allocation_unit, 391 uint64_t *bytes_per_sector) 392 { 393 bool ret = False; 394 uint16 setup; 395 char param[2]; 396 char *rparam=NULL, *rdata=NULL; 397 unsigned int rparam_count=0, rdata_count=0; 398 399 setup = TRANSACT2_QFSINFO; 400 401 SSVAL(param,0,SMB_FS_FULL_SIZE_INFORMATION); 402 403 if (!cli_send_trans(cli, SMBtrans2, 404 NULL, 405 0, 0, 406 &setup, 1, 0, 407 param, 2, 0, 408 NULL, 0, 560)) { 409 goto cleanup; 410 } 411 412 if (!cli_receive_trans(cli, SMBtrans2, 413 &rparam, &rparam_count, 414 &rdata, &rdata_count)) { 415 goto cleanup; 416 } 417 418 if (cli_is_error(cli)) { 419 ret = False; 420 goto cleanup; 421 } else { 422 ret = True; 423 } 424 425 if (rdata_count != 32) { 426 goto cleanup; 408 TALLOC_FREE(rdata); 409 return NT_STATUS_OK; 410 } 411 412 NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli, 413 uint64_t *total_allocation_units, 414 uint64_t *caller_allocation_units, 415 uint64_t *actual_allocation_units, 416 uint64_t *sectors_per_allocation_unit, 417 uint64_t *bytes_per_sector) 418 { 419 uint16 setup[1]; 420 uint8_t param[2]; 421 uint8_t *rdata = NULL; 422 uint32_t rdata_count; 423 NTSTATUS status; 424 425 SSVAL(setup, 0, TRANSACT2_QFSINFO); 426 SSVAL(param, 0, SMB_FS_FULL_SIZE_INFORMATION); 427 428 status = cli_trans(talloc_tos(), cli, SMBtrans2, 429 NULL, 0, 0, 0, 430 setup, 1, 0, /* setup */ 431 param, 2, 0, /* param */ 432 NULL, 0, 560, /* data */ 433 NULL, 434 NULL, 0, NULL, /* rsetup */ 435 NULL, 0, NULL, /* rparam */ 436 &rdata, 32, &rdata_count); /* rdata */ 437 if (!NT_STATUS_IS_OK(status)) { 438 goto fail; 427 439 } 428 440 … … 443 455 } 444 456 445 cleanup: 446 SAFE_FREE(rparam); 447 SAFE_FREE(rdata); 448 449 return ret; 450 } 451 452 bool cli_get_posix_fs_info(struct cli_state *cli, 453 uint32 *optimal_transfer_size, 454 uint32 *block_size, 455 uint64_t *total_blocks, 456 uint64_t *blocks_available, 457 uint64_t *user_blocks_available, 458 uint64_t *total_file_nodes, 459 uint64_t *free_file_nodes, 460 uint64_t *fs_identifier) 461 { 462 bool ret = False; 463 uint16 setup; 464 char param[2]; 465 char *rparam=NULL, *rdata=NULL; 466 unsigned int rparam_count=0, rdata_count=0; 467 468 setup = TRANSACT2_QFSINFO; 469 457 fail: 458 TALLOC_FREE(rdata); 459 return status; 460 } 461 462 NTSTATUS cli_get_posix_fs_info(struct cli_state *cli, 463 uint32 *optimal_transfer_size, 464 uint32 *block_size, 465 uint64_t *total_blocks, 466 uint64_t *blocks_available, 467 uint64_t *user_blocks_available, 468 uint64_t *total_file_nodes, 469 uint64_t *free_file_nodes, 470 uint64_t *fs_identifier) 471 { 472 uint16 setup[1]; 473 uint8_t param[2]; 474 uint8_t *rdata = NULL; 475 uint32_t rdata_count; 476 NTSTATUS status; 477 478 SSVAL(setup, 0, TRANSACT2_QFSINFO); 470 479 SSVAL(param,0,SMB_QUERY_POSIX_FS_INFO); 471 480 472 if (!cli_send_trans(cli, SMBtrans2, 473 NULL, 474 0, 0, 475 &setup, 1, 0, 476 param, 2, 0, 477 NULL, 0, 560)) { 478 goto cleanup; 479 } 480 481 if (!cli_receive_trans(cli, SMBtrans2, 482 &rparam, &rparam_count, 483 &rdata, &rdata_count)) { 484 goto cleanup; 485 } 486 487 if (cli_is_error(cli)) { 488 ret = False; 489 goto cleanup; 490 } else { 491 ret = True; 492 } 493 494 if (rdata_count != 56) { 495 goto cleanup; 481 status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, 0, 0, 0, 482 setup, 1, 0, 483 param, 2, 0, 484 NULL, 0, 560, 485 NULL, 486 NULL, 0, NULL, /* rsetup */ 487 NULL, 0, NULL, /* rparam */ 488 &rdata, 56, &rdata_count); 489 if (!NT_STATUS_IS_OK(status)) { 490 return status; 496 491 } 497 492 … … 520 515 *fs_identifier = BIG_UINT(rdata,48); 521 516 } 522 523 cleanup: 524 SAFE_FREE(rparam); 525 SAFE_FREE(rdata); 526 527 return ret; 517 return NT_STATUS_OK; 528 518 } 529 519 … … 535 525 static NTSTATUS enc_blob_send_receive(struct cli_state *cli, DATA_BLOB *in, DATA_BLOB *out, DATA_BLOB *param_out) 536 526 { 537 uint16 setup; 538 char param[4]; 539 char *rparam=NULL, *rdata=NULL; 540 unsigned int rparam_count=0, rdata_count=0; 541 NTSTATUS status = NT_STATUS_OK; 542 543 setup = TRANSACT2_SETFSINFO; 544 527 uint16_t setup[1]; 528 uint8_t param[4]; 529 uint8_t *rparam=NULL, *rdata=NULL; 530 uint32_t num_rparam, num_rdata; 531 NTSTATUS status; 532 533 SSVAL(setup+0, 0, TRANSACT2_SETFSINFO); 545 534 SSVAL(param,0,0); 546 535 SSVAL(param,2,SMB_REQUEST_TRANSPORT_ENCRYPTION); 547 536 548 if (!cli_send_trans(cli, SMBtrans2, 549 NULL, 550 0, 0, 551 &setup, 1, 0, 552 param, 4, 0, 553 (char *)in->data, in->length, CLI_BUFFER_SIZE)) { 554 status = cli_nt_error(cli); 555 goto out; 556 } 557 558 if (!cli_receive_trans(cli, SMBtrans2, 559 &rparam, &rparam_count, 560 &rdata, &rdata_count)) { 561 status = cli_nt_error(cli); 562 goto out; 563 } 564 565 if (cli_is_error(cli)) { 566 status = cli_nt_error(cli); 567 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { 568 goto out; 569 } 570 } 571 572 *out = data_blob(rdata, rdata_count); 573 *param_out = data_blob(rparam, rparam_count); 574 575 out: 576 577 SAFE_FREE(rparam); 578 SAFE_FREE(rdata); 537 status = cli_trans(talloc_tos(), cli, SMBtrans2, NULL, 0, 0, 0, 538 setup, 1, 0, 539 param, 4, 2, 540 (uint8_t *)in->data, in->length, CLI_BUFFER_SIZE, 541 NULL, /* recv_flags */ 542 NULL, 0, NULL, /* rsetup */ 543 &rparam, 0, &num_rparam, 544 &rdata, 0, &num_rdata); 545 546 if (!NT_STATUS_IS_OK(status) && 547 !NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { 548 return status; 549 } 550 551 *out = data_blob(rdata, num_rdata); 552 *param_out = data_blob(rparam, num_rparam); 553 554 TALLOC_FREE(rparam); 555 TALLOC_FREE(rdata); 579 556 return status; 580 557 } … … 625 602 return NT_STATUS_NO_MEMORY; 626 603 } 627 status = ntlmssp_client_start(&es->s.ntlmssp_state); 604 status = ntlmssp_client_start(NULL, 605 global_myname(), 606 lp_workgroup(), 607 lp_client_ntlmv2_auth(), 608 &es->s.ntlmssp_state); 628 609 if (!NT_STATUS_IS_OK(status)) { 629 610 goto fail; … … 693 674 ******************************************************************************/ 694 675 695 static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es, 676 static NTSTATUS make_cli_gss_blob(TALLOC_CTX *ctx, 677 struct smb_trans_enc_state *es, 696 678 const char *service, 697 679 const char *host, … … 740 722 } else { 741 723 /* Remove the SPNEGO wrapper */ 742 if (!spnego_parse_auth_response( spnego_blob_in, status_in, OID_KERBEROS5, &blob_in)) {724 if (!spnego_parse_auth_response(ctx, spnego_blob_in, status_in, OID_KERBEROS5, &blob_in)) { 743 725 status = NT_STATUS_UNSUCCESSFUL; 744 726 goto fail; … … 775 757 } 776 758 777 blob_out = data_blob (tok_out.value, tok_out.length);759 blob_out = data_blob_talloc(ctx, tok_out.value, tok_out.length); 778 760 779 761 /* Wrap in an SPNEGO wrapper */ 780 *p_blob_out = gen_negTokenTarg(krb_mechs, blob_out);762 *p_blob_out = spnego_gen_negTokenInit(ctx, krb_mechs, &blob_out, NULL); 781 763 782 764 fail: … … 814 796 815 797 servicename = "cifs"; 816 status = make_cli_gss_blob( es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);798 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send); 817 799 if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) { 818 800 servicename = "host"; 819 status = make_cli_gss_blob( es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send);801 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, NT_STATUS_OK, blob_recv, &blob_send); 820 802 if (!NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) { 821 803 goto fail; … … 830 812 } 831 813 data_blob_free(&blob_send); 832 status = make_cli_gss_blob( es, servicename, fqdn, status, blob_recv, &blob_send);814 status = make_cli_gss_blob(talloc_tos(), es, servicename, fqdn, status, blob_recv, &blob_send); 833 815 } while (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)); 834 816 data_blob_free(&blob_recv);
Note:
See TracChangeset
for help on using the changeset viewer.