286
286
tmp_int = atoi(arg);
287
287
if (tmp_int < 0 || tmp_int > 65535) {
288
288
LogError("Config option \"port\" out of range. %s:%d: \"%d\"",
289
TCSD_CONFIG_FILE, line_num, tmp_int);
289
tcsd_config_file, line_num, tmp_int);
290
290
return TCSERR(TSS_E_INTERNAL_ERROR);
292
292
conf->port = tmp_int;
297
297
tmp_int = atoi(arg);
298
298
if (tmp_int <= 0) {
299
299
LogError("Config option \"num_threads\" out of range. %s:%d: \"%d\"",
300
TCSD_CONFIG_FILE, line_num, tmp_int);
300
tcsd_config_file, line_num, tmp_int);
301
301
return TCSERR(TSS_E_INTERNAL_ERROR);
303
303
conf->num_threads = tmp_int;
319
319
conf->firmware_pcrs |= (1 << tmp_int);
321
321
LogError("Config option \"firmware_pcrs\" is out of range."
322
"%s:%d: \"%d\"", TCSD_CONFIG_FILE, line_num,
322
"%s:%d: \"%d\"", tcsd_config_file, line_num,
330
330
conf->firmware_pcrs |= (1 << tmp_int);
332
332
LogError("Config option \"firmware_pcrs\" is out of range. "
333
"%s:%d: \"%d\"", TCSD_CONFIG_FILE, line_num, tmp_int);
333
"%s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int);
336
336
case opt_kernel_pcrs:
348
348
conf->kernel_pcrs |= (1 << tmp_int);
350
350
LogError("Config option \"kernel_pcrs\" is out of range. "
351
"%s:%d: \"%d\"", TCSD_CONFIG_FILE, line_num,
351
"%s:%d: \"%d\"", tcsd_config_file, line_num,
359
359
conf->kernel_pcrs |= (1 << tmp_int);
361
361
LogError("Config option \"kernel_pcrs\" is out of range. "
362
"%s:%d: \"%d\"", TCSD_CONFIG_FILE, line_num, tmp_int);
362
"%s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int);
365
365
case opt_system_ps_file:
366
366
if (*arg != '/') {
367
367
LogError("Config option \"system_ps_dir\" must be an absolute path name. "
368
"%s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, arg);
368
"%s:%d: \"%s\"", tcsd_config_file, line_num, arg);
373
373
if ((rc = get_file_path(arg, &tmp_ptr)) < 0) {
374
374
LogError("Config option \"system_ps_file\" is invalid."
375
" %s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, arg);
375
" %s:%d: \"%s\"", tcsd_config_file, line_num, arg);
376
376
return TCSERR(TSS_E_INTERNAL_ERROR);
377
377
} else if (rc > 0) {
378
378
LogError("Config option \"system_ps_file\" is invalid. %s:%d:"
379
" \"%s\"", TCSD_CONFIG_FILE, line_num, tmp_ptr);
379
" \"%s\"", tcsd_config_file, line_num, tmp_ptr);
380
380
return TCSERR(TSS_E_INTERNAL_ERROR);
382
382
if (tmp_ptr == NULL)
408
408
case opt_kernel_log:
409
409
if (*arg != '/') {
410
410
LogError("Config option \"kernel_log\" must be an absolute path name."
411
" %s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, arg);
411
" %s:%d: \"%s\"", tcsd_config_file, line_num, arg);
415
415
if ((rc = get_file_path(arg, &tmp_ptr)) < 0) {
416
416
LogError("Config option \"kernel_log\" is invalid. %s:%d: \"%s\"",
417
TCSD_CONFIG_FILE, line_num, arg);
417
tcsd_config_file, line_num, arg);
418
418
return TCSERR(TSS_E_INTERNAL_ERROR);
419
419
} else if (rc > 0) {
420
420
LogError("Config option \"kernel_log\" is invalid. %s:%d: \"%s\"",
421
TCSD_CONFIG_FILE, line_num, tmp_ptr);
421
tcsd_config_file, line_num, tmp_ptr);
422
422
return TCSERR(TSS_E_INTERNAL_ERROR);
424
424
if (tmp_ptr == NULL)
434
434
case opt_firmware_log:
435
435
if (*arg != '/') {
436
436
LogError("Config option \"firmware_log\" must be an absolute path name."
437
" %s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, arg);
437
" %s:%d: \"%s\"", tcsd_config_file, line_num, arg);
441
441
if ((rc = get_file_path(arg, &tmp_ptr)) < 0) {
442
442
LogError("Config option \"firmware_log\" is invalid. %s:%d: \"%s\"",
443
TCSD_CONFIG_FILE, line_num, arg);
443
tcsd_config_file, line_num, arg);
444
444
return TCSERR(TSS_E_INTERNAL_ERROR);
445
445
} else if (rc > 0) {
446
446
LogError("Config option \"firmware_log\" is invalid. %s:%d: \"%s\"",
447
TCSD_CONFIG_FILE, line_num, tmp_ptr);
447
tcsd_config_file, line_num, tmp_ptr);
448
448
return TCSERR(TSS_E_INTERNAL_ERROR);
450
450
if (tmp_ptr == NULL)
460
460
case opt_platform_cred:
461
461
if (*arg != '/') {
462
462
LogError("Config option \"platform_cred\" must be an absolute path name. "
463
"%s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, arg);
463
"%s:%d: \"%s\"", tcsd_config_file, line_num, arg);
467
467
if ((rc = get_file_path(arg, &tmp_ptr)) < 0) {
468
468
LogError("Config option \"platform_cred\" is invalid. %s:%d: "
469
"\"%s\"", TCSD_CONFIG_FILE, line_num, arg);
469
"\"%s\"", tcsd_config_file, line_num, arg);
470
470
return TCSERR(TSS_E_INTERNAL_ERROR);
471
471
} else if (rc > 0) {
472
472
LogError("Config option \"platform_cred\" is invalid. %s:%d: "
473
"\"%s\"", TCSD_CONFIG_FILE, line_num, tmp_ptr);
473
"\"%s\"", tcsd_config_file, line_num, tmp_ptr);
474
474
return TCSERR(TSS_E_INTERNAL_ERROR);
476
476
if (tmp_ptr == NULL)
486
486
case opt_conformance_cred:
487
487
if (*arg != '/') {
488
488
LogError("Config option \"conformance_cred\" must be an absolute path name."
489
" %s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, arg);
489
" %s:%d: \"%s\"", tcsd_config_file, line_num, arg);
493
493
if ((rc = get_file_path(arg, &tmp_ptr)) < 0) {
494
494
LogError("Config option \"conformance_cred\" is invalid. %s:%d: "
495
"\"%s\"", TCSD_CONFIG_FILE, line_num, arg);
495
"\"%s\"", tcsd_config_file, line_num, arg);
496
496
return TCSERR(TSS_E_INTERNAL_ERROR);
497
497
} else if (rc > 0) {
498
498
LogError("Config option \"conformance_cred\" is invalid. %s:%d: "
499
"\"%s\"", TCSD_CONFIG_FILE, line_num, tmp_ptr);
499
"\"%s\"", tcsd_config_file, line_num, tmp_ptr);
500
500
return TCSERR(TSS_E_INTERNAL_ERROR);
502
502
if (tmp_ptr == NULL)
512
512
case opt_endorsement_cred:
513
513
if (*arg != '/') {
514
514
LogError("Config option \"endorsement_cred\" must be an absolute path name."
515
" %s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, arg);
515
" %s:%d: \"%s\"", tcsd_config_file, line_num, arg);
519
519
if ((rc = get_file_path(arg, &tmp_ptr)) < 0) {
520
520
LogError("Config option \"endorsement_cred\" is invalid. %s:%d: "
521
"\"%s\"", TCSD_CONFIG_FILE, line_num, arg);
521
"\"%s\"", tcsd_config_file, line_num, arg);
522
522
return TCSERR(TSS_E_INTERNAL_ERROR);
523
523
} else if (rc > 0) {
524
524
LogError("Config option \"endorsement_cred\" is invalid. %s:%d: "
525
"\"%s\"", TCSD_CONFIG_FILE, line_num, tmp_ptr);
525
"\"%s\"", tcsd_config_file, line_num, tmp_ptr);
526
526
return TCSERR(TSS_E_INTERNAL_ERROR);
528
528
if (tmp_ptr == NULL)
548
548
if (comma != NULL) {
549
549
if (tcsd_set_remote_op(conf, comma)) {
550
550
LogError("Config option \"remote_ops\" is invalid. "
551
"%s:%d: \"%s\"", TCSD_CONFIG_FILE,
551
"%s:%d: \"%s\"", tcsd_config_file,
552
552
line_num, comma);
559
559
if (tcsd_set_remote_op(conf, comma)) {
560
560
LogError("Config option \"remote_ops\" is invalid. "
561
"%s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, comma);
561
"%s:%d: \"%s\"", tcsd_config_file, line_num, comma);
566
566
tmp_int = atoi(arg);
567
567
if (tmp_int < 0 || tmp_int > 1) {
568
568
LogError("Config option \"enforce_exclusive_transport\" out of range."
569
" %s:%d: \"%d\"", TCSD_CONFIG_FILE, line_num, tmp_int);
569
" %s:%d: \"%d\"", tcsd_config_file, line_num, tmp_int);
570
570
return TCSERR(TSS_E_INTERNAL_ERROR);
572
572
conf->exclusive_transport = tmp_int;
583
583
/* At least one comma: error - more than one host class defined */
584
584
if (comma != NULL) {
585
585
LogError("Config option \"host_platform_class\" error: more than one "
586
"defined. %s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, comma);
586
"defined. %s:%d: \"%s\"", tcsd_config_file, line_num, comma);
587
587
return TCSERR(TSS_E_INTERNAL_ERROR);
590
590
/* Add the platform class on the list */
591
591
if ((result = platform_class_list_append(conf, comma, TRUE))){
592
592
LogError("Config option \"host_platform_class\" invalid. "
593
"%s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, comma);
593
"%s:%d: \"%s\"", tcsd_config_file, line_num, comma);
610
610
if ((result = platform_class_list_append(conf, comma,
612
612
LogError("Config option \"all_platform_class\" "
613
"invalid. %s:%d: \"%s\"", TCSD_CONFIG_FILE,
613
"invalid. %s:%d: \"%s\"", tcsd_config_file,
614
614
line_num, comma);
621
621
/* Add the platform class on the list */
622
622
if ((result = platform_class_list_append(conf, comma, FALSE))) {
623
623
LogError("Config option \"all_platform_class\" invalid. "
624
"%s:%d: \"%s\"", TCSD_CONFIG_FILE, line_num, comma);
624
"%s:%d: \"%s\"", tcsd_config_file, line_num, comma);
630
630
/* bail out on any unknown option */
631
LogError("Unknown config option %s:%d \"%s\"!", TCSD_CONFIG_FILE, line_num, arg);
631
LogError("Unknown config option %s:%d \"%s\"!", tcsd_config_file, line_num, arg);
632
632
return TCSERR(TSS_E_INTERNAL_ERROR);
726
726
/* look for a config file, create if it doesn't exist */
727
if (stat(TCSD_CONFIG_FILE, &stat_buf) == -1) {
727
if (stat(tcsd_config_file, &stat_buf) == -1) {
728
728
if (errno == ENOENT) {
729
729
/* no config file? use defaults */
730
730
config_set_defaults(conf);
731
LogInfo("Config file %s not found, using defaults.", TCSD_CONFIG_FILE);
731
LogInfo("Config file %s not found, using defaults.", tcsd_config_file);
732
732
return TSS_SUCCESS;
734
LogError("stat(%s): %s", TCSD_CONFIG_FILE, strerror(errno));
734
LogError("stat(%s): %s", tcsd_config_file, strerror(errno));
735
735
return TCSERR(TSS_E_INTERNAL_ERROR);
765
765
/* make sure user/group TSS owns the conf file */
766
766
if (pw->pw_uid != stat_buf.st_uid || grp->gr_gid != stat_buf.st_gid) {
767
LogError("TCSD config file (%s) must be user/group %s/%s", TCSD_CONFIG_FILE,
767
LogError("TCSD config file (%s) must be user/group %s/%s", tcsd_config_file,
768
768
TSS_USER_NAME, TSS_GROUP_NAME);
769
769
return TCSERR(TSS_E_INTERNAL_ERROR);
772
772
/* make sure only the tss user can manipulate the config file */
773
773
if (((stat_buf.st_mode & 0777) ^ mode) != 0) {
774
LogError("TCSD config file (%s) must be mode 0600", TCSD_CONFIG_FILE);
774
LogError("TCSD config file (%s) must be mode 0600", tcsd_config_file);
775
775
return TCSERR(TSS_E_INTERNAL_ERROR);
777
777
#endif /* SOLARIS */
779
if ((f = fopen(TCSD_CONFIG_FILE, "r")) == NULL) {
780
LogError("fopen(%s): %s", TCSD_CONFIG_FILE, strerror(errno));
779
if ((f = fopen(tcsd_config_file, "r")) == NULL) {
780
LogError("fopen(%s): %s", tcsd_config_file, strerror(errno));
781
781
return TCSERR(TSS_E_INTERNAL_ERROR);