diff --git a/CHANGELOG b/CHANGELOG index 10464e8..851b6e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -45,4 +45,6 @@ · Also, deleted the plaintext version - 1.1 · Added license to source code to better comply with GPLv2; - · Added confirmation dialog for modification of passwords \ No newline at end of file + · Added confirmation dialog for modification of passwords +- 1.2 + · Added search function \ No newline at end of file diff --git a/doc/MANUAL.pdf b/doc/MANUAL.pdf index abdf0df..ed45140 100644 Binary files a/doc/MANUAL.pdf and b/doc/MANUAL.pdf differ diff --git a/doc/MANUAL.tex b/doc/MANUAL.tex index 0ce271d..80f85f4 100644 --- a/doc/MANUAL.tex +++ b/doc/MANUAL.tex @@ -51,6 +51,7 @@ \begin{itemize} \item Navigate through your passwords \item View a password (ENTER or E) + \item Search for a passwrd (S or F6) \item Create a new password (N or F4) \item Modify an existing password (M or F5) \item Copy the password to your clipboard (C or F3) @@ -67,6 +68,13 @@ \subsection{View a password} To view a password, press ENTER. The view password window will open. You can modify, copy or delete the password in the view password window. + + \subsection{Search for a password} + To search for the password for a specific service, press S. The search window will open, you can type your service's name on the window + and press ENTER to search. If no passwords are found, you'll see a warning and the query will not complete, showing all items on the + screen again. To reset your search filter, just open the search window again.\\ + \textbf{Important: The search filter is case-sensitive.} + \subsection{Create a new password} To create a new password, press N, the new password window will open, first type the service name (\texttt{SRVC}), then the username (\texttt{USER}), then the password (\texttt{PSWD}). \textbf{To cancel the addition of a new password, lave either the \texttt{SRVC} or the \texttt{USER} fields diff --git a/doc/html/MANUAL.html b/doc/html/MANUAL.html index dc63c0c..d716630 100644 --- a/doc/html/MANUAL.html +++ b/doc/html/MANUAL.html @@ -24,7 +24,7 @@ User Manual
Kamal ’brejela’ Curi

January 1, 2022
+class="cmr-12">January 10, 2022

Contents

@@ -46,29 +46,31 @@ href="#x1-80003.1" id="QQ2-1-8">Navigate through passwords
  3.2 View a password
  3.3 Create a new password +href="#x1-100003.3" id="QQ2-1-10">Search for a password
  3.4 Modify a password +href="#x1-110003.4" id="QQ2-1-11">Create a new password
  3.5 Copy the password to your clipboard +href="#x1-140003.5" id="QQ2-1-14">Modify a password
  3.6 Delete a password +href="#x1-150003.6" id="QQ2-1-15">Copy the password to your clipboard
  3.7 Generate a random string +href="#x1-160003.7" id="QQ2-1-16">Delete a password
  3.8 Open the help window +href="#x1-170003.8" id="QQ2-1-17">Generate a random string
  3.9 Quit steelbox +href="#x1-180003.9" id="QQ2-1-18">Open the help window +
  3.10 Quit steelbox
 4 F.A.Q. +href="#x1-200004" id="QQ2-1-20">F.A.Q.
  4.1 Contact +href="#x1-210004.1" id="QQ2-1-21">Contact
 5 Licenses +href="#x1-220005" id="QQ2-1-22">Licenses
  5.1 pyperclip +href="#x1-230005.1" id="QQ2-1-23">pyperclip
  5.2 Steelbox +href="#x1-240005.2" id="QQ2-1-24">Steelbox @@ -153,43 +155,56 @@ password saved. You can:

View a password (ENTER or E)

  • -

    Create a new password (N or F4) +

    Search for a passwrd (S or F6)

  • -

    Modify an existing password (M or F5) +

    Create a new password (N or F4)

  • -

    Copy the password to your clipboard (C or F3) +

    Modify an existing password (M or F5)

  • -

    Delete a password (D or Delete) +

    Copy the password to your clipboard (C or F3)

  • -

    Generate a random string (R) +

    Delete a password (D or Delete)

  • -

    Open the help window (H) +

    Generate a random string (R)

  • -

    Quit Steelbox (Q)

  • +

    Open the help window (H) -

    + +

  • +

    Quit Steelbox (Q)

  • +

    3.1 Navigate through passwords

    -

    You can move around the main window with the directional keys. If you have more +

    You can move around the main window with the directional keys. If you have more passwords than can fit on the screen, your list will have multiple pages. You can change your current page with PageUp/F2 and PageDown/F1. -

    +

    3.2 View a password

    -

    To view a password, press ENTER. The view password window will open. You can +

    To view a password, press ENTER. The view password window will open. You can modify, copy or delete the password in the view password window. -

    +

    3.3 Create a new password

    -

    To create a new password, press N, the new password window will open, first type + id="x1-100003.3">Search for a password +

    To search for the password for a specific service, press S. The search window will +open, you can type your service’s name on the window and press ENTER to search. +If no passwords are found, you’ll see a warning and the query will not complete, +showing all items on the screen again. To reset your search filter, just open the search +window again.
    Important: The search filter is case-sensitive. +

    +

    3.4 Create a new password

    +

    To create a new password, press N, the new password window will open, first type the service name (SRVC), then the username (USER), then the password (or the USER fields empty . Press ENTER to move to the next field -

    -

    3.3.1 Using random strings as passwords
    -

    To create a random password for your service, leave the

    +

    3.4.1 Using random strings as passwords
    +

    To create a random password for your service, leave the PSWD field empty. A random string will be given to it as a password. -

    -

    3.3.2 Setting up the length of a random string in a password
    -

    You can specify the length of a random password when creating (or modifying) one. + + + +

    +

    3.4.2 Setting up the length of a random string in a password
    +

    You can specify the length of a random password when creating (or modifying) one. Steelbox will recognize any integer between 0 and 45 after a colon(:). For example, if you need a random password of 16 characters in length:
    PSWD::16 -

    -

    3.4 Modify a password

    -

    To modify a password, press M, the modify password window will open, first edit the +

    +

    3.5 Modify a password

    +

    To modify a password, press M, the modify password window will open, first edit the service name, then the username, then the password. Leaving the PSWD empty in the modify window will give it a random string. through the currently selected field with:

    -

    You can see these commands with in the help window. -

    -

    3.5 Copy the password to your clipboard

    -

    To copy a highlighted service’s password, press C. You can do this in the main -window or in the View Password window. -

    -

    3.6 Delete a password

    -

    To delete a password, press D. You can do this in the main window or in the View -Password window. Steelbox will prompt you for confirmation, pressing anything but -Y will not remove your password. -

    -

    3.7 Generate a random string

    -

    If you just wish to generate a random string, you can press R. It will open a window -with a random string in it. +

    CTRL+O to clear the field +

    You can see these commands with in the help window. -

    +

    +

    3.6 Copy the password to your clipboard

    +

    To copy a highlighted service’s password, press C. You can do this in the main +window or in the View Password window. +

    +

    3.7 Delete a password

    +

    To delete a password, press D. You can do this in the main window or in the View +Password window. Steelbox will prompt you for confirmation, pressing anything but +Y will not remove your password. +

    3.8 Open the help window

    -

    To open the help window, press H. The help window has information on -steelbox. -

    + id="x1-170003.8">Generate a random string +

    If you just wish to generate a random string, you can press R. It will open a window +with a random string in it. +

    3.9 Quit steelbox

    -

    To quit steelbox, press Q from the main window. Steelbox will close its windows and + id="x1-180003.9">Open the help window +

    To open the help window, press H. The help window has information on +steelbox. +

    +

    3.10 Quit steelbox

    +

    To quit steelbox, press Q from the main window. Steelbox will close its windows and you’ll be asked to lock your password file with a password again. If you quit the HOME/pasfile.csv. Opening steelbox again will throw a war saying that no encrypted password file could be found, it will then try to open the unencrypted file. Quitting steelbox and entering a password solves this problem. -

    +

    4 F.A.Q.

    -

    F.A.Q. +

    Q: Why do I need to put my password when I enter *and* when I quit steelbox
    A: Yes. You first create a password with a dummy entry in whic to leave empty, and then modify it, leaving it empty.
    Q: Can I have a service with an empty password? A: Yes. With PSWD::0 +class="cmtt-10">PSWD::0 Q: +Can I migrate my password file from one system to another?
    A: The password file in $HOME/.pasfile.csv.gpg contains all saved passwords, that +file can be moved from one home directory to another.

    4.1 Contact

    -

    The author of this software can be contacted in kamalcuri@outlook.com. -

    + id="x1-210004.1">Contact +

    The author of this software can be contacted in kamalcuri@outlook.com. +

    5 Licenses

    -

    + id="x1-220005">Licenses +

    5.1 pyperclip

    -

    pyperclip’s license can be found in pyperclip +

    pyperclip’s license can be found in https://github.com/asweigart/pyperclip/blob/master/LICENSE.txt - - -

    5.2 Steelbox

    + id="x1-240005.2">Steelbox
    -

    -

    Copyright

    +

    Copyright © 1989, 1991 Free Software Foundation, Inc. -

    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA -

    Everyone is permitted to copy and distribute verbatim copies of this license +

    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +

    Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

    -

    -

    +

    Preamble

    -

    The licenses for most software are designed to take away your freedom to share and +

    The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software—to make sure the software is free for all its users. This General Public License applies to most of the Free Software + + + Foundation’s software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. -

    When we speak of free software, we are referring to freedom, not price. Our +

    When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. -

    To protect your rights, we need to make restrictions that forbid anyone to deny +

    To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. -

    For example, if you distribute copies of such a program, whether gratis or for a +

    For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. -

    We protect your rights with two steps: (1) copyright the software, and (2) offer +

    We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. - - - -

    Also, for each author’s protection and ours, we want to make certain that +

    Also, for each author’s protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors’ reputations. -

    Finally, any free program is threatened constantly by software patents. We wish +

    Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone’s free use or not licensed at all. -

    The precise terms and conditions for copying, distribution and modification +

    The precise terms and conditions for copying, distribution and modification follow.

    -

    -

    +

    Tertion

    -

    +

    1. -

      -

      This License applies to any program or other work which contains a notice + class="enumerate" id="x1-24002x0"> +

      + + + +

      This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The “Program”, below, refers to any such program or work, and a “work based on the Program” means @@ -450,7 +472,7 @@ class="small-caps">n with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term “modification”.) Each licensee is addressed as “you”. -

      Activities other than copying, distribution and modification are not +

      Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of @@ -458,45 +480,45 @@ class="small-caps">n on what the Program does.

    2. - - - -

      You may copy and distribute verbatim copies of the Program’s source code + class="enumerate" id="x1-24004x1"> +

      You may copy and distribute verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. -

      You may charge a fee for the physical act of transferring a copy, and you +

      You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

    3. -

      -

      You may modify your copy or copies of the Program or any portion of it, + class="enumerate" id="x1-24006x2"> +

      +

      You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: -

      +

      1. -

        -

        You must cause the modified files to carry prominent notices stating + class="enumerate" id="x1-24008x1"> +

        +

        You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + +

      2. -

        -

        You must cause any work that you distribute or publish, that in + class="enumerate" id="x1-24010x2"> +

        +

        You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.

      3. -

        If the modified program normally reads commands interactively when + class="enumerate" id="x1-24012x3"> +

        If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there @@ -504,13 +526,10 @@ class="small-caps">n that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an - - - announcement, your work based on the Program is not required to print an announcement.)

      -

      These requirements apply to the modified work as a whole. If identifiable +

      These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as @@ -519,53 +538,53 @@ class="small-caps">n the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. -

      Thus, it is not the intent of this section to claim rights or contest your rights to +

      Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. -

      In addition, mere aggregation of another work not based on the Program with +

      In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

    4. -

      You may copy and distribute the Program (or a work based on it, under + class="enumerate" id="x1-24014x3"> + + + +

      You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: -

      +

      1. -

        -

        Accompany it with the complete corresponding machine-readable + class="enumerate" id="x1-24016x1"> +

        +

        Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

      2. -

        -

        Accompany it with a written offer, valid for at least three years, to + class="enumerate" id="x1-24018x2"> +

        +

        Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically - - - performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

      3. -

        -

        Accompany it with the information you received as to the offer to + class="enumerate" id="x1-24020x3"> +

        +

        Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

      -

      The source code for a work means the preferred form of the work for +

      The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control @@ -575,15 +594,18 @@ class="small-caps">n components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. -

      If distribution of executable or object code is made by offering access to copy + + + +

      If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

    5. -

      You may not copy, modify, sublicense, or distribute the Program except + class="enumerate" id="x1-24022x4"> +

      You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who @@ -592,11 +614,8 @@ class="small-caps">n compliance.

    6. - - - -

      You are not required to accept this License, since you have not signed it. + class="enumerate" id="x1-24024x5"> +

      You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing @@ -606,8 +625,8 @@ class="small-caps">n it.

    7. -

      Each time you redistribute the Program (or any work based on the Program), + class="enumerate" id="x1-24026x6"> +

      Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients’ exercise of the rights @@ -615,11 +634,14 @@ class="small-caps">n parties to this License.

    8. -

      If, as a consequence of a court judgment or allegation of patent infringement + class="enumerate" id="x1-24028x7"> +

      If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the + + + conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program @@ -628,10 +650,10 @@ class="small-caps">n indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. -

      If any portion of this section is held invalid or unenforceable under any +

      If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. -

      It is not the purpose of this section to induce you to infringe any patents or +

      It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many @@ -639,16 +661,13 @@ class="small-caps">n distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that - - - choice. -

      This section is intended to make thoroughly clear what is believed to be a +

      This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

    9. -

      If the distribution and/or use of the Program is restricted in certain countries + class="enumerate" id="x1-24030x8"> +

      If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is @@ -657,22 +676,25 @@ class="small-caps">n License.

    10. -

      The Free Software Foundation may publish revised and/or new versions of the + class="enumerate" id="x1-24032x9"> +

      The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. -

      Each version is given a distinguishing version number. If the Program specifies +

      Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and “any later version”, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software + + + Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

    11. -

      If you wish to incorporate parts of the Program into other free programs whose + class="enumerate" id="x1-24034x10"> +

      If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision @@ -681,11 +703,8 @@ class="small-caps">n generally.

      -

      - - - -

      +

      No Waty

    12. -

      +

      Becon.

    13. -

      +

      In nss of + + + ds.

    -

    -

    +

    End ions

    -

    +

    Appendix: How to Apply These Terms to Your New Programs

    - - - -

    If you develop a new program, and you want it to be of the greatest possible use to + id="x1-250005.2">Appendix: How to Apply These Terms to Your New Programs +

    If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. -

    To do so, attach the following notices to the program. It is safest to attach them +

    To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. -

    +

    -

    one line to give the program’s name and a brief idea of what it does. +

    one line to give the program’s name and a brief idea of what it does.
    Copyright (C) yyyy name of author
    -

    This program is free software; you can redistribute it and/or modify +

    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -

    This program is distributed in the hope that it will be useful, but +

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -

    You should have received a copy of the GNU General Public +

    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

    -

    Also add information on how to contact you by electronic and paper + + + +

    Also add information on how to contact you by electronic and paper mail. -

    If the program is interactive, make it output a short notice like this when it starts +

    If the program is interactive, make it output a short notice like this when it starts in an interactive mode: -

    +

    -

    Gnomovision version 69, Copyright (C) yyyy name of author

    Gnomovision version 69, Copyright (C) yyyy name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type ‘show w’.
    This is free software, and you are welcome to redistribute it under certain conditions; type ‘show c’ for details.

    -

    The hypothetical commands

    The hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, the commands you use may be called @@ -1795,22 +1817,19 @@ something other than show w and show c; they could even be mouse-clicks or menu items—whatever suits your program. - - - -

    You should also get your employer (if you work as a programmer) or your school, +

    You should also get your employer (if you work as a programmer) or your school, if any, to sign a “copyright disclaimer” for the program, if necessary. Here is a sample; alter the names: -

    +

    -

    Yoyodyne, Inc., hereby disclaims all copyright interest in the +

    Yoyodyne, Inc., hereby disclaims all copyright interest in the program
    ‘Gnomovision’ (which makes passes at compilers) written by James Hacker.
    -

    signature of Ty Coon, 1 April 1989

    signature of Ty Coon, 1 April 1989
    Ty Coon, President of Vice

    -

    This General Public License does not permit incorporating your program into +

    This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this diff --git a/steelbox.py b/steelbox.py index 4233f1f..7685ecf 100644 --- a/steelbox.py +++ b/steelbox.py @@ -23,7 +23,7 @@ import os import pyperclip as pc import random -version = "v120d" +version = sys.argv[1] ## Initialization of bottomline dependencies @@ -37,15 +37,22 @@ fields = ["service", "user", "pswd"] # Password file HOMEDIR = os.environ['HOME'] -PASFILE="pasfile.csv" +PASFILE=HOMEDIR+"/.pasfile.csv" def reloadFiles(): + global SQUERY files.clear() with open(PASFILE, mode='r') as pasfile: # Creates reader object csvreader=csv.DictReader(pasfile) - for ids in csvreader: - files.append(ids) + if SQUERY == '': + for ids in csvreader: + files.append(ids) + else: + for ids in csvreader: + if ids['service'].find(SQUERY) != -1: + files.append(ids) + # Initializes the curses screen @@ -87,7 +94,7 @@ def steelbox(): while True: termGlobals() reloadFiles() - if len(files) < 1: + if len(files) < 1 and SQUERY == '': populate() displayItems() stdscr.move(0, 0) @@ -103,14 +110,8 @@ def displayItems(): global displayList displayList = [] # Appends the names in the CSV to display on the main window - if SQUERY == '': - for ps_name in files: - displayList.append(ps_name['service'][:15]) - else: - for ps_name in files: - sname = ps_name['service'] - if ps_name['service'].find(SQUERY) != -1: - displayList.append(ps_name['service'][:15]) + for ps_name in files: + displayList.append(ps_name['service'][:15]) # Reset global necessities LINE = 0 @@ -120,8 +121,8 @@ def displayItems(): global highOpt highOpt = () # Defines what to display - startDisplay = (CURR_PAGE-1)*len(displayList) - stopDisplay = CURR_PAGE*len(displayList) + startDisplay = (CURR_PAGE-1)*MAX_ITEMS + stopDisplay = CURR_PAGE*MAX_ITEMS for item in displayList[startDisplay:stopDisplay]: # If the item is the one with the cursor, highlight it @@ -215,6 +216,11 @@ def termGlobals(): # Gets user command def command(): + # This solution, for the case where the search function finds nothing, is cursed beyond belief, + global displayList + if len(displayList) < 1: + noMatch() + return() # The GLOBAL_CURSOR points to the main files object, so that it gets the right file. global c global CUROW @@ -379,10 +385,9 @@ def examine(): copy() def modFile(): + global files # Extracts the file to be modified modFile = files[GLOBAL_CURSOR] - # Removes it from the main file - files.pop(GLOBAL_CURSOR) # Creates the 'modify password' window modWin = curses.newwin(5, 60,int(TERM_LINES/2)-2, int(TERM_COLS/2)-18) # Gets the coordinates for the top left corner of said window @@ -446,7 +451,6 @@ def modFile(): pSize = 45 passPswd = randString(pSize) modFile = {'service' : passService, 'user' : passUser, 'pswd' : passPswd} - # This is just a copy of delfile's confirmation routine dlWin = curses.newwin(3, 22, int(TERM_LINES/2), int(TERM_COLS/2)) dlWin.border() @@ -456,9 +460,20 @@ def modFile(): dlWin.addstr(1, 1, "Are you sure? (y/N)") c = dlWin.getch() if c == ord('y'): - files.insert(GLOBAL_CURSOR, modFile) + iCount = 0 + with open(PASFILE, mode='r') as pasfile: + oldFiles = [] + csvreader = csv.DictReader(pasfile) + for ids in csvreader: + oldFiles.append(ids) + for ids in oldFiles: + if ids['service'] == files[GLOBAL_CURSOR]['service'] and ids['user'] == files[GLOBAL_CURSOR]['user'] and ids['pswd'] == files[GLOBAL_CURSOR]['pswd']: + oldFiles.pop(iCount) + iPos = iCount + iCount += 1 + oldFiles.insert(iPos, modFile) + files = oldFiles with open(PASFILE, mode='w') as pasfile: - # Creates writer object and writes to the csv file csvwriter = csv.DictWriter(pasfile, fields) csvwriter.writeheader() csvwriter.writerows(files) @@ -468,6 +483,7 @@ def modFile(): def delFile(): global GLOBAL_CURSOR global ITEM_CURSOR + global files dlWin = curses.newwin(3, 22, int(TERM_LINES/2), int(TERM_COLS/2)) dlWin.border() dlWin.refresh() @@ -476,7 +492,17 @@ def delFile(): dlWin.addstr(1, 1, "Are you sure? (y/N)") c = dlWin.getch() if c == ord('y'): - files.pop(GLOBAL_CURSOR) + iCount = 0 + with open(PASFILE, mode='r') as pasfile: + oldFiles = [] + csvreader = csv.DictReader(pasfile) + for ids in csvreader: + oldFiles.append(ids) + for ids in oldFiles: + if ids['service'] == files[GLOBAL_CURSOR]['service'] and ids['user'] == files[GLOBAL_CURSOR]['user'] and ids['pswd'] == files[GLOBAL_CURSOR]['pswd']: + oldFiles.pop(iCount) + iCount += 1 + files = oldFiles with open(PASFILE, mode='w') as pasfile: csvwriter = csv.DictWriter(pasfile, fields) csvwriter.writeheader() @@ -511,6 +537,8 @@ def searchWin(): global TERM_LINES global TERM_COLS global SQUERY + global ITEM_CURSOR + global GLOBAL_CURSOR searchWin = curses.newwin(3, 49, int(TERM_LINES/2), int(TERM_COLS/2)) searchWin.border() searchWin.addstr(0, 1, "Search service") @@ -525,6 +553,17 @@ def searchWin(): SQUERY = sbox.gather() l = len(SQUERY) SQUERY = SQUERY[:l-1] + ITEM_CURSOR = 0 + GLOBAL_CURSOR = 0 + + +def noMatch(): + global SQUERY + nomwin = curses.newwin(3, 40, int(TERM_LINES/2), int(TERM_COLS/2)) + nomwin.border() + nomwin.addstr(1, 1, "No passwords match the search criteria") + SQUERY = '' + nomwin.getch() # Cleans the windows diff --git a/steelbox.sh b/steelbox.sh index 7a6e41e..70c657c 100755 --- a/steelbox.sh +++ b/steelbox.sh @@ -3,10 +3,10 @@ #!/usr/bin/env bash -version="1.04" +version="1.2" echo "Steelbox V$version, Copyright (C) 2022 Kamal Curi" -echo "Steelbox comes with ABSOLUTELY NO WARRANTY; for details, read the manual in doc/" +echo "Steelbox comes with ABSOLUTELY NO WARRANTY; For license details, read the manual in doc/" if [ -f $HOME/.pasfile.csv.gpg ]