Changeset 16354


Ignore:
Timestamp:
Jul 20, 2016, 2:24:37 PM (3 years ago)
Author:
dcorreia
Message:

Added final step of configuration: pam-auth-update execution
Changed user-certificate mapping logic
Added documentation to config module
Code refactoring in config module

Location:
internals/2016/linuxloginsmartcardwizard
Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • internals/2016/linuxloginsmartcardwizard/.idea/dictionaries/danielcorreia.xml

    r16311 r16354  
    11<component name="ProjectDictionaryState">
    2   <dictionary name="danielcorreia" />
     2  <dictionary name="danielcorreia">
     3    <words>
     4      <w>assinado</w>
     5      <w>autentica</w>
     6      <w>cacerts</w>
     7      <w>cartaode</w>
     8      <w>cidadao</w>
     9      <w>crls</w>
     10      <w>estado</w>
     11      <w>gunzip</w>
     12      <w>novo</w>
     13      <w>pteid</w>
     14      <w>raiz</w>
     15      <w>wget</w>
     16    </words>
     17  </dictionary>
    318</component>
  • internals/2016/linuxloginsmartcardwizard/.idea/estagiopycharm.iml

    r16302 r16354  
    22<module type="PYTHON_MODULE" version="4">
    33  <component name="NewModuleRootManager">
    4     <content url="file://$MODULE_DIR$" />
     4    <content url="file://$MODULE_DIR$">
     5      <sourceFolder url="file://$MODULE_DIR$/trunk/project1" isTestSource="false" />
     6    </content>
    57    <orderEntry type="inheritedJdk" />
    68    <orderEntry type="sourceFolder" forTests="false" />
  • internals/2016/linuxloginsmartcardwizard/.idea/workspace.xml

    r16346 r16354  
    22<project version="4">
    33  <component name="ChangeListManager">
    4     <list 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="MOVED" beforePath="$PROJECT_DIR$/trunk/project1/configpkcs11.py" afterPath="$PROJECT_DIR$/trunk/project1/config.py" />
     6      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/dictionaries/danielcorreia.xml" afterPath="$PROJECT_DIR$/.idea/dictionaries/danielcorreia.xml" />
     7      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/estagiopycharm.iml" afterPath="$PROJECT_DIR$/.idea/estagiopycharm.iml" />
    58      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
     9      <change type="MODIFICATION" beforePath="$PROJECT_DIR$/trunk/project1/main.py" afterPath="$PROJECT_DIR$/trunk/project1/main.py" />
    610    </list>
    7     <list default="true" id="b585d4db-50d8-4fb7-be87-de5ad4ae7ca8" name="Rejected commit: Default" comment="Added backup configuration folder." />
    811    <ignored path="estagiopycharm.iws" />
    912    <ignored path=".idea/workspace.xml" />
     
    2528  <component name="FileEditorManager">
    2629    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
    27       <file leaf-file-name="configpkcs11.py" pinned="false" current-in-tab="false">
    28         <entry file="file://$PROJECT_DIR$/trunk/project1/configpkcs11.py">
     30      <file leaf-file-name="config.py" pinned="false" current-in-tab="true">
     31        <entry file="file://$PROJECT_DIR$/trunk/project1/config.py">
    2932          <provider selected="true" editor-type-id="text-editor">
    30             <state relative-caret-position="-558">
    31               <caret line="5" column="14" selection-start-line="5" selection-start-column="14" selection-end-line="5" selection-end-column="14" />
     33            <state relative-caret-position="1170">
     34              <caret line="176" column="48" selection-start-line="176" selection-start-column="48" selection-end-line="176" selection-end-column="48" />
    3235              <folding>
    3336                <element signature="e#19#28#0" expanded="true" />
    34                 <element signature="e#363#565#1" expanded="true" />
    35                 <element signature="e#971#1165#0" expanded="false" />
    36                 <element signature="e#971#1083#1" expanded="true" />
    37                 <element signature="e#1205#1324#1" expanded="true" />
    38                 <element signature="e#1481#1601#1" expanded="true" />
    39                 <element signature="e#1827#1992#1" expanded="true" />
    40                 <element signature="e#2157#2283#1" expanded="true" />
    41                 <element signature="e#2472#2643#1" expanded="true" />
     37                <element signature="e#1116#1682#0" expanded="false" />
     38                <element signature="e#1116#1314#1" expanded="true" />
     39                <element signature="e#1761#2157#0" expanded="false" />
     40                <element signature="e#1761#2031#1" expanded="true" />
     41                <element signature="e#2195#2389#0" expanded="false" />
     42                <element signature="e#2195#2307#1" expanded="true" />
     43                <element signature="e#2429#2610#0" expanded="false" />
     44                <element signature="e#2429#2548#1" expanded="true" />
     45                <element signature="e#2651#2940#0" expanded="false" />
     46                <element signature="e#2651#2771#1" expanded="true" />
     47                <element signature="e#2997#3286#0" expanded="false" />
     48                <element signature="e#2997#3162#1" expanded="true" />
     49                <element signature="e#3323#3529#0" expanded="false" />
     50                <element signature="e#3323#3481#1" expanded="true" />
     51                <element signature="e#3568#3760#0" expanded="false" />
     52                <element signature="e#3568#3715#1" expanded="true" />
     53                <element signature="e#3812#4012#0" expanded="false" />
     54                <element signature="e#3812#3965#1" expanded="true" />
     55                <element signature="e#4060#4273#0" expanded="false" />
     56                <element signature="e#4060#4222#1" expanded="true" />
     57                <element signature="e#4326#4545#0" expanded="false" />
     58                <element signature="e#4326#4498#1" expanded="true" />
     59                <element signature="e#4586#4775#0" expanded="false" />
     60                <element signature="e#4586#4712#1" expanded="true" />
     61                <element signature="e#4825#5066#0" expanded="false" />
     62                <element signature="e#4825#4996#1" expanded="true" />
     63                <element signature="e#5135#5672#0" expanded="false" />
     64                <element signature="e#5135#5433#1" expanded="true" />
     65                <element signature="e#5728#6117#0" expanded="false" />
     66                <element signature="e#5728#5951#1" expanded="true" />
     67                <element signature="e#6162#6437#0" expanded="false" />
     68                <element signature="e#6162#6345#1" expanded="true" />
     69                <element signature="e#6502#6939#0" expanded="false" />
     70                <element signature="e#6502#6726#1" expanded="true" />
     71                <element signature="e#6990#7261#0" expanded="false" />
     72                <element signature="e#6990#7193#1" expanded="true" />
     73                <element signature="e#7314#7584#0" expanded="false" />
     74                <element signature="e#7314#7514#1" expanded="true" />
     75                <element signature="e#7621#7942#0" expanded="false" />
     76                <element signature="e#7621#7724#1" expanded="true" />
     77                <element signature="e#7998#8549#0" expanded="false" />
     78                <element signature="e#7998#8209#1" expanded="true" />
     79                <element signature="e#8580#9006#0" expanded="false" />
     80                <element signature="e#8580#8702#1" expanded="true" />
    4281              </folding>
    4382            </state>
     
    4584        </entry>
    4685      </file>
    47       <file leaf-file-name="main.py" pinned="false" current-in-tab="true">
     86      <file leaf-file-name="main.py" pinned="false" current-in-tab="false">
    4887        <entry file="file://$PROJECT_DIR$/trunk/project1/main.py">
    4988          <provider selected="true" editor-type-id="text-editor">
    50             <state relative-caret-position="455">
    51               <caret line="79" column="0" selection-start-line="79" selection-start-column="0" selection-end-line="79" selection-end-column="0" />
     89            <state relative-caret-position="-635">
     90              <caret line="8" column="26" selection-start-line="8" selection-start-column="26" selection-end-line="8" selection-end-column="26" />
    5291              <folding>
    53                 <element signature="e#19#38#0" expanded="true" />
     92                <element signature="e#19#32#0" expanded="true" />
    5493              </folding>
    5594            </state>
     
    82121        <option value="$PROJECT_DIR$/trunk/project1/configpkcs11.py" />
    83122        <option value="$PROJECT_DIR$/trunk/project1/main.py" />
     123        <option value="$PROJECT_DIR$/trunk/project1/config.py" />
    84124      </list>
    85125    </option>
     
    135175    </navigator>
    136176    <panes>
     177      <pane id="Scratches" />
     178      <pane id="ProjectPane">
     179        <subPane />
     180      </pane>
    137181      <pane id="Scope" />
    138       <pane id="ProjectPane">
    139         <subPane>
    140           <PATH>
    141             <PATH_ELEMENT>
    142               <option name="myItemId" value="estagiopycharm" />
    143               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    144             </PATH_ELEMENT>
    145             <PATH_ELEMENT>
    146               <option name="myItemId" value="External Libraries" />
    147               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
    148             </PATH_ELEMENT>
    149             <PATH_ELEMENT>
    150               <option name="myItemId" value="&lt; Python 3.4.3 (/usr/bin/python3.4) &gt;" />
    151               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode" />
    152             </PATH_ELEMENT>
    153             <PATH_ELEMENT>
    154               <option name="myItemId" value="python-skeletons" />
    155               <option name="myItemType" value="com.jetbrains.python.projectView.PyUserSkeletonsNode" />
    156             </PATH_ELEMENT>
    157           </PATH>
    158           <PATH>
    159             <PATH_ELEMENT>
    160               <option name="myItemId" value="estagiopycharm" />
    161               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    162             </PATH_ELEMENT>
    163             <PATH_ELEMENT>
    164               <option name="myItemId" value="External Libraries" />
    165               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
    166             </PATH_ELEMENT>
    167             <PATH_ELEMENT>
    168               <option name="myItemId" value="&lt; Python 3.4.3 (/usr/bin/python3.4) &gt;" />
    169               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode" />
    170             </PATH_ELEMENT>
    171             <PATH_ELEMENT>
    172               <option name="myItemId" value="-1247971765" />
    173               <option name="myItemType" value="com.jetbrains.python.projectView.PySkeletonsNode" />
    174             </PATH_ELEMENT>
    175           </PATH>
    176           <PATH>
    177             <PATH_ELEMENT>
    178               <option name="myItemId" value="estagiopycharm" />
    179               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    180             </PATH_ELEMENT>
    181             <PATH_ELEMENT>
    182               <option name="myItemId" value="External Libraries" />
    183               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
    184             </PATH_ELEMENT>
    185             <PATH_ELEMENT>
    186               <option name="myItemId" value="&lt; Python 3.4.3 (/usr/bin/python3.4) &gt;" />
    187               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode" />
    188             </PATH_ELEMENT>
    189             <PATH_ELEMENT>
    190               <option name="myItemId" value="dist-packages" />
    191               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    192             </PATH_ELEMENT>
    193           </PATH>
    194           <PATH>
    195             <PATH_ELEMENT>
    196               <option name="myItemId" value="estagiopycharm" />
    197               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    198             </PATH_ELEMENT>
    199             <PATH_ELEMENT>
    200               <option name="myItemId" value="External Libraries" />
    201               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
    202             </PATH_ELEMENT>
    203             <PATH_ELEMENT>
    204               <option name="myItemId" value="&lt; Python 3.4.3 (/usr/bin/python3.4) &gt;" />
    205               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode" />
    206             </PATH_ELEMENT>
    207           </PATH>
    208           <PATH>
    209             <PATH_ELEMENT>
    210               <option name="myItemId" value="estagiopycharm" />
    211               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    212             </PATH_ELEMENT>
    213             <PATH_ELEMENT>
    214               <option name="myItemId" value="External Libraries" />
    215               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
    216             </PATH_ELEMENT>
    217             <PATH_ELEMENT>
    218               <option name="myItemId" value="&lt; Python 3.4.3 (/usr/bin/python3.4) &gt;" />
    219               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode" />
    220             </PATH_ELEMENT>
    221             <PATH_ELEMENT>
    222               <option name="myItemId" value="lib-dynload" />
    223               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    224             </PATH_ELEMENT>
    225           </PATH>
    226           <PATH>
    227             <PATH_ELEMENT>
    228               <option name="myItemId" value="estagiopycharm" />
    229               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    230             </PATH_ELEMENT>
    231             <PATH_ELEMENT>
    232               <option name="myItemId" value="External Libraries" />
    233               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ExternalLibrariesNode" />
    234             </PATH_ELEMENT>
    235             <PATH_ELEMENT>
    236               <option name="myItemId" value="&lt; Python 3.4.3 (/usr/bin/python3.4) &gt;" />
    237               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.NamedLibraryElementNode" />
    238             </PATH_ELEMENT>
    239             <PATH_ELEMENT>
    240               <option name="myItemId" value="python3.4" />
    241               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    242             </PATH_ELEMENT>
    243           </PATH>
    244           <PATH>
    245             <PATH_ELEMENT>
    246               <option name="myItemId" value="estagiopycharm" />
    247               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    248             </PATH_ELEMENT>
    249             <PATH_ELEMENT>
    250               <option name="myItemId" value="estagiopycharm" />
    251               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    252             </PATH_ELEMENT>
    253             <PATH_ELEMENT>
    254               <option name="myItemId" value="trunk" />
    255               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    256             </PATH_ELEMENT>
    257           </PATH>
    258           <PATH>
    259             <PATH_ELEMENT>
    260               <option name="myItemId" value="estagiopycharm" />
    261               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    262             </PATH_ELEMENT>
    263             <PATH_ELEMENT>
    264               <option name="myItemId" value="estagiopycharm" />
    265               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    266             </PATH_ELEMENT>
    267             <PATH_ELEMENT>
    268               <option name="myItemId" value="trunk" />
    269               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    270             </PATH_ELEMENT>
    271             <PATH_ELEMENT>
    272               <option name="myItemId" value="project1" />
    273               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    274             </PATH_ELEMENT>
    275           </PATH>
    276           <PATH>
    277             <PATH_ELEMENT>
    278               <option name="myItemId" value="estagiopycharm" />
    279               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    280             </PATH_ELEMENT>
    281             <PATH_ELEMENT>
    282               <option name="myItemId" value="estagiopycharm" />
    283               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    284             </PATH_ELEMENT>
    285           </PATH>
    286           <PATH>
    287             <PATH_ELEMENT>
    288               <option name="myItemId" value="estagiopycharm" />
    289               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
    290             </PATH_ELEMENT>
    291             <PATH_ELEMENT>
    292               <option name="myItemId" value="estagiopycharm" />
    293               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    294             </PATH_ELEMENT>
    295             <PATH_ELEMENT>
    296               <option name="myItemId" value="docs" />
    297               <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
    298             </PATH_ELEMENT>
    299           </PATH>
    300         </subPane>
    301       </pane>
    302       <pane id="Scratches" />
    303182    </panes>
    304183  </component>
     
    343222      <option name="ADD_SOURCE_ROOTS" value="true" />
    344223      <module name="estagiopycharm" />
    345       <option name="SCRIPT_NAME" value="$PROJECT_DIR$/trunk/project1/configpkcs11.py" />
     224      <option name="SCRIPT_NAME" value="$PROJECT_DIR$/trunk/project1/config.py" />
    346225      <option name="PARAMETERS" value="" />
    347226      <option name="SHOW_COMMAND_LINE" value="false" />
     
    655534      <updated>1468940950021</updated>
    656535    </task>
    657     <option name="localTasksCounter" value="14" />
     536    <task id="LOCAL-00014" summary="IDE file&#10;&#10;">
     537      <created>1468941039521</created>
     538      <option name="number" value="00014" />
     539      <option name="presentableId" value="LOCAL-00014" />
     540      <option name="project" value="LOCAL" />
     541      <updated>1468941039522</updated>
     542    </task>
     543    <option name="localTasksCounter" value="15" />
    658544    <servers />
    659545  </component>
     
    671557    <editor active="false" />
    672558    <layout>
    673       <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" />
     559      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.19411297" sideWeight="0.49195403" order="0" side_tool="false" content_ui="combo" />
    674560      <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" />
    675561      <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" />
    676562      <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" />
    677       <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" />
     563      <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.23802164" sideWeight="0.49752998" order="7" side_tool="false" content_ui="tabs" />
    678564      <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" />
    679565      <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" />
     
    692578    <layout-to-restore>
    693579      <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" />
    694       <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32945737" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
     580      <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" />
    695581      <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" />
    696582      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
    697583      <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" />
    698       <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="8" side_tool="true" content_ui="tabs" />
     584      <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="8" side_tool="true" content_ui="tabs" />
    699585      <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" />
    700586      <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="9" side_tool="false" content_ui="tabs" />
    701       <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.31839257" sideWeight="0.49752998" order="10" side_tool="false" content_ui="tabs" />
     587      <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.23802164" sideWeight="0.49752998" order="10" side_tool="false" content_ui="tabs" />
    702588      <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" />
    703       <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32766616" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
    704       <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2545744" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
     589      <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="11" side_tool="false" content_ui="tabs" />
     590      <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.19411297" sideWeight="0.49195403" order="0" side_tool="false" content_ui="combo" />
    705591      <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" />
    706       <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
    707       <window_info id="Structure" active="false" anchor="left" 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" />
     592      <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" />
     593      <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" />
    708594      <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" />
    709       <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" />
     595      <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" />
    710596      <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" />
    711597    </layout-to-restore>
     
    726612  </component>
    727613  <component name="VcsManagerConfiguration">
     614    <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="true" />
    728615    <MESSAGE value="Sync Pycharm project files" />
    729616    <MESSAGE value="Added weekly report for Week 1&#10;Added troubleshooting file" />
     
    739626    <MESSAGE value="Added pteid module data file to project folder.&#10;FInished first part of configuration process." />
    740627    <MESSAGE value="Added features of second part of configuration process: subject mapping, card certificate operations and pam-configs.&#10;&#10;" />
    741     <option name="LAST_COMMIT_MESSAGE" value="Added features of second part of configuration process: subject mapping, card certificate operations and pam-configs.&#10;&#10;" />
     628    <MESSAGE value="IDE file&#10;&#10;" />
     629    <MESSAGE value="Added final step of configuration: pam-auth-update execution&#10;Changed user-certificate mapping logic&#10;Added documentation to config module&#10;Code refactoring in config module&#10;" />
     630    <option name="LAST_COMMIT_MESSAGE" value="Added final step of configuration: pam-auth-update execution&#10;Changed user-certificate mapping logic&#10;Added documentation to config module&#10;Code refactoring in config module&#10;" />
    742631  </component>
    743632  <component name="XDebuggerManager">
    744633    <breakpoint-manager>
    745       <option name="time" value="14" />
     634      <option name="time" value="19" />
    746635    </breakpoint-manager>
    747636    <watches-manager />
    748637  </component>
    749638  <component name="editorHistoryManager">
     639    <entry file="file://$PROJECT_DIR$/trunk/project1/config.py">
     640      <provider selected="true" editor-type-id="text-editor">
     641        <state relative-caret-position="18">
     642          <caret line="5" column="14" selection-start-line="5" selection-start-column="14" selection-end-line="5" selection-end-column="14" />
     643          <folding>
     644            <element signature="e#19#28#0" expanded="true" />
     645            <element signature="e#1116#1682#0" expanded="false" />
     646            <element signature="e#1116#1314#1" expanded="true" />
     647            <element signature="e#1761#2157#0" expanded="false" />
     648            <element signature="e#1761#2031#1" expanded="true" />
     649            <element signature="e#2195#2389#0" expanded="false" />
     650            <element signature="e#2195#2307#1" expanded="true" />
     651            <element signature="e#2429#2610#0" expanded="false" />
     652            <element signature="e#2429#2548#1" expanded="true" />
     653            <element signature="e#2651#2940#0" expanded="false" />
     654            <element signature="e#2651#2771#1" expanded="true" />
     655            <element signature="e#2997#3286#0" expanded="false" />
     656            <element signature="e#2997#3162#1" expanded="true" />
     657            <element signature="e#3323#3529#0" expanded="false" />
     658            <element signature="e#3323#3481#1" expanded="true" />
     659            <element signature="e#3568#3760#0" expanded="false" />
     660            <element signature="e#3568#3715#1" expanded="true" />
     661            <element signature="e#3812#4012#0" expanded="false" />
     662            <element signature="e#3812#3965#1" expanded="true" />
     663            <element signature="e#4060#4273#0" expanded="false" />
     664            <element signature="e#4060#4222#1" expanded="true" />
     665            <element signature="e#4326#4545#0" expanded="false" />
     666            <element signature="e#4326#4498#1" expanded="true" />
     667            <element signature="e#4586#4775#0" expanded="false" />
     668            <element signature="e#4586#4712#1" expanded="true" />
     669            <element signature="e#4825#5066#0" expanded="false" />
     670            <element signature="e#4825#4996#1" expanded="true" />
     671            <element signature="e#5135#5672#0" expanded="false" />
     672            <element signature="e#5135#5433#1" expanded="true" />
     673            <element signature="e#5728#6117#0" expanded="false" />
     674            <element signature="e#5728#5951#1" expanded="true" />
     675            <element signature="e#6162#6437#0" expanded="false" />
     676            <element signature="e#6162#6345#1" expanded="true" />
     677            <element signature="e#6502#6939#0" expanded="false" />
     678            <element signature="e#6502#6726#1" expanded="true" />
     679            <element signature="e#6990#7261#0" expanded="false" />
     680            <element signature="e#6990#7193#1" expanded="true" />
     681            <element signature="e#7314#7584#0" expanded="false" />
     682            <element signature="e#7314#7514#1" expanded="true" />
     683            <element signature="e#7621#7942#0" expanded="false" />
     684            <element signature="e#7621#7724#1" expanded="true" />
     685            <element signature="e#7998#8549#0" expanded="false" />
     686            <element signature="e#7998#8209#1" expanded="true" />
     687            <element signature="e#8580#9006#0" expanded="false" />
     688            <element signature="e#8580#8702#1" expanded="true" />
     689          </folding>
     690        </state>
     691      </provider>
     692    </entry>
    750693    <entry file="file://$PROJECT_DIR$/trunk/dir1/testfile" />
    751694    <entry file="file://$PROJECT_DIR$/trunk/dir1/testfile" />
     
    771714      </provider>
    772715    </entry>
    773     <entry file="file://$PROJECT_DIR$/trunk/project1/configmapper.py">
    774       <provider selected="true" editor-type-id="text-editor">
    775         <state relative-caret-position="36">
    776           <caret line="2" column="6" selection-start-line="2" selection-start-column="6" selection-end-line="2" selection-end-column="6" />
    777           <folding />
    778         </state>
    779       </provider>
    780     </entry>
     716    <entry file="file://$PROJECT_DIR$/trunk/project1/configmapper.py" />
    781717    <entry file="file://$PROJECT_DIR$/trunk/project1/pkcs11.example">
    782718      <provider selected="true" editor-type-id="text-editor">
    783719        <state relative-caret-position="72">
    784720          <caret line="4" column="74" selection-start-line="4" selection-start-column="74" selection-end-line="4" selection-end-column="74" />
    785           <folding />
    786         </state>
    787       </provider>
    788     </entry>
    789     <entry file="file://$PROJECT_DIR$/trunk/project1/configpkcs11.py">
    790       <provider selected="true" editor-type-id="text-editor">
    791         <state relative-caret-position="-558">
    792           <caret line="5" column="14" selection-start-line="5" selection-start-column="14" selection-end-line="5" selection-end-column="14" />
    793           <folding>
    794             <element signature="e#19#28#0" expanded="true" />
    795             <element signature="e#363#565#1" expanded="true" />
    796             <element signature="e#971#1165#0" expanded="false" />
    797             <element signature="e#971#1083#1" expanded="true" />
    798             <element signature="e#1205#1324#1" expanded="true" />
    799             <element signature="e#1481#1601#1" expanded="true" />
    800             <element signature="e#1827#1992#1" expanded="true" />
    801             <element signature="e#2157#2283#1" expanded="true" />
    802             <element signature="e#2472#2643#1" expanded="true" />
    803           </folding>
    804721        </state>
    805722      </provider>
     
    807724    <entry file="file://$PROJECT_DIR$/trunk/project1/main.py">
    808725      <provider selected="true" editor-type-id="text-editor">
    809         <state relative-caret-position="455">
    810           <caret line="79" column="0" selection-start-line="79" selection-start-column="0" selection-end-line="79" selection-end-column="0" />
     726        <state relative-caret-position="-635">
     727          <caret line="8" column="26" selection-start-line="8" selection-start-column="26" selection-end-line="8" selection-end-column="26" />
    811728          <folding>
    812             <element signature="e#19#38#0" expanded="true" />
     729            <element signature="e#19#32#0" expanded="true" />
    813730          </folding>
    814731        </state>
    815732      </provider>
    816733    </entry>
     734    <entry file="file://$PROJECT_DIR$/trunk/project1/config.py">
     735      <provider selected="true" editor-type-id="text-editor">
     736        <state relative-caret-position="1170">
     737          <caret line="176" column="48" selection-start-line="176" selection-start-column="48" selection-end-line="176" selection-end-column="48" />
     738          <folding>
     739            <element signature="e#19#28#0" expanded="true" />
     740            <element signature="e#1116#1682#0" expanded="false" />
     741            <element signature="e#1116#1314#1" expanded="true" />
     742            <element signature="e#1761#2157#0" expanded="false" />
     743            <element signature="e#1761#2031#1" expanded="true" />
     744            <element signature="e#2195#2389#0" expanded="false" />
     745            <element signature="e#2195#2307#1" expanded="true" />
     746            <element signature="e#2429#2610#0" expanded="false" />
     747            <element signature="e#2429#2548#1" expanded="true" />
     748            <element signature="e#2651#2940#0" expanded="false" />
     749            <element signature="e#2651#2771#1" expanded="true" />
     750            <element signature="e#2997#3286#0" expanded="false" />
     751            <element signature="e#2997#3162#1" expanded="true" />
     752            <element signature="e#3323#3529#0" expanded="false" />
     753            <element signature="e#3323#3481#1" expanded="true" />
     754            <element signature="e#3568#3760#0" expanded="false" />
     755            <element signature="e#3568#3715#1" expanded="true" />
     756            <element signature="e#3812#4012#0" expanded="false" />
     757            <element signature="e#3812#3965#1" expanded="true" />
     758            <element signature="e#4060#4273#0" expanded="false" />
     759            <element signature="e#4060#4222#1" expanded="true" />
     760            <element signature="e#4326#4545#0" expanded="false" />
     761            <element signature="e#4326#4498#1" expanded="true" />
     762            <element signature="e#4586#4775#0" expanded="false" />
     763            <element signature="e#4586#4712#1" expanded="true" />
     764            <element signature="e#4825#5066#0" expanded="false" />
     765            <element signature="e#4825#4996#1" expanded="true" />
     766            <element signature="e#5135#5672#0" expanded="false" />
     767            <element signature="e#5135#5433#1" expanded="true" />
     768            <element signature="e#5728#6117#0" expanded="false" />
     769            <element signature="e#5728#5951#1" expanded="true" />
     770            <element signature="e#6162#6437#0" expanded="false" />
     771            <element signature="e#6162#6345#1" expanded="true" />
     772            <element signature="e#6502#6939#0" expanded="false" />
     773            <element signature="e#6502#6726#1" expanded="true" />
     774            <element signature="e#6990#7261#0" expanded="false" />
     775            <element signature="e#6990#7193#1" expanded="true" />
     776            <element signature="e#7314#7584#0" expanded="false" />
     777            <element signature="e#7314#7514#1" expanded="true" />
     778            <element signature="e#7621#7942#0" expanded="false" />
     779            <element signature="e#7621#7724#1" expanded="true" />
     780            <element signature="e#7998#8549#0" expanded="false" />
     781            <element signature="e#7998#8209#1" expanded="true" />
     782            <element signature="e#8580#9006#0" expanded="false" />
     783            <element signature="e#8580#8702#1" expanded="true" />
     784          </folding>
     785        </state>
     786      </provider>
     787    </entry>
    817788  </component>
    818789</project>
  • internals/2016/linuxloginsmartcardwizard/trunk/project1/config.py

    r16345 r16354  
    77
    88
    9 INSTALL_COMMAND = "apt-get install "
    10 HASHLINK_COMMAND = "pkcs11_make_hash_link"
    11 WGET_COMMAND = "wget "
    12 GUNZIP_COMMAND = "gunzip "
    13 MV_COMMAND = "mv "
    14 INSPECT_COMMAND = "pkcs11_inspect"
    15 PAMAUTHUP_COMMAND = "pam-auth-update"
     9INSTALL_COMMAND = "apt-get install "        # Package installation
     10HASHLINK_COMMAND = "pkcs11_make_hash_link"  # PKCS11 hash links creation
     11WGET_COMMAND = "wget "                      # Download file with wget
     12GUNZIP_COMMAND = "gunzip "                  # Extract zipped files with gunzip
     13MV_COMMAND = "mv "                          # Move/Rename file
     14INSPECT_COMMAND = "pkcs11_inspect"          # PKCS11 inspect card data
     15COMMONAUTH = "/etc/pam.d/common-auth"       # PAM file with authentication configurations
     16TRASH_OUTPUT = open(os.devnull, "wb")       # Send output to trash file
     17TEMP_OUTPUT = "/tmp/cardData"               # Send output to temporary file
     18USEMODULE_OPTION = "use_pkcs11_module"      # Configuration option to choose the active module
     19USEMAPPERS_OPTION = "use_mappers"           # Configuration option to choose the active mappers
     20# PKCS11 update for common-auth
     21PKCS11AUTH = "auth\tsufficient\tpam_pkcs11.so config_file=/etc/pam_pkcs11/pam_pkcs11.conf"
    1622
    1723
    1824def executeCommand(command, outputPath=None):
    19     '''
    20     Executes a shell command and redirects output if necessary
     25    """
     26    Executes a shell command and redirects output (optional)
    2127    :param command: command to execute
    22     :param outputPath: path to redirect output if necessary
    23     :return: no return value
    24     '''
     28    :param outputPath: path to redirect output (optional)
     29    :return: no return value
     30    """
    2531    try:
    2632        process = subprocess.Popen(command, shell=True, stdout=outputPath, stderr=subprocess.PIPE)
     
    3137
    3238
     39def executeCommandInDirectory(command, directoryPath, outputPath=None):
     40    """
     41    Executes a shell command in a specific directory and redirects output (optional)
     42    :param command: command to execute
     43    :param directoryPath: path of the directory
     44    :param outputPath: path to redirect output (optional)
     45    :return: no return value
     46    """
     47    oldDirectory = os.getcwd()
     48    os.chdir(directoryPath)
     49    executeCommand(command, outputPath)
     50    os.chdir(oldDirectory)
     51
     52
    3353def printDebugInfo(debugData):
    34     '''
     54    """
    3555    Prints debug information
    3656    :param debugData: string of debug data
    3757    :return: no return value
    38     '''
     58    """
    3959    print("DEBUG: %s - %s" % (inspect.stack()[1][3], debugData), file=sys.stderr)
    4060
    4161
    4262def installPackage(packageName):
    43     '''
     63    """
    4464    Installs package using apt-get
    4565    :param packageName: name of the package
    4666    :return: no return value
    47     '''
    48     command = INSTALL_COMMAND + packageName
    49     output = open(os.devnull, "wb")
    50     executeCommand(command, output)
     67    """
     68    executeCommand(INSTALL_COMMAND+packageName, TRASH_OUTPUT)
    5169
    5270
    5371def makeDirectory(directoryPath):
    54     '''
     72    """
    5573    Creates a new directory
    5674    :param directoryPath: path of the new directory
    5775    :return: no return value
    58     '''
     76    """
    5977    try:
    6078        os.mkdir(directoryPath)
     
    6583
    6684def copyFileToDirectory(filePath, directoryPath):
    67     '''
     85    """
    6886    Copy a file to a directory
    6987    :param filePath: path of the file to copy
    7088    :param directoryPath: path of the directory
    7189    :return: no return value
    72     '''
     90    """
    7391    try:
    7492        shutil.copy2(filePath, directoryPath)
     
    7795
    7896
     97def readFileToList(filePath):
     98    """
     99    Reads the file and returns a list with the content
     100    :param filePath: path of the file
     101    :return: list of strings with content of the file
     102    """
     103    return open(filePath, mode="r").readlines()
     104
     105
     106def readFileToString(filePath):
     107    """
     108    Reads a file and returns a string with the content
     109    :param filePath: path of the file
     110    :return: string of content of the file
     111    """
     112    return "".join(readFileToList(filePath))
     113
     114
     115def writeStringToFile(filePath, stringData):
     116    """
     117    Writes input string in the file
     118    :param filePath: path of the file
     119    :param stringData: string to write
     120    :return: no return value
     121    """
     122    open(filePath, mode="w").write(stringData)
     123
     124
     125def writeListToFile(filePath, listData):
     126    """
     127    Write input list of data in the file
     128    :param filePath: path of the file
     129    :param listData: list of data to write
     130    :return: no return value
     131    """
     132    writeStringToFile(filePath, "".join(listData))
     133
     134
     135def appendStringToFile(filePath, stringData):
     136    """
     137    Append input string to the end of the file
     138    :param filePath: path of the file
     139    :param stringData: string of data to write
     140    :return: no return value
     141    """
     142    open(filePath, mode="a").write(stringData)
     143
     144
    79145def makeHashLinks(directoryPath):
    80     '''
     146    """
    81147    Make pkcs11 hash links in a directory
    82148    :param directoryPath: path of directory
    83149    :return: no return value
    84     '''
    85     currentDirectoryPath = os.getcwd()
    86     os.chdir(directoryPath)
    87     executeCommand(HASHLINK_COMMAND)
    88     os.chdir(currentDirectoryPath)
     150    """
     151    executeCommandInDirectory(HASHLINK_COMMAND, directoryPath)
    89152
    90153
    91154def getCRLFile(crlWebLink, directoryPath):
    92     '''
     155    """
    93156    Download crl file into a directory
    94157    :param crlWebLink: link of the crl file
    95158    :param directoryPath: path of the directory
    96159    :return: no return value
    97     '''
    98     currentDirectoryPath = os.getcwd()
    99     os.chdir(directoryPath)
    100     executeCommand(WGET_COMMAND+crlWebLink)
    101     os.chdir(currentDirectoryPath)
     160    """
     161    executeCommandInDirectory(WGET_COMMAND+crlWebLink, directoryPath)
    102162
    103163
    104164def makeConfigFile(configZipPath, configPath, directoryPath):
    105     currentDirectoryPath = os.getcwd()
     165    """
     166    Make pam_pkcs11.conf configuration file
     167    :param configZipPath: path of the configuration file example zip archive
     168    :param configPath: path to store the configuration file
     169    :param directoryPath: path of the directory for shell commands execution
     170    :return: no return value
     171    """
    106172    copyFileToDirectory(configZipPath, directoryPath)
    107     os.chdir(directoryPath)
    108     executeCommand(GUNZIP_COMMAND+"pam_pkcs11.conf.example.gz")
    109     executeCommand(MV_COMMAND+"pam_pkcs11.conf.example "+configPath)
    110     os.chdir(currentDirectoryPath)
     173    executeCommandInDirectory(GUNZIP_COMMAND+"pam_pkcs11.conf.example.gz", directoryPath)
     174    executeCommandInDirectory(MV_COMMAND+"pam_pkcs11.conf.example "+configPath, directoryPath)
    111175
    112176
    113177def addConfigModule(moduleFileName, configPath):
    114     configData = open(configPath, mode="r").readlines()
    115     moduleData = open(moduleFileName, mode="r").readlines()
    116     old_last = configData[len(configData)-1]
    117     configData[len(configData)-1] = "".join(moduleData) + "\n" + old_last
    118     open(configPath,mode="w").write("".join(configData))
    119 
    120 
    121 def changeActiveModule(newModule, configPath):
    122     configData = open(configPath, mode="r").readlines()
    123     for i in range(0,len(configData)):
    124         if "use_pkcs11_module" in configData[i]:
    125             configData[i] = "  use_pkcs11_module = " + newModule + ";\n"
    126             break
    127     open(configPath, mode="w").write("".join(configData))
    128 
    129 
    130 def testInspect():
    131     executeCommand(INSPECT_COMMAND)
    132 
    133 
    134 def 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 
    143 def 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 
    152 def 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)
     178    """
     179    Add a configuration module to the pam_pkcs11.conf configuration file
     180    :param moduleFileName: name of the module data file
     181    :param configPath: path of the configuration file
     182    :return: no return value
     183    """
     184    configData = readFileToList(configPath)
     185    configData[-1] = readFileToString(moduleFileName) + "\n" + configData[-1]
     186    writeListToFile(configPath, configData)
     187
     188
     189def getIndexOfToken(token, listData):
     190    """
     191    Gets index of list element that contains the input token
     192    :param token: token to find
     193    :param listData: list of data
     194    :return: index where the token was found
     195    """
     196    for i in range(0, len(listData)):
     197        if token in listData[i]:
     198            return i
     199
     200
     201def setConfigurationOption(option, newValue, configPath):
     202    """
     203    Sets value of a configuration option
     204    :param option: the configuration option
     205    :param newValue: the new value to be set
     206    :param configPath: path of the configuration file
     207    :return: no return value
     208    """
     209    configData = readFileToList(configPath)
     210    moduleIndex = getIndexOfToken(option, configData)
     211    configData[moduleIndex] = "  " + option + " = " + newValue + ";\n"
     212    writeListToFile(configPath, configData)
     213
     214
     215def changeUseModule(newModule, configPath):
     216    """
     217    Changes module of the use_pkcs11_module configuration option
     218    :param newModule: new module to be used
     219    :param configPath: path of the configuration file
     220    :return: no return value
     221    """
     222    setConfigurationOption(USEMODULE_OPTION, newModule, configPath)
     223
     224
     225def changeUseMappers(newMappers, configPath):
     226    """
     227    Changes mappers of the use_mappers configuration option
     228    :param newMappers: new mappers to be used
     229    :param configPath: path of the configuration file
     230    :return: no return value
     231    """
     232    setConfigurationOption(USEMAPPERS_OPTION, newMappers, configPath)
     233
     234
     235def getCardAuthCertificate():
     236    """
     237    Gets authentication certificate from the card
     238    :return: certificate in string format
     239    """
     240    executeCommand(INSPECT_COMMAND, open(TEMP_OUTPUT, mode="w"))
     241    cardData = readFileToList(TEMP_OUTPUT)
     242    for line in cardData:
     243        if "Autentica" in line and "serialNumber=" in line:
     244            return line
     245
     246
     247def addUserMapping(mappingConfigPath, username):
     248    """
     249    Add a user mapping with a certificate
     250    :param mappingConfigPath: path of the mapping configurations file
     251    :param username: name of the user
     252    :return: True on success and False on failure
     253    """
     254    certificate = getCardAuthCertificate()
     255    if certificate is None:
     256        printDebugInfo("No certificate found. Make sure the card is inserted and the PIN is correct")
     257        return False
     258    else:
     259        combo = certificate.strip() + " -> " + username + "\n"
     260        appendStringToFile(mappingConfigPath, combo)
     261        return True
    156262
    157263
    158264def runPamAuthUpdate():
    159     executeCommand(PAMAUTHUP_COMMAND)
     265    """
     266    Simulates the execution of pam-auth-update to active pam_pkcs11 in the system
     267    :return: no return value
     268    """
     269    authData = readFileToList(COMMONAUTH)
     270    pkcs11Index = getIndexOfToken("pam_pkcs11.so", authData)
     271    unixIndex = getIndexOfToken("pam_unix.so", authData)
     272    if pkcs11Index is None:
     273        authData[unixIndex] = PKCS11AUTH + "\n" + authData[unixIndex]
     274        writeListToFile(COMMONAUTH, authData)
  • internals/2016/linuxloginsmartcardwizard/trunk/project1/main.py

    r16345 r16354  
    11#!/usr/bin/python3
    2 import configpkcs11
     2import config
    33import os
    44
     5# PAM-PKCS#11
    56PAMPKCS11_PACKAGE = "libpam-pkcs11"
    67PAMPKCS11_DIRPATH = "/etc/pam_pkcs11"
     8PAMPKCS11_CONFIG = "/etc/pam_pkcs11/pam_pkcs11.conf"
     9GUNZIP_DIRPATH = "/usr/share/doc/libpam-pkcs11/examples/pam_pkcs11.conf.example.gz"
     10PTEID_MODULE = "pteid.txt"
     11
     12# Cacerts
    713CACERTS_DIRPATH = "/etc/pam_pkcs11/cacerts"
     14ECRAIZ_CERT = "/usr/local/share/certs/ECRaizEstado_novo_assinado_GTE.der"
     15CC001_CERT = "/usr/local/share/certs/CartaodeCidadao001.der"
     16
     17# Crls
    818CRLS_DIRPATH = "/etc/pam_pkcs11/crls"
    919CRL_FILENAME = "cc_ec_cidadao_crl001_crl.crl"
    10 ECRAIZ_CERT = "/usr/local/share/certs/ECRaizEstado_novo_assinado_GTE.der"
    11 CC001_CERT = "/usr/local/share/certs/CartaodeCidadao001.der"
    1220CC_CRL_HTTP = "https://pki.cartaodecidadao.pt/publico/lrc/cc_ec_cidadao_crl001_crl.crl"
    13 GUNZIP_DIRPATH = "/usr/share/doc/libpam-pkcs11/examples/pam_pkcs11.conf.example.gz"
    14 PAMPKCS11_CONFIG = "/etc/pam_pkcs11/pam_pkcs11.conf"
    15 PTEID_MODULE = "pteid.txt"
     21
     22# Mapping
    1623SUBJECTMAPPING_EXAMPLE = "/usr/share/doc/libpam-pkcs11/examples/subject_mapping.example"
    1724PAMPKCS11_MAPPING = "/etc/pam_pkcs11/subject_mapping"
    18 CARD_DATAFILE = "/tmp/cardData"
     25
     26# Pam-configs
    1927PAMCONFIG_EXAMPLE = "pkcs11.example"
    2028PAMCONFIG = "/usr/share/pam-configs/pkcs11"
     
    2331
    2432# Install PKCS#11 module for PAM
    25 configpkcs11.installPackage(PAMPKCS11_PACKAGE)
     33config.installPackage(PAMPKCS11_PACKAGE)
    2634
    2735# Create directories to support configuration files
    28 configpkcs11.makeDirectory(PAMPKCS11_DIRPATH)
    29 configpkcs11.makeDirectory(CACERTS_DIRPATH)
    30 configpkcs11.makeDirectory(CRLS_DIRPATH)
     36config.makeDirectory(PAMPKCS11_DIRPATH)
     37config.makeDirectory(CACERTS_DIRPATH)
     38config.makeDirectory(CRLS_DIRPATH)
    3139
    3240# Copy pteid module data file to general directory
    33 configpkcs11.copyFileToDirectory(PTEID_MODULE, PAMPKCS11_DIRPATH)
     41config.copyFileToDirectory(PTEID_MODULE, PAMPKCS11_DIRPATH)
    3442
    3543# Copy certificate files to cacerts directory and make hash links
    36 configpkcs11.copyFileToDirectory(ECRAIZ_CERT, CACERTS_DIRPATH)
    37 configpkcs11.copyFileToDirectory(CC001_CERT, CACERTS_DIRPATH)
    38 configpkcs11.makeHashLinks(CACERTS_DIRPATH)
     44config.copyFileToDirectory(ECRAIZ_CERT, CACERTS_DIRPATH)
     45config.copyFileToDirectory(CC001_CERT, CACERTS_DIRPATH)
     46config.makeHashLinks(CACERTS_DIRPATH)
    3947
    4048# Get crl file from web link
    41 if not os.path.exists(os.path.join(CRLS_DIRPATH,CRL_FILENAME)):
    42     configpkcs11.getCRLFile(CC_CRL_HTTP, CRLS_DIRPATH)
     49if not os.path.exists(os.path.join(CRLS_DIRPATH, CRL_FILENAME)):
     50    config.getCRLFile(CC_CRL_HTTP, CRLS_DIRPATH)
    4351
    4452# Generate pam_pkcs11.conf file
    45 configpkcs11.makeConfigFile(GUNZIP_DIRPATH, PAMPKCS11_CONFIG, PAMPKCS11_DIRPATH)
     53config.makeConfigFile(GUNZIP_DIRPATH, PAMPKCS11_CONFIG, PAMPKCS11_DIRPATH)
    4654
    4755# Add portuguese CC module to pam_pkcs11.conf file
    4856if "pteid" not in "".join(open(PAMPKCS11_CONFIG, mode="r").readlines()):
    49     configpkcs11.addConfigModule(PTEID_MODULE, PAMPKCS11_CONFIG)
     57    config.addConfigModule(PTEID_MODULE, PAMPKCS11_CONFIG)
    5058
    5159# Change pkcs11 module to be used in pam_pkcs11.conf file
    52 configpkcs11.changeActiveModule("pteid", PAMPKCS11_CONFIG)
     60config.changeUseModule("pteid", PAMPKCS11_CONFIG)
    5361
    5462# Test this phase of configuration by running pkcs11_inspect
    55 configpkcs11.testInspect()
    5663
    5764# Part 2 - User mapping configuration
    5865
    5966# Change use_mappers to subject in pam_pkcs11.conf
    60 configpkcs11.changeUseMappers("subject", PAMPKCS11_CONFIG)
     67config.changeUseMappers("subject", PAMPKCS11_CONFIG)
    6168
    6269# Copy subject_mapping file to main configuration folder
    63 configpkcs11.copyFileToDirectory(SUBJECTMAPPING_EXAMPLE, PAMPKCS11_MAPPING)
     70config.copyFileToDirectory(SUBJECTMAPPING_EXAMPLE, PAMPKCS11_MAPPING)
    6471
    6572# Extract user authentication certificate from pkcs11_inspect execution
    66 configpkcs11.getCardAuthCertificate(CARD_DATAFILE)
    67 
    6873# Add certificate->user mapping to subject_mapping file
    6974username = input("Please write the username to used in the mapping\n")
    70 configpkcs11.addUserMapping(CARD_DATAFILE, PAMPKCS11_MAPPING, username)
     75if config.addUserMapping(PAMPKCS11_MAPPING, username):
     76    print("Added mapping for user '%s'\n" % username)
     77else:
     78    print("Failed to add mapping for user '%s'" % username)
    7179
    7280# Create the pkcs11 file with configuration info
    73 configpkcs11.copyFileToDirectory(PAMCONFIG_EXAMPLE, PAMCONFIG)
     81config.copyFileToDirectory(PAMCONFIG_EXAMPLE, PAMCONFIG)
    7482
    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 
     83# Simulate pam-auth-update manually to change content of common-auth
     84config.runPamAuthUpdate()
Note: See TracChangeset for help on using the changeset viewer.