[PATCHES] improve extensions support

HacKan hackan at gmail.com
Mon Feb 6 17:40:30 CET 2017


Hello there! I spent the last few days playing around with pass, so I
forked it [1] and changed the way it handles extensions, because I
wanted to allow extensions to override internal commands. I.E. if
someone wants to modify the way /generate/ works, there's no need to
touch pass's core but simply create an extension named /generate.bash
/and that's all/./

Here's the rough changes list:

  * Modified the way commands are interpreted in the script: replaced
    the switch case selection to a more flexible eval'd one.
  * Changed how extensions are handled: now extensions are loaded first,
    before interpreting the command as an internal command. This allows
    extensions to override internal commands. A helper function is
    provided so that an overridden function can still be called from the
    extension.
  * Issuing help command now shows help from the extensions if they
    implement a function named help_{extension name}(). Otherwise, it
    will list enabled extensions as commands.

This keeps backwards compatibility at 100%, existing extensions are too
100% compatible. So for the final user these patches doesn't have any
effect at all.

Patches and signed hashes are attached.

Also, I tested these and all tests passed (attached as
/tests-result.txt/). Note that tests must be fixed first (see /[PATCH]
Fixes for tests/ [2]).

A sample /pass --help/ output with a couple of extensions I made is
attached (/help-example.txt/).

Attachment list:
0001-Changed-function-switch-based-on-parameters-by-a-mor.patch
0002-Added-helper-override_function-to-enable-extensions-.patch
0003-Modified-cmd_usage-to-show-extensions-usage-help-too.patch
0004-Minor-bugfixes-in-cmd_usage-when-showing-extensions-.patch
0005-Fixed-multiname-functions-parameters-were-not-being-.patch
0006-Small-bugfix-in-usage-command.-Also-changed-spaces-f.patch
SHA512SUMS
SHA512SUMS.sig
help-example.txt
tests-result.txt

Cheers!

[1]: https://github.com/HacKanCuBa/passh
[2]:
https://lists.zx2c4.com/pipermail/password-store/2017-February/002727.html

-- 
HacKan || Iván
GPG: 0x35710D312FDE468B

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Fixed-multiname-functions-parameters-were-not-being-.patch
Type: text/x-patch
Size: 3088 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0006.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Minor-bugfixes-in-cmd_usage-when-showing-extensions-.patch
Type: text/x-patch
Size: 1517 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Modified-cmd_usage-to-show-extensions-usage-help-too.patch
Type: text/x-patch
Size: 1925 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Added-helper-override_function-to-enable-extensions-.patch
Type: text/x-patch
Size: 1019 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0009.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Changed-function-switch-based-on-parameters-by-a-mor.patch
Type: text/x-patch
Size: 5156 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0010.bin>
-------------- next part --------------
Running all enabled tests...

Running: t0001-sanity-checks.sh
ok 1 - Make sure we can run pass
ok 2 - Make sure we can initialize our test store
# passed all 2 test(s)
1..2
Done

Running: t0010-generate-tests.sh
ok 1 - Test "generate" command
ok 2 - Test replacement of first line
ok 3 - Test replacement of first line with random
# passed all 3 test(s)
1..3
Done

Running: t0020-show-tests.sh
ok 1 - Test "show" command
ok 2 - Test "show" command with spaces
ok 3 - Test "show" of nonexistant password
# passed all 3 test(s)
1..3
Done

Running: t0050-mv-tests.sh
ok 1 - Basic move command
ok 2 - Directory creation
ok 3 - Directory creation with file rename and empty directory removal
ok 4 - Directory rename
ok 5 - Directory move into new directory
ok 6 - Multi-directory creation and multi-directory empty removal
ok 7 - Password made it until the end
ok 8 - Git is consistent
# passed all 8 test(s)
1..8
Done

Running: t0060-rm-tests.sh
ok 1 - Test "rm" command
ok 2 - Test "rm" command with spaces
ok 3 - Test "rm" of non-existent password
# passed all 3 test(s)
1..3
Done

Running: t0100-insert-tests.sh
ok 1 - Test "insert" command
# passed all 1 test(s)
1..1
Done

Running: t0200-edit-tests.sh
ok 1 - Test "edit" command
# passed all 1 test(s)
1..1
Done

Running: t0300-reencryption.sh
ok 1 - Setup initial key and git
ok 2 - Root key encryption
ok 3 - Reencryption root single key
ok 4 - Reencryption root multiple key
ok 5 - Reencryption root multiple key with string
ok 6 - Reencryption root group
ok 7 - Reencryption root group with spaces
ok 8 - Reencryption root group with spaces and other keys
ok 9 - Reencryption root group and other keys
ok 10 - Reencryption root group to identical individual with no file change
ok 11 - Reencryption subfolder multiple keys, copy
ok 12 - Reencryption subfolder multiple keys, move, deinit
ok 13 - Password lived through all transformations
ok 14 - Git picked up all changes throughout
# passed all 14 test(s)
1..14
Done

Running: t0400-grep.sh
ok 1 - Make sure grep prints normal lines
# passed all 1 test(s)
1..1
Done

Running: t0500-find.sh
ok 1 - Make sure find resolves correct files
# passed all 1 test(s)
1..1
Done

All enabled tests executed, have a nice day
-------------- next part --------------
============================================
= pass: the standard unix password manager =
=                                          =
=                  v1.6.5                  =
=                                          =
=             Jason A. Donenfeld           =
=               Jason at zx2c4.com            =
=                                          =
=      http://www.passwordstore.org/       =
============================================

Usage:
    pass init [--path=subfolder,-p subfolder] gpg-id...
        Initialize new password storage and use gpg-id for encryption.
        Selectively reencrypt existing passwords using new gpg-id.
    pass [ls] [subfolder]
        List passwords.
    pass find pass-names...
    	List passwords that match pass-names.
    pass [show] [--clip[=line-number],-c[line-number]] pass-name
        Show existing password and optionally put it on the clipboard.
        If put on the clipboard, it will be cleared in 12 seconds.
    pass grep search-string
        Search for password files containing search-string when decrypted.
    pass insert [--echo,-e | --multiline,-m] [--force,-f] pass-name
        Insert new password. Optionally, echo the password back to the console
        during entry. Or, optionally, the entry may be multiline. Prompt before
        overwriting existing password unless forced.
    pass edit pass-name
        Insert a new password or edit an existing password using vi.
    pass generate [--no-symbols,-n] [--clip,-c] [--in-place,-i | --force,-f] pass-name [pass-length]
        Generate a new password of pass-length (or 20 if unspecified) with optionally no symbols.
        Optionally put it on the clipboard and clear board after 12 seconds.
        Prompt before overwriting existing password unless forced.
        Optionally replace only the first line of an existing file with a new password.
    pass rm [--recursive,-r] [--force,-f] pass-name
        Remove existing password or directory, optionally forcefully.
    pass mv [--force,-f] old-path new-path
        Renames or moves old-path to new-path, optionally forcefully, selectively reencrypting.
    pass cp [--force,-f] old-path new-path
        Copies old-path to new-path, optionally forcefully, selectively reencrypting.
    pass git git-command-args...
        If the password store is a git repository, execute a git command
        specified by git-command-args.
    pass help
        Show this text.
    pass version
        Show version information.

From extensions:
    pass init [--path=subfolder,-p subfolder] [--git,-g] [--sign,-s] gpg-id
        Initialize new password storage and use gpg-id for encryption.
        Selectively reencrypt existing passwords using new gpg-id.
        Additionally, --git or -g initializes the git repository (same as 
        pass git init).
        Optionally, --sign or -s can be passed to temporarily set 
        PASSWORD_STORE_SIGNING_KEY to gpg-ip.
        If PASSWORD_STORE_SIGNING_KEY is set (either by --sign or 
        externally), it will be used to sign gpg-id files and also commits 
        (if git is initialized or already exists). Note that only the first 
        key in PASSWORD_STORE_SIGNING_KEY is used to sign commits! (this is
        a git limitation).
    pass insert [--echo,-e | --multiline,-m] [--force,-f] pass-name [file-path]
        Insert new password. Optionally, echo the password back to the console
        during entry. Or, the entry may be multiline. 
        If file-path is a file, it will be inserted (options for 
        echo and multiline are ignored)
        Prompt before overwriting existing password or file unless forced.

More information may be found in the pass(1) man page.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Small-bugfix-in-usage-command.-Also-changed-spaces-f.patch
Type: text/x-patch
Size: 2658 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0011.bin>
-------------- next part --------------
c61e47b84e2e7318c3366f586e87304722646a197f21d895c42801435cd670cca007c666e8edcc102048acc5150cb6f42857fa78dc113d9ecb271571fd4ac36d  0001-Changed-function-switch-based-on-parameters-by-a-mor.patch
d6781bf10dcf154c48a548bb782ffb72db65fdacc9e0da1d4f6381ffb064239929419b9b54a6a01007d0f9c8cbe61c99d26be0f7d7c37efabafed69d98079fe4  0002-Added-helper-override_function-to-enable-extensions-.patch
85d6b9ae376e42be0a8101055f2ea196fe453fd5985015884c424d6be6af4689a0eee6f813c5362dff4f79e751c17e623371d897665f69c305d6219c8fa63d38  0003-Modified-cmd_usage-to-show-extensions-usage-help-too.patch
4dd01d2762e6988cf83841ce12939a1bcfce99939f01c75111c2e66e535454fbd1ed09e68bc92660114b18ffd19e173981f40dd23916d00ed443199d1e5de8da  0004-Minor-bugfixes-in-cmd_usage-when-showing-extensions-.patch
730af4c505ec80fa2bacf32f5b6e8374718b928fda568a0aa628c9aed451c8eb58f6e6a2ab874383840d2084e485456bade09b32c6a2ef9d02ec106d42c8f76c  0005-Fixed-multiname-functions-parameters-were-not-being-.patch
6e287545124086fdfae2402d85a278fc38a41bdeefd3fdb5c00aa65c0fa99b34f2222d02f139298dff042cf6482a5ff79fcae249a60aee3bc71645b438e9a453  0006-Small-bugfix-in-usage-command.-Also-changed-spaces-f.patch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SHA512SUMS.sig
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20170206/c5bf8436/attachment-0001.sig>


More information about the Password-Store mailing list