Changeset 16501


Ignore:
Timestamp:
Aug 8, 2016, 2:46:57 PM (3 years ago)
Author:
dcorreia
Message:

Added support to control configuration progress.
Added check for user+card mapping to avoid duplicates.

Location:
internals/2016/linuxloginsmartcardwizard
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/linuxloginsmartcardwizard/.idea/workspace.xml

    r16500 r16501  
    33  <component name="ChangeListManager">
    44    <list default="true" readonly="true" id="fbd8e757-714d-41c6-a2b9-8558c09dbd04" name="Default" comment="Update IDE workspace">
     5      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/trunk/proto1/img/green-checkmark.png" />
     6      <change type="DELETED" beforePath="$PROJECT_DIR$/trunk/proto1/img/transparent-green-checkmark-hi.png" afterPath="" />
    57      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
    6       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/carduser.py" afterPath="$PROJECT_DIR$/trunk/proto1/carduser.py" />
    78      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/config.py" afterPath="$PROJECT_DIR$/trunk/proto1/config.py" />
    8       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/final.py" afterPath="$PROJECT_DIR$/trunk/proto1/final.py" />
    99      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/main.py" afterPath="$PROJECT_DIR$/trunk/proto1/main.py" />
    10       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/system.py" afterPath="$PROJECT_DIR$/trunk/proto1/system.py" />
    11       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/w4pages.py" afterPath="$PROJECT_DIR$/trunk/proto1/w4pages.py" />
    12       <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/proto1/welcome.py" afterPath="$PROJECT_DIR$/trunk/proto1/welcome.py" />
    1310    </list>
    1411    <ignored path="estagiopycharm.iws" />
     
    714711      <updated>1470415036209</updated>
    715712    </task>
    716     <option name="localTasksCounter" value="31" />
     713    <task id="LOCAL-00031" summary="Added progress messages to system page.&#10;Fixed bugs and design.">
     714      <created>1470669346344</created>
     715      <option name="number" value="00031" />
     716      <option name="presentableId" value="LOCAL-00031" />
     717      <option name="project" value="LOCAL" />
     718      <updated>1470669346344</updated>
     719    </task>
     720    <option name="localTasksCounter" value="32" />
    717721    <servers />
    718722  </component>
     
    768772  <component name="VcsManagerConfiguration">
    769773    <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="true" />
    770     <MESSAGE value="Added main.py to manage calls to config modules.&#10;Added tests.py to manage tests." />
    771774    <MESSAGE value="Added troubleshooting regarding CyberTrust certificate." />
    772775    <MESSAGE value="Added support for creating directories and copying files.&#10;Abstracted debug printing and command execution.&#10;Updated package installation.&#10;Added make pkcs11 hash links and get crl file features." />
     
    793796    <MESSAGE value="Added read smartcard info feature and troubleshooting messages.&#10;Fixed hidden button trick in system page.&#10;Fixed design characteristics in carduser page." />
    794797    <MESSAGE value="Update IDE workspace" />
    795     <option name="LAST_COMMIT_MESSAGE" value="Update IDE workspace" />
     798    <MESSAGE value="Added progress messages to system page.&#10;Fixed bugs and design." />
     799    <option name="LAST_COMMIT_MESSAGE" value="Added progress messages to system page.&#10;Fixed bugs and design." />
    796800  </component>
    797801  <component name="XDebuggerManager">
     
    994998        <state relative-caret-position="18">
    995999          <caret line="304" column="4" selection-start-line="304" selection-start-column="4" selection-end-line="304" selection-end-column="4" />
     1000          <folding />
    9961001        </state>
    9971002      </provider>
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/config.py

    r16492 r16501  
    1616COMMONAUTH = "/etc/pam.d/common-auth"       # PAM file with authentication configurations
    1717TRASH_OUTPUT = open(os.devnull, "wb")       # Send output to trash file
    18 TEMP_OUTPUT = "/tmp/cardData"               # Send output to temporary file
    1918USEMODULE_OPTION = "use_pkcs11_module"      # Configuration option to choose the active module
    2019USEMAPPERS_OPTION = "use_mappers"           # Configuration option to choose the active mappers
    2120# PKCS11 update for common-auth
    2221PKCS11AUTH = "auth\tsufficient\tpam_pkcs11.so config_file=/etc/pam_pkcs11/pam_pkcs11.conf"
    23 BACKUP_DIRPATH = "/tmp/backup_pam.d"
    2422REMOVEFILES_COMMAND = "rm "
    2523REMOVEDIRS_COMMAND = "rm -r "
     
    4240        if stderrData != "":
    4341            print("DEBUG: executeCommand (%s) - %s" % (command, stderrData), file=sys.stderr)
     42        return True
    4443    except subprocess.CalledProcessError as error:
    4544        print("DEBUG: executeCommand (%s) - %s" % (command, error), file=sys.stderr)
     45        return False
    4646
    4747
     
    5656    oldDirectory = os.getcwd()
    5757    os.chdir(directoryPath)
    58     executeCommand(command, outputPath)
    59     os.chdir(oldDirectory)
     58    if executeCommand(command, outputPath):
     59        os.chdir(oldDirectory)
     60        return True
     61    else:
     62        os.chdir(oldDirectory)
     63        return False
    6064
    6165
     
    7579    :return: no return value
    7680    """
    77     executeCommand(INSTALL_COMMAND+packageName, TRASH_OUTPUT)
     81    return executeCommand(INSTALL_COMMAND+packageName, TRASH_OUTPUT)
    7882
    7983
     
    100104    try:
    101105        shutil.copy2(filePath, directoryPath)
     106        return True
    102107    except FileNotFoundError as error:
    103108        printDebugInfo(error)
     109        return False
    104110
    105111
     
    158164    :return: no return value
    159165    """
    160     executeCommandInDirectory(HASHLINK_COMMAND, directoryPath)
     166    return executeCommandInDirectory(HASHLINK_COMMAND, directoryPath)
    161167
    162168
     
    264270
    265271
     272def hasUserCardCombo(mappingConfigPath, combo):
     273    mappings = readFileToList(mappingConfigPath)
     274    for line in mappings:
     275        if line == combo:
     276            return True
     277    return False
     278
     279
    266280def addUserMapping(mappingConfigPath, username, certificate=None):
    267281    """
     
    276290    try:
    277291        combo = certificate.strip() + " -> " + username + "\n"
    278         appendStringToFile(mappingConfigPath, combo)
    279         printDebugInfo("Added mapping for user '%s'" % username)
     292        if not hasUserCardCombo(mappingConfigPath, combo):
     293            appendStringToFile(mappingConfigPath, combo)
     294            printDebugInfo("Added mapping for user '%s'" % username)
    280295        return True
    281296    except AttributeError as error:
     
    310325
    311326def deleteTemporaryData():
    312     deleteDirectory(BACKUP_DIRPATH)
    313     deleteFile(TEMP_OUTPUT)
    314327    deleteFile(TEMP_LOCALUSERS)
    315328    deleteFile(TEMP_CERTDATA)
     
    340353    executeCommand(awkCmd, open(TEMP_LOCALUSERS, mode="w"))
    341354    return [s.strip() for s in readFileToList(TEMP_LOCALUSERS)]
     355
     356
     357
     358
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/main.py

    r16492 r16501  
    2929
    3030
    31 # Part 1 - Configuration of PKCS#11 module for PAM
    32 def configurePamPkcs11():
     31def checkPackages():
    3332    # Install PKCS#11 module for PAM
    34     config.installPackage(PAMPKCS11_PACKAGE)
     33    return config.installPackage(PAMPKCS11_PACKAGE)
    3534
     35
     36def checkDirectories():
    3637    # Create directories to support configuration files
    3738    config.makeDirectory(PAMPKCS11_DIRPATH)
     
    4041
    4142    # Copy pteid module data file to general directory
    42     config.copyFileToDirectory(PTEID_MODULE, PAMPKCS11_DIRPATH)
     43    return config.copyFileToDirectory(PTEID_MODULE, PAMPKCS11_DIRPATH)
    4344
     45
     46def copyCertificates():
    4447    # Copy certificate files to cacerts directory and make hash links
    4548    config.copyFileToDirectory(ECRAIZ_CERT, CACERTS_DIRPATH)
    4649    config.copyFileToDirectory(CC001_CERT, CACERTS_DIRPATH)
    47     config.makeHashLinks(CACERTS_DIRPATH)
    4850
    4951    # Get crl file from web link
     
    5153        config.getCRLFile(CC_CRL_HTTP, CRLS_DIRPATH)
    5254
     55    return config.makeHashLinks(CACERTS_DIRPATH)
     56
     57
     58def setupConfigurationFiles():
    5359    # Generate pam_pkcs11.conf file
    5460    config.makeConfigFile(GUNZIP_DIRPATH, PAMPKCS11_CONFIG, PAMPKCS11_DIRPATH)
     
    7278        config.copyFileToDirectory(PAMCONFIG_EXAMPLE, PAMCONFIG)
    7379
     80    return True
     81
     82
     83# Part 1 - Configuration of PKCS#11 module for PAM
     84def configurePamPkcs11():
     85    checkPackages()
     86    checkDirectories()
     87    copyCertificates()
     88    setupConfigurationFiles()
     89
    7490
    7591# Part 2 - User mapping configuration
Note: See TracChangeset for help on using the changeset viewer.