Changeset 16492


Ignore:
Timestamp:
Aug 5, 2016, 4:01:06 PM (3 years ago)
Author:
dcorreia
Message:

Updated add user mapping feature to take username and certificate as optional arguments.
Fixed subject mapping reset bug.

Location:
internals/2016/linuxloginsmartcardwizard/trunk/proto1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/config.py

    r16484 r16492  
    245245def getCardSubject():
    246246    cardHelper.init()
    247     baseOutputFileName, totalCerts = cardHelper.start()
     247    try:
     248        baseOutputFileName, totalCerts = cardHelper.start()
     249    except TypeError as error:
     250        printDebugInfo(error)
     251        cardHelper.release()
     252        return ""
    248253    cardHelper.release()
    249254    cardSubject = ""
     
    259264
    260265
    261 def addUserMapping(mappingConfigPath, username):
     266def addUserMapping(mappingConfigPath, username, certificate=None):
    262267    """
    263268    Add a user mapping with a certificate
    264269    :param mappingConfigPath: path of the mapping configurations file
    265270    :param username: name of the user
     271    :param certificate: card subject certificate
    266272    :return: True on success and False otherwise
    267273    """
    268     certificate = getCardSubject()
     274    if certificate is None:
     275        certificate = getCardSubject()
    269276    try:
    270277        combo = certificate.strip() + " -> " + username + "\n"
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/main.py

    r16468 r16492  
    6565
    6666    # Copy subject_mapping file to main configuration folder
    67     config.copyFileToDirectory(SUBJECTMAPPING_EXAMPLE, PAMPKCS11_MAPPING)
     67    if not os.path.exists(PAMPKCS11_MAPPING):
     68        config.copyFileToDirectory(SUBJECTMAPPING_EXAMPLE, PAMPKCS11_MAPPING)
    6869
    6970    # Create the pkcs11 file with configuration info
    70     config.copyFileToDirectory(PAMCONFIG_EXAMPLE, PAMCONFIG)
     71    if not os.path.exists(PAMCONFIG):
     72        config.copyFileToDirectory(PAMCONFIG_EXAMPLE, PAMCONFIG)
    7173
    7274
    7375# Part 2 - User mapping configuration
    74 def configureUserMapping():
     76def configureUserMapping(username=None, certificate=None):
    7577    # Add certificate->user mapping to subject_mapping file
    76     username = input("Please write the username to be used in the mapping\n")
    77     if config.addUserMapping(PAMPKCS11_MAPPING, username):
     78    if username is None:
     79        username = input("Please write the username to be used in the mapping\n")
     80    if config.addUserMapping(PAMPKCS11_MAPPING, username, certificate):
    7881        # Simulate pam-auth-update manually to change content of common-auth
    7982        config.runPamAuthUpdate()
    80     config.deleteTemporaryData()
     83        config.deleteTemporaryData()
     84        return True
     85    return False
    8186
    8287
Note: See TracChangeset for help on using the changeset viewer.