Ignore:
Timestamp:
Jul 19, 2016, 2:39:26 PM (4 years ago)
Author:
dcorreia
Message:

Added features of second part of configuration process: subject mapping, card certificate operations and pam-configs.

File:
1 edited

Legend:

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

    r16337 r16345  
    66import inspect
    77
     8
    89INSTALL_COMMAND = "apt-get install "
    910HASHLINK_COMMAND = "pkcs11_make_hash_link"
     
    1213MV_COMMAND = "mv "
    1314INSPECT_COMMAND = "pkcs11_inspect"
     15PAMAUTHUP_COMMAND = "pam-auth-update"
    1416
    1517
     
    122124        if "use_pkcs11_module" in configData[i]:
    123125            configData[i] = "  use_pkcs11_module = " + newModule + ";\n"
     126            break
    124127    open(configPath, mode="w").write("".join(configData))
    125128
     
    127130def testInspect():
    128131    executeCommand(INSPECT_COMMAND)
     132
     133
     134def changeUseMappers(newValue, configPath):
     135    configData = open(configPath, mode="r").readlines()
     136    for i in range(0, len(configData)):
     137        if "use_mappers = " in configData[i]:
     138            configData[i] = "  #" + configData[i] + "  use_mappers = " + newValue + "\n"
     139            break
     140    open(configPath, mode="w").write("".join(configData))
     141
     142
     143def getCardAuthCertificate(outputFilePath):
     144    executeCommand(INSPECT_COMMAND, open(outputFilePath, mode="w"))
     145    cardData = open(outputFilePath, mode="r").readlines()
     146    for i in range(0, len(cardData)):
     147        if "Autentica" in cardData[i] and "serialNumber=" in cardData[i]:
     148            open(outputFilePath, mode="w").write(cardData[i])
     149            break
     150
     151
     152def addUserMapping(cardDataFilePath, mappingConfigPath, username):
     153    certificate = "".join(open(cardDataFilePath, mode="r").readlines()).strip()
     154    combo = certificate + " -> " + username + "\n"
     155    open(mappingConfigPath, mode="a").write(combo)
     156
     157
     158def runPamAuthUpdate():
     159    executeCommand(PAMAUTHUP_COMMAND)
Note: See TracChangeset for help on using the changeset viewer.