├── .github └── FUNDING.yml ├── debian ├── source │ └── format ├── rules ├── pass-extension-update.docs ├── copyright ├── changelog └── control ├── tests ├── .gitignore ├── gnupg │ ├── pubring.gpg │ ├── secring.gpg │ └── trustdb.gpg ├── fake-editor ├── 40_sanitychecks.sh ├── 10_paths.sh ├── 30_regex.sh ├── 20_options.sh ├── results ├── commons ├── lib-sharness │ └── functions.sh └── sharness ├── .gitignore ├── share ├── bash-completion │ └── completions │ │ └── pass-update ├── zsh │ └── site-functions │ │ └── _pass-update ├── __main__.py └── man │ └── man1 │ └── pass-update.md ├── .gitlab-ci.yml ├── CHANGELOG.md ├── Makefile ├── README.md ├── update.bash └── LICENSE /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: roddhjav -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | %: 4 | dh ${@} 5 | -------------------------------------------------------------------------------- /debian/pass-extension-update.docs: -------------------------------------------------------------------------------- 1 | README.md 2 | CHANGELOG.md 3 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | gnupg/ 2 | password-store/ 3 | test-results/ 4 | -------------------------------------------------------------------------------- /tests/gnupg/pubring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roddhjav/pass-update/HEAD/tests/gnupg/pubring.gpg -------------------------------------------------------------------------------- /tests/gnupg/secring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roddhjav/pass-update/HEAD/tests/gnupg/secring.gpg -------------------------------------------------------------------------------- /tests/gnupg/trustdb.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roddhjav/pass-update/HEAD/tests/gnupg/trustdb.gpg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # generated man pages 7 | share/man/man1/*.1 8 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: pass-update 3 | Upstream-Contact: Alexandre Pujol 4 | Source: https://github.com/roddhjav/pass-update 5 | 6 | Files: * 7 | Copyright: 2017-2024 Alexandre Pujol 8 | License: GPL-3+ 9 | -------------------------------------------------------------------------------- /share/bash-completion/completions/pass-update: -------------------------------------------------------------------------------- 1 | # pass-update completion file for bash 2 | 3 | PASSWORD_STORE_EXTENSION_COMMANDS+=(update) 4 | 5 | __password_store_extension_complete_update() { 6 | local args=(-h --help -c --clip -n --no-symbols -l --length -a --auto-length -p --provide 7 | -m --multiline -i --include -e --exclude -E --edit -f --force -V --version) 8 | COMPREPLY+=($(compgen -W "${args[*]}" -- ${cur})) 9 | _pass_complete_entries 10 | } 11 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | pass-update (2.2.1-1) stable; urgency=medium 2 | 3 | * Release pass-update v2.2.1 4 | 5 | -- Alexandre Pujol Wed, 28 Feb 2024 11:44:51 +0000 6 | 7 | pass-update (2.2-1) stable; urgency=medium 8 | 9 | * Release pass-update v2.2 10 | 11 | -- Alexandre Pujol Mon, 26 Feb 2024 20:01:01 +0000 12 | 13 | pass-update (2.1-1) unstable; urgency=medium 14 | 15 | * Initial release 16 | 17 | -- Alexandre Pujol Fri, 24 Apr 2020 20:30:06 +0100 18 | -------------------------------------------------------------------------------- /tests/fake-editor: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Fake editor program for testing 'pass update --edit'. 3 | # Changes password to 'correct horse battery staple', leaving rest of file intact. 4 | # 5 | # Intended use: 6 | # export FAKE_EDITOR_PASSWORD="blah blah blah" 7 | # export EDITOR=fake-editor-change-password.sh 8 | # $EDITOR 9 | # 10 | # Arguments: 11 | # Returns: 0 on success, 1 on error 12 | 13 | if [[ $# -ne 1 ]]; then 14 | echo "Usage: $0 " 15 | exit 1 16 | fi 17 | 18 | filename=$1 ; shift ; 19 | new_password="${FAKE_EDITOR_PASSWORD:-correct horse battery staple}" 20 | 21 | # And change only first line of file 22 | # -i.tmp allows editing file in place. Extension needed on Mac OSX 23 | sed -i.tmp "1 s/^.*\$/$new_password/g" "$filename" 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: pass-update 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Alexandre Pujol 5 | Build-Depends: 6 | debhelper-compat (= 12), 7 | Homepage: https://github.com/roddhjav/pass-update 8 | Vcs-Browser: https://github.com/roddhjav/pass-update 9 | Vcs-Git: https://github.com/roddhjav/pass-update.git 10 | Standards-Version: 4.6.0.1 11 | Rules-Requires-Root: no 12 | 13 | Package: pass-extension-update 14 | Architecture: all 15 | Depends: 16 | ${misc:Depends}, 17 | pass (>= 1.7.0), 18 | Description: pass extension that provides an easy flow for updating passwords 19 | Extends the pass utility with an update command providing an easy flow for 20 | updating passwords. It supports path, directory and wildcard update. 21 | Moreover, you can select how to update your passwords by automatically 22 | generating new passwords or manually setting your own. 23 | -------------------------------------------------------------------------------- /share/zsh/site-functions/_pass-update: -------------------------------------------------------------------------------- 1 | #compdef pass-update 2 | #description An easy flow for updating passwords 3 | 4 | _pass-update () { 5 | _arguments : \ 6 | {-h,--help}'[display help information]' \ 7 | {-V,--version}'[display version information]' \ 8 | {-c,--clip}'[write the password to the clipboard]' \ 9 | {-n,--no-symbols}'[do not use any non-alphanumeric characters]' \ 10 | {-l,--length}'[provide a password length]' \ 11 | {-a,--auto-length}'[match the previous password length]' \ 12 | {-p,--provide}'[let the user specify a password by hand]' \ 13 | {-m,--multiline}'[update a multiline password]' \ 14 | {-i,--include}'[only update the password that match a regex]' \ 15 | {-e,--exclude}'[do not update password that macth a regex]' \ 16 | {-E,--edit}'[edit the password using the default editor]' \ 17 | {-f,--force}'[force update]' 18 | _pass_complete_entries_with_subdirs 19 | } 20 | 21 | _pass-update "$@" 22 | -------------------------------------------------------------------------------- /tests/40_sanitychecks.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=SC2016,SC1091,SC2164 3 | 4 | export test_description="Testing pass update." 5 | cd tests 6 | source ./commons 7 | 8 | 9 | test_export "sanitychecks" 10 | 11 | 12 | test_expect_success 'Testing corner cases' ' 13 | test_must_fail _pass update --not-an-option && 14 | _pass update warning-not-in-the-store/ 15 | ' 16 | 17 | test_expect_success 'Testing incompatible options: --provide & --clip' ' 18 | test_must_fail _pass update --force --provide --clip Email/zx2c4.com 19 | ' 20 | 21 | test_expect_success 'Testing incompatible options: --provide & --multiline' ' 22 | test_must_fail _pass update --force --provide --multiline Email/zx2c4.com 23 | ' 24 | 25 | test_expect_success 'Testing wrong password length' ' 26 | test_must_fail _pass update --force --length number Email/zx2c4.com 27 | ' 28 | 29 | test_expect_success 'Testing help message' ' 30 | _pass update --help 31 | ' 32 | 33 | test_expect_success 'Testing version message' ' 34 | _pass update --version 35 | ' 36 | 37 | 38 | test_done 39 | -------------------------------------------------------------------------------- /tests/10_paths.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=SC2016,SC1091,SC2164 3 | 4 | export test_description="Testing pass update." 5 | cd tests 6 | source ./commons 7 | 8 | 9 | test_cleanup 10 | test_export "paths" 11 | test_pass_populate 12 | 13 | 14 | test_expect_success 'Testing not updating one password' ' 15 | _pass update Business/site.com && 16 | test_password_is Business/site.com $PASSWORD 17 | ' 18 | 19 | test_expect_success 'Testing updating multiple passwords' ' 20 | _pass update --force France/bank France/freebox France/mobilephone && 21 | test_password_is_not France/bank $PASSWORD && 22 | test_password_is_not France/freebox $PASSWORD && 23 | test_password_is_not France/mobilephone $PASSWORD 24 | ' 25 | 26 | test_expect_success 'Testing updating folder' ' 27 | _pass update --force Email/ && 28 | test_password_is_not Email/donenfeld.com $PASSWORD && 29 | test_password_is_not Email/zx2c4.com $PASSWORD 30 | ' 31 | 32 | test_expect_success "Testing bulk update" " 33 | _pass update --force 'Business/*/login' && 34 | test_password_is_not Business/bitcoin/login $PASSWORD && 35 | test_password_is_not 'Business/a space/login' $PASSWORD && 36 | test_password_is_not Business/euro/login $PASSWORD 37 | " 38 | 39 | test_expect_success "Testing updating everything" " 40 | _pass update --force / &> /dev/null 41 | " 42 | 43 | 44 | test_done 45 | -------------------------------------------------------------------------------- /tests/30_regex.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=SC2016,SC1091,SC2164 3 | 4 | export test_description="Testing pass update." 5 | cd tests 6 | source ./commons 7 | 8 | 9 | test_export "regex" 10 | test_pass_populate &> /dev/null 11 | 12 | 13 | test_expect_success 'Testing updating only passwords that follow a regex (1)' " 14 | _pass update --force --include '^[0-9]+$' Include/ && 15 | test_password_is_not Include/numbers1 $PASSWORD_NUMBERS1 && 16 | test_password_is_not Include/numbers2 $PASSWORD_NUMBERS2 && 17 | test_password_is Include/letters $PASSWORD_LETTERS 18 | " 19 | 20 | pass_insert Include/numbers1 "$PASSWORD_NUMBERS1" 21 | pass_insert Include/numbers2 "$PASSWORD_NUMBERS2" 22 | test_expect_success 'Testing updating only passwords that macth a regex (2)' " 23 | _pass update --force --include '^[a-z]+$' Include/ && 24 | test_password_is Include/numbers1 $PASSWORD_NUMBERS1 && 25 | test_password_is Include/numbers2 $PASSWORD_NUMBERS2 && 26 | test_password_is_not Include/letters $PASSWORD_LETTERS 27 | " 28 | 29 | 30 | test_expect_success 'Testing do not update passwords that macth a regex (1)' " 31 | _pass update --force --exclude '^[0-9]+$' Exclude/ && 32 | test_password_is Exclude/numbers1 $PASSWORD_NUMBERS1 && 33 | test_password_is Exclude/numbers2 $PASSWORD_NUMBERS2 && 34 | test_password_is_not Exclude/letters $PASSWORD_LETTERS 35 | " 36 | 37 | pass_insert Exclude/letters "$PASSWORD_LETTERS" 38 | test_expect_success 'Testing do not update passwords that macth a regex (2)' " 39 | _pass update --force --exclude '^[a-z]+$' Exclude/ && 40 | test_password_is_not Exclude/numbers1 $PASSWORD_NUMBERS1 && 41 | test_password_is_not Exclude/numbers2 $PASSWORD_NUMBERS2 && 42 | test_password_is Exclude/letters $PASSWORD_LETTERS 43 | " 44 | 45 | 46 | test_done 47 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | --- 2 | stages: 3 | - lint 4 | - tests 5 | - dist 6 | - deploy 7 | 8 | 9 | # Dependencies definitions 10 | # ------------------------ 11 | 12 | .distribution: 13 | stage: dist 14 | script: 15 | - make tests 16 | 17 | # Jobs definitions 18 | # ---------------- 19 | 20 | # Code Linters 21 | 22 | shellcheck: 23 | stage: lint 24 | image: koalaman/shellcheck-alpine 25 | script: 26 | - shellcheck --shell=bash update.bash tests/commons tests/results 27 | 28 | # Code tests 29 | 30 | tests: 31 | stage: tests 32 | image: archlinux 33 | before_script: 34 | - pacman -Syu --noconfirm --noprogressbar make grep pass git jq kcov 35 | script: 36 | - make tests COVERAGE=true 37 | - mv /tmp/tests/pass-update/kcov kcov/ 38 | artifacts: 39 | expire_in: 2 days 40 | paths: 41 | - kcov/ 42 | 43 | # Distribution tests 44 | 45 | archlinux: 46 | image: archlinux 47 | extends: .distribution 48 | before_script: 49 | - pacman -Syu --noconfirm --noprogressbar make grep pass git jq kcov 50 | 51 | ubuntu: 52 | image: ubuntu 53 | extends: .distribution 54 | before_script: 55 | - apt-get update -q && apt-get install -y make pass grep git 56 | 57 | debian: 58 | image: debian 59 | extends: .distribution 60 | before_script: 61 | - apt-get update -q && apt-get install -y make pass grep wget git xz-utils 62 | 63 | fedora: 64 | image: fedora 65 | extends: .distribution 66 | before_script: 67 | - dnf -y install make gpg pass grep git findutils --setopt=install_weak_deps=False 68 | 69 | # Code coverage deployment 70 | 71 | pages: 72 | stage: deploy 73 | dependencies: 74 | - tests 75 | script: 76 | - mv kcov/ public/ 77 | artifacts: 78 | expire_in: 2 days 79 | paths: 80 | - public 81 | rules: 82 | - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH 83 | -------------------------------------------------------------------------------- /tests/20_options.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=SC2016,SC1091,SC2164 3 | 4 | export test_description="Testing pass update." 5 | cd tests 6 | source ./commons 7 | 8 | 9 | test_export "options" 10 | test_pass_populate 11 | 12 | 13 | test_expect_success 'Testing updating password with specific length' ' 14 | _pass update --force --length=50 France/bank && 15 | newpasswd="$(pass show France/bank | head -n 1)" && 16 | [[ "${#newpasswd}" == 50 ]] 17 | ' 18 | 19 | test_expect_success 'Testing updating password with no symbols' ' 20 | _pass update --force --no-symbols Business/site.eu 21 | ' 22 | 23 | test_expect_success 'Testing updating password with a provided password' ' 24 | echo -e "dummypass\ndummypass" | _pass update --force --provide Business/site.com && 25 | test_password_is Business/site.com dummypass 26 | ' 27 | 28 | testing_password_notmatching() { 29 | echo -e "pass\ndummypass" | _pass update --force --provide Business/site.com 30 | } 31 | test_expect_success 'Testing passwords not matching' ' 32 | test_must_fail testing_password_notmatching 33 | ' 34 | 35 | test_expect_success 'Testing updating a multiline password' ' 36 | echo -e "dummypass\nlogin: dummylogin" | _pass update --force --multiline Business/site.eu && 37 | test_password_is Business/site.eu dummypass 38 | ' 39 | 40 | test_expect_success 'Testing updating a password by editing it' " 41 | _pass update --edit Business/site.eu && 42 | test_password_is Business/site.eu 'correct horse battery staple' 43 | " 44 | 45 | test_expect_success 'Testing updating a password with the same length' ' 46 | _pass update --force --auto-length Business/site.eu && 47 | newpasswd="$(pass show Business/site.eu | head -n 1)" && 48 | [[ "${#newpasswd}" == 28 ]] 49 | ' 50 | 51 | if test_have_prereq XCLIP; then 52 | test_expect_success 'Testing updating password with clipboard output' ' 53 | _pass update --force --clip Email/donenfeld.com && 54 | test_password_is_not Email/donenfeld.com $PASSWORD 55 | ' 56 | fi 57 | 58 | 59 | test_done 60 | -------------------------------------------------------------------------------- /share/__main__.py: -------------------------------------------------------------------------------- 1 | # pass update - Password Store Extension (https://www.passwordstore.org/) 2 | # Copyright (C) 2018-2024 Alexandre PUJOL . 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | """Generate release in this repo.""" 5 | 6 | import re 7 | import subprocess # nosec 8 | import sys 9 | from datetime import datetime 10 | 11 | EXT = 'update' 12 | 13 | 14 | def git_add(path: str): 15 | """Add file contents to the index.""" 16 | subprocess.call(["/usr/bin/git", "add", path], shell=False) # nosec 17 | 18 | 19 | def git_commit(msg: str): 20 | """Record changes to the repository.""" 21 | subprocess.call(["/usr/bin/git", "commit", "-S", "-m", msg], 22 | shell=False) # nosec 23 | 24 | 25 | def debian_changelog(version: str): 26 | """Update debian/changelog.""" 27 | path = "debian/changelog" 28 | now = datetime.now() 29 | date = now.strftime('%a, %d %b %Y %H:%M:%S +0000') 30 | template = f"""pass-{EXT} ({version}-1) stable; urgency=medium 31 | 32 | * Release pass-{EXT} v{version} 33 | 34 | -- Alexandre Pujol {date} 35 | 36 | """ 37 | with open(path, 'r') as file: 38 | data = file.read() 39 | with open(path, 'w') as file: 40 | file.write(template + data) 41 | git_add(path) 42 | 43 | 44 | def makerelease(): 45 | """Make a new release commit.""" 46 | version = sys.argv.pop() 47 | oldversion = sys.argv.pop() 48 | release = { 49 | 'README.md': [ 50 | (f'pass-{EXT}-{oldversion}', f'pass-{EXT}-{version}'), 51 | (f'pass {EXT} {oldversion}', f'pass {EXT} {version}'), 52 | (f'v{oldversion}', f'v{version}'), 53 | ], 54 | f'{EXT}.bash': [ 55 | (f'VERSION="{oldversion}"', f'VERSION="{version}"'), 56 | ], 57 | } 58 | debian_changelog(version) 59 | for path, pattern in release.items(): 60 | with open(path, 'r') as file: 61 | data = file.read() 62 | 63 | for old, new in pattern: 64 | data = re.sub(old, new, data) 65 | 66 | with open(path, 'w') as file: 67 | file.write(data) 68 | 69 | git_add(path) 70 | git_commit(f"Release pass-{EXT} {version}") 71 | 72 | 73 | if __name__ == "__main__": 74 | if '--release' in sys.argv: 75 | makerelease() 76 | else: 77 | print('Usage: python share --release OLDVERSION VERSION') 78 | sys.exit(1) 79 | -------------------------------------------------------------------------------- /tests/results: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # pass update - Password Store Extension (https://www.passwordstore.org/) 3 | # Copyright (C) 2008-2012 Git project 4 | # Copyright (C) 2017-2019 Alexandre PUJOL . 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | # shellcheck disable=SC2094,SC2153 21 | 22 | _die() { echo "${@}" && exit 1; } 23 | if $COVERAGE; then 24 | KCOV="$(command -v kcov)" 25 | [[ -e "$KCOV" ]] || _die "Could not find kcov command" 26 | mapfile -t COVERED < <(find "$TMP"/*.sh -maxdepth 0 -type d) 27 | [[ -z "$TRAVIS_JOB_ID" ]] || OPTS=("--coveralls-id=$TRAVIS_JOB_ID") 28 | "$KCOV" "${OPTS[@]}" --merge "$TMP/kcov" "${COVERED[@]}" 29 | covered="$(jq -r '.percent_covered' "$TMP/kcov/kcov-merged/coverage.json")" 30 | printf "%s: %s\n" coverage "$covered" 31 | fi 32 | 33 | failed_tests= 34 | fixed=0 35 | success=0 36 | failed=0 37 | broken=0 38 | total=0 39 | for file in tests/test-results/*.counts; do 40 | while read -r type value; do 41 | case $type in 42 | '') 43 | continue ;; 44 | fixed) 45 | fixed=$((fixed + value)) ;; 46 | success) 47 | success=$((success + value)) ;; 48 | failed) 49 | failed=$((failed + value)) 50 | if test "$value" != 0; then 51 | test_name=$(expr "$file" : 'tests/test-results/\(.*\)\.[0-9]*\.counts') 52 | failed_tests="$failed_tests $test_name" 53 | fi 54 | ;; 55 | broken) 56 | broken=$((broken + value)) ;; 57 | total) 58 | total=$((total + value)) ;; 59 | esac 60 | done <"$file" 61 | done 62 | 63 | if test -n "$failed_tests"; then 64 | printf "\nfailed test(s):%d\n\n" "$failed_tests" 65 | fi 66 | 67 | printf "%-8s%d\n" fixed "$fixed" 68 | printf "%-8s%d\n" success "$success" 69 | printf "%-8s%d\n" failed "$failed" 70 | printf "%-8s%d\n" broken "$broken" 71 | printf "%-8s%d\n" total "$total" 72 | 73 | rm -rf tests/test-results 74 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog][keep-changelog]. 6 | 7 | ## [2.2.1] - 2024-02-26 8 | 9 | ### Fixed 10 | 11 | - Ensure that `share/__main__.py` is not part of the distribution packaging. [#31](https://github.com/roddhjav/pass-update/issues/31) 12 | 13 | ## [2.2] - 2024-02-26 14 | 15 | ### Added 16 | 17 | - Add the `-a` option to generate password with the same lenght than the former ones. 18 | 19 | ### Changed 20 | 21 | - The man pages are now generated from markdown with pandoc. 22 | - Automated release process. 23 | - Updated the sharness test suite to `1.2.0` 24 | 25 | ## [2.1] - 2018-12-11 26 | ### Added 27 | * Add completion file for bash and zsh. 28 | * Add an `--include` option to only update the password that match a regex. [#15](https://github.com/roddhjav/pass-update/issues/15) 29 | * Add an `--exclude` option to not update the password that match a regex. 30 | * Add ability to skip certain password modification. [#12](https://github.com/roddhjav/pass-import/issues/12) 31 | * Added Gitlab CI and tests on Archlinux, CentOS, Debian, OpenSUSE, Ubuntu and Fedora. 32 | * Added this changelog. 33 | 34 | ### Changed 35 | * The `-e` option now means `--exclude` while `-E` means `--edit`. 36 | * The test suite has been simplified and the tests extended. 37 | * Multiple bash issues have been fixed. 38 | 39 | 40 | ## [2.0] - 2017-09-16 41 | ### Changed 42 | * For this release, most of the source code has been completely re-implemented. 43 | It allows us to provide the following **new** features in order to make password 44 | update an easier flow. 45 | 46 | ### Added 47 | * Support file, directory and wildcard update. 48 | * Let the user specify a password by hand: `--provide`, `-p` 49 | * Update a multi-line password: `--multiline`, `-m` 50 | * Edit the password using the default editor: `--edit`, `-e` 51 | 52 | 53 | ## [1.0] - 2017-04-14 54 | ### Added 55 | * Add `--no-symbols` option in order to not use any non-alphanumeric characters 56 | in the generated password. 57 | * Add the ability to set the password length with the new `--length` option. 58 | 59 | 60 | ## [0.2] - 2017-03-01 61 | ### Fixed 62 | * Fixed the makefile 63 | 64 | 65 | ## [0.1] - 2017-01-28 66 | 67 | * Initial release. 68 | 69 | 70 | [2.2.1]: https://github.com/roddhjav/pass-update/releases/tag/v2.2.1 71 | [2.2]: https://github.com/roddhjav/pass-update/releases/tag/v2.2 72 | [2.1]: https://github.com/roddhjav/pass-update/releases/tag/v2.1 73 | [2.0]: https://github.com/roddhjav/pass-update/releases/tag/v2.0 74 | [1.0]: https://github.com/roddhjav/pass-update/releases/tag/v1.0 75 | [0.2]: https://github.com/roddhjav/pass-update/releases/tag/v0.2 76 | [0.1]: https://github.com/roddhjav/pass-update/releases/tag/v0.1 77 | 78 | [keep-changelog]: https://keepachangelog.com/en/1.0.0/ 79 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # pass update - Password Store Extension (https://www.passwordstore.org/) 3 | # Copyright (C) 2017-2024 Alexandre PUJOL . 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | UNAME := $(shell uname) 7 | 8 | EXT ?= update 9 | ifeq ($(UNAME), Darwin) 10 | BREW_PREFIX := $(shell command -v brew >/dev/null 2>&1 && brew --prefix) 11 | ifneq ($(BREW_PREFIX),) 12 | PREFIX ?= $(BREW_PREFIX) 13 | else 14 | PREFIX ?= /usr/local 15 | endif 16 | else 17 | PREFIX ?= /usr 18 | endif 19 | DESTDIR ?= 20 | LIBDIR ?= $(PREFIX)/lib 21 | MANDIR ?= $(PREFIX)/share/man 22 | SYSTEM_EXTENSION_DIR ?= ${LIBDIR}/password-store/extensions 23 | ifeq ($(UNAME), Darwin) 24 | BASHCOMPDIR ?= $(PREFIX)/etc/bash_completion.d 25 | else 26 | BASHCOMPDIR ?= $(PREFIX)/share/bash-completion/completions 27 | endif 28 | ZSHCOMPDIR ?= $(PREFIX)/share/zsh/site-functions 29 | 30 | all: 31 | @echo "pass-${EXT} is a shell script and does not need compilation, it can be simply executed." 32 | @echo "To install it try \"make install\" instead." 33 | 34 | install_share: 35 | @install -Dm0644 share/bash-completion/completions/pass-${EXT} "${DESTDIR}${BASHCOMPDIR}/pass-${EXT}" 36 | @install -Dm0644 share/zsh/site-functions/_pass-${EXT} "${DESTDIR}${ZSHCOMPDIR}/_pass-${EXT}" 37 | ifneq (,$(wildcard ./share/man/man1/pass-${EXT}.1)) 38 | @install -Dm0644 share/man/man1/pass-${EXT}.1 "${DESTDIR}${MANDIR}/man1/pass-${EXT}.1" 39 | endif 40 | 41 | install: install_share 42 | @install -Dm0755 ${EXT}.bash "${DESTDIR}${SYSTEM_EXTENSION_DIR}/${EXT}.bash" 43 | @echo "pass-${EXT} is installed succesfully" 44 | 45 | COVERAGE ?= false 46 | TMP ?= /tmp/tests/pass-update 47 | PASS_TEST_OPTS ?= --verbose --immediate --chain-lint --root=/tmp/sharness 48 | T = $(sort $(wildcard tests/*.sh)) 49 | export COVERAGE TMP 50 | tests: $(T) 51 | @tests/results 52 | $(T): 53 | @$@ $(PASS_TEST_OPTS) 54 | 55 | lint: 56 | shellcheck --shell=bash ${EXT}.bash tests/commons tests/results 57 | 58 | docs: 59 | @pandoc -t man -s -o share/man/man1/pass-${EXT}.1 share/man/man1/pass-${EXT}.md 60 | 61 | OLDVERSION ?= 62 | VERSION ?= 63 | GPGKEY ?= 06A26D531D56C42D66805049C5469996F0DF68EC 64 | archive: 65 | @python3 share --release ${OLDVERSION} ${VERSION} 66 | @git tag v${VERSION} -m "pass-${EXT} v${VERSION}" --local-user=${GPGKEY} 67 | @git archive \ 68 | --format=tar.gz \ 69 | --prefix=pass-${EXT}-${VERSION}/share/man/man1/ \ 70 | --add-file=share/man/man1/pass-${EXT}.1 \ 71 | --prefix=pass-${EXT}-${VERSION}/ \ 72 | --output=pass-${EXT}-${VERSION}.tar.gz \ 73 | v${VERSION} ':!debian' ':!share/man/man1/*.md' 74 | @gpg --armor --default-key ${GPGKEY} --detach-sig pass-${EXT}-${VERSION}.tar.gz 75 | @gpg --verify pass-${EXT}-${VERSION}.tar.gz.asc 76 | 77 | PKGNAME := pass-extension-${EXT} 78 | BUILDIR := /home/build/${PKGNAME} 79 | BASEIMAGE := registry.gitlab.com/roddhjav/builders/debian 80 | CTNAME := builder-debian-pass-${EXT} 81 | debian: 82 | @docker stop ${CTNAME} &> /dev/null || true 83 | @docker pull ${BASEIMAGE} 84 | @docker run --rm -tid --name ${CTNAME} --volume ${PWD}:${BUILDIR} \ 85 | --volume ${HOME}/.gnupg:/home/build/.gnupg ${BASEIMAGE} &> /dev/null || true 86 | @docker exec --workdir=${BUILDIR} ${CTNAME} \ 87 | dpkg-buildpackage -b -d -us -ui --sign-key=${GPGKEY} 88 | @docker exec --workdir=${BUILDIR} ${CTNAME} lintian 89 | @docker exec ${CTNAME} bash -c 'mv ~/${PKGNAME}*.* ~/${PKGNAME}' 90 | @docker exec ${CTNAME} bash -c 'mv ~/pass-${EXT}*.* ~/${PKGNAME}' 91 | 92 | release: tests lint docs commitdocs archive 93 | 94 | clean: 95 | @rm -rf debian/.debhelper debian/debhelper* debian/pass-extension-${EXT}* \ 96 | tests/test-results/ tests/gnupg/random_seed debian/files *.deb \ 97 | *.buildinfo *.changes share/__pycache__ \ 98 | share/man/man1/pass-${EXT}.1 99 | 100 | .PHONY: install tests $(T) lint docs archive debian release clean 101 | -------------------------------------------------------------------------------- /share/man/man1/pass-update.md: -------------------------------------------------------------------------------- 1 | % pass-update(1) 2 | % pass update was written by Alexandre Pujol (alexandre@pujol.io) 3 | % February 2024 4 | 5 | # NAME 6 | 7 | pass-update — A **pass**(1) extension that provides an easy flow for updating passwords. 8 | 9 | # SYNOPSIS 10 | 11 | **pass update** [*options…*] *pass-names...* 12 | 13 | # DESCRIPTION 14 | 15 | **pass update** extends the pass utility with an update command providing an easy flow for updating passwords. It supports path, directory and wildcard update. Moreover, you can select how to update your passwords by automatically 16 | generating new passwords or manually setting your own. 17 | 18 | **pass update** assumes that the first line of the password file is the password and so only ever updates the first line unless the `--multiline` option is specified. 19 | 20 | By default, `pass update` prints the old password and wait for the user before generating a new one. This behaviour can be changed using the provided options. 21 | 22 | # COMMAND 23 | 24 | **pass update** [ `--clip`, `-c` ] [ `--no-symbols`, `-n` ] [ `--provide`, `-p` ] [`--length=`, `-l `] [ `--include=`, `-i ` ] [ `--exclude=`, `-e=` ] [ `--edit`, `-E` ] [ `--multiline`, `-m` ] `pass-names...` 25 | 26 | Update the password provided: print the password and wait for the user to generate a new one. 27 | 28 | *pass-names* 29 | 30 | : Can refer either to password store path(s) or directory. Both path and directory can be given in the same command. When updating a directory, all the passwords in this directory are updated. Wildcard update is supported by quoting `'*'`. 31 | 32 | 33 | # OPTIONS 34 | 35 | **`-c`, `--clip`** 36 | 37 | : Write both old and newly generated password to the clipboard. 38 | 39 | **`-n`, `--no-symbols`** 40 | 41 | : Do not use any non-alphanumeric characters in the generated password. 42 | 43 | **`-l `, `--length=`** 44 | 45 | : Provide a password length 46 | 47 | **`-a`, `--auto-length`** 48 | 49 | : The password length will match the previous password's length 50 | 51 | **`-p`, `--provide`** 52 | 53 | : Let the user specify a password by hand. 54 | 55 | **`-m`, `--multiline`** 56 | 57 | : Update a multiline password. Beware this option will overwrite the full password file instead of updating the password field. 58 | 59 | **`-i `, `--include=`** 60 | 61 | : Only update the passwords that match a regexp. 62 | 63 | **`-e `, `--exclude=`** 64 | 65 | : Do not update the passwords that match a given regexp. 66 | 67 | **`-E`, `--edit`** 68 | 69 | : Edit the password using the default editor. This editor can be specified with **EDITOR**. 70 | 71 | **`-f`, `--force`** 72 | 73 | : Do not wait for the user and generate a new password immediately. 74 | 75 | **`-V`, `--version`** 76 | 77 | : Show version information 78 | 79 | **`-h`, `--help`** 80 | 81 | : Show usage message. 82 | 83 | # EXAMPLES 84 | 85 | ### Update Social/twitter.com 86 | 87 | ```sh 88 | $ pass update Social/twitter.com 89 | Changing password for Social/twitter.com 90 | [}p&62"#"x'aF/_ix}6X3a)zq 91 | Are you ready to generate a new password? [y/N] y 92 | The generated password for Social/twitter.com is: 93 | ~*>afZsB+G\,c#+g$-,{OqJ{w 94 | ``` 95 | 96 | 97 | ### Update all the Emails 98 | 99 | ```sh 100 | $ pass update Email 101 | Changing password for Email/donenfeld.com 102 | b9b"k(u#m7|ST-400B5gM%[Kq 103 | Are you ready to generate a new password? [y/N] y 104 | The generated password for Email/donenfeld.com is: 105 | m6~!b5U`OhloT~R,4-OCa:h$Q 106 | Changing password for Email/zx2c4.com 107 | 4Fg{1Wg;WM{JZHqAMI:j5Jo$7 108 | Are you ready to generate a new password? [y/N] y 109 | The generated password for Email/zx2c4.com is: 110 | @uLYW_X9a",?wDQN=hp/^Z!$J 111 | ``` 112 | 113 | ### Set password length 114 | 115 | ```sh 116 | $ pass update France/bank -l 50 117 | Changing password for France/bank 118 | 9b'I;]b)>06xug!3.ME1*E+M3 119 | login: zx2c4 120 | Are you ready to generate a new password? [y/N] y 121 | The generated password for France/bank is: 122 | |3=&{ko:#I|A,P4*=[|hk^/V4jIcRN.uBBd-~RB0_L. 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | # This file should be sourced by all test-scripts 19 | # 20 | # This scripts sets the following: 21 | # $PASS Full path to password-store script to test 22 | # $GPG Name of gpg executable 23 | # $KEY{1..5} GPG key ids of testing keys 24 | # $TEST_HOME This folder 25 | # 26 | 27 | # shellcheck disable=SC1091,SC2016 28 | 29 | # Project directory 30 | TESTS_HOME="$(pwd)" 31 | PROJECT_HOME="$(dirname "$TESTS_HOME")" 32 | 33 | # Check dependencies 34 | _die() { echo "${@}" && exit 1; } 35 | PASS="$(command -v pass)" 36 | GPG="$(command -v gpg)" 37 | GIT=true 38 | [[ -e "$PASS" ]] || _die "Could not find pass command" 39 | [[ -e "$GPG" ]] || _die "Could not find gpg command" 40 | if $COVERAGE; then 41 | KCOV="$(command -v kcov)" 42 | [[ -e "$KCOV" ]] || _die "Could not find kcov command" 43 | _pass() { 44 | "$KCOV" --exclude-line='esac done,clip' \ 45 | --include-path="$PROJECT_HOME/update.bash" --exclude-path=/ \ 46 | "$TMP/$(basename "$0")" "$PASS" "${@}" 47 | } 48 | else 49 | _pass() { "$PASS" "${@}"; } 50 | fi 51 | 52 | # sharness config 53 | export SHARNESS_TEST_DIRECTORY="$TESTS_HOME" 54 | export SHARNESS_TEST_SRCDIR="$PROJECT_HOME" 55 | source ./lib-sharness/functions.sh 56 | source ./sharness 57 | 58 | # Prepare pass config vars 59 | unset PASSWORD_STORE_DIR 60 | unset PASSWORD_STORE_KEY 61 | unset PASSWORD_STORE_GIT 62 | unset PASSWORD_STORE_GPG_OPTS 63 | unset PASSWORD_STORE_X_SELECTION 64 | unset PASSWORD_STORE_CLIP_TIME 65 | unset PASSWORD_STORE_UMASK 66 | unset PASSWORD_STORE_GENERATED_LENGTH 67 | unset PASSWORD_STORE_CHARACTER_SET 68 | unset PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS 69 | unset PASSWORD_STORE_ENABLE_EXTENSIONS 70 | unset PASSWORD_STORE_EXTENSIONS_DIR 71 | unset PASSWORD_STORE_SIGNING_KEY 72 | unset GNUPGHOME 73 | unset EDITOR 74 | 75 | export PASSWORD_STORE_ENABLE_EXTENSIONS=true 76 | export PASSWORD_STORE_EXTENSIONS_DIR="$PROJECT_HOME" 77 | 78 | # GnuPG config 79 | unset GPG_AGENT_INFO 80 | export GNUPGHOME="$TESTS_HOME/gnupg/" 81 | export KEY1="D4C78DB7920E1E27F5416B81CC9DB947CF90C77B" 82 | export KEY2="70BD448330ACF0653645B8F2B4DDBFF0D774A374" 83 | export KEY3="62EBE74BE834C2EC71E6414595C4B715EB7D54A8" 84 | export KEY4="9378267629F989A0E96677B7976DD3D6E4691410" 85 | export KEY5="4D2AFBDE67C60F5999D143AFA6E073D439E5020C" 86 | chmod 700 "$GNUPGHOME" 87 | 88 | # Predefined passwords to be updated 89 | export PASSWORD="$RANDOM" 90 | export PASSWORD_NUMBERS1="$RANDOM" 91 | export PASSWORD_NUMBERS2="$RANDOM" 92 | export PASSWORD_LETTERS=correcthorsebatterystaple 93 | 94 | # Test helpers 95 | 96 | pw() { 97 | local length="${1:-25}" characters="${2:-[:graph:]}" 98 | bash -c 'read -r -n "$0" pass < <(LC_ALL=C tr -dc "$1" < /dev/urandom) && echo $pass' "$length" "$characters" 99 | } 100 | 101 | pass_insert() { 102 | echo -e "$2\nlogin: $(pw 8 "[:lower:]")\nurl: $(basename "$1")" | 103 | pass insert --multiline --force "$1" &>/dev/null 104 | } 105 | 106 | test_pass_populate() { 107 | pass init "$KEY1" &>/dev/null 108 | if $GIT; then 109 | pass git init &>/dev/null 110 | pass git config user.email "Pass-Automated-Testing-Suite@zx2c4.com" &>/dev/null 111 | pass git config user.name "Pass Automated Testing Suite" &>/dev/null 112 | fi 113 | pass_insert Business/site.com "$PASSWORD" 114 | pass_insert Business/site.eu "$PASSWORD" 115 | pass_insert Business/bitcoin/login "$PASSWORD" 116 | pass_insert Business/bitcoin/username "$PASSWORD" 117 | pass_insert 'Business/a space/login' "$PASSWORD" 118 | pass_insert 'Business/a space/username' "$PASSWORD" 119 | pass_insert Business/euro/login "$PASSWORD" 120 | pass_insert Business/euro/username "$PASSWORD" 121 | pass_insert Email/donenfeld.com "$PASSWORD" 122 | pass_insert Email/zx2c4.com "$PASSWORD" 123 | pass_insert France/bank "$PASSWORD" 124 | pass_insert France/freebox "$PASSWORD" 125 | pass_insert France/mobilephone "$PASSWORD" 126 | pass_insert Include/numbers1 "$PASSWORD_NUMBERS1" 127 | pass_insert Include/numbers2 "$PASSWORD_NUMBERS2" 128 | pass_insert Include/letters "$PASSWORD_LETTERS" 129 | pass_insert Exclude/numbers1 "$PASSWORD_NUMBERS1" 130 | pass_insert Exclude/numbers2 "$PASSWORD_NUMBERS2" 131 | pass_insert Exclude/letters "$PASSWORD_LETTERS" 132 | } 133 | 134 | test_password_is() { 135 | newpasswd="$(pass show "$1" | head -n 1)" 136 | [[ "$newpasswd" == "$2" ]] 137 | } 138 | 139 | test_password_is_not() { 140 | newpasswd="$(pass show "$1" | head -n 1)" 141 | [[ "$newpasswd" != "$2" ]] 142 | } 143 | 144 | test_cleanup() { 145 | rm -rf "$TMP" 146 | mkdir -p "$TMP" 147 | } 148 | 149 | test_export() { 150 | export testname="$1" 151 | export PASSWORD_STORE_DIR="$TMP/${testname}-store" 152 | export PASSWORD_STORE_CLIP_TIME="1" 153 | export PATH="$TESTS_HOME:$PATH" 154 | export EDITOR="fake-editor" 155 | export GIT_DIR="$PASSWORD_STORE_DIR/.git" 156 | export GIT_WORK_TREE="$PASSWORD_STORE_DIR" 157 | } 158 | 159 | test_xclip() { 160 | echo "$RANDOM" | xclip -i &>/dev/null 161 | return $? 162 | } 163 | 164 | # Check for auxiliary programs 165 | test_xclip && test_set_prereq XCLIP 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [][github-link] 2 | 3 | # pass update 4 | 5 | [![][gitlab]][gitlab-link] [![][coverage]][coverage-link] [![][quality]][quality-link] [![][release]][release-link] 6 | 7 | **A [pass] extension that provides an easy flow for updating passwords.** 8 | 9 | 10 | ## Description 11 | 12 | `pass update` extends the pass utility with an update command providing 13 | an easy flow for updating passwords. It supports path, directory and wildcard 14 | update. Moreover, you can select how to update your passwords by automatically 15 | generating new passwords or manually setting your own. 16 | 17 | `pass update` assumes that the first line of the password file is the password 18 | and so only ever updates the first line unless the `--multiline` option is 19 | specified. 20 | 21 | By default, `pass update` prints the old password and waits for the user before 22 | generating a new one. This behaviour can be changed using the provided options. 23 | 24 | ## Usage 25 | 26 | ``` 27 | pass update 2.2.1 - A pass extension that provides an easy flow for updating passwords. 28 | 29 | Usage: 30 | pass update [-h] [-n] [-l ] [-c | -p] [-p | -m] 31 | [-e ] [-i ] [-E] [-f] pass-names... 32 | Provide an interactive solution to update a set of passwords. 33 | pass-names can refer either to password store path(s) or to 34 | directory. 35 | 36 | It prints the old password and waits for the user before generating 37 | a new one. This behaviour can be changed using the provided options. 38 | 39 | Only the first line of a password file is updated unless the 40 | --multiline option is specified. 41 | 42 | Options: 43 | -c, --clip Write the password to the clipboard. 44 | -n, --no-symbols Do not use any non-alphanumeric characters. 45 | -l, --length Provide a password length. 46 | -a, --auto-length Match the previous password's length. 47 | -p, --provide Let the user specify a password by hand. 48 | -m, --multiline Update a multiline password. 49 | -i, --include Only update the passwords that match a regex. 50 | -e, --exclude Do not update the passwords that macth a regex. 51 | -E, --edit Edit the password using the default editor. 52 | -f, --force Force update. 53 | -V, --version Show version information. 54 | -h, --help Print this help message and exit. 55 | 56 | More information may be found in the pass-update(1) man page. 57 | ``` 58 | 59 | See `man pass-update` for more information. 60 | 61 | ## Examples 62 | 63 | **Update `Social/twitter.com`** 64 | ``` 65 | pass update Social/twitter.com 66 | Changing password for Social/twitter.com 67 | [}p&62"#"x'aF/_ix}6X3a)zq 68 | Are you ready to generate a new password? [y/N] y 69 | The generated password for Social/twitter.com is: 70 | ~*>afZsB+G\,c#+g$-,{OqJ{w 71 | ``` 72 | 73 | **Update all the Emails** 74 | ``` 75 | pass update Email 76 | Changing password for Email/donenfeld.com 77 | b9b"k(u#m7|ST-400B5gM%[Kq 78 | Are you ready to generate a new password? [y/N] y 79 | The generated password for Email/donenfeld.com is: 80 | m6~!b5U`OhloT~R,4-OCa:h$Q 81 | Changing password for Email/zx2c4.com 82 | HWl7u\Aqdk]AY$y!='@>]8"@` 83 | Are you ready to generate a new password? [y/N] y 84 | The generated password for Email/zx2c4.com is: 85 | @uLYW_X9a",?wDQN=hp/^Z!$J 86 | ``` 87 | 88 | **Set password length** 89 | ``` 90 | pass update -l 50 France/bank 91 | Changing password for France/bank 92 | 9b'I;]b)>06xug!3.ME1*E+M3 93 | login: zx2c4 94 | Are you ready to generate a new password? [y/N] y 95 | The generated password for France/bank is: 96 | |3=&{ko:#I|A,P4*=[|hk^/V4jIcRN.uBBd-~RB0_L][repology-link] 121 | 122 | **Requirements** 123 | * `pass 1.7.0` or greater. 124 | * `bash 4.0` or greater. 125 | 126 | **ArchLinux** 127 | 128 | `pass-update` is available in the [Arch User Repository][aur]. 129 | ```sh 130 | yay -S pass-update # or your preferred AUR install method 131 | ``` 132 | 133 | **Debian/Ubuntu** 134 | 135 | `pass-update` is available [my own debian repository][repo] with the package name 136 | `pass-extension-update`. Both the repository and the package are signed with 137 | my GPG key: [`06A26D531D56C42D66805049C5469996F0DF68EC`][keys]. 138 | ```sh 139 | wget -qO - https://pkg.pujol.io/debian/gpgkey | gpg --dearmor | sudo tee /usr/share/keyrings/pujol.io.gpg >/dev/null 140 | echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/pujol.io.gpg] https://pkg.pujol.io/debian/repo all main' | sudo tee /etc/apt/sources.list.d/pkg.pujol.io.list 141 | sudo apt-get update 142 | sudo apt-get install pass-extension-update 143 | ``` 144 | 145 | **NixOS** 146 | ```sh 147 | nix-env -iA nixos.passExtensions.pass-update 148 | ``` 149 | 150 | **OSX** 151 | 152 | `pass-update` is available with Homebrew using a [third-party][brew-tap] repository 153 | ```sh 154 | brew tap simplydanny/pass-extensions 155 | brew install pass-update 156 | ``` 157 | 158 | **From git** 159 | ```sh 160 | git clone https://github.com/roddhjav/pass-update/ 161 | cd pass-update 162 | sudo make install # For OSX: make install PREFIX=$(brew --prefix) 163 | ``` 164 | 165 | **Stable version** 166 | ```sh 167 | wget https://github.com/roddhjav/pass-update/releases/download/v2.2.1/pass-update-2.2.1.tar.gz 168 | tar xzf pass-update-2.2.1.tar.gz 169 | cd pass-update-2.2.1 170 | sudo make install # For OSX: make install PREFIX=$(brew --prefix) 171 | ``` 172 | 173 | [Releases][releases] and commits are signed using [`06A26D531D56C42D66805049C5469996F0DF68EC`][keys]. 174 | You should check the key's fingerprint and verify the signature: 175 | ```sh 176 | wget https://github.com/roddhjav/pass-update/releases/download/v2.2.1/pass-update-2.2.1.tar.gz.asc 177 | gpg --recv-keys 06A26D531D56C42D66805049C5469996F0DF68EC 178 | gpg --verify pass-update-2.2.1.tar.gz.sig 179 | ``` 180 | 181 | ## Contribution 182 | 183 | Feedback, contributors, pull requests are all very welcome. 184 | 185 | [github-link]: https://github.com/roddhjav/pass-update 186 | [gitlab]: https://gitlab.com/roddhjav/pass-update/badges/master/pipeline.svg?style=flat-square 187 | [gitlab-link]: https://gitlab.com/roddhjav/pass-update/pipelines 188 | [coverage]: https://img.shields.io/coveralls/roddhjav/pass-update/master.svg?style=flat-square 189 | [coverage-link]: https://coveralls.io/github/roddhjav/pass-update 190 | [quality]: https://img.shields.io/codacy/grade/1eccb02d0b9a4c3d834c01b8f67b6cb4/master.svg?style=flat-square 191 | [quality-link]: https://www.codacy.com/app/roddhjav/pass-update 192 | [release]: https://img.shields.io/github/release/roddhjav/pass-update.svg?maxAge=600&style=flat-square 193 | [release-link]: https://github.com/roddhjav/pass-update/releases/latest 194 | [repology-link]: https://repology.org/project/pass-update/versions 195 | 196 | [pass]: https://www.passwordstore.org/ 197 | [keys]: https://pujol.io/keys 198 | [repo]: https://pkg.pujol.io 199 | [aur]: https://aur.archlinux.org/packages/pass-update 200 | [releases]: https://github.com/roddhjav/pass-update/releases 201 | [keybase]: https://keybase.io/roddhjav 202 | [brew-tap]: https://github.com/SimplyDanny/homebrew-pass-extensions 203 | -------------------------------------------------------------------------------- /update.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # pass update - Password Store Extension (https://www.passwordstore.org/) 3 | # Copyright (C) 2017-2024 Alexandre PUJOL . 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | set -e -o pipefail 7 | 8 | readonly VERSION="2.2.1" 9 | 10 | warning() { printf 'Warning %s\n' "$*" >&2; } 11 | 12 | cmd_update_version() { 13 | cat <<-_EOF 14 | $PROGRAM $COMMAND $VERSION - A pass extension that provides an easy flow for updating passwords. 15 | _EOF 16 | } 17 | 18 | cmd_update_usage() { 19 | cmd_update_version 20 | echo 21 | cat <<-_EOF 22 | Usage: 23 | $PROGRAM update [-h] [-n] [-l ] [-c | -p] [-p | -m] 24 | [-e ] [-i ] [-E] [-f] pass-names... 25 | Provide an interactive solution to update a set of passwords. 26 | pass-names can refer either to password store path(s) or to 27 | directory. 28 | 29 | It prints the old password and waits for the user before generating 30 | a new one. This behaviour can be changed using the provided options. 31 | 32 | Only the first line of a password file is updated unless the 33 | --multiline option is specified. 34 | 35 | Options: 36 | -c, --clip Write the password to the clipboard. 37 | -n, --no-symbols Do not use any non-alphanumeric characters. 38 | -l, --length Provide a password length. 39 | -a, --auto-length Match the previous password's length. 40 | -p, --provide Let the user specify a password by hand. 41 | -m, --multiline Update a multiline password. 42 | -i, --include Only update the passwords that match a regex. 43 | -e, --exclude Do not update the passwords that macth a regex. 44 | -E, --edit Edit the password using the default editor. 45 | -f, --force Force update. 46 | -V, --version Show version information. 47 | -h, --help Print this help message and exit. 48 | 49 | More information may be found in the pass-update(1) man page. 50 | _EOF 51 | } 52 | 53 | # Print the content of a passfile 54 | # $1: Path in the password store 55 | # Return 0 if the password is shown, 1 otherwise 56 | # Print the file content on stdout 57 | _show() { 58 | local path="${1%/}" 59 | local passfile="$PREFIX/$path.gpg" 60 | if [[ -f "$passfile" ]]; then 61 | $GPG -d "${GPG_OPTS[@]}" "$passfile" || return 1 62 | fi 63 | } 64 | 65 | # Insert data to the password store 66 | # $1: Path in the password store 67 | # $2: Data to insert 68 | # Return 0 if the password is inserted, 1 otherwise 69 | _insert() { 70 | local path="${1%/}" data="$2" 71 | local passfile="$PREFIX/$path.gpg" 72 | 73 | set_git "$passfile" 74 | mkdir -p -v "$PREFIX/$(dirname "$path")" 75 | set_gpg_recipients "$(dirname "$path")" 76 | if [[ $MULTLINE -eq 0 ]]; then 77 | $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" <<<"$data" || return 1 78 | else 79 | echo -e "Enter the updated contents of $path and press Ctrl+D when finished:\n" 80 | $GPG -e "${GPG_RECIPIENT_ARGS[@]}" -o "$passfile" "${GPG_OPTS[@]}" || return 1 81 | fi 82 | git_add_file "$passfile" "Update password for $path to store." || return 2 83 | } 84 | 85 | cmd_update() { 86 | # Sanity checks 87 | [[ -z "${*}" ]] && die "Usage: $PROGRAM $COMMAND [-h] [-n] [-l ] [-c | -p] [-p | -m] [-e ] [-i ] [-E] [-f] pass-names" 88 | [[ ! $LENGTH =~ ^[0-9]+$ ]] && die "Error: pass-length \"$LENGTH\" must be a number." 89 | [[ -n "$CLIP" && $PROVIDED -eq 1 ]] && die "Error: cannot use the options --clip and --provide together" 90 | [[ $MULTLINE -eq 1 && $PROVIDED -eq 1 ]] && die "Error: cannot use the options --multiline and --provide together" 91 | 92 | # Get a curated list of path to update 93 | typeset -a paths=() passfiles=() 94 | local path passfile passdir file tmpfile 95 | for path in "$@"; do 96 | check_sneaky_paths "$path" 97 | passfile="$PREFIX/${path%/}.gpg" 98 | passdir="$PREFIX/${path%/}" 99 | if [[ $path =~ [*] ]]; then 100 | for file in "$PREFIX/"$path.gpg; do 101 | if [[ -f "$file" ]]; then 102 | tmpfile="${file#"$PREFIX"/}" 103 | paths+=("${tmpfile%.gpg}") 104 | fi 105 | done 106 | elif [[ -d "$passdir" ]]; then 107 | mapfile -t passfiles < <(find "$passdir" -type f -iname '*.gpg' -printf "$path/%P\n") 108 | for file in "${passfiles[@]}"; do 109 | paths+=("${file%.gpg}") 110 | done 111 | elif [[ -f $passfile ]]; then 112 | paths+=("$path") 113 | else 114 | warning "$path is not in the password store." 115 | fi 116 | done 117 | 118 | local content oldpassword 119 | for path in "${paths[@]}"; do 120 | if [[ $EDIT -eq 0 ]]; then 121 | if ! content="$(_show "$path")"; then 122 | die "Error: Password decryption aborted." 123 | fi 124 | 125 | oldpassword="$(echo "$content" | head -n 1)" 126 | [[ -n "$INCLUDE" && ! "$oldpassword" =~ $INCLUDE ]] && continue 127 | [[ -n "$EXCLUDE" && "$oldpassword" =~ $EXCLUDE ]] && continue 128 | 129 | # Show old password 130 | printf "\e[1m\e[37mChanging password for \e[4m%s\e[0m\n" "$path" 131 | if [[ -z "$CLIP" ]]; then 132 | printf "%s\n" "$content" 133 | else 134 | clip "$oldpassword" "$path" 135 | fi 136 | 137 | # Ask user for confirmation 138 | if [[ $YES -eq 0 ]]; then 139 | [[ $PROVIDED -eq 1 || $MULTLINE -eq 1 ]] && verb="provide" || verb="generate" 140 | read -r -p "Are you ready to $verb a new password? [y/N] " response 141 | [[ $response == [yY] ]] || continue 142 | fi 143 | 144 | # Update the password 145 | if [[ $PROVIDED -eq 1 ]]; then 146 | local newcontent password password_again 147 | while true; do 148 | read -r -p "Enter the new password for $path: " -s password || exit 1 149 | echo 150 | read -r -p "Retype the new password for $path: " -s password_again || exit 1 151 | echo 152 | if [[ "$password" == "$password_again" ]]; then 153 | break 154 | else 155 | die "Error: the entered passwords do not match." 156 | fi 157 | done 158 | newcontent="$(echo "$content" | sed $'1c \\\n'"$(sed 's/[\/&]/\\&/g' <<<"$password")"$'\n')" 159 | if ! _insert "$path" "$newcontent"; then 160 | die "Error: Password encryption aborted." 161 | fi 162 | elif [[ $MULTLINE -eq 1 ]]; then 163 | if ! _insert "$path"; then 164 | die "Error: Password encryption aborted." 165 | fi 166 | else 167 | if [[ $AUTOLENGTH -eq 1 ]]; then 168 | LENGTH="${#oldpassword}" 169 | echo "Using the old password length: $LENGTH" 170 | fi 171 | cmd_generate "$path" "$LENGTH" $SYMBOLS $CLIP '--in-place' || exit 1 172 | fi 173 | else 174 | cmd_edit "$path" 175 | fi 176 | done 177 | } 178 | 179 | # Global options 180 | YES=0 181 | MULTLINE=0 182 | CLIP="" 183 | SYMBOLS="" 184 | PROVIDED=0 185 | EDIT=0 186 | INCLUDE="" 187 | EXCLUDE="" 188 | AUTOLENGTH=0 189 | LENGTH="$GENERATED_LENGTH" 190 | 191 | # Getopt options 192 | small_arg="hVcfnl:apmEi:e:" 193 | long_arg="help,version,clip,force,no-symbols,length:,auto-length,provide,multiline,edit,include:,exclude:" 194 | opts="$($GETOPT -o $small_arg -l $long_arg -n "$PROGRAM $COMMAND" -- "$@")" 195 | err=$? 196 | eval set -- "$opts" 197 | while true; do case $1 in 198 | -c | --clip) 199 | CLIP="--clip" 200 | shift 201 | ;; 202 | -f | --force) 203 | YES=1 204 | shift 205 | ;; 206 | -n | --no-symbols) 207 | SYMBOLS="--no-symbols" 208 | shift 209 | ;; 210 | -p | --provide) 211 | PROVIDED=1 212 | shift 213 | ;; 214 | -l | --length) 215 | LENGTH="$2" 216 | shift 2 217 | ;; 218 | -a | --auto-length) 219 | AUTOLENGTH=1 220 | shift 1 221 | ;; 222 | -m | --multiline) 223 | MULTLINE=1 224 | shift 225 | ;; 226 | -i | --include) 227 | INCLUDE="$2" 228 | shift 2 229 | ;; 230 | -e | --exclude) 231 | EXCLUDE="$2" 232 | shift 2 233 | ;; 234 | -E | --edit) 235 | EDIT=1 236 | shift 237 | ;; 238 | -h | --help) 239 | shift 240 | cmd_update_usage 241 | exit 0 242 | ;; 243 | -V | --version) 244 | shift 245 | cmd_update_version 246 | exit 0 247 | ;; 248 | --) 249 | shift 250 | break 251 | ;; 252 | esac done 253 | 254 | [[ $err -ne 0 ]] && cmd_update_usage && exit 1 255 | cmd_update "$@" 256 | -------------------------------------------------------------------------------- /tests/lib-sharness/functions.sh: -------------------------------------------------------------------------------- 1 | # Library of functions shared by all tests scripts, included by 2 | # sharness.sh. 3 | # 4 | # Copyright (c) 2005-2019 Junio C Hamano 5 | # Copyright (c) 2005-2019 Git project 6 | # Copyright (c) 2011-2019 Mathias Lafeldt 7 | # Copyright (c) 2015-2019 Christian Couder 8 | # 9 | # This program is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see http://www.gnu.org/licenses/ . 21 | 22 | 23 | # Public: Define that a test prerequisite is available. 24 | # 25 | # The prerequisite can later be checked explicitly using test_have_prereq or 26 | # implicitly by specifying the prerequisite name in calls to test_expect_success 27 | # or test_expect_failure. 28 | # 29 | # $1 - Name of prerequisite (a simple word, in all capital letters by convention) 30 | # 31 | # Examples 32 | # 33 | # # Set PYTHON prerequisite if interpreter is available. 34 | # command -v python >/dev/null && test_set_prereq PYTHON 35 | # 36 | # # Set prerequisite depending on some variable. 37 | # test -z "$NO_GETTEXT" && test_set_prereq GETTEXT 38 | # 39 | # Returns nothing. 40 | test_set_prereq() { 41 | satisfied_prereq="$satisfied_prereq$1 " 42 | } 43 | satisfied_prereq=" " 44 | 45 | # Public: Check if one or more test prerequisites are defined. 46 | # 47 | # The prerequisites must have previously been set with test_set_prereq. 48 | # The most common use of this is to skip all the tests if some essential 49 | # prerequisite is missing. 50 | # 51 | # $1 - Comma-separated list of test prerequisites. 52 | # 53 | # Examples 54 | # 55 | # # Skip all remaining tests if prerequisite is not set. 56 | # if ! test_have_prereq PERL; then 57 | # skip_all='skipping perl interface tests, perl not available' 58 | # test_done 59 | # fi 60 | # 61 | # Returns 0 if all prerequisites are defined or 1 otherwise. 62 | test_have_prereq() { 63 | # prerequisites can be concatenated with ',' 64 | save_IFS=$IFS 65 | IFS=, 66 | # shellcheck disable=SC2086 67 | set -- $1 68 | IFS=$save_IFS 69 | 70 | total_prereq=0 71 | ok_prereq=0 72 | missing_prereq= 73 | 74 | for prerequisite; do 75 | case "$prerequisite" in 76 | !*) 77 | negative_prereq=t 78 | prerequisite=${prerequisite#!} 79 | ;; 80 | *) 81 | negative_prereq= 82 | esac 83 | 84 | total_prereq=$((total_prereq + 1)) 85 | case "$satisfied_prereq" in 86 | *" $prerequisite "*) 87 | satisfied_this_prereq=t 88 | ;; 89 | *) 90 | satisfied_this_prereq= 91 | esac 92 | 93 | case "$satisfied_this_prereq,$negative_prereq" in 94 | t,|,t) 95 | ok_prereq=$((ok_prereq + 1)) 96 | ;; 97 | *) 98 | # Keep a list of missing prerequisites; restore 99 | # the negative marker if necessary. 100 | prerequisite=${negative_prereq:+!}$prerequisite 101 | if test -z "$missing_prereq"; then 102 | missing_prereq=$prerequisite 103 | else 104 | missing_prereq="$prerequisite,$missing_prereq" 105 | fi 106 | esac 107 | done 108 | 109 | test $total_prereq = $ok_prereq 110 | } 111 | 112 | # Public: Execute commands in debug mode. 113 | # 114 | # Takes a single argument and evaluates it only when the test script is started 115 | # with --debug. This is primarily meant for use during the development of test 116 | # scripts. 117 | # 118 | # $1 - Commands to be executed. 119 | # 120 | # Examples 121 | # 122 | # test_debug "cat some_log_file" 123 | # 124 | # Returns the exit code of the last command executed in debug mode or 0 125 | # otherwise. 126 | test_debug() { 127 | # shellcheck disable=SC2154 128 | test "$debug" = "" || eval "$1" 129 | } 130 | 131 | # Public: Stop execution and start a shell. 132 | # 133 | # This is useful for debugging tests and only makes sense together with "-v". 134 | # Be sure to remove all invocations of this command before submitting. 135 | test_pause() { 136 | # shellcheck disable=SC2154 137 | if test "$verbose" = t; then 138 | "$SHELL_PATH" <&6 >&3 2>&4 139 | else 140 | error >&5 "test_pause requires --verbose" 141 | fi 142 | } 143 | 144 | # Public: Run command and ensure that it fails in a controlled way. 145 | # 146 | # Use it instead of "! ". For example, when dies due to a 147 | # segfault, test_must_fail diagnoses it as an error, while "! " would 148 | # mistakenly be treated as just another expected failure. 149 | # 150 | # This is one of the prefix functions to be used inside test_expect_success or 151 | # test_expect_failure. 152 | # 153 | # $1.. - Command to be executed. 154 | # 155 | # Examples 156 | # 157 | # test_expect_success 'complain and die' ' 158 | # do something && 159 | # do something else && 160 | # test_must_fail git checkout ../outerspace 161 | # ' 162 | # 163 | # Returns 1 if the command succeeded (exit code 0). 164 | # Returns 1 if the command died by signal (exit codes 130-192) 165 | # Returns 1 if the command could not be found (exit code 127). 166 | # Returns 0 otherwise. 167 | test_must_fail() { 168 | "$@" 169 | exit_code=$? 170 | if test $exit_code = 0; then 171 | echo >&2 "test_must_fail: command succeeded: $*" 172 | return 1 173 | elif test $exit_code -gt 129 -a $exit_code -le 192; then 174 | echo >&2 "test_must_fail: died by signal: $*" 175 | return 1 176 | elif test $exit_code = 127; then 177 | echo >&2 "test_must_fail: command not found: $*" 178 | return 1 179 | fi 180 | return 0 181 | } 182 | 183 | # Public: Run command and ensure that it succeeds or fails in a controlled way. 184 | # 185 | # Similar to test_must_fail, but tolerates success too. Use it instead of 186 | # " || :" to catch failures caused by a segfault, for instance. 187 | # 188 | # This is one of the prefix functions to be used inside test_expect_success or 189 | # test_expect_failure. 190 | # 191 | # $1.. - Command to be executed. 192 | # 193 | # Examples 194 | # 195 | # test_expect_success 'some command works without configuration' ' 196 | # test_might_fail git config --unset all.configuration && 197 | # do something 198 | # ' 199 | # 200 | # Returns 1 if the command died by signal (exit codes 130-192) 201 | # Returns 1 if the command could not be found (exit code 127). 202 | # Returns 0 otherwise. 203 | test_might_fail() { 204 | "$@" 205 | exit_code=$? 206 | if test $exit_code -gt 129 -a $exit_code -le 192; then 207 | echo >&2 "test_might_fail: died by signal: $*" 208 | return 1 209 | elif test $exit_code = 127; then 210 | echo >&2 "test_might_fail: command not found: $*" 211 | return 1 212 | fi 213 | return 0 214 | } 215 | 216 | # Public: Run command and ensure it exits with a given exit code. 217 | # 218 | # This is one of the prefix functions to be used inside test_expect_success or 219 | # test_expect_failure. 220 | # 221 | # $1 - Expected exit code. 222 | # $2.. - Command to be executed. 223 | # 224 | # Examples 225 | # 226 | # test_expect_success 'Merge with d/f conflicts' ' 227 | # test_expect_code 1 git merge "merge msg" B master 228 | # ' 229 | # 230 | # Returns 0 if the expected exit code is returned or 1 otherwise. 231 | test_expect_code() { 232 | want_code=$1 233 | shift 234 | "$@" 235 | exit_code=$? 236 | if test "$exit_code" = "$want_code"; then 237 | return 0 238 | fi 239 | 240 | echo >&2 "test_expect_code: command exited with $exit_code, we wanted $want_code $*" 241 | return 1 242 | } 243 | 244 | # Public: Compare two files to see if expected output matches actual output. 245 | # 246 | # The TEST_CMP variable defines the command used for the comparison; it 247 | # defaults to "diff -u". Only when the test script was started with --verbose, 248 | # will the command's output, the diff, be printed to the standard output. 249 | # 250 | # This is one of the prefix functions to be used inside test_expect_success or 251 | # test_expect_failure. 252 | # 253 | # $1 - Path to file with expected output. 254 | # $2 - Path to file with actual output. 255 | # 256 | # Examples 257 | # 258 | # test_expect_success 'foo works' ' 259 | # echo expected >expected && 260 | # foo >actual && 261 | # test_cmp expected actual 262 | # ' 263 | # 264 | # Returns the exit code of the command set by TEST_CMP. 265 | test_cmp() { 266 | ${TEST_CMP:-diff -u} "$@" 267 | } 268 | 269 | # Public: portably print a sequence of numbers. 270 | # 271 | # seq is not in POSIX and GNU seq might not be available everywhere, 272 | # so it is nice to have a seq implementation, even a very simple one. 273 | # 274 | # $1 - Starting number. 275 | # $2 - Ending number. 276 | # 277 | # Examples 278 | # 279 | # test_expect_success 'foo works 10 times' ' 280 | # for i in $(test_seq 1 10) 281 | # do 282 | # foo || return 283 | # done 284 | # ' 285 | # 286 | # Returns 0 if all the specified numbers can be displayed. 287 | test_seq() { 288 | i="$1" 289 | j="$2" 290 | while test "$i" -le "$j" 291 | do 292 | echo "$i" || return 293 | i=$((i + 1)) 294 | done 295 | } 296 | 297 | # Public: Check if the file expected to be empty is indeed empty, and barfs 298 | # otherwise. 299 | # 300 | # $1 - File to check for emptiness. 301 | # 302 | # Returns 0 if file is empty, 1 otherwise. 303 | test_must_be_empty() { 304 | if test -s "$1" 305 | then 306 | echo "'$1' is not empty, it contains:" 307 | cat "$1" 308 | return 1 309 | fi 310 | } 311 | 312 | # debugging-friendly alternatives to "test [-f|-d|-e]" 313 | # The commands test the existence or non-existence of $1. $2 can be 314 | # given to provide a more precise diagnosis. 315 | test_path_is_file () { 316 | if ! test -f "$1" 317 | then 318 | echo "File $1 doesn't exist. $2" 319 | false 320 | fi 321 | } 322 | 323 | test_path_is_dir () { 324 | if ! test -d "$1" 325 | then 326 | echo "Directory $1 doesn't exist. $2" 327 | false 328 | fi 329 | } 330 | 331 | # Check if the directory exists and is empty as expected, barf otherwise. 332 | test_dir_is_empty () { 333 | test_path_is_dir "$1" && 334 | if test -n "$(find "$1" -mindepth 1 -maxdepth 1)" 335 | then 336 | echo "Directory '$1' is not empty, it contains:" 337 | ls -la "$1" 338 | return 1 339 | fi 340 | } 341 | 342 | # Public: Schedule cleanup commands to be run unconditionally at the end of a 343 | # test. 344 | # 345 | # If some cleanup command fails, the test will not pass. With --immediate, no 346 | # cleanup is done to help diagnose what went wrong. 347 | # 348 | # This is one of the prefix functions to be used inside test_expect_success or 349 | # test_expect_failure. 350 | # 351 | # $1.. - Commands to prepend to the list of cleanup commands. 352 | # 353 | # Examples 354 | # 355 | # test_expect_success 'test core.capslock' ' 356 | # git config core.capslock true && 357 | # test_when_finished "git config --unset core.capslock" && 358 | # do_something 359 | # ' 360 | # 361 | # Returns the exit code of the last cleanup command executed. 362 | test_when_finished() { 363 | test_cleanup="{ $* 364 | } && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup" 365 | } 366 | 367 | # Public: Schedule cleanup commands to be run unconditionally when all tests 368 | # have run. 369 | # 370 | # This can be used to clean up things like test databases. It is not needed to 371 | # clean up temporary files, as test_done already does that. 372 | # 373 | # Examples: 374 | # 375 | # cleanup mysql -e "DROP DATABASE mytest" 376 | # 377 | # Returns the exit code of the last cleanup command executed. 378 | final_cleanup= 379 | cleanup() { 380 | final_cleanup="{ $* 381 | } && (exit \"\$eval_ret\"); eval_ret=\$?; $final_cleanup" 382 | } 383 | -------------------------------------------------------------------------------- /tests/sharness: -------------------------------------------------------------------------------- 1 | # Sharness test framework. 2 | # 3 | # Copyright (c) 2011-2012 Mathias Lafeldt 4 | # Copyright (c) 2005-2012 Git project 5 | # Copyright (c) 2005-2012 Junio C Hamano 6 | # Copyright (c) 2019-2023 Felipe Contreras 7 | # 8 | # This program is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation, either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see http://www.gnu.org/licenses/ . 20 | 21 | if test -n "${ZSH_VERSION-}" 22 | then 23 | emulate sh -o POSIX_ARGZERO 24 | fi 25 | 26 | # Public: Current version of Sharness. 27 | SHARNESS_VERSION="1.2.0" 28 | export SHARNESS_VERSION 29 | 30 | : "${SHARNESS_TEST_EXTENSION:=t}" 31 | # Public: The file extension for tests. By default, it is set to "t". 32 | export SHARNESS_TEST_EXTENSION 33 | 34 | : "${SHARNESS_TEST_DIRECTORY:=$(dirname "$0")}" 35 | # ensure that SHARNESS_TEST_DIRECTORY is an absolute path so that it 36 | # is valid even if the current working directory is changed 37 | SHARNESS_TEST_DIRECTORY=$(cd "$SHARNESS_TEST_DIRECTORY" && pwd) || exit 1 38 | # Public: Root directory containing tests. Tests can override this variable, 39 | # e.g. for testing Sharness itself. 40 | export SHARNESS_TEST_DIRECTORY 41 | 42 | # shellcheck disable=SC3028 43 | : "${SHARNESS_TEST_SRCDIR:=$(cd "$(dirname "${BASH_SOURCE-$0}")" && pwd)}" 44 | # Public: Source directory of test code and sharness library. 45 | # This directory may be different from the directory in which tests are 46 | # being run. 47 | export SHARNESS_TEST_SRCDIR 48 | 49 | : "${SHARNESS_TEST_OUTDIR:=$SHARNESS_TEST_DIRECTORY}" 50 | # Public: Directory where the output of the tests should be stored (i.e. 51 | # trash directories). 52 | export SHARNESS_TEST_OUTDIR 53 | 54 | # Reset TERM to original terminal if found, otherwise save original TERM 55 | [ -z "$SHARNESS_ORIG_TERM" ] && 56 | SHARNESS_ORIG_TERM="$TERM" || 57 | TERM="$SHARNESS_ORIG_TERM" 58 | # Public: The unsanitized TERM under which sharness is originally run 59 | export SHARNESS_ORIG_TERM 60 | 61 | # Export SHELL_PATH 62 | : "${SHELL_PATH:=/bin/sh}" 63 | export SHELL_PATH 64 | 65 | # if --tee was passed, write the output not only to the terminal, but 66 | # additionally to the file test-results/$BASENAME.out, too. 67 | case "$SHARNESS_TEST_TEE_STARTED, $* " in 68 | done,*) 69 | # do not redirect again 70 | ;; 71 | *' --tee '*|*' --verbose-log '*) 72 | mkdir -p "$SHARNESS_TEST_OUTDIR/test-results" 73 | BASE="$SHARNESS_TEST_OUTDIR/test-results/$(basename "$0" ".$SHARNESS_TEST_EXTENSION")" 74 | 75 | # Make this filename available to the sub-process in case it is using 76 | # --verbose-log. 77 | SHARNESS_TEST_TEE_OUTPUT_FILE="$BASE.out" 78 | export SHARNESS_TEST_TEE_OUTPUT_FILE 79 | 80 | # Truncate before calling "tee -a" to get rid of the results 81 | # from any previous runs. 82 | : >"$SHARNESS_TEST_TEE_OUTPUT_FILE" 83 | 84 | (SHARNESS_TEST_TEE_STARTED="done" ${SHELL_PATH} "$0" "$@" 2>&1; 85 | echo $? >"$BASE.exit") | tee -a "$SHARNESS_TEST_TEE_OUTPUT_FILE" 86 | test "$(cat "$BASE.exit")" = 0 87 | exit 88 | ;; 89 | esac 90 | 91 | # For repeatability, reset the environment to a known state. 92 | # TERM is sanitized below, after saving color control sequences. 93 | LANG=C 94 | LC_ALL=C 95 | PAGER="cat" 96 | TZ=UTC 97 | EDITOR=: 98 | export LANG LC_ALL PAGER TZ EDITOR 99 | unset VISUAL CDPATH GREP_OPTIONS 100 | 101 | [ "x$TERM" != "xdumb" ] && ( 102 | [ -t 1 ] && 103 | tput bold >/dev/null 2>&1 && 104 | tput setaf 1 >/dev/null 2>&1 && 105 | tput sgr0 >/dev/null 2>&1 106 | ) && 107 | color=t 108 | 109 | while test "$#" -ne 0; do 110 | case "$1" in 111 | -d|--d|--de|--deb|--debu|--debug) 112 | debug=t; shift ;; 113 | -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate) 114 | immediate=t; shift ;; 115 | -l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests) 116 | TEST_LONG=t; export TEST_LONG; shift ;; 117 | --in|--int|--inte|--inter|--intera|--interac|--interact|--interacti|--interactiv|--interactive|--interactive-|--interactive-t|--interactive-te|--interactive-tes|--interactive-test|--interactive-tests): 118 | TEST_INTERACTIVE=t; export TEST_INTERACTIVE; verbose=t; shift ;; 119 | -h|--h|--he|--hel|--help) 120 | help=t; shift ;; 121 | -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) 122 | verbose=t; shift ;; 123 | -q|--q|--qu|--qui|--quie|--quiet) 124 | # Ignore --quiet under a TAP::Harness. Saying how many tests 125 | # passed without the ok/not ok details is always an error. 126 | test -z "$HARNESS_ACTIVE" && quiet=t; shift ;; 127 | --chain-lint) 128 | chain_lint=t; shift ;; 129 | --no-chain-lint) 130 | chain_lint=; shift ;; 131 | --no-color) 132 | color=; shift ;; 133 | --tee) 134 | shift ;; # was handled already 135 | --root=*) 136 | root=$(expr "z$1" : 'z[^=]*=\(.*\)') 137 | shift ;; 138 | -x) 139 | trace=t 140 | shift ;; 141 | --verbose-log) 142 | verbose_log=t 143 | shift ;; 144 | *) 145 | echo "error: unknown test option '$1'" >&2; exit 1 ;; 146 | esac 147 | done 148 | 149 | if test -n "$color"; then 150 | # Save the color control sequences now rather than run tput 151 | # each time say_color() is called. This is done for two 152 | # reasons: 153 | # * TERM will be changed to dumb 154 | # * HOME will be changed to a temporary directory and tput 155 | # might need to read ~/.terminfo from the original HOME 156 | # directory to get the control sequences 157 | # Note: This approach assumes the control sequences don't end 158 | # in a newline for any terminal of interest (command 159 | # substitutions strip trailing newlines). Given that most 160 | # (all?) terminals in common use are related to ECMA-48, this 161 | # shouldn't be a problem. 162 | say_color_error=$(tput bold; tput setaf 1) # bold red 163 | say_color_skip=$(tput setaf 4) # blue 164 | say_color_warn=$(tput setaf 3) # brown/yellow 165 | say_color_pass=$(tput setaf 2) # green 166 | say_color_info=$(tput setaf 6) # cyan 167 | say_color_reset=$(tput sgr0) 168 | say_color_raw="" # no formatting for normal text 169 | say_color() { 170 | test -z "$1" && test -n "$quiet" && return 171 | case "$1" in 172 | error) say_color_color=$say_color_error ;; 173 | skip) say_color_color=$say_color_skip ;; 174 | warn) say_color_color=$say_color_warn ;; 175 | pass) say_color_color=$say_color_pass ;; 176 | info) say_color_color=$say_color_info ;; 177 | *) say_color_color=$say_color_raw ;; 178 | esac 179 | shift 180 | printf '%s%s%s\n' "$say_color_color" "$*" "$say_color_reset" 181 | } 182 | else 183 | say_color() { 184 | test -z "$1" && test -n "$quiet" && return 185 | shift 186 | printf '%s\n' "$*" 187 | } 188 | fi 189 | 190 | : "${test_untraceable:=}" 191 | # Public: When set to a non-empty value, the current test will not be 192 | # traced, unless it's run with a Bash version supporting 193 | # BASH_XTRACEFD, i.e. v4.1 or later. 194 | export test_untraceable 195 | 196 | if test -n "$trace" && test -n "$test_untraceable" 197 | then 198 | # '-x' tracing requested, but this test script can't be reliably 199 | # traced, unless it is run with a Bash version supporting 200 | # BASH_XTRACEFD (introduced in Bash v4.1). 201 | # 202 | # Perform this version check _after_ the test script was 203 | # potentially re-executed with $TEST_SHELL_PATH for '--tee' or 204 | # '--verbose-log', so the right shell is checked and the 205 | # warning is issued only once. 206 | if test -n "$BASH_VERSION" && eval ' 207 | test ${BASH_VERSINFO[0]} -gt 4 || { 208 | test ${BASH_VERSINFO[0]} -eq 4 && 209 | test ${BASH_VERSINFO[1]} -ge 1 210 | } 211 | ' 212 | then 213 | : Executed by a Bash version supporting BASH_XTRACEFD. Good. 214 | else 215 | echo >&2 "warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD" 216 | trace= 217 | fi 218 | fi 219 | if test -n "$trace" && test -z "$verbose_log" 220 | then 221 | verbose=t 222 | fi 223 | 224 | TERM=dumb 225 | export TERM 226 | 227 | error() { 228 | say_color error "error: $*" 229 | EXIT_OK=t 230 | exit 1 231 | } 232 | 233 | say() { 234 | say_color info "$*" 235 | } 236 | 237 | test -n "${test_description:-}" || error "Test script did not set test_description." 238 | 239 | if test "$help" = "t"; then 240 | echo "$test_description" 241 | exit 0 242 | fi 243 | 244 | exec 5>&1 245 | exec 6<&0 246 | if test "$verbose_log" = "t" 247 | then 248 | exec 3>>"$SHARNESS_TEST_TEE_OUTPUT_FILE" 4>&3 249 | elif test "$verbose" = "t" 250 | then 251 | exec 4>&2 3>&1 252 | else 253 | exec 4>/dev/null 3>/dev/null 254 | fi 255 | 256 | # Send any "-x" output directly to stderr to avoid polluting tests 257 | # which capture stderr. We can do this unconditionally since it 258 | # has no effect if tracing isn't turned on. 259 | # 260 | # Note that this sets up the trace fd as soon as we assign the variable, so it 261 | # must come after the creation of descriptor 4 above. Likewise, we must never 262 | # unset this, as it has the side effect of closing descriptor 4, which we 263 | # use to show verbose tests to the user. 264 | # 265 | # Note also that we don't need or want to export it. The tracing is local to 266 | # this shell, and we would not want to influence any shells we exec. 267 | BASH_XTRACEFD=4 268 | 269 | # Public: The current test number, starting at 0. 270 | SHARNESS_TEST_NB=0 271 | export SHARNESS_TEST_NB 272 | 273 | die() { 274 | code=$? 275 | if test -n "$EXIT_OK"; then 276 | exit $code 277 | else 278 | echo >&5 "FATAL: Unexpected exit with code $code" 279 | exit 1 280 | fi 281 | } 282 | 283 | EXIT_OK= 284 | trap 'die' EXIT 285 | 286 | test_prereq= 287 | missing_prereq= 288 | 289 | test_failure=0 290 | test_fixed=0 291 | test_broken=0 292 | test_success=0 293 | 294 | if test -e "$SHARNESS_TEST_SRCDIR/lib-sharness/functions.sh" 295 | then 296 | . "$SHARNESS_TEST_SRCDIR/lib-sharness/functions.sh" 297 | fi 298 | 299 | # You are not expected to call test_ok_ and test_failure_ directly, use 300 | # the text_expect_* functions instead. 301 | 302 | test_ok_() { 303 | test_success=$((test_success + 1)) 304 | say_color "" "ok $SHARNESS_TEST_NB - $*" 305 | } 306 | 307 | test_failure_() { 308 | test_failure=$((test_failure + 1)) 309 | say_color error "not ok $SHARNESS_TEST_NB - $1" 310 | shift 311 | echo "$@" | sed -e 's/^/# /' 312 | test "$immediate" = "" || { EXIT_OK=t; exit 1; } 313 | } 314 | 315 | test_known_broken_ok_() { 316 | test_fixed=$((test_fixed + 1)) 317 | say_color error "ok $SHARNESS_TEST_NB - $* # TODO known breakage vanished" 318 | } 319 | 320 | test_known_broken_failure_() { 321 | test_broken=$((test_broken + 1)) 322 | say_color warn "not ok $SHARNESS_TEST_NB - $* # TODO known breakage" 323 | } 324 | 325 | want_trace () { 326 | test "$trace" = t && { 327 | test "$verbose" = t || test "$verbose_log" = t 328 | } 329 | } 330 | 331 | # This is a separate function because some tests use 332 | # "return" to end a test_expect_success block early 333 | # (and we want to make sure we run any cleanup like 334 | # "set +x"). 335 | test_eval_inner_ () { 336 | # Do not add anything extra (including LF) after '$*' 337 | eval " 338 | want_trace && set -x 339 | $*" 340 | } 341 | 342 | test_eval_x_ () { 343 | # If "-x" tracing is in effect, then we want to avoid polluting stderr 344 | # with non-test commands. But once in "set -x" mode, we cannot prevent 345 | # the shell from printing the "set +x" to turn it off (nor the saving 346 | # of $? before that). But we can make sure that the output goes to 347 | # /dev/null. 348 | # 349 | # There are a few subtleties here: 350 | # 351 | # - we have to redirect descriptor 4 in addition to 2, to cover 352 | # BASH_XTRACEFD 353 | # 354 | # - the actual eval has to come before the redirection block (since 355 | # it needs to see descriptor 4 to set up its stderr) 356 | # 357 | # - likewise, any error message we print must be outside the block to 358 | # access descriptor 4 359 | # 360 | # - checking $? has to come immediately after the eval, but it must 361 | # be _inside_ the block to avoid polluting the "set -x" output 362 | # 363 | 364 | test_eval_inner_ "$@" &3 2>&4 365 | { 366 | test_eval_ret_=$? 367 | if want_trace 368 | then 369 | set +x 370 | fi 371 | } 2>/dev/null 4>&2 372 | 373 | if test "$test_eval_ret_" != 0 && want_trace 374 | then 375 | say_color error >&4 "error: last command exited with \$?=$test_eval_ret_" 376 | fi 377 | return $test_eval_ret_ 378 | } 379 | 380 | test_eval_() { 381 | case ",$test_prereq," in 382 | *,INTERACTIVE,*) 383 | eval "$*" 384 | ;; 385 | *) 386 | test_eval_x_ "$@" 387 | ;; 388 | esac 389 | } 390 | 391 | test_run_() { 392 | test_cleanup=: 393 | expecting_failure=$2 394 | test_eval_ "$1" 395 | eval_ret=$? 396 | 397 | if test "$chain_lint" = "t"; then 398 | # turn off tracing for this test-eval, as it simply creates 399 | # confusing noise in the "-x" output 400 | trace_tmp=$trace 401 | trace= 402 | # 117 is magic because it is unlikely to match the exit 403 | # code of other programs 404 | test_eval_ "(exit 117) && $1" 405 | if test "$?" != 117; then 406 | error "bug in the test script: broken &&-chain: $1" 407 | fi 408 | trace=$trace_tmp 409 | fi 410 | 411 | if test -z "$immediate" || test $eval_ret = 0 || 412 | test -n "$expecting_failure" && test "$test_cleanup" != ":" 413 | then 414 | test_eval_ "$test_cleanup" 415 | fi 416 | if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then 417 | echo "" 418 | fi 419 | return "$eval_ret" 420 | } 421 | 422 | test_skip_() { 423 | SHARNESS_TEST_NB=$((SHARNESS_TEST_NB + 1)) 424 | to_skip= 425 | for skp in $SKIP_TESTS; do 426 | # shellcheck disable=SC2254 427 | case $this_test.$SHARNESS_TEST_NB in 428 | $skp) 429 | to_skip=t 430 | break 431 | esac 432 | done 433 | if test -z "$to_skip" && test -n "$test_prereq" && ! test_have_prereq "$test_prereq"; then 434 | to_skip=t 435 | fi 436 | case "$to_skip" in 437 | t) 438 | of_prereq= 439 | if test "$missing_prereq" != "$test_prereq"; then 440 | of_prereq=" of $test_prereq" 441 | fi 442 | 443 | say_color skip >&3 "skipping test: $*" 444 | say_color skip "ok $SHARNESS_TEST_NB # skip $1 (missing $missing_prereq${of_prereq})" 445 | : true 446 | ;; 447 | *) 448 | false 449 | ;; 450 | esac 451 | } 452 | 453 | remove_trash_() { 454 | test -d "$remove_trash" && ( 455 | cd "$(dirname "$remove_trash")" && 456 | rm -rf "$(basename "$remove_trash")" 457 | ) 458 | } 459 | 460 | # Public: Run test commands and expect them to succeed. 461 | # 462 | # When the test passed, an "ok" message is printed and the number of successful 463 | # tests is incremented. When it failed, a "not ok" message is printed and the 464 | # number of failed tests is incremented. 465 | # 466 | # With --immediate, exit test immediately upon the first failed test. 467 | # 468 | # Usually takes two arguments: 469 | # $1 - Test description 470 | # $2 - Commands to be executed. 471 | # 472 | # With three arguments, the first will be taken to be a prerequisite: 473 | # $1 - Comma-separated list of test prerequisites. The test will be skipped if 474 | # not all of the given prerequisites are set. To negate a prerequisite, 475 | # put a "!" in front of it. 476 | # $2 - Test description 477 | # $3 - Commands to be executed. 478 | # 479 | # Examples 480 | # 481 | # test_expect_success \ 482 | # 'git-write-tree should be able to write an empty tree.' \ 483 | # 'tree=$(git-write-tree)' 484 | # 485 | # # Test depending on one prerequisite. 486 | # test_expect_success TTY 'git --paginate rev-list uses a pager' \ 487 | # ' ... ' 488 | # 489 | # # Multiple prerequisites are separated by a comma. 490 | # test_expect_success PERL,PYTHON 'yo dawg' \ 491 | # ' test $(perl -E 'print eval "1 +" . qx[python -c "print 2"]') == "4" ' 492 | # 493 | # Returns nothing. 494 | test_expect_success() { 495 | test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq= 496 | test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test_expect_success" 497 | export test_prereq 498 | if ! test_skip_ "$@"; then 499 | say >&3 "expecting success: $2" 500 | if test_run_ "$2"; then 501 | test_ok_ "$1" 502 | else 503 | test_failure_ "$@" 504 | fi 505 | fi 506 | echo >&3 "" 507 | } 508 | 509 | # Public: Run test commands and expect them to fail. Used to demonstrate a known 510 | # breakage. 511 | # 512 | # This is NOT the opposite of test_expect_success, but rather used to mark a 513 | # test that demonstrates a known breakage. 514 | # 515 | # When the test passed, an "ok" message is printed and the number of fixed tests 516 | # is incremented. When it failed, a "not ok" message is printed and the number 517 | # of tests still broken is incremented. 518 | # 519 | # Failures from these tests won't cause --immediate to stop. 520 | # 521 | # Usually takes two arguments: 522 | # $1 - Test description 523 | # $2 - Commands to be executed. 524 | # 525 | # With three arguments, the first will be taken to be a prerequisite: 526 | # $1 - Comma-separated list of test prerequisites. The test will be skipped if 527 | # not all of the given prerequisites are set. To negate a prerequisite, 528 | # put a "!" in front of it. 529 | # $2 - Test description 530 | # $3 - Commands to be executed. 531 | # 532 | # Returns nothing. 533 | test_expect_failure() { 534 | test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq= 535 | test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test_expect_failure" 536 | export test_prereq 537 | if ! test_skip_ "$@"; then 538 | say >&3 "checking known breakage: $2" 539 | if test_run_ "$2" expecting_failure; then 540 | test_known_broken_ok_ "$1" 541 | else 542 | test_known_broken_failure_ "$1" 543 | fi 544 | fi 545 | echo >&3 "" 546 | } 547 | 548 | # Public: Run test commands and expect anything from them. Used when a 549 | # test is not stable or not finished for some reason. 550 | # 551 | # When the test passed, an "ok" message is printed, but the number of 552 | # fixed tests is not incremented. 553 | # 554 | # When it failed, a "not ok ... # TODO known breakage" message is 555 | # printed, and the number of tests still broken is incremented. 556 | # 557 | # Failures from these tests won't cause --immediate to stop. 558 | # 559 | # Usually takes two arguments: 560 | # $1 - Test description 561 | # $2 - Commands to be executed. 562 | # 563 | # With three arguments, the first will be taken to be a prerequisite: 564 | # $1 - Comma-separated list of test prerequisites. The test will be skipped if 565 | # not all of the given prerequisites are set. To negate a prerequisite, 566 | # put a "!" in front of it. 567 | # $2 - Test description 568 | # $3 - Commands to be executed. 569 | # 570 | # Returns nothing. 571 | test_expect_unstable() { 572 | test "$#" = 3 && { test_prereq=$1; shift; } || test_prereq= 573 | test "$#" = 2 || error "bug in the test script: not 2 or 3 parameters to test_expect_unstable" 574 | export test_prereq 575 | if ! test_skip_ "$@"; then 576 | say >&3 "checking unstable test: $2" 577 | if test_run_ "$2" unstable; then 578 | test_ok_ "$1" 579 | else 580 | test_known_broken_failure_ "$1" 581 | fi 582 | fi 583 | echo >&3 "" 584 | } 585 | 586 | # Public: Summarize test results and exit with an appropriate error code. 587 | # 588 | # Must be called at the end of each test script. 589 | # 590 | # Can also be used to stop tests early and skip all remaining tests. For this, 591 | # set skip_all to a string explaining why the tests were skipped before calling 592 | # test_done. 593 | # 594 | # Examples 595 | # 596 | # # Each test script must call test_done at the end. 597 | # test_done 598 | # 599 | # # Skip all remaining tests if prerequisite is not set. 600 | # if ! test_have_prereq PERL; then 601 | # skip_all='skipping perl interface tests, perl not available' 602 | # test_done 603 | # fi 604 | # 605 | # Returns 0 if all tests passed or 1 if there was a failure. 606 | # shellcheck disable=SC2154,SC2034 607 | test_done() { 608 | EXIT_OK=t 609 | 610 | if test -z "$HARNESS_ACTIVE"; then 611 | test_results_dir="$SHARNESS_TEST_OUTDIR/test-results" 612 | mkdir -p "$test_results_dir" 613 | test_results_path="$test_results_dir/$this_test.$$.counts" 614 | 615 | cat >>"$test_results_path" <<-EOF 616 | total $SHARNESS_TEST_NB 617 | success $test_success 618 | fixed $test_fixed 619 | broken $test_broken 620 | failed $test_failure 621 | 622 | EOF 623 | fi 624 | 625 | if test "$test_fixed" != 0; then 626 | say_color error "# $test_fixed known breakage(s) vanished; please update test(s)" 627 | fi 628 | if test "$test_broken" != 0; then 629 | say_color warn "# still have $test_broken known breakage(s)" 630 | fi 631 | if test "$test_broken" != 0 || test "$test_fixed" != 0; then 632 | test_remaining=$((SHARNESS_TEST_NB - test_broken - test_fixed)) 633 | msg="remaining $test_remaining test(s)" 634 | else 635 | test_remaining=$SHARNESS_TEST_NB 636 | msg="$SHARNESS_TEST_NB test(s)" 637 | fi 638 | 639 | case "$test_failure" in 640 | 0) 641 | # Maybe print SKIP message 642 | check_skip_all_ 643 | if test "$test_remaining" -gt 0; then 644 | say_color pass "# passed all $msg" 645 | fi 646 | say "1..$SHARNESS_TEST_NB$skip_all" 647 | 648 | test_eval_ "$final_cleanup" 649 | 650 | remove_trash_ 651 | 652 | exit 0 ;; 653 | 654 | *) 655 | say_color error "# failed $test_failure among $msg" 656 | say "1..$SHARNESS_TEST_NB" 657 | 658 | exit 1 ;; 659 | 660 | esac 661 | } 662 | 663 | : "${SHARNESS_BUILD_DIRECTORY:="$SHARNESS_TEST_DIRECTORY/.."}" 664 | # Public: Build directory that will be added to PATH. By default, it is set to 665 | # the parent directory of SHARNESS_TEST_DIRECTORY. 666 | export SHARNESS_BUILD_DIRECTORY 667 | PATH="$SHARNESS_BUILD_DIRECTORY:$PATH" 668 | export PATH 669 | 670 | # Public: Path to test script currently executed. 671 | SHARNESS_TEST_FILE="$0" 672 | export SHARNESS_TEST_FILE 673 | 674 | # Prepare test area. 675 | SHARNESS_TRASH_DIRECTORY="trash directory.$(basename "$SHARNESS_TEST_FILE" ".$SHARNESS_TEST_EXTENSION")" 676 | test -n "$root" && SHARNESS_TRASH_DIRECTORY="$root/$SHARNESS_TRASH_DIRECTORY" 677 | case "$SHARNESS_TRASH_DIRECTORY" in 678 | /*) ;; # absolute path is good 679 | *) SHARNESS_TRASH_DIRECTORY="$SHARNESS_TEST_OUTDIR/$SHARNESS_TRASH_DIRECTORY" ;; 680 | esac 681 | test "$debug" = "t" || remove_trash="$SHARNESS_TRASH_DIRECTORY" 682 | rm -rf "$SHARNESS_TRASH_DIRECTORY" || { 683 | EXIT_OK=t 684 | echo >&5 "FATAL: Cannot prepare test area" 685 | exit 1 686 | } 687 | 688 | 689 | # 690 | # Load any extensions in $testdir/sharness.d/*.sh 691 | # 692 | if test -d "${SHARNESS_TEST_DIRECTORY}/sharness.d" 693 | then 694 | for file in "${SHARNESS_TEST_DIRECTORY}"/sharness.d/*.sh 695 | do 696 | # Ensure glob was not an empty match: 697 | test -e "${file}" || break 698 | 699 | if test -n "$debug" 700 | then 701 | echo >&5 "sharness: loading extensions from ${file}" 702 | fi 703 | # shellcheck disable=SC1090 704 | . "${file}" 705 | if test $? != 0 706 | then 707 | echo >&5 "sharness: Error loading ${file}. Aborting." 708 | exit 1 709 | fi 710 | done 711 | fi 712 | 713 | # Public: Empty trash directory, the test area, provided for each test. The HOME 714 | # variable is set to that directory too. 715 | export SHARNESS_TRASH_DIRECTORY 716 | 717 | HOME="$SHARNESS_TRASH_DIRECTORY" 718 | export HOME 719 | 720 | # shellcheck disable=SC3028 721 | if [ "$OSTYPE" = msys ]; then 722 | USERPROFILE="$SHARNESS_TRASH_DIRECTORY" 723 | export USERPROFILE 724 | fi 725 | 726 | mkdir -p "$SHARNESS_TRASH_DIRECTORY" || exit 1 727 | # Use -P to resolve symlinks in our working directory so that the cwd 728 | # in subprocesses like git equals our $PWD (for pathname comparisons). 729 | cd -P "$SHARNESS_TRASH_DIRECTORY" || exit 1 730 | 731 | check_skip_all_() { 732 | if test -n "$skip_all" && test $SHARNESS_TEST_NB -gt 0; then 733 | error "Can't use skip_all after running some tests" 734 | fi 735 | [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all" 736 | } 737 | 738 | this_test=${SHARNESS_TEST_FILE##*/} 739 | this_test=${this_test%".$SHARNESS_TEST_EXTENSION"} 740 | for skp in $SKIP_TESTS; do 741 | # shellcheck disable=SC2254 742 | case "$this_test" in 743 | $skp) 744 | say_color info >&3 "skipping test $this_test altogether" 745 | skip_all="skip all tests in $this_test" 746 | test_done 747 | esac 748 | done 749 | 750 | test -n "$TEST_LONG" && test_set_prereq EXPENSIVE 751 | test -n "$TEST_INTERACTIVE" && test_set_prereq INTERACTIVE 752 | 753 | # Make sure this script ends with code 0 754 | : 755 | 756 | # vi: set ts=4 sw=4 noet : 757 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | pass-update 635 | Copyright (C) 2017-2019 Alexandre PUJOL 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | pass-update Copyright (C) 2017-2019 Alexandre PUJOL 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------