Changeset 16337


Ignore:
Timestamp:
Jul 18, 2016, 1:56:32 PM (3 years ago)
Author:
dcorreia
Message:

Added pteid module data file to project folder.
FInished first part of configuration process.

Location:
internals/2016/linuxloginsmartcardwizard/trunk/project1
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/linuxloginsmartcardwizard/trunk/project1/configpkcs11.py

    r16332 r16337  
    1111GUNZIP_COMMAND = "gunzip "
    1212MV_COMMAND = "mv "
     13INSPECT_COMMAND = "pkcs11_inspect"
    1314
    1415
     
    100101
    101102def makeConfigFile(configZipPath, configPath, directoryPath):
     103    currentDirectoryPath = os.getcwd()
    102104    copyFileToDirectory(configZipPath, directoryPath)
    103105    os.chdir(directoryPath)
    104106    executeCommand(GUNZIP_COMMAND+"pam_pkcs11.conf.example.gz")
    105107    executeCommand(MV_COMMAND+"pam_pkcs11.conf.example "+configPath)
     108    os.chdir(currentDirectoryPath)
     109
     110
     111def addConfigModule(moduleFileName, configPath):
     112    configData = open(configPath, mode="r").readlines()
     113    moduleData = open(moduleFileName, mode="r").readlines()
     114    old_last = configData[len(configData)-1]
     115    configData[len(configData)-1] = "".join(moduleData) + "\n" + old_last
     116    open(configPath,mode="w").write("".join(configData))
     117
     118
     119def changeActiveModule(newModule, configPath):
     120    configData = open(configPath, mode="r").readlines()
     121    for i in range(0,len(configData)):
     122        if "use_pkcs11_module" in configData[i]:
     123            configData[i] = "  use_pkcs11_module = " + newModule + ";\n"
     124    open(configPath, mode="w").write("".join(configData))
     125
     126
     127def testInspect():
     128    executeCommand(INSPECT_COMMAND)
  • internals/2016/linuxloginsmartcardwizard/trunk/project1/main.py

    r16332 r16337  
    22import configpkcs11
    33import os
     4
    45PAMPKCS11_PACKAGE = "libpam-pkcs11"
    5 PAMPKCS11_DIRPATH = "/etc/pampkcs11"
    6 CACERTS_DIRPATH = "/etc/pampkcs11/cacerts"
    7 CRLS_DIRPATH = "/etc/pampkcs11/crls"
     6PAMPKCS11_DIRPATH = "/etc/pam_pkcs11"
     7CACERTS_DIRPATH = "/etc/pam_pkcs11/cacerts"
     8CRLS_DIRPATH = "/etc/pam_pkcs11/crls"
    89CRL_FILENAME = "cc_ec_cidadao_crl001_crl.crl"
    910ECRAIZ_CERT = "/usr/local/share/certs/ECRaizEstado_novo_assinado_GTE.der"
     
    1112CC_CRL_HTTP = "https://pki.cartaodecidadao.pt/publico/lrc/cc_ec_cidadao_crl001_crl.crl"
    1213GUNZIP_DIRPATH = "/usr/share/doc/libpam-pkcs11/examples/pam_pkcs11.conf.example.gz"
    13 PAMPKCS11_CONFIG = "/etc/pampkcs11/pampkcs11.conf"
     14PAMPKCS11_CONFIG = "/etc/pam_pkcs11/pam_pkcs11.conf"
     15PTEID_MODULE = "pteid.txt"
    1416
    1517
     
    2224configpkcs11.makeDirectory(CRLS_DIRPATH)
    2325
     26# Copy pteid module data file to general directory
     27configpkcs11.copyFileToDirectory(PTEID_MODULE, PAMPKCS11_DIRPATH)
     28
    2429# Copy certificate files to cacerts directory and make hash links
    2530configpkcs11.copyFileToDirectory(ECRAIZ_CERT, CACERTS_DIRPATH)
    2631configpkcs11.copyFileToDirectory(CC001_CERT, CACERTS_DIRPATH)
    2732configpkcs11.makeHashLinks(CACERTS_DIRPATH)
    28 
    2933
    3034# Get crl file from web link
     
    3539configpkcs11.makeConfigFile(GUNZIP_DIRPATH, PAMPKCS11_CONFIG, PAMPKCS11_DIRPATH)
    3640
    37 # TODO Add portuguese CC module to pam_pkcs11.conf file
     41# Add portuguese CC module to pam_pkcs11.conf file
     42if "pteid" not in "".join(open(PAMPKCS11_CONFIG, mode="r").readlines()):
     43    configpkcs11.addConfigModule(PTEID_MODULE, PAMPKCS11_CONFIG)
    3844
     45# Change pkcs11 module to be used in pam_pkcs11.conf file
     46configpkcs11.changeActiveModule("pteid", PAMPKCS11_CONFIG)
    3947
    40 # TODO Change pkcs11 module to be used in pam_pkcs11.conf file
     48# Test this phase of configuration by running pkcs11_inspect
     49configpkcs11.testInspect()
    4150
    42 
    43 # TODO Test this phase of configuration by running pkcs11_inspect
    44 
Note: See TracChangeset for help on using the changeset viewer.