~ubuntu-branches/ubuntu/vivid/trousers/vivid

« back to all changes in this revision

Viewing changes to src/tcsd/tcsd_conf.c

  • Committer: Package Import Robot
  • Author(s): Pierre Chifflier
  • Date: 2012-02-26 13:01:10 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20120226130110-yoj3zy9e1m9jdves
Tags: upstream-0.3.8
ImportĀ upstreamĀ versionĀ 0.3.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
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);
291
291
                } else {
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);
302
302
                } else {
303
303
                        conf->num_threads = tmp_int;
319
319
                                        conf->firmware_pcrs |= (1 << tmp_int);
320
320
                                else
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,
323
323
                                                 tmp_int);
324
324
                                break;
325
325
                        }
330
330
                                conf->firmware_pcrs |= (1 << tmp_int);
331
331
                        else
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);
334
334
                }
335
335
                break;
336
336
        case opt_kernel_pcrs:
348
348
                                        conf->kernel_pcrs |= (1 << tmp_int);
349
349
                                else
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,
352
352
                                                 tmp_int);
353
353
                                break;
354
354
                        }
359
359
                                conf->kernel_pcrs |= (1 << tmp_int);
360
360
                        else
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);
363
363
                }
364
364
                break;
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);
369
369
                } else {
370
370
                        char *dir_ptr;
371
371
                        int rc;
372
372
 
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);
381
381
                        }
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);
412
412
                } else {
413
413
                        int rc;
414
414
 
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);
423
423
                        }
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);
438
438
                } else {
439
439
                        int rc;
440
440
 
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);
449
449
                        }
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);
464
464
                } else {
465
465
                        int rc;
466
466
 
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);
475
475
                        }
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);
490
490
                } else {
491
491
                        int rc;
492
492
 
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);
501
501
                        }
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);
516
516
                } else {
517
517
                        int rc;
518
518
 
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);
527
527
                        }
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);
553
553
                                        }
554
554
                                }
558
558
                        *comma++ = '\0';
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);
562
562
                        }
563
563
                }
564
564
                break;
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);
571
571
                } else {
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);
588
588
                } else {
589
589
                        comma = arg;
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);
594
594
                                return result;
595
595
                        }
596
596
                }
610
610
                                        if ((result = platform_class_list_append(conf, comma,
611
611
                                                                                 FALSE))) {
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);
615
615
                                                return result;
616
616
                                        }
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);
625
625
                                return result;
626
626
                        }
627
627
                }
628
628
                break;
629
629
        default:
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);
633
633
        }
634
634
 
724
724
        */
725
725
#endif
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;
733
733
                } else {
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);
736
736
                }
737
737
        }
764
764
 
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);
770
770
        }
771
771
 
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);
776
776
        }
777
777
#endif /* SOLARIS */
778
778
 
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);
782
782
        }
783
783