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.

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

Legend:

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

    r16339 r16345  
    22<project version="4">
    33  <component name="ChangeListManager">
    4     <list default="true" readonly="true" id="fbd8e757-714d-41c6-a2b9-8558c09dbd04" name="Default" comment="" />
     4    <list default="true" readonly="true" id="fbd8e757-714d-41c6-a2b9-8558c09dbd04" name="Default" comment="">
     5      <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/trunk/project1/pkcs11.example" />
     6      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
     7      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/project1/configpkcs11.py" afterPath="$PROJECT_DIR$/trunk/project1/configpkcs11.py" />
     8      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/project1/main.py" afterPath="$PROJECT_DIR$/trunk/project1/main.py" />
     9    </list>
    510    <list id="b585d4db-50d8-4fb7-be87-de5ad4ae7ca8" name="Rejected commit: Default" comment="Added backup configuration folder." />
    611    <ignored path="estagiopycharm.iws" />
     
    2328  <component name="FileEditorManager">
    2429    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
    25       <file leaf-file-name="configpkcs11.py" pinned="false" current-in-tab="true">
     30      <file leaf-file-name="configpkcs11.py" pinned="false" current-in-tab="false">
    2631        <entry file="file://$PROJECT_DIR$/trunk/project1/configpkcs11.py">
    2732          <provider selected="true" editor-type-id="text-editor">
    28             <state relative-caret-position="180">
    29               <caret line="10" column="26" selection-start-line="10" selection-start-column="26" selection-end-line="10" selection-end-column="26" />
     33            <state relative-caret-position="-558">
     34              <caret line="5" column="14" selection-start-line="5" selection-start-column="14" selection-end-line="5" selection-end-column="14" />
    3035              <folding>
    3136                <element signature="e#19#28#0" expanded="true" />
    32                 <element signature="e#324#894#0" expanded="false" />
    33                 <element signature="e#324#526#1" expanded="true" />
    34                 <element signature="e#932#1126#0" expanded="false" />
    35                 <element signature="e#932#1044#1" expanded="true" />
    36                 <element signature="e#1166#1285#1" expanded="true" />
    37                 <element signature="e#1442#1562#1" expanded="true" />
    38                 <element signature="e#1788#1953#1" expanded="true" />
    39                 <element signature="e#2118#2244#1" expanded="true" />
    40                 <element signature="e#2433#2604#1" expanded="true" />
     37                <element signature="e#363#565#1" expanded="true" />
     38                <element signature="e#971#1165#0" expanded="false" />
     39                <element signature="e#971#1083#1" expanded="true" />
     40                <element signature="e#1205#1324#1" expanded="true" />
     41                <element signature="e#1481#1601#1" expanded="true" />
     42                <element signature="e#1827#1992#1" expanded="true" />
     43                <element signature="e#2157#2283#1" expanded="true" />
     44                <element signature="e#2472#2643#1" expanded="true" />
    4145              </folding>
    4246            </state>
     
    4448        </entry>
    4549      </file>
    46       <file leaf-file-name="main.py" pinned="false" current-in-tab="false">
     50      <file leaf-file-name="main.py" pinned="false" current-in-tab="true">
    4751        <entry file="file://$PROJECT_DIR$/trunk/project1/main.py">
    4852          <provider selected="true" editor-type-id="text-editor">
    49             <state relative-caret-position="828">
    50               <caret line="46" column="0" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
     53            <state relative-caret-position="383">
     54              <caret line="75" column="0" selection-start-line="75" selection-start-column="0" selection-end-line="75" selection-end-column="0" />
    5155              <folding>
    5256                <element signature="e#19#38#0" expanded="true" />
     
    7680        <option value="$PROJECT_DIR$/trunk/project1/tests.py" />
    7781        <option value="$PROJECT_DIR$/trunk/project1/editfiles.py" />
     82        <option value="$PROJECT_DIR$/trunk/backup/pam_pkcs11.conf" />
     83        <option value="$PROJECT_DIR$/trunk/project1/configmapper.py" />
     84        <option value="$PROJECT_DIR$/trunk/project1/pkcs11.example" />
     85        <option value="$PROJECT_DIR$/trunk/project1/configpkcs11.py" />
    7886        <option value="$PROJECT_DIR$/trunk/project1/main.py" />
    79         <option value="$PROJECT_DIR$/trunk/project1/configpkcs11.py" />
    80         <option value="$PROJECT_DIR$/trunk/backup/pam_pkcs11.conf" />
    8187      </list>
    8288    </option>
    8389  </component>
    8490  <component name="ProjectFrameBounds">
    85     <option name="x" value="1279" />
    86     <option name="width" value="1442" />
    87     <option name="height" value="900" />
     91    <option name="x" value="-1" />
     92    <option name="y" value="27" />
     93    <option name="width" value="1282" />
     94    <option name="height" value="773" />
    8895  </component>
    8996  <component name="ProjectInspectionProfilesVisibleTreeState">
     
    131138    </navigator>
    132139    <panes>
    133       <pane id="Scratches" />
     140      <pane id="Scope" />
    134141      <pane id="ProjectPane">
    135142        <subPane>
     
    163170              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    164171            </PATH_ELEMENT>
     172            <PATH_ELEMENT>
     173              <option name="myItemId" value="trunk" />
     174              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
     175            </PATH_ELEMENT>
     176            <PATH_ELEMENT>
     177              <option name="myItemId" value="project1" />
     178              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
     179            </PATH_ELEMENT>
     180          </PATH>
     181          <PATH>
     182            <PATH_ELEMENT>
     183              <option name="myItemId" value="estagiopycharm" />
     184              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
     185            </PATH_ELEMENT>
     186            <PATH_ELEMENT>
     187              <option name="myItemId" value="estagiopycharm" />
     188              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
     189            </PATH_ELEMENT>
    165190          </PATH>
    166191          <PATH>
     
    180205        </subPane>
    181206      </pane>
    182       <pane id="Scope" />
     207      <pane id="Scratches" />
    183208    </panes>
    184209  </component>
     
    541566  </component>
    542567  <component name="ToolWindowManager">
    543     <frame x="1279" y="0" width="1442" height="900" extended-state="6" />
     568    <frame x="-1" y="27" width="1282" height="773" extended-state="6" />
    544569    <editor active="false" />
    545570    <layout>
    546       <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.22582921" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
     571      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17263326" sideWeight="0.49195403" order="0" side_tool="false" content_ui="combo" />
    547572      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32921174" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
    548       <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32816538" sideWeight="0.50247" order="7" side_tool="true" content_ui="tabs" />
    549       <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32921174" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
     573      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3164179" sideWeight="0.5046875" order="7" side_tool="true" content_ui="tabs" />
    550574      <window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32766616" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
    551       <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.26614988" sideWeight="0.49752998" order="7" side_tool="false" content_ui="tabs" />
    552       <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2797527" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
     575      <window_info id="Version Control" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.19938177" sideWeight="0.49752998" order="7" side_tool="false" content_ui="tabs" />
    553576      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24980111" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
    554       <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32766616" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
    555       <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
    556       <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39922482" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
     577      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32766616" sideWeight="0.4953125" order="7" side_tool="false" content_ui="tabs" />
     578      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.17263326" sideWeight="0.508046" order="2" side_tool="true" content_ui="tabs" />
    557579      <window_info id="SVN Repositories" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32921174" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
    558580      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
     
    560582      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
    561583      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
     584      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2797527" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
    562585      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
     586      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32921174" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
    563587      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
     588      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39922482" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
    564589    </layout>
    565590    <layout-to-restore>
     
    615640  <component name="XDebuggerManager">
    616641    <breakpoint-manager>
    617       <option name="time" value="13" />
     642      <option name="time" value="14" />
    618643    </breakpoint-manager>
    619644    <watches-manager />
     
    631656        <state relative-caret-position="144">
    632657          <caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
     658        </state>
     659      </provider>
     660    </entry>
     661    <entry file="file://$PROJECT_DIR$/trunk/project1/expfile.txt" />
     662    <entry file="file://$PROJECT_DIR$/trunk/project1/editfiles.py" />
     663    <entry file="file://$PROJECT_DIR$/trunk/backup/pam_pkcs11.conf">
     664      <provider selected="true" editor-type-id="text-editor">
     665        <state relative-caret-position="114">
     666          <caret line="224" column="43" selection-start-line="224" selection-start-column="43" selection-end-line="224" selection-end-column="43" />
     667        </state>
     668      </provider>
     669    </entry>
     670    <entry file="file://$PROJECT_DIR$/trunk/project1/configmapper.py">
     671      <provider selected="true" editor-type-id="text-editor">
     672        <state relative-caret-position="36">
     673          <caret line="2" column="6" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="6" />
    633674          <folding />
    634675        </state>
    635676      </provider>
    636677    </entry>
    637     <entry file="file://$PROJECT_DIR$/trunk/project1/expfile.txt">
     678    <entry file="file://$PROJECT_DIR$/trunk/project1/pkcs11.example">
    638679      <provider selected="true" editor-type-id="text-editor">
    639         <state relative-caret-position="0">
    640           <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
     680        <state relative-caret-position="72">
     681          <caret line="4" column="74" selection-start-line="4" selection-start-column="74" selection-end-line="4" selection-end-column="74" />
    641682          <folding />
    642683        </state>
    643684      </provider>
    644685    </entry>
    645     <entry file="file://$PROJECT_DIR$/trunk/project1/editfiles.py">
     686    <entry file="file://$PROJECT_DIR$/trunk/project1/configpkcs11.py">
    646687      <provider selected="true" editor-type-id="text-editor">
    647         <state relative-caret-position="382">
    648           <caret line="23" column="29" selection-start-line="23" selection-start-column="29" selection-end-line="23" selection-end-column="29" />
    649           <folding />
    650         </state>
    651       </provider>
    652     </entry>
    653     <entry file="file://$PROJECT_DIR$/trunk/backup/pam_pkcs11.conf">
    654       <provider selected="true" editor-type-id="text-editor">
    655         <state relative-caret-position="114">
    656           <caret line="224" column="43" selection-start-line="224" selection-start-column="43" selection-end-line="224" selection-end-column="43" />
    657           <folding />
     688        <state relative-caret-position="-558">
     689          <caret line="5" column="14" selection-start-line="5" selection-start-column="14" selection-end-line="5" selection-end-column="14" />
     690          <folding>
     691            <element signature="e#19#28#0" expanded="true" />
     692            <element signature="e#363#565#1" expanded="true" />
     693            <element signature="e#971#1165#0" expanded="false" />
     694            <element signature="e#971#1083#1" expanded="true" />
     695            <element signature="e#1205#1324#1" expanded="true" />
     696            <element signature="e#1481#1601#1" expanded="true" />
     697            <element signature="e#1827#1992#1" expanded="true" />
     698            <element signature="e#2157#2283#1" expanded="true" />
     699            <element signature="e#2472#2643#1" expanded="true" />
     700          </folding>
    658701        </state>
    659702      </provider>
     
    661704    <entry file="file://$PROJECT_DIR$/trunk/project1/main.py">
    662705      <provider selected="true" editor-type-id="text-editor">
    663         <state relative-caret-position="828">
    664           <caret line="46" column="0" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
     706        <state relative-caret-position="383">
     707          <caret line="75" column="0" selection-start-line="75" selection-start-column="0" selection-end-line="75" selection-end-column="0" />
    665708          <folding>
    666709            <element signature="e#19#38#0" expanded="true" />
     
    669712      </provider>
    670713    </entry>
    671     <entry file="file://$PROJECT_DIR$/trunk/project1/configpkcs11.py">
    672       <provider selected="true" editor-type-id="text-editor">
    673         <state relative-caret-position="180">
    674           <caret line="10" column="26" selection-start-line="10" selection-start-column="26" selection-end-line="10" selection-end-column="26" />
    675           <folding>
    676             <element signature="e#19#28#0" expanded="true" />
    677             <element signature="e#324#894#0" expanded="false" />
    678             <element signature="e#324#526#1" expanded="true" />
    679             <element signature="e#932#1126#0" expanded="false" />
    680             <element signature="e#932#1044#1" expanded="true" />
    681             <element signature="e#1166#1285#1" expanded="true" />
    682             <element signature="e#1442#1562#1" expanded="true" />
    683             <element signature="e#1788#1953#1" expanded="true" />
    684             <element signature="e#2118#2244#1" expanded="true" />
    685             <element signature="e#2433#2604#1" expanded="true" />
    686           </folding>
    687         </state>
    688       </provider>
    689     </entry>
    690714  </component>
    691715</project>
  • 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)
  • internals/2016/linuxloginsmartcardwizard/trunk/project1/main.py

    r16337 r16345  
    1414PAMPKCS11_CONFIG = "/etc/pam_pkcs11/pam_pkcs11.conf"
    1515PTEID_MODULE = "pteid.txt"
     16SUBJECTMAPPING_EXAMPLE = "/usr/share/doc/libpam-pkcs11/examples/subject_mapping.example"
     17PAMPKCS11_MAPPING = "/etc/pam_pkcs11/subject_mapping"
     18CARD_DATAFILE = "/tmp/cardData"
     19PAMCONFIG_EXAMPLE = "pkcs11.example"
     20PAMCONFIG = "/usr/share/pam-configs/pkcs11"
    1621
     22# Part 1 - Configuration of PKCS#11 module for PAM
    1723
    1824# Install PKCS#11 module for PAM
     
    4955configpkcs11.testInspect()
    5056
     57# Part 2 - User mapping configuration
     58
     59# Change use_mappers to subject in pam_pkcs11.conf
     60configpkcs11.changeUseMappers("subject", PAMPKCS11_CONFIG)
     61
     62# Copy subject_mapping file to main configuration folder
     63configpkcs11.copyFileToDirectory(SUBJECTMAPPING_EXAMPLE, PAMPKCS11_MAPPING)
     64
     65# Extract user authentication certificate from pkcs11_inspect execution
     66configpkcs11.getCardAuthCertificate(CARD_DATAFILE)
     67
     68# Add certificate->user mapping to subject_mapping file
     69username = input("Please write the username to used in the mapping\n")
     70configpkcs11.addUserMapping(CARD_DATAFILE, PAMPKCS11_MAPPING, username)
     71
     72# Create the pkcs11 file with configuration info
     73configpkcs11.copyFileToDirectory(PAMCONFIG_EXAMPLE, PAMCONFIG)
     74
     75# TODO Use pam-auth-update to activate the new configurations
     76
     77
     78# TODO Check configurations by looking at the common-auth file
     79
     80
     81
     82
Note: See TracChangeset for help on using the changeset viewer.