Ignore:
Timestamp:
Jul 21, 2016, 3:34:24 PM (4 years ago)
Author:
dcorreia
Message:

Added reset to default configuration feature

File:
1 edited

Legend:

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

    r16354 r16364  
    2020# PKCS11 update for common-auth
    2121PKCS11AUTH = "auth\tsufficient\tpam_pkcs11.so config_file=/etc/pam_pkcs11/pam_pkcs11.conf"
     22BACKUP_DIRPATH = "/tmp/backup_pam.d"
     23REMOVEFILES_COMMAND = "rm "
     24REMOVEDIRS_COMMAND = "rm -r "
    2225
    2326
     
    262265
    263266
    264 def runPamAuthUpdate():
    265     """
    266     Simulates the execution of pam-auth-update to active pam_pkcs11 in the system
     267def runPamAuthUpdate(mode="enable"):
     268    """
     269    Simulates the execution of pam-auth-update
    267270    :return: no return value
    268271    """
     
    270273    pkcs11Index = getIndexOfToken("pam_pkcs11.so", authData)
    271274    unixIndex = getIndexOfToken("pam_unix.so", authData)
    272     if pkcs11Index is None:
     275
     276    if pkcs11Index is None and mode == "enable":
     277        printDebugInfo("Enabling pam_pkcs11 at pam.d")
    273278        authData[unixIndex] = PKCS11AUTH + "\n" + authData[unixIndex]
    274279        writeListToFile(COMMONAUTH, authData)
     280
     281    elif pkcs11Index is not None and mode == "disable":
     282        printDebugInfo("Disabling pam_pkcs11 at pam.d")
     283        authData[pkcs11Index] = ""
     284        writeListToFile(COMMONAUTH, authData)
     285
     286
     287def resetPamAuth():
     288    runPamAuthUpdate("disable")
     289
     290
     291def deleteTemporaryData():
     292    deleteDirectory(BACKUP_DIRPATH)
     293    deleteFile(TEMP_OUTPUT)
     294
     295
     296def deleteFile(filePath):
     297    executeCommand(REMOVEFILES_COMMAND + filePath)
     298
     299
     300def deleteDirectory(directoryPath):
     301    executeCommand(REMOVEDIRS_COMMAND + directoryPath)
Note: See TracChangeset for help on using the changeset viewer.