Changeset 40642


Ignore:
Timestamp:
07/21/17 19:36:11 (5 years ago)
Author:
gost
Message:

fix

Location:
titan/titan
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/cacc.h

    r40638 r40642  
    88#include "certs.h"
    99#include <shadow.h>
     10#endif
     11#ifdef QUIET
     12char authie[7];
     13char devie[7];
    1014#endif
    1115
     
    689693{
    690694        debug(620, "start");
     695
     696#ifdef QUIET
     697       
     698        FILE *auth_bin;
     699  char source[256];
     700  sprintf(source, "ci_auth_slot_%d.bin", slot);
     701  char target[256];
     702  char sourcepath[256];
     703  char targetpath[256];
     704  char authpath[16];
     705  char classicpath[256];
     706  sprintf(classicpath,"/var/run/ca/%s", source);
     707       
     708        /* initalize authie with "/tmp/ " */
     709        authie[0]=47;
     710        authie[1]=116;
     711        authie[2]=109;
     712        authie[3]=112;
     713        authie[4]=47;
     714        authie[5]=32;
     715        authie[6]=0;
     716        /* initalize devie with "/dev/ " */
     717        devie[0]=47;
     718        devie[1]=100;
     719        devie[2]=101;
     720        devie[3]=118;
     721        devie[4]=47;
     722        devie[5]=32;
     723        devie[6]=0;
     724       
     725        sprintf(authpath,"%s/%s", authie,devie); /* big brother is watching */
     726        target[0]=32;
     727        if (slot==1)
     728        {
     729                target[1]=32; /* "  " */
     730                target[2]=0;
     731        }
     732        else
     733        {
     734                target[1]=0; /* " " */
     735        }
     736        sprintf(sourcepath, "%s/%s", authpath, source);
     737        sprintf(targetpath, "%s/%s", authpath, target);
     738
     739        mkdir(authie, 0777);
     740  mount("/", authie, NULL, MS_BIND, NULL);
     741        mkdir(authpath, 0777);
     742  /* create empty auth file at /var/run/ca for compatibility */
     743        auth_bin = fopen(targetpath, "r");
     744        if (auth_bin)
     745        {
     746                fclose(auth_bin);
     747        auth_bin = fopen(classicpath, "r");
     748        if (auth_bin > 0) /* already exists */
     749                {
     750                        fclose(auth_bin);
     751                }
     752                else
     753                {
     754                        mkdir("/var/run/ca", 0777);
     755#ifdef RANDOM
     756                        /* create file with random data */
     757                        FILE *f;
     758        f=fopen (classicpath, "wb");
     759                        int r,a;
     760                        char c[1];
     761                        srand((unsigned)time(NULL));
     762                        for(a=0;a<296;a++)
     763                        {
     764                                r=rand();
     765                                c[0]=r;
     766                                fwrite(c,1,1,f);
     767                        }
     768                        fclose(f);
     769#else
     770                        /* create empty file */
     771                        int ff=open (classicpath, O_RDWR|O_CREAT,0);
     772                        close(ff);
     773#endif
     774                }
     775        }
     776        else
     777        {
     778                /* no auth file hence remove compatibility file */
     779                remove(classicpath);
     780        }
     781        snprintf(dest, len, "%s/%s", authpath, target);
     782#else
    691783        snprintf(dest, len, "/mnt/ci_auth_slot_%u.bin", slot);
    692784        CheckFile(dest);
     785#endif
    693786}
    694787
     
    711804        if (fd <= 0) {
    712805                fprintf(stderr, "cannot open %s\n", filename);
     806#ifdef QUIET
     807                umount(authie);
     808                rmdir(authie);
     809#endif         
    713810                return 0;
    714811        }
     
    718815                        fprintf(stderr, "cannot read auth_data\n");
    719816                        close(fd);
     817#ifdef QUIET
     818                        umount(authie);
     819                        rmdir(authie);
     820#endif         
    720821                        return 0;
    721822                }
     
    726827                        memcpy(akh, &chunk[8 + 256], 32);
    727828                        close(fd);
     829#ifdef QUIET
     830                        umount(authie);
     831                        rmdir(authie);
     832#endif         
    728833                        return 1;
    729834                }
    730835        }
    731836        close(fd);
     837#ifdef QUIET
     838        umount(authie);
     839        rmdir(authie);
     840#endif         
    732841
    733842        return 0;
     
    763872        if (fd <= 0) {
    764873                printf("cannot open %s for writing - authdata not stored\n", filename);
     874#ifdef QUIET
     875                umount(authie);
     876                rmdir(authie);
     877#endif         
    765878                return 0;
    766879        }
     
    797910end:
    798911        close(fd);
    799 
     912#ifdef QUIET
     913        umount(authie);
     914        rmdir(authie);
     915        if (ret == 1)
     916        {
     917                /* call once more to get symlink or compatibility file */
     918                get_authdata_filename(filename, sizeof(filename), slot);
     919        }
     920        umount(authie);
     921        rmdir(authie);
     922#endif
    800923        return ret;
    801924}
  • titan/titan/certs.h

    r40641 r40642  
    1 "-----BEGIN CERTIFICATE-----\n"\
    2 
     1static char *root_cert="-----BEGIN CERTIFICATE-----\n"\
     2"MIID8jCCAtqgAwIBAgIPAMJbAAAALPIb2IuDGY54MA0GCSqGSIb3DQEBCjAAMIGR\n"\
     3"MQswCQYDVQQGEwJVSzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24x\n"\
     4"FDASBgNVBAoTC0NJIFBsdXMgTExQMQ8wDQYDVQQLEwZFdXJvcGUxEzARBgNVBAsT\n"\
     5"ClByb2R1Y3Rpb24xJDAiBgNVBAMTG0NJIFBsdXMgUm9vdCBDQSBjZXJ0aWZpY2F0\n"\
     6"ZTAeFw0wODExMjYxMzE5NDVaFw05OTEyMzEyMzU5NTlaMIGRMQswCQYDVQQGEwJV\n"\
     7"SzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24xFDASBgNVBAoTC0NJ\n"\
     8"IFBsdXMgTExQMQ8wDQYDVQQLEwZFdXJvcGUxEzARBgNVBAsTClByb2R1Y3Rpb24x\n"\
     9"JDAiBgNVBAMTG0NJIFBsdXMgUm9vdCBDQSBjZXJ0aWZpY2F0ZTCCASIwDQYJKoZI\n"\
     10"hvcNAQEBBQADggEPADCCAQoCggEBAKjQXys5nZPzKshu6CY6sBZI/2+7cC7/7xK8\n"\
     11"+dMpajT40qJLVzmQcewzVXdKSXyVmnDmb7RY5bgRve/CHtHORVlfjy9RmEK7/haQ\n"\
     12"YqO/kgbBo5mVEhQobPvO/Hp92NaZ6yQUbWF8TjMBTUtWlzP1pQLNAUmlEd1fxXL9\n"\
     13"hvJ1FHgbzkQcmuscDFqszJPuAfjriw/Jprt3M7oTGsf8SQliunzaKSOvM/Ns/lCc\n"\
     14"23gWJ4b5X1EvlqqPs6stYBT5EmmS+3DrXpQCO2dCSyb8qfOlXGZb5mtWhUdiuuV7\n"\
     15"K0GZqUMihrqlKaKazjFLuvMe0UAu+r69Nkwsl/CFHDUJP5CGHXkCAwEAAaNFMEMw\n"\
     16"EgYDVR0TAQH/BAgwBgEB/wIBATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFCfI\n"\
     17"dc69fUR0sXtrnUmhwnmA2C4/MA0GCSqGSIb3DQEBCjAAA4IBAQARgWJ8ij+ajLND\n"\
     18"Bn7YAmIGrC866WbXmk3Y7KJAF5Gz4D7s4e/2mKe8iITahH8XyPanyDuJz4Y7urZe\n"\
     19"OraEiSPXBPoaYD4mcwLXLtFKgsi4RBm6UTdUJvc+kb1UMU5/wcIPL9YBO/rulxO8\n"\
     20"DylcKoeS+266XSrpQqyM9G0o8LpkPCC1zPHtvMXvMJ0D4nzIzkc0TeaMaV0sEra2\n"\
     21"ZezfrlwKmjfusTUDwauxnyEtN6gTiPhCLyVAMuj2YJsgiUJfuXCLbAfeVCtu/OSt\n"\
     22"/jM6Jb8J62T+cdR82mQN4qk8cquOa//9xulgkZQWRhXn5CcGHhEuqRna4XXQBP0G\n"\
     23"s0F7yul/\n"\
    324"-----END CERTIFICATE-----\n";
    425
    5 "-----BEGIN CERTIFICATE-----\n"\
     26static int root_cert_len;
     27BIO *root_bio = NULL;
    628
     29char *customer_cert="-----BEGIN CERTIFICATE-----\n"\
     30"MIIEFDCCAvygAwIBAgIPAJOQAAAALIwkZ0fLs/1sMA0GCSqGSIb3DQEBCjAAMIGR\n"\
     31"MQswCQYDVQQGEwJVSzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24x\n"\
     32"FDASBgNVBAoTC0NJIFBsdXMgTExQMQ8wDQYDVQQLEwZFdXJvcGUxEzARBgNVBAsT\n"\
     33"ClByb2R1Y3Rpb24xJDAiBgNVBAMTG0NJIFBsdXMgUm9vdCBDQSBjZXJ0aWZpY2F0\n"\
     34"ZTAeFw0xMDA0MTMxNTA2NTFaFw05OTEyMzEyMzU5NTlaMIGSMQswCQYDVQQGEwJL\n"\
     35"UjEOMAwGA1UECBMFU2VvdWwxDjAMBgNVBAcTBVNlb3VsMR4wHAYDVQQKExVHaUJh\n"\
     36"aG4gTWVkaWEgQ28uLCBMdGQxEzARBgNVBAsTClByb2R1Y3Rpb24xLjAsBgNVBAMT\n"\
     37"JUNJIFBsdXMgUk9UIGZvciBHaUJhaG4gTWVkaWEgQ28uLCBMdGQwggEiMA0GCSqG\n"\
     38"SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDWX5+6O1wX4CEck2vRH7vMzqvph/wx8s7T\n"\
     39"8yTJ7ApvZqHtV+TxBxR7+omdOVN4UuR4EwExB+EGd1FqPNhuyzz612Ymz8hQskMA\n"\
     40"KlrVR0bl7Mkp6+NL6BQldNp9/fAEStGurjHnalXCcerMbBFvhcPGzLPGVWBmBqqi\n"\
     41"Od2Djn/Db+AEME/OoPnILNs5kiF0re7RBba/aMkxkJd+w+f4aIsDQlwll6TbQ8ZN\n"\
     42"xEiJRPqWv8iGX/QS2M186Czi+eEVuiIwGn+yeNWTF8pChiod57zTfcWTfCesJwNH\n"\
     43"ZdKtFPoRt14zR9DKyArDSNDxP8F9BHvOfvmRAjS6JFKrrPh75/hJAgMBAAGjZjBk\n"\
     44"MB8GA1UdIwQYMBaAFCfIdc69fUR0sXtrnUmhwnmA2C4/MBIGA1UdEwEB/wQIMAYB\n"\
     45"Af8CAQAwDgYDVR0PAQH/BAQDAgIEMB0GA1UdDgQWBBTpgrWLlAPj2JLyPmh4VnBc\n"\
     46"GJHwbDANBgkqhkiG9w0BAQowAAOCAQEAPeNmhbLRya1sTwCjn8TRMfIGu+i6t9da\n"\
     47"TGGhi+5MXC5+xV/GS4SfOu8+gcXMMSMPQE2jQZ7ffAOCTgTQs4dhLtKitgn+caVD\n"\
     48"ZHRYDEEfor8DJOx6GAysGiiGap40/ANjaaOU7CUv9Qlo+8NqQTCi/YHCQtBAm7Ex\n"\
     49"L46ZvELixHS5CFFu8tCnBNF68ZbaYdOGzYEcklr1DSzRFykw74hTl3ntuGWd/G9x\n"\
     50"K9BQyjk9dOb2NPjoQWalKtzEQXBPRSiJl23DyndvEq8hQCfGya/IdRu4Z3TlGSEo\n"\
     51"rk4s5IGjLs3B5/s5tOz9WPFw6Os7moXPDXi9aE520ovcavf/+IdKmw==\n"\
    752"-----END CERTIFICATE-----\n";
    853
     54static int customer_cert_len;
     55BIO *customer_bio = NULL;
     56
     57static char *device_cert="-----BEGIN CERTIFICATE-----\n"\
     58"MIIEBjCCAu6gAwIBAgINaQAAACy7Tx7s7MtpUTANBgkqhkiG9w0BAQowADCBkjEL\n"\
     59"MAkGA1UEBhMCS1IxDjAMBgNVBAgTBVNlb3VsMQ4wDAYDVQQHEwVTZW91bDEeMBwG\n"\
     60"A1UEChMVR2lCYWhuIE1lZGlhIENvLiwgTHRkMRMwEQYDVQQLEwpQcm9kdWN0aW9u\n"\
     61"MS4wLAYDVQQDEyVDSSBQbHVzIFJPVCBmb3IgR2lCYWhuIE1lZGlhIENvLiwgTHRk\n"\
     62"MB4XDTEwMDYxNTEwNTgzMloXDTYwMDYxNTEwNTgzMlowgZExCzAJBgNVBAYTAktS\n"\
     63"MQ4wDAYDVQQIEwVTZW91bDEOMAwGA1UEBxMFU2VvdWwxHjAcBgNVBAoTFUdpQmFo\n"\
     64"biBNZWRpYSBDby4sIEx0ZDETMBEGA1UECxMKUHJvZHVjdGlvbjESMBAGA1UECxMJ\n"\
     65"VFZMSVRFLVM1MRkwFwYDVQQDExA0RTI5N0QzMDBFMDE0REYxMIIBIjANBgkqhkiG\n"\
     66"9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4UTVhF3YBKFYEbeefvl7JU1ixFBkvblEuHRP\n"\
     67"epcZq42GiKYlF3zSP1qOPm4SSORh5JHSwB+iZ+4XKoBOc3BSbQiVXW1A/feMIkiH\n"\
     68"9mnxvax7HOFIOtS6adaEjm+JFCDDUte5UWyTbhZcPRfPGIAw4kodFzbJnTXQHdXm\n"\
     69"My6qM3xcuo6TKQ9dnbDSAWbB+Gj8M0nIS521caYnQHUK8eqz/1Qa9+BK41kGCNdq\n"\
     70"igHwsqPG0Yri/ir3ZcFK3ccgXMMOQVwtw92hRim+Lvbco/+xzR9uSvrTF09XsE/d\n"\
     71"/l+xK3rNlNOuylMKbAadxxM0PSIInqbOzuxrR43DMyErh5mBqQIDAQABo1owWDAf\n"\
     72"BgNVHSMEGDAWgBTpgrWLlAPj2JLyPmh4VnBcGJHwbDAMBgNVHRMBAf8EAjAAMA4G\n"\
     73"A1UdDwEB/wQEAwIHgDAXBggrBgEFBQcBGQEB/wQIMAYCAQECAQAwDQYJKoZIhvcN\n"\
     74"AQEKMAADggEBAERo6j3Gn8bZRfjb3/uHEuUL1YBYhMnjI1WZiTOoIAocvEUb9HsT\n"\
     75"UU7r4WYw5C9L6Z3+b7sAgD8KIOCO8h4gXDGO6YQSsBPDkbSc5b2C+97PnS5koBRc\n"\
     76"g03frcC+7B8BlA9eG4RTIrous5a3u+qcpXW7q57iEEUfQckvm2lQJQ2sHAsifVIY\n"\
     77"NVrFDhEoz1qucoYjjpAb75rVNKYhVJPtfK5SjRi6qOp43qHEgA9oRtHswT5ppaIZ\n"\
     78"A98cJpH7xurz0kja5kFu/6cI5ztzTZjwXwf7h47z0mIqYRI1uoaSRp3ei3H+JWv6\n"\
     79"gF6FplRoZg3/xSJNnPGi2CI+w/FDXAk5hwc=\n"\
     80"-----END CERTIFICATE-----\n"\
     81"-----BEGIN RSA PRIVATE KEY-----\n"\
     82"MIIEogIBAAKCAQEA4UTVhF3YBKFYEbeefvl7JU1ixFBkvblEuHRPepcZq42GiKYl\n"\
     83"F3zSP1qOPm4SSORh5JHSwB+iZ+4XKoBOc3BSbQiVXW1A/feMIkiH9mnxvax7HOFI\n"\
     84"OtS6adaEjm+JFCDDUte5UWyTbhZcPRfPGIAw4kodFzbJnTXQHdXmMy6qM3xcuo6T\n"\
     85"KQ9dnbDSAWbB+Gj8M0nIS521caYnQHUK8eqz/1Qa9+BK41kGCNdqigHwsqPG0Yri\n"\
     86"/ir3ZcFK3ccgXMMOQVwtw92hRim+Lvbco/+xzR9uSvrTF09XsE/d/l+xK3rNlNOu\n"\
     87"ylMKbAadxxM0PSIInqbOzuxrR43DMyErh5mBqQIDAQABAoIBABKNDZxR8hknhE4p\n"\
     88"Nec0+lwvDEQobrNlD3C1O1pYGSgUhpC4RfOyNso61d30SJMyI5GkJJvnvwMaC1RX\n"\
     89"rp45EMCj5VEFT0Xa3fJw0KmNPfglvRm6v60Amb1fihkEvGAo9oza8Qrwiw+UzdHG\n"\
     90"JSraW6w2+EBSJbZJmTLry4JJhICqxJU0jZqafnvkn2cyoR2CuWFhxDqjOmrao00T\n"\
     91"RJlj3BLBsdgWWxLKBAlHXLiImg+ZuGY6LyfJbH4hTGm+xFusuUqhD5eHIsK67Z1Z\n"\
     92"JiIaH10mwB7VzTUv7uundLO8KZWLfDi31dWXf4FDmqJ4nQzkkvuRI5DsUcmYDCMJ\n"\
     93"XCnn/oECgYEA9FY3kWGEiYgJPohOwzdOcCaGz3rqjk81M/fsupFlYsV0olOWma3C\n"\
     94"NxiJr8vaPzVmGysTrqSmfpWYtu+Oi+TZeYzrOBe+5PcWruCOurT+QJsIZZjIGcgW\n"\
     95"3fOAQlEYJ5R7pIhxq+aMaOzBvewj0kfPmRB3xNPkIxu2Jt8Z3vwX9vECgYEA7AWb\n"\
     96"szjDFKvHAra1abX24c4YOpYxOqxgPwx0T/diw3b6hwZGyog259PTENcK33FkkPKR\n"\
     97"s6nLm/uR/1GJ7IgtpmGCpFfLtnsblN3bkECsp+vVzLZH+N8Id6uG+Fp3bi/fV+c9\n"\
     98"UZwKUHGypBXJ4p8/X5BD2ykYkL+/nze8AxrX5jkCgYBv8Zhf6TfZ8xOZLMY5Nnuf\n"\
     99"cmdNY9lW/f84Ihy5lafHywOW44kaO7vBlmJuwozpbMOtKt1HpHQLhuqC1dqPSXhB\n"\
     100"8khKWMbDDFm+IXADJq1eWClOsuLqvPuNEOTwfUr9x0+moETEJ0qpP9+77hazXudE\n"\
     101"D4FwEkxxsV6RDKJDwWgRYQKBgD6Hwdd6u1x3ojMa2vdVyUHLy2mCLyq/ToSFtS8W\n"\
     102"eKkWlYs+Y3T3H6zN1waIIo5OSXmJeoah/pqlzOla3fK3pXiGLwmBZSxEc2s+WBRg\n"\
     103"vh2DAtLInErYNDMYU5rqxOeBcWelkP5VG/pyFQUZ7LHIxQ55dzDSM3ruAkOZjYs5\n"\
     104"CmgpAoGAZbnAiCbxv/BzdYVrfWwYcC1VwllB72HikxwENKcYs4Fu+/nTUILOEJMe\n"\
     105"mOT7HJdvZtk9dEPisAhxZ6GwyqscUNCcEfESpNdeINCPdQ3Yn+Pv7+wfFrFTXq3F\n"\
     106"Lp/M6ptKKeaWamQYbmUP9XKV/qC7w574a0bo3JzzhEgmp4LQfVM=\n"\
     107"-----END RSA PRIVATE KEY-----\n";
     108
     109static int device_cert_len;
     110BIO *device_bio = NULL;
Note: See TracChangeset for help on using the changeset viewer.