| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Licensed Materials - Property of IBM | 3 * Licensed Materials - Property of IBM |
| 4 * | 4 * |
| 5 * trousers - An open source TCG Software Stack | 5 * trousers - An open source TCG Software Stack |
| 6 * | 6 * |
| 7 * (C) Copyright International Business Machines Corp. 2004-2007 | 7 * (C) Copyright International Business Machines Corp. 2004-2007 |
| 8 * | 8 * |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 {tcs_wrap_CMK_CreateBlob,"CMK_CreateBlob"}, | 509 {tcs_wrap_CMK_CreateBlob,"CMK_CreateBlob"}, |
| 510 {tcs_wrap_CMK_ConvertMigration,"CMK_ConvertMigration"}, | 510 {tcs_wrap_CMK_ConvertMigration,"CMK_ConvertMigration"}, |
| 511 {tcs_wrap_FlushSpecific,"FlushSpecific"}, /* 120 */ | 511 {tcs_wrap_FlushSpecific,"FlushSpecific"}, /* 120 */ |
| 512 {tcs_wrap_KeyControlOwner, "KeyControlOwner"}, | 512 {tcs_wrap_KeyControlOwner, "KeyControlOwner"}, |
| 513 {tcs_wrap_DSAP, "DSAP"} | 513 {tcs_wrap_DSAP, "DSAP"} |
| 514 }; | 514 }; |
| 515 | 515 |
| 516 int | 516 int |
| 517 access_control(struct tcsd_thread_data *thread_data) | 517 access_control(struct tcsd_thread_data *thread_data) |
| 518 { | 518 { |
| 519 » int i = 0; | 519 » // Unix domain socket, so just allow |
| 520 » struct hostent *local_hostent = NULL; | 520 » return 0; |
| 521 » static char *localhostname = NULL; | |
| 522 » static int localhostname_len = 0; | |
| 523 | |
| 524 » if (!localhostname) { | |
| 525 » » if ((local_hostent = gethostbyname("localhost")) == NULL) { | |
| 526 » » » LogError("Error resolving localhost: %s", hstrerror(h_er
rno)); | |
| 527 » » » return 1; | |
| 528 » » } | |
| 529 | |
| 530 » » LogDebugFn("Cached local hostent:"); | |
| 531 » » LogDebugFn("h_name: %s", local_hostent->h_name); | |
| 532 » » for (i = 0; local_hostent->h_aliases[i]; i++) { | |
| 533 » » » LogDebugFn("h_aliases[%d]: %s", i, local_hostent->h_alia
ses[i]); | |
| 534 » » } | |
| 535 » » LogDebugFn("h_addrtype: %s", | |
| 536 » » » (local_hostent->h_addrtype == AF_INET6 ? "AF_INET6" :
"AF_INET")); | |
| 537 | |
| 538 » » localhostname_len = strlen(local_hostent->h_name); | |
| 539 » » if ((localhostname = strdup(local_hostent->h_name)) == NULL) { | |
| 540 » » » LogError("malloc of %d bytes failed.", localhostname_len
); | |
| 541 » » » return TCSERR(TSS_E_OUTOFMEMORY); | |
| 542 » » } | |
| 543 » } | |
| 544 | |
| 545 » /* if the request comes from localhost, or is in the accepted ops list, | |
| 546 » * approve it */ | |
| 547 » if (!strncmp(thread_data->hostname, localhostname, | |
| 548 » » MIN((size_t)localhostname_len, strlen(thread_data->hostname
)))) { | |
| 549 » » return 0; | |
| 550 » } else { | |
| 551 » » while (tcsd_options.remote_ops[i]) { | |
| 552 » » » if ((UINT32)tcsd_options.remote_ops[i] == thread_data->c
omm.hdr.u.ordinal) { | |
| 553 » » » » LogInfo("Accepted %s operation from %s", | |
| 554 » » » » » tcs_func_table[thread_data->comm.hdr.u.o
rdinal].name, | |
| 555 » » » » » thread_data->hostname); | |
| 556 » » » » return 0; | |
| 557 » » » } | |
| 558 » » » i++; | |
| 559 » » } | |
| 560 » } | |
| 561 | |
| 562 » return 1; | |
| 563 } | 521 } |
| 564 | 522 |
| 565 TSS_RESULT | 523 TSS_RESULT |
| 566 dispatchCommand(struct tcsd_thread_data *data) | 524 dispatchCommand(struct tcsd_thread_data *data) |
| 567 { | 525 { |
| 568 UINT64 offset; | 526 UINT64 offset; |
| 569 TSS_RESULT result; | 527 TSS_RESULT result; |
| 570 | 528 |
| 571 /* First, check the ordinal bounds */ | 529 /* First, check the ordinal bounds */ |
| 572 if (data->comm.hdr.u.ordinal >= TCSD_MAX_NUM_ORDS) { | 530 if (data->comm.hdr.u.ordinal >= TCSD_MAX_NUM_ORDS) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 { | 575 { |
| 618 /* make sure the all the data is present */ | 576 /* make sure the all the data is present */ |
| 619 if (data->comm.hdr.num_parms > 0 && | 577 if (data->comm.hdr.num_parms > 0 && |
| 620 data->comm.hdr.packet_size != | 578 data->comm.hdr.packet_size != |
| 621 (UINT32)(data->comm.hdr.parm_offset + data->comm.hdr.parm_size)) | 579 (UINT32)(data->comm.hdr.parm_offset + data->comm.hdr.parm_size)) |
| 622 return TCSERR(TSS_E_INTERNAL_ERROR); | 580 return TCSERR(TSS_E_INTERNAL_ERROR); |
| 623 | 581 |
| 624 /* dispatch the command to the TCS */ | 582 /* dispatch the command to the TCS */ |
| 625 return dispatchCommand(data); | 583 return dispatchCommand(data); |
| 626 } | 584 } |
| OLD | NEW |