├── README ├── .gitignore ├── AUTHORS ├── .reuse └── dep5 ├── pre-inst-env.in ├── NEWS ├── hall.scm ├── guix.scm ├── configure.ac ├── HACKING ├── doc └── pinentry-rofi.texi ├── ChangeLog ├── Makefile.am ├── scripts └── pinentry-rofi.in ├── README.org ├── LICENSES ├── CC0-1.0.txt └── GPL-3.0-or-later.txt ├── pinentry-rofi.scm └── tests └── pinentry-rofi.scm /README: -------------------------------------------------------------------------------- 1 | README.org -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Fredrik Salomonsson 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | pinentry-rofi.log 6 | build 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023-2024 Fredrik Salomonsson 2 | # 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | Contributers to Pinentry-Rofi: 6 | 7 | Fredrik Salomonsson 8 | Jakob Simon Kukla 9 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: pinentry-rofi 3 | Upstream-Contact: Fredrik Salomonsson 4 | Source: https://github.com/plattfot/pinentry-rofi/ 5 | 6 | # Sample paragraph, commented out: 7 | # 8 | # Files: src/* 9 | # Copyright: $YEAR $NAME <$CONTACT> 10 | # License: ... 11 | -------------------------------------------------------------------------------- /pre-inst-env.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # SPDX-FileCopyrightText: 2023 Fredrik Salomonsson 4 | # 5 | # SPDX-License-Identifier: CC0-1.0 6 | 7 | abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd`" 8 | abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`" 9 | 10 | GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH" 11 | GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}:$GUILE_LOAD_PATH" 12 | export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH 13 | 14 | PATH="$abs_top_builddir/scripts:$PATH" 15 | export PATH 16 | 17 | exec "$@" 18 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | # -*- mode: org; coding: utf-8; -*- 2 | # SPDX-License-Identifier: GPL-3.0-or-later 3 | 4 | #+TITLE: Pinentry-Rofi NEWS – history of user-visible changes 5 | #+STARTUP: content hidestars 6 | 7 | Copyright © (2020-2023) Fredrik Salomonsson 8 | 9 | Copying and distribution of this file, with or without modification, 10 | are permitted in any medium without royalty provided the copyright 11 | notice and this notice are preserved. 12 | 13 | Please file bugs for pinentry-rofi at [[https://github.com/plattfot/pinentry-rofi]] 14 | 15 | Please see the [[file:ChangeLog][ChangeLog]] for what changed in pinentry-rofi. 16 | 17 | -------------------------------------------------------------------------------- /hall.scm: -------------------------------------------------------------------------------- 1 | ;; SPDX-FileCopyrightText: 2023-2024 Fredrik Salomonsson 2 | ;; 3 | ;; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | (hall-description 6 | (name "pinentry-rofi") 7 | (prefix "") 8 | (version "3.0.0") 9 | (author "Fredrik Salomonsson") 10 | (copyright (2020 2021 2022 2023)) 11 | (synopsis "Rofi frontend to pinentry") 12 | (description 13 | "Simple pinentry gui using rofi, it is written in GNU guile.") 14 | (home-page 15 | "https://github.com/plattfot/pinentry-rofi/") 16 | (license gpl3+) 17 | (dependencies `(("rofi" ,rofi))) 18 | (files (libraries ((scheme-file "pinentry-rofi"))) 19 | (tests ((directory 20 | "tests" 21 | ((scheme-file "pinentry-rofi"))))) 22 | (programs 23 | ((directory "scripts" ((in-file "pinentry-rofi"))))) 24 | (documentation 25 | ((org-file "README") 26 | (symlink "README" "README.org") 27 | (text-file "AUTHORS") 28 | (text-file "NEWS") 29 | (text-file "HACKING") 30 | (text-file "COPYING") 31 | (directory "doc" ((texi-file "pinentry-rofi"))) 32 | (text-file "ChangeLog"))) 33 | (infrastructure 34 | ((scheme-file "guix") (scheme-file "hall"))))) 35 | -------------------------------------------------------------------------------- /guix.scm: -------------------------------------------------------------------------------- 1 | ;; SPDX-FileCopyrightText: 2023 Fredrik Salomonsson 2 | ;; 3 | ;; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | (use-modules 6 | (guix packages) 7 | (guix git-download) 8 | (guix gexp) 9 | (guix build-system gnu) 10 | ((guix licenses) #:prefix license:) 11 | (gnu packages autotools) 12 | (gnu packages guile) 13 | (gnu packages pkg-config) 14 | (gnu packages texinfo) 15 | (gnu packages xdisorg) 16 | (gnu packages gnupg) 17 | (ice-9 popen) 18 | (ice-9 rdelim) 19 | ) 20 | 21 | ;; From the talk "Just build it with Guix" by Efraim Flashner 22 | ;; presented on the Guix days 2020 23 | ;; https://guix.gnu.org/en/blog/2020/online-guix-day-announce-2/ 24 | (define %source-dir (dirname (current-filename))) 25 | 26 | (define %git-commit 27 | (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f2" OPEN_READ))) 28 | 29 | (define (skip-git-and-build-directory file stat) 30 | "Skip the `.git` and `build` directory when collecting the sources." 31 | (let ((name (basename file))) 32 | (not (or (string=? name ".git") (string=? name "build"))))) 33 | 34 | (package 35 | (inherit pinentry-rofi) 36 | (name "pinentry-rofi-git") 37 | (version (git-version (package-version pinentry-rofi) "HEAD" %git-commit)) 38 | (source (local-file %source-dir 39 | #:recursive? #t 40 | #:select? skip-git-and-build-directory))) 41 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl SPDX-FileCopyrightText: 2023-2024 Fredrik Salomonsson 2 | dnl 3 | dnl SPDX-License-Identifier: CC0-1.0 4 | 5 | dnl -*- Autoconf -*- 6 | 7 | AC_INIT(pinentry-rofi, 3.0.0) 8 | AC_SUBST(HVERSION, "\"3.0.0\"") 9 | AC_SUBST(AUTHOR, "\"Fredrik Salomonsson\"") 10 | AC_SUBST(COPYRIGHT, "'(2020 2021 2022 2023 2024)") 11 | AC_SUBST(LICENSE, gpl3+) 12 | AC_CONFIG_SRCDIR(pinentry-rofi.scm) 13 | AC_CONFIG_AUX_DIR([build-aux]) 14 | AM_INIT_AUTOMAKE([1.12 gnu silent-rules subdir-objects color-tests parallel-tests -Woverride -Wno-portability]) 15 | AM_SILENT_RULES([yes]) 16 | 17 | AC_CONFIG_FILES([Makefile]) 18 | AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env]) 19 | AC_CONFIG_FILES([scripts/pinentry-rofi],[chmod +x scripts/pinentry-rofi]) 20 | dnl Search for 'guile' and 'guild'. This macro defines 21 | dnl 'GUILE_EFFECTIVE_VERSION'. 22 | GUILE_PKG([3.0 2.2 2.0]) 23 | GUILE_PROGS 24 | GUILE_SITE_DIR 25 | if test "x$GUILD" = "x"; then 26 | AC_MSG_ERROR(['guild' binary not found; please check your guile-2.x installation.]) 27 | fi 28 | 29 | dnl Hall auto-generated guile-module dependencies 30 | 31 | 32 | dnl Installation directories for .scm and .go files. 33 | guilemoduledir="${datarootdir}/guile/site/$GUILE_EFFECTIVE_VERSION" 34 | guileobjectdir="${libdir}/guile/$GUILE_EFFECTIVE_VERSION/site-ccache" 35 | AC_SUBST([guilemoduledir]) 36 | AC_SUBST([guileobjectdir]) 37 | 38 | AX_COMPUTE_RELATIVE_PATHS([bindir:guilemoduledir:GUILE_MODULE_DIR bindir:guileobjectdir:GUILE_OBJECT_DIR]) 39 | 40 | AC_SUBST([GUILE_MODULE_DIR]) 41 | AC_SUBST([GUILE_OBJECT_DIR]) 42 | 43 | AC_OUTPUT 44 | -------------------------------------------------------------------------------- /HACKING: -------------------------------------------------------------------------------- 1 | # -*- mode: org; coding: utf-8; -*- 2 | # SPDX-FileCopyrightText: 2023 Fredrik Salomonsson 3 | # 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | #+TITLE: Hacking pinentry-rofi 7 | 8 | * Contributing 9 | 10 | By far the easiest way to hack on pinentry-rofi is to develop using 11 | Guix: 12 | 13 | #+BEGIN_SRC bash 14 | # Obtain the source code 15 | cd /path/to/source-code 16 | guix build -f guix.scm 17 | #+END_SRC 18 | 19 | You can now hack this project's files to your heart's content, whilst 20 | testing them from Guix. 21 | 22 | To try out any scripts in the project, the easiest is just to install it to a guix profile. 23 | 24 | Here is an example to install it to the default profile: 25 | #+BEGIN_SRC bash 26 | guix package -f guix.scm 27 | #+END_SRC 28 | 29 | Then when you're done simply roll back. This can also be used when 30 | testing it against gpg-agent by following what is described in the 31 | [[file:README.org][README]]. 32 | 33 | ** Manual Installation 34 | 35 | If you do not yet use Guix, you will have to install this project's 36 | dependencies manually: 37 | - autoconf 38 | - autoconf-archive 39 | - automake 40 | - coreutils 41 | - gawk 42 | - grep 43 | - guile 44 | - make 45 | - pkg-config (or pkgconf) 46 | - sed 47 | - texinfo 48 | 49 | Once those dependencies are installed you can run: 50 | 51 | #+BEGIN_SRC bash 52 | autoreconf -vif && ./configure && make check 53 | #+END_SRC 54 | 55 | ** Guile Hall 56 | 57 | The core of the gnu build system is generated by guile-hall. There 58 | are some modifications done after that so avoid running 59 | =hall clean -x= and =hall dist -x= as that will override those 60 | changes. 61 | 62 | Right now I haven't figured out a good way of dealing with keeping 63 | the version in sync between the different files, which what I 64 | mainly used =hall= for. 65 | -------------------------------------------------------------------------------- /doc/pinentry-rofi.texi: -------------------------------------------------------------------------------- 1 | @c SPDX-FileCopyrightText: 2023 Fredrik Salomonsson 2 | @c 3 | @c SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | \input texinfo 6 | @c -*-texinfo-*- 7 | 8 | @c %**start of header 9 | @setfilename pinentry-rofi.info 10 | @documentencoding UTF-8 11 | @settitle Pinentry-Rofi Reference Manual 12 | @c %**end of header 13 | 14 | @include version.texi 15 | 16 | @copying 17 | Copyright @copyright{} 2020 Fredrik Salomonsson 18 | 19 | Permission is granted to copy, distribute and/or modify this document 20 | under the terms of the GNU Free Documentation License, Version 1.3 or 21 | any later version published by the Free Software Foundation; with no 22 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A 23 | copy of the license is included in the section entitled ``GNU Free 24 | Documentation License''. 25 | @end copying 26 | 27 | @dircategory The Algorithmic Language Scheme 28 | @direntry 29 | * Pinentry-Rofi: (pinentry-rofi). 30 | @end direntry 31 | 32 | @titlepage 33 | @title The Pinentry-Rofi Manual 34 | @author Fredrik Salomonsson 35 | 36 | @page 37 | @vskip 0pt plus 1filll 38 | Edition @value{EDITION} @* 39 | @value{UPDATED} @* 40 | 41 | @insertcopying 42 | @end titlepage 43 | 44 | @contents 45 | 46 | @c ********************************************************************* 47 | @node Top 48 | @top Pinentry-Rofi 49 | 50 | This document describes Pinentry-Rofi version @value{VERSION}. 51 | 52 | @menu 53 | * Introduction:: Why Pinentry-Rofi? 54 | @end menu 55 | 56 | @c ********************************************************************* 57 | @node Introduction 58 | @chapter Introduction 59 | 60 | Based on 61 | @url{https://gist.github.com/sardemff7/759cbf956bea20d382a6128c641d2746,this 62 | gist} 63 | 64 | Simple pinentry gui using @command{rofi} written in GNU guile. 65 | 66 | It's similar in functionality as the gist but this one doesn't force 67 | the width to be 27 and doesn't depend on systemd. 68 | 69 | I also wanted a small project which I could use to practice writing 70 | GNU guile. 71 | 72 | @bye 73 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2023-2024 Fredrik Salomonsson 2 | 3 | SPDX-License-Identifier: GPL-3.0-or-later 4 | 2024-09-15 Fredrik Salomonsson 5 | * 3.0.0 6 | URI Encode password before handing it to gpg. 7 | NOTE: Potentially breaking the input of older passwords! 8 | 2024-07-14 Fredrik Salomonsson 9 | * 2.2.0 10 | Mimic CLI options to be compatible with `rbw`. 11 | 2024-06-28 Fredrik Salomonsson 12 | * 2.1.1 13 | Add SETTITLE option - Contributed by jakobkukla. 14 | 2024-03-31 Fredrik Salomonsson 15 | * 2.1.0: 16 | Add feature to pass options directly to rofi. 17 | 2023-03-19 Fredrik Salomonsson 18 | * 2.0.5: 19 | Remove unused scrollbar - Contributed by 2tefan. 20 | 2023-03-19 Fredrik Salomonsson 21 | * 2.0.4: 22 | Version 3.0 of the REUSE specification compliant. 23 | 2021-01-31 Fredrik Salomonsson 24 | * 2.0.3: 25 | Fix issue with the executable not finding the module. 26 | Add info on how to use it in the README. 27 | Add gotcha in the README when using this with guix on a foreign distro. 28 | 2021-01-27 Fredrik Salomonsson 29 | * 2.0.2: 30 | Update guix.scm to build from source. 31 | Add search paths to guile's module and object directory in the executable. 32 | Fix issue with --version. 33 | 2020-10-09 Fredrik Salomonsson 34 | * 2.0.1: 35 | Update guix.scm to build from github. 36 | 2020-06-14 Fredrik Salomonsson 37 | * 2.0.0: 38 | Using Hall to handle the project. 39 | 2020-05-11 Fredrik Salomonsson 40 | * 1.0.2: 41 | Fixed crash when rofi is aborted. 42 | 2020-05-11 Fredrik Salomonsson 43 | * 1.0.1: 44 | Propper newline between error and description. 45 | More unit test coverage. 46 | Fixed hang when run via gpg, that was introduced in 1.0.0. 47 | 2020-05-11 Fredrik Salomonsson 48 | * 1.0.0: 49 | Added unit tests. 50 | Added support for popup. 51 | Added support for underline characters in message. 52 | Fixed high CPU usage bug - thanks to em0lar and n0emis. 53 | 2020-04-21 Fredrik Salomonsson 54 | * 0.5.0 : 55 | Added support to ask again if password is wrong. 56 | 2019-06-06 Fredrik Salomonsson 57 | * 0.4.0 : 58 | Removed compiling of script. 59 | Behaves better with the REPL. 60 | 2018-11-10 Fredrik Salomonsson 61 | * 0.3.0 : 62 | Removed dependency on systemd. 63 | Works with gpg. 64 | Removed conflict with pinentry-rofi. 65 | 2018-11-04 Fredrik Salomonsson 66 | * 0.2.0 : 67 | Forcing the output. 68 | 2018-11-04 Fredrik Salomonsson 69 | * 0.1.0 : 70 | Initial release. Matching functionality as the pinentry-rofi gist. 71 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Fredrik Salomonsson 2 | # 3 | # SPDX-License-Identifier: CC0-1.0 4 | 5 | bin_SCRIPTS = scripts/pinentry-rofi 6 | 7 | # Handle substitution of fully-expanded Autoconf variables. 8 | do_subst = $(SED) \ 9 | -e 's,[@]GUILE[@],$(GUILE),g' \ 10 | -e 's,[@]guilemoduledir[@],$(guilemoduledir),g' \ 11 | -e 's,[@]guileobjectdir[@],$(guileobjectdir),g' \ 12 | -e 's,[@]GUILE_OBJECT_DIR[@],$(prefix)/$(GUILE_OBJECT_DIR),g' \ 13 | -e 's,[@]GUILE_MODULE_DIR[@],$(exec_prefix)/$(GUILE_MODULE_DIR),g' \ 14 | -e 's,[@]localedir[@],$(localedir),g' 15 | 16 | nodist_noinst_SCRIPTS = pre-inst-env 17 | 18 | GOBJECTS = $(SOURCES:%.scm=%.go) 19 | 20 | moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION) 21 | godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache 22 | ccachedir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache 23 | 24 | nobase_mod_DATA = $(SOURCES) $(NOCOMP_SOURCES) 25 | nobase_go_DATA = $(GOBJECTS) 26 | 27 | # Make sure source files are installed first, so that the mtime of 28 | # installed compiled files is greater than that of installed source 29 | # files. See 30 | # 31 | # for details. 32 | guile_install_go_files = install-nobase_goDATA 33 | $(guile_install_go_files): install-nobase_modDATA 34 | 35 | EXTRA_DIST = $(SOURCES) $(NOCOMP_SOURCES) 36 | GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat 37 | SUFFIXES = .scm .go 38 | .scm.go: 39 | $(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILE_TOOLS) compile $(GUILE_WARNINGS) -o "$@" "$<" 40 | 41 | SOURCES = pinentry-rofi.scm 42 | 43 | TESTS = tests/pinentry-rofi.scm 44 | 45 | TEST_EXTENSIONS = .scm 46 | SCM_LOG_DRIVER = \ 47 | $(top_builddir)/pre-inst-env \ 48 | $(GUILE) --no-auto-compile -e main \ 49 | $(top_srcdir)/build-aux/test-driver.scm 50 | 51 | # Tell 'build-aux/test-driver.scm' to display only source file names, 52 | # not indivdual test names. 53 | AM_SCM_LOG_DRIVER_FLAGS = --brief=yes 54 | 55 | AM_SCM_LOG_FLAGS = --no-auto-compile -L "$(top_srcdir)" 56 | 57 | AM_TESTS_ENVIRONMENT = abs_top_srcdir="$(abs_top_srcdir)" 58 | 59 | info_TEXINFOS = doc/pinentry-rofi.texi 60 | dvi: # Don't build dvi docs 61 | 62 | EXTRA_DIST += README.org \ 63 | README \ 64 | AUTHORS \ 65 | NEWS \ 66 | HACKING \ 67 | COPYING \ 68 | ChangeLog \ 69 | guix.scm \ 70 | hall.scm \ 71 | build-aux/test-driver.scm \ 72 | $(TESTS) 73 | 74 | ACLOCAL_AMFLAGS = -I m4 75 | 76 | clean-go: 77 | -$(RM) $(GOBJECTS) 78 | .PHONY: clean-go 79 | 80 | CLEANFILES = \ 81 | $(GOBJECTS) \ 82 | $(TESTS:tests/%.scm=%.log) 83 | 84 | # Sanity checks for the script 85 | installcheck-local: 86 | [ `$(bindir)/pinentry-rofi --version` = $(HVERSION) ] 87 | $(bindir)/pinentry-rofi --help 88 | echo BYE | $(bindir)/pinentry-rofi 89 | -------------------------------------------------------------------------------- /scripts/pinentry-rofi.in: -------------------------------------------------------------------------------- 1 | #! @GUILE@ \ 2 | --no-auto-compile -e main -s 3 | !# 4 | 5 | ;; SPDX-FileCopyrightText: 2016 Quentin "Sardem FF7" Glidic 6 | ;; SPDX-FileCopyrightText: 2018-2023 Fredrik "PlaTFooT" Salomonsson 7 | ;; 8 | ;; SPDX-License-Identifier: GPL-3.0-or-later 9 | 10 | (eval-when (load expand eval) 11 | (set! %load-path 12 | (cons (format #f "~a/@GUILE_MODULE_DIR@" (dirname (current-filename))) %load-path)) 13 | (set! %load-compiled-path 14 | (cons (format #f "~a/@GUILE_OBJECT_DIR@" (dirname (current-filename))) %load-compiled-path))) 15 | 16 | (use-modules (ice-9 getopt-long) 17 | (ice-9 format) 18 | (pinentry-rofi)) 19 | (define (main args) 20 | (let* ((option-spec 21 | '((display (single-char #\D) (value #t)) 22 | (xauthority (single-char #\a) (value #t)) 23 | (version (single-char #\v) (value #f)) 24 | (debug (single-char #\d) (value #f)) 25 | (ttyname (single-char #\T) (value #t)) 26 | (ttytype (single-char #\N) (value #t)) 27 | (lc-ctype (single-char #\C) (value #t)) 28 | (lc-message (single-char #\M) (value #t)) 29 | (timeout (single-char #\o) (value #t)) 30 | (no-global-grab (single-char #\g) (value #f)) 31 | (parent-wid (single-char #\W) (value #f)) 32 | (colors (single-char #\c) (value #f)) 33 | (ttyalert (single-char #\a) (value #f)) 34 | (log (value #t)) 35 | (help (single-char #\h) (value #f)))) 36 | (default-display ":0") 37 | (default-lc-ctype "C") 38 | (default-lc-message "C") 39 | (options (getopt-long (command-line) option-spec)) 40 | (pinentry (make-pinentry #t "Passphrase:" "Ok" "Cancel" 41 | (option-ref options 'display default-display) 42 | (let ((logfile (option-ref options 'log #f))) 43 | (when logfile 44 | (open-output-file 45 | (format #f "~a.~a" logfile (getpid))))) 46 | (option-ref options 'lc-ctype default-lc-ctype) 47 | (option-ref options 'lc-message default-lc-message) 48 | (option-ref options '() 49 | (if (option-ref options 'no-global-grab #f) 50 | '("-no-lazy-grab") 51 | '()))))) 52 | (when (option-ref options 'help #f) 53 | (format #t "\ 54 | Usage: ~a [OPTIONS]... 55 | Options: 56 | -D, --display DISPLAY Set display, default is ~s 57 | --log LOGFILE Log unknown commands to LOGFILE 58 | -v, --version Display version. 59 | -h, --help Display this help. 60 | -C, --lc-ctype STRING Set the tty LC_CTYPE value 61 | -M, --lc-messages STRING Set the tty LC_MESSAGES value 62 | -g, --no-global-grab Grab keyboard only while window is focused 63 | -- [ROFI-OPTIONS]... Options after -- will be sent to rofi 64 | Dummy options (does not do anything just for compatibility): 65 | -d, --debug Turn on debugging output 66 | -T, --ttyname FILE Set the tty terminal node name 67 | -N, --ttytype NAME Set the tty terminal type 68 | -o, --timeout SECS Timeout waiting for input after this many seconds 69 | -W, --parent-wid Parent window ID (for positioning) 70 | -c, --colors STRING Set custom colors for ncurses 71 | -a, --ttyalert STRING Set the alert mode (none, beep or flash) 72 | Author: 73 | ~a 74 | " 75 | (car (command-line)) 76 | default-display 77 | @AUTHOR@) 78 | (exit #t)) 79 | (let ((unimplemented (lambda (option) 80 | (when (option-ref options option #f) 81 | (format (current-error-port) "warning: --~a is not implemented~%" 82 | (symbol->string option)))))) 83 | (unimplemented 'debug) 84 | (unimplemented 'ttyname) 85 | (unimplemented 'ttytype) 86 | (unimplemented 'timeout) 87 | (unimplemented 'parent-wid) 88 | (unimplemented 'colors) 89 | (unimplemented 'ttyalert)) 90 | (when (option-ref options 'version #f) 91 | (format #t "~a~%" @HVERSION@) 92 | (exit #t)) 93 | (format #t "OK Please go ahead\n") 94 | (force-output) 95 | (pinentry-loop pinentry (current-input-port)))) 96 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | # -*- mode: org; coding: utf-8; -*- 2 | # SPDX-FileCopyrightText: 2023 Fredrik Salomonsson 3 | # 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | 6 | #+TITLE: README for Pinentry-Rofi 7 | 8 | * Description 9 | Based on [[https://gist.github.com/sardemff7/759cbf956bea20d382a6128c641d2746][this gist]] 10 | 11 | Simple [[https://www.gnupg.org/related_software/pinentry/index.html][pinentry]] gui using [[https://github.com/davatorium/rofi][rofi]] written in [[https://www.gnu.org/software/guile/][GNU guile]]. 12 | 13 | It's similar in functionality as the gist but this one doesn't force 14 | the width to be 27 and doesn't depend on systemd. 15 | 16 | I also wanted a small project which I could use to practice writing 17 | GNU guile. 18 | 19 | * 3.0.0 Breaking changes please read 20 | 21 | There is a major bug in pinentry-rofi 2.2.0 and below. The password 22 | was not encoded before giving it to gpg. Which meant that passwords 23 | including character other than alphanumerics from ASCII and `-`, 24 | `.`, `_` and `~` ended up being decoded on gpg's side. Making them 25 | not match the input and therefore not work on other pinentry tools. 26 | See [[https://github.com/plattfot/pinentry-rofi/issues/27][#27]] for details. 27 | 28 | Before moving to pinentry-rofi-3.0.0, please make sure to 29 | temporarily change the passwords affected by this bug to something 30 | that does not include those special characters. Make the upgrade 31 | then change back. 32 | 33 | An alternative is to figure out what gnupg decoded the passwords too 34 | and use that as the input when using pinentry-rofi-3.0.0. And 35 | change the passwords to match what they where suppose to be. 36 | 37 | Sorry for the headaches. 38 | 39 | * 2.0.0 Breaking changes please read 40 | 41 | As of version 2.0.0, =pinentry-rofi= is now built using [[https://www.gnu.org/software/automake][automake]]. 42 | See [[file:HACKING][HACKING]] for more info on that. It also lost its =-guile= suffix 43 | for the executable. And it is no longer just one file, most of its 44 | content is now a [[https://www.gnu.org/software/guile/manual/html_node/General-Information-about-Modules.html][guile module]], which the executable now calls. 45 | 46 | * Install 47 | ** Guix (Recommended) 48 | To install it using [[https://guix.gnu.org/][guix]], run 49 | #+begin_src shell 50 | guix install pinentry-rofi 51 | #+end_src 52 | 53 | Just make sure you have a version of `guix` that is newer than Jan 54 | 8 2021. 55 | 56 | The binary location is then `$HOME/.guix-profile/bin/pinentry-rofi` 57 | were the `$HOME` is the home location of the user you used to 58 | install it with. E.g. `/home/$USER` for a normal user and `/root` 59 | for the root user. 60 | 61 | Install it with guix is recommended as that will work on most linux 62 | distributions. 63 | 64 | Then add it to your =~/.gnupg/gpg-agent.conf= 65 | 66 | *** Guix on a foreign distro 67 | 68 | If you are running guix on a foreign distro, you need to make sure 69 | the =GUIX_LOCPATH= environment variable is passed to the gpg-agent 70 | otherwise rofi will fail to set the locale and therefore cannot 71 | launch. Which result in the pinentry aborting. 72 | 73 | On a distribution that is using systemd (here I'm using Arch Linux 74 | as an example) simply run: 75 | 76 | #+begin_src shell 77 | echo "GUIX_LOCPATH=$GUIX_LOCPATH" 78 | #+end_src 79 | 80 | Copy that, then run: 81 | #+begin_src shell 82 | systend --user edit gpg-agent.service 83 | #+end_src 84 | 85 | And add it in the =override.conf=: 86 | #+begin_src conf 87 | [Service] 88 | Environment=GUIX_LOCPATH=%h/.guix-profile/lib/locale 89 | #+end_src 90 | 91 | On my system, =GUIX_LOCPATH= points to the default profile i.e. 92 | =$HOME/.guix-profile/lib/locale=. =%h= in systemd gives you the 93 | path to the home directory. This should be the case for most 94 | people, but if your =GUIX_LOCPATH= points to something different 95 | change the =override.conf= to reflect that. 96 | 97 | ** Arch Linux 98 | The =PKGBUILD= file for arch is in the =build-aux=, so just run: 99 | 100 | #+begin_src shell 101 | cd build-aux 102 | makepkg -ic 103 | #+end_src 104 | 105 | The binary location is then `/usr/bin/pinentry-rofi`. 106 | 107 | ** From Source 108 | 109 | See [[file:HACKING][HACKING]] on how to build this from source 110 | 111 | * Gpg-agent 112 | 113 | To use =pinentry-rofi= with =gpg-agent=, you can set it as the 114 | =pinentry-program= in the =~/.gnupg/gpg-agent.conf=. Note that you 115 | need to use the full path to the binary. 116 | 117 | For example for Arch Linux this would be: 118 | #+begin_src conf 119 | pinentry-program /usr/bin/pinentry-rofi 120 | #+end_src 121 | 122 | And for guix: 123 | #+begin_src conf 124 | pinentry-program /.guix-profile/bin/pinentry-rofi 125 | #+end_src 126 | Where == is the full path to home for your user. 127 | 128 | Don't forget to restart =gpg-agent= for the changes to take affect: 129 | #+begin_src shell 130 | gpg-connect-agent reloadagent /bye 131 | #+end_src 132 | -------------------------------------------------------------------------------- /LICENSES/CC0-1.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /pinentry-rofi.scm: -------------------------------------------------------------------------------- 1 | ;; SPDX-FileCopyrightText: 2016 Quentin "Sardem FF7" Glidic 2 | ;; SPDX-FileCopyrightText: 2018-2023 Fredrik Salomonsson 3 | ;; SPDX-FileCopyrightText: 2024 Jakob Simon Kukla 4 | ;; 5 | ;; SPDX-License-Identifier: GPL-3.0-or-later 6 | 7 | (define-module (pinentry-rofi) 8 | #:use-module (ice-9 format) 9 | #:use-module (ice-9 popen) 10 | #:use-module (ice-9 regex) 11 | #:use-module (ice-9 textual-ports) 12 | #:use-module (srfi srfi-1) ;; concatenate 13 | #:use-module (srfi srfi-9) ;; For records 14 | #:use-module (web uri) 15 | #:export (make-pinentry 16 | pinentry? 17 | pinentry-ok set-pinentry-ok! 18 | pinentry-prompt set-pinentry-prompt! 19 | pinentry-desc set-pinentry-desc! 20 | pinentry-visibility set-pinentry-visibility! 21 | pinentry-display set-pinentry-display! 22 | pinentry-error set-pinentry-error! 23 | pinentry-title set-pinentry-title! 24 | pinentry-logfile set-pinentry-logfile! 25 | pinentry-ok-button set-pinentry-ok-button! 26 | pinentry-notok-button set-pinentry-notok-button! 27 | pinentry-cancel-button set-pinentry-cancel-button! 28 | pinentry-lc-ctype set-pinentry-lc-ctype! 29 | pinentry-lc-messages set-pinentry-lc-messages! 30 | pinentry-rofi-options 31 | 32 | remove-underline 33 | escape-underscore 34 | 35 | html-newline 36 | html-underline 37 | html-< 38 | string-empty? 39 | 40 | hex->char 41 | input-string 42 | pango-markup 43 | 44 | pinentry-set 45 | 46 | rofi-popup 47 | 48 | pinentry-option 49 | pinentry-getinfo 50 | pinentry-setkeyinfo 51 | pinentry-setok 52 | pinentry-setcancel 53 | pinentry-setnotok 54 | pinentry-setdesc 55 | pinentry-seterror 56 | pinentry-settitle 57 | pinentry-setprompt 58 | pinentry-getpin 59 | pinentry-confirm 60 | pinentry-bye 61 | pinentry-loop)) 62 | 63 | (when (equal? (system-file-name-convention) 'windows) 64 | (format #t "Only support posix systems!") 65 | (exit #f)) 66 | 67 | (define-record-type 68 | (make-pinentry ok prompt ok-button cancel-button display logfile lc-ctype lc-messages rofi-options) 69 | pinentry? 70 | (ok pinentry-ok set-pinentry-ok!) 71 | (prompt pinentry-prompt set-pinentry-prompt!) 72 | (desc pinentry-desc set-pinentry-desc!) 73 | (visibility pinentry-visibility set-pinentry-visibility!) 74 | (display pinentry-display set-pinentry-display!) 75 | (error pinentry-error set-pinentry-error!) 76 | (title pinentry-title set-pinentry-title!) 77 | (logfile pinentry-logfile set-pinentry-logfile!) 78 | (ok-button pinentry-ok-button set-pinentry-ok-button!) 79 | (notok-button pinentry-notok-button set-pinentry-notok-button!) 80 | (cancel-button pinentry-cancel-button set-pinentry-cancel-button!) 81 | (lc-ctype pinentry-lc-ctype set-pinentry-lc-ctype!) 82 | (lc-messages pinentry-lc-messages set-pinentry-lc-messages!) 83 | (rofi-options pinentry-rofi-options set-pinentry-rofi-options!)) 84 | 85 | (define-syntax-rule (set-and-return! val expr) 86 | "Set val to expr and return val." 87 | (begin (set! val expr) val)) 88 | 89 | (define (string-empty? str) 90 | "Evaluates to #t if string is empty." 91 | (string=? str "")) 92 | 93 | (define (remove-underline str) 94 | "Replace _ followed by a character with just the character." 95 | (regexp-substitute/global #f "(^|%0A| |\n|[[:blank:]])_([[:alpha:]])" str 96 | 'pre 1 2 'post)) 97 | 98 | (define (escape-underscore str) 99 | "Replace __ followed by a character with _ and said character. 100 | Always call this after `remove-underline' or 101 | `html-underline'." 102 | (regexp-substitute/global #f "(^|%0A| |\n|[[:blank:]])__([[:alpha:]])" str 103 | 'pre 1 "_" 2 'post)) 104 | 105 | (define (html-newline str) 106 | "Replace %0A with " 107 | (regexp-substitute/global #f "%0A" str 'pre " " 'post)) 108 | 109 | (define (html-underline str) 110 | "Underscore followed by a character, underlines that character." 111 | (regexp-substitute/global #f "(^|%0A| |\n|[[:blank:]])_([[:alpha:]])" str 112 | 'pre 1""2"" 'post)) 113 | (define (html-< str) 114 | "Replace < with <" 115 | (regexp-substitute/global #f "<" str 'pre "<" 'post)) 116 | 117 | (define (hex->char str) 118 | "Replace matching'%XX' where X ∈ {0-F} with their respective char." 119 | (regexp-substitute/global 120 | #f "%([[:xdigit:]]{2})" str 'pre 121 | (lambda (m) (integer->char 122 | (string->number 123 | (match:substring m 1) 16))) 'post)) 124 | 125 | (define (pango-markup str) 126 | "Transform string to pango." 127 | (escape-underscore 128 | (html-underline 129 | (hex->char 130 | (html-< 131 | (html-newline str)))))) 132 | 133 | (define (input-string str) 134 | "Transform string to input for rofi. 135 | Input strings does not support pango markup" 136 | (escape-underscore 137 | (remove-underline str))) 138 | 139 | (define* (pinentry-set set-func pinentry label) 140 | "Using SET-FUNC, set the entry in PINENTRY to LABEL." 141 | (set-func pinentry label) 142 | (set-pinentry-ok! pinentry #t)) 143 | 144 | (define (pinentry-set-button set-func pinentry label) 145 | "Using SET-BUTTON-FUNC, set the entry in PINENTRY to LABEL. 146 | LABEL will be transformed using `input-string'" 147 | (pinentry-set set-func pinentry (input-string label))) 148 | 149 | (define (pinentry-set-mesg set-func pinentry label) 150 | "Using SET-FUNC, set the entry in PINENTRY to LABEL. 151 | LABEL will be transformed using `pango-markup'" 152 | (pinentry-set set-func pinentry (pango-markup label))) 153 | 154 | (define (pinentry-option pinentry line) 155 | "Process line if it starts with OPTION. 156 | Return false otherwise. 157 | 158 | Known options are: 159 | grab 160 | ttyname=/dev/pts/1 161 | ttytype=tmux-256color 162 | lc-ctype=C 163 | lc-messages=C 164 | allow-external-password-cache 165 | default-ok=_OK 166 | default-cancel=_Cancel 167 | default-yes=_Yes 168 | default-no=_No 169 | default-prompt=PIN: 170 | default-pwmngr=_Save in password manager 171 | default-cf-visi=Do you really want to make your passphrase visible on the screen? 172 | default-tt-visi=Make passphrase visible 173 | default-tt-hide=Hide passphrase 174 | touch-file=/run/user/1000/gnupg/S.gpg-agent" 175 | (let ((regex-match #f) 176 | (option-re (make-regexp "^OPTION (.+)$"))) 177 | (cond 178 | ((set-and-return! regex-match 179 | (regexp-exec 180 | (make-regexp "^OPTION[[:blank:]]+default-ok=(.+)$") line)) 181 | (pinentry-set-button 182 | set-pinentry-ok-button! 183 | pinentry 184 | (match:substring regex-match 1))) 185 | ((set-and-return! regex-match 186 | (regexp-exec 187 | (make-regexp "^OPTION[[:blank:]]+default-cancel=(.+)$") line)) 188 | (pinentry-set-button 189 | set-pinentry-cancel-button! 190 | pinentry 191 | (match:substring regex-match 1))) 192 | ((set-and-return! regex-match 193 | (regexp-exec 194 | (make-regexp "^OPTION[[:blank:]]+default-prompt=(.+)$") line)) 195 | (pinentry-set-mesg 196 | set-pinentry-prompt! 197 | pinentry 198 | (match:substring regex-match 1))) 199 | ((set-and-return! regex-match 200 | (regexp-exec 201 | (make-regexp "^OPTION[[:blank:]]+lc-ctype=(.+)$") line)) 202 | (pinentry-set 203 | set-pinentry-lc-ctype! 204 | pinentry 205 | (match:substring regex-match 1))) 206 | ((set-and-return! regex-match 207 | (regexp-exec 208 | (make-regexp "^OPTION[[:blank:]]+lc-messages=(.+)$") line)) 209 | (pinentry-set 210 | set-pinentry-lc-messages! 211 | pinentry 212 | (match:substring regex-match 1))) 213 | ((set-and-return! regex-match (regexp-exec option-re line)))) 214 | regex-match)) 215 | 216 | (define* (pinentry-getinfo pinentry line #:key (port #t)) 217 | "Process line if it starts with GETINFO" 218 | (let ((getinfo-re (make-regexp "^GETINFO (.+)$")) 219 | (regex-match #f)) 220 | (when (set-and-return! regex-match (regexp-exec getinfo-re line)) 221 | (let ((info (match:substring regex-match 1))) 222 | (cond 223 | ((string=? info "pid") 224 | (format port "D ~a~%~!" (getpid))))) 225 | (set-pinentry-ok! pinentry #t)) 226 | regex-match)) 227 | 228 | (define (pinentry-setkeyinfo pinentry line) 229 | "SETKEYINFO s/FINGERPRINT" 230 | (let ((setkeyinfo-re (make-regexp "^SETKEYINFO (.+)$")) 231 | (regex-match #f)) 232 | (when (set-and-return! regex-match (regexp-exec setkeyinfo-re line)) 233 | (set-pinentry-ok! pinentry #t)) 234 | regex-match)) 235 | 236 | (define (pinentry-setok pinentry line) 237 | "Set ok button label." 238 | (let ((setok-button-re (make-regexp "^SETOK (.+)$")) 239 | (regex-match #f)) 240 | (when (set-and-return! regex-match (regexp-exec setok-button-re line)) 241 | (pinentry-set-button 242 | set-pinentry-ok-button! 243 | pinentry 244 | (match:substring regex-match 1))) 245 | regex-match)) 246 | 247 | (define (pinentry-setcancel pinentry line) 248 | "Set cancel button label." 249 | (let ((setcancel-button-re (make-regexp "^SETCANCEL (.+)$")) 250 | (regex-match #f)) 251 | (when (set-and-return! regex-match (regexp-exec setcancel-button-re line)) 252 | (pinentry-set-button 253 | set-pinentry-cancel-button! 254 | pinentry 255 | (match:substring regex-match 1))) 256 | regex-match)) 257 | 258 | (define (pinentry-setnotok pinentry line) 259 | "Set notok button label." 260 | (let ((setnotok-button-re (make-regexp "^SETNOTOK (.+)$")) 261 | (regex-match #f)) 262 | (when (set-and-return! regex-match (regexp-exec setnotok-button-re line)) 263 | (pinentry-set-button 264 | set-pinentry-notok-button! 265 | pinentry 266 | (match:substring regex-match 1))) 267 | regex-match)) 268 | 269 | (define (pinentry-setdesc pinentry line) 270 | "SETDESC description" 271 | (let ((setdesc-re (make-regexp "^SETDESC (.+)$")) 272 | (regex-match #f)) 273 | (when (set-and-return! regex-match (regexp-exec setdesc-re line)) 274 | (pinentry-set-mesg 275 | set-pinentry-desc! 276 | pinentry 277 | (match:substring regex-match 1))) 278 | regex-match)) 279 | 280 | (define (pinentry-seterror pinentry line) 281 | "SETERROR MESSAGE" 282 | (let ((seterror-re (make-regexp "^SETERROR (.+)$")) 283 | (regex-match #f)) 284 | (when (set-and-return! regex-match (regexp-exec seterror-re line)) 285 | (pinentry-set-mesg 286 | set-pinentry-error! 287 | pinentry 288 | (match:substring regex-match 1))) 289 | regex-match)) 290 | 291 | (define (pinentry-settitle pinentry line) 292 | "SETTITLE window title" 293 | (let ((settitle-re (make-regexp "^SETTITLE (.+)$")) 294 | (regex-match #f)) 295 | (when (set-and-return! regex-match (regexp-exec settitle-re line)) 296 | (pinentry-set-mesg 297 | set-pinentry-title! 298 | pinentry 299 | (match:substring regex-match 1))) 300 | regex-match)) 301 | 302 | (define (pinentry-setprompt pinentry line) 303 | "SETPROMPT Passphrase:" 304 | (let ((setprompt-re (make-regexp "^SETPROMPT (.+)$")) 305 | (regex-match #f)) 306 | (when (set-and-return! regex-match (regexp-exec setprompt-re line)) 307 | (pinentry-set-mesg 308 | set-pinentry-prompt! 309 | pinentry 310 | (match:substring regex-match 1))) 311 | regex-match)) 312 | 313 | (define* (rofi-popup #:key (env '()) 314 | visibility 315 | title 316 | (prompt ">") 317 | message 318 | buttons 319 | only-match 320 | (extra-options '())) 321 | "Run external program rofi and fetch the input from the user. 322 | 323 | Keyword arguments: 324 | TITLE: Text for the window title 325 | PROMPT: Text for the prompt, default '>' 326 | ENV: List of environemnt variables in the form (ENVVAR . VALUE) 327 | VISIBILITY: If #t show the input 328 | MESSAGE: Message for the popup window 329 | BUTTONS: List of strings that will be buttons. 330 | ONLY-MATCH: Only allow to match what is listed in the buttons. 331 | EXTRA-OPTIONS: A list of extra options to pass to rofi. 332 | 333 | Return the input from the user if succeeded else #f." 334 | (let* ((inputs (if buttons `("echo -e" 335 | ,(format #f "~s" (string-join buttons "\n")) 336 | "|") 337 | '())) 338 | (rofi-sh `("env" 339 | ,(string-join 340 | (map (lambda (x) (format #f "~a=~s" (car x) (cdr x))) env)) 341 | ,(format #f "rofi -dmenu -disable-history -no-fixed-num-lines -l ~a -i" 342 | (if (list? buttons) (length buttons) 1)) 343 | ,(if (and only-match buttons) "-only-match" "") 344 | ,(if (not buttons) "-input /dev/null" "") 345 | ,(if visibility "" "-password") 346 | ,(if title (format #f "-window-title ~s" title) "") 347 | ,(format #f "-p ~s" prompt) 348 | ,(if message (format #f "-mesg ~s" message) "") 349 | ,@(map (lambda (option) (format #f "~s" option)) extra-options))) 350 | (pipe (open-pipe (string-join (concatenate `(,inputs ,rofi-sh))) OPEN_READ)) 351 | (pass (get-string-all pipe)) 352 | (status (close-pipe pipe))) 353 | (if (and (equal? (status:exit-val status) 0)) pass #f))) 354 | 355 | (define (compose-message pinentry) 356 | "Create the message by combining the error and desc from PINENTRY" 357 | (if (pinentry-error pinentry) 358 | (format #f "~a ~a" 359 | (pinentry-error pinentry) 360 | (pinentry-desc pinentry)) 361 | (pinentry-desc pinentry))) 362 | 363 | (define* (pinentry-getpin pinentry line pin-program #:key (port #t)) 364 | "Get pin using PIN-PROGRAM if LINE is equal to GETPIN." 365 | (let ((getpin-re (make-regexp "^GETPIN$")) 366 | (regex-match #f)) 367 | (when (set-and-return! regex-match (regexp-exec getpin-re line)) 368 | (let ((pass (pin-program #:title (pinentry-title pinentry) 369 | #:prompt (pinentry-prompt pinentry) 370 | #:message (compose-message pinentry) 371 | #:visibility (pinentry-visibility pinentry) 372 | #:env `(("DISPLAY" . ,(pinentry-display pinentry)) 373 | ("LC_CTYPE" . ,(pinentry-lc-ctype pinentry)) 374 | ("LC_MESSAGES" . ,(pinentry-lc-messages pinentry))) 375 | #:extra-options (pinentry-rofi-options pinentry)))) 376 | (if (and pass (not (string-empty? (string-trim-both pass)))) 377 | (begin 378 | (format port "D ~a~%~!" (uri-encode (string-trim-right pass #\newline))) 379 | (set-pinentry-ok! pinentry #t)) 380 | (begin 381 | (format port "ERR 83886179 Operation cancelled ~%~!") 382 | (set-pinentry-ok! pinentry #f))))) 383 | regex-match)) 384 | 385 | (define* (pinentry-confirm pinentry line confirm-program #:key (port #t)) 386 | (let ((confirm-re (make-regexp "^CONFIRM$")) 387 | (confirm-one-button-re 388 | (make-regexp "^CONFIRM[[:blank:]]+--one-button[[:blank:]]*$")) 389 | (message-re (make-regexp "^MESSAGE$")) 390 | (regex-match #f)) 391 | (cond 392 | ((set-and-return! regex-match (regexp-exec confirm-re line)) 393 | ;; Can probably do this with a pipe in both direction, but 394 | ;; manual warns about deadlocks so sticking with this for now. 395 | (let ((button (confirm-program 396 | #:env `(("DISPLAY" . ,(pinentry-display pinentry)) 397 | ("LC_CTYPE" . ,(pinentry-lc-ctype pinentry)) 398 | ("LC_MESSAGES" . ,(pinentry-lc-messages pinentry))) 399 | #:visibility #t 400 | #:only-match #t 401 | #:buttons `(,(pinentry-ok-button pinentry) 402 | ,(or (pinentry-notok-button pinentry) 403 | (pinentry-cancel-button pinentry))) 404 | #:message (compose-message pinentry) 405 | #:extra-options (pinentry-rofi-options pinentry)))) 406 | (if (and button 407 | (string=? (string-trim-right button) (pinentry-ok-button pinentry))) 408 | (set-pinentry-ok! pinentry #t) 409 | (begin 410 | (format port "ERR 277 Operation cancelled~%~!") 411 | (set-pinentry-ok! pinentry #f))))) 412 | ((or (set-and-return! regex-match (regexp-exec confirm-one-button-re line)) 413 | (set-and-return! regex-match (regexp-exec message-re line))) 414 | (let ((button (confirm-program 415 | #:env `(("DISPLAY" . ,(pinentry-display pinentry)) 416 | ("LC_CTYPE" . ,(pinentry-lc-ctype pinentry)) 417 | ("LC_MESSAGES" . ,(pinentry-lc-messages pinentry))) 418 | #:visibility #t 419 | #:only-match #t 420 | #:buttons `(,(pinentry-ok-button pinentry)) 421 | #:message (compose-message pinentry)))) 422 | (if (and button 423 | (string=? (string-trim-right button) (pinentry-ok-button pinentry))) 424 | (set-pinentry-ok! pinentry #t) 425 | (begin 426 | (format port "ERR 277 Operation cancelled~%~!") 427 | (set-pinentry-ok! pinentry #f)))))) 428 | regex-match)) 429 | 430 | (define (pinentry-bye pinentry line) 431 | (let ((bye-re (make-regexp "^BYE")) 432 | (regex-match #f)) 433 | (when (set-and-return! regex-match (regexp-exec bye-re line)) 434 | (exit #t)) 435 | regex-match)) 436 | 437 | (define (pinentry-loop pinentry input-port) 438 | (let ((line (get-line input-port))) 439 | (unless (eof-object? line) 440 | (cond 441 | ((pinentry-option pinentry line)) 442 | ((pinentry-getinfo pinentry line)) 443 | ((pinentry-setkeyinfo pinentry line)) 444 | ((pinentry-setdesc pinentry line)) 445 | ((pinentry-setok pinentry line)) 446 | ((pinentry-setnotok pinentry line)) 447 | ((pinentry-setcancel pinentry line)) 448 | ((pinentry-setprompt pinentry line)) 449 | ((pinentry-getpin pinentry line rofi-popup)) 450 | ((pinentry-confirm pinentry line rofi-popup)) 451 | ((pinentry-seterror pinentry line)) 452 | ((pinentry-settitle pinentry line)) 453 | ((pinentry-bye pinentry line)) 454 | (#t (begin 455 | (let ((log (pinentry-logfile pinentry))) 456 | (when (file-port? log) 457 | (format log "Unknown command: ~s~%~!" line))) 458 | ;; GPG_ERR_ASS_UNKNOWN_CMD = 275, 459 | (format #t "ERR 275 Unknown command ~s~%~!" line) 460 | (set-pinentry-ok! pinentry #f)))) 461 | (when (pinentry-ok pinentry) 462 | (format #t "OK~%~!")) 463 | (pinentry-loop pinentry input-port)))) 464 | -------------------------------------------------------------------------------- /tests/pinentry-rofi.scm: -------------------------------------------------------------------------------- 1 | ;; SPDX-FileCopyrightText: 2020-2023 Fredrik Salomonsson 2 | ;; 3 | ;; SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | (define-module (tests-pinentry-rofi) 6 | #:use-module (srfi srfi-1) 7 | #:use-module (srfi srfi-64) 8 | #:use-module (ice-9 popen) 9 | #:use-module (ice-9 textual-ports) 10 | #:use-module (pinentry-rofi)) 11 | 12 | (test-begin "pinentry-rofi") 13 | 14 | ;; (test-begin "pinentry") 15 | (let ((pinentry (make-pinentry #t "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 16 | (test-assert (pinentry? pinentry)) 17 | (test-assert (pinentry-ok pinentry)) 18 | (test-equal "Prompt" (pinentry-prompt pinentry)) 19 | (test-equal "Ok" (pinentry-ok-button pinentry)) 20 | (test-equal "Cancel" (pinentry-cancel-button pinentry)) 21 | (test-equal ":1" (pinentry-display pinentry)) 22 | (test-equal "test.log" (pinentry-logfile pinentry)) 23 | (test-assert (not (pinentry-notok-button pinentry))) 24 | (test-assert (not (pinentry-visibility pinentry))) 25 | (test-assert (not (pinentry-error pinentry)))) 26 | 27 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 28 | (test-assert (not (pinentry-ok pinentry)))) 29 | 30 | ;; (test-end "pinentry") 31 | 32 | ;; (test-begin "utils") 33 | 34 | (test-equal "Ok" (remove-underline "_Ok")) 35 | (test-equal " Ok" (remove-underline " _Ok")) 36 | (test-equal "foo_bar" (remove-underline "foo_bar")) 37 | (test-equal "foo__bar" (remove-underline "foo__bar")) 38 | (test-equal " __Ok" (remove-underline " __Ok")) 39 | (test-equal "__Ok" (remove-underline "__Ok")) 40 | (test-equal "Ok%0ACancel" (remove-underline "_Ok%0A_Cancel")) 41 | (test-equal "Ok Cancel" (remove-underline "_Ok _Cancel")) 42 | 43 | (test-equal "_Ok" (escape-underscore "_Ok")) 44 | (test-equal " _Ok" (escape-underscore " _Ok")) 45 | (test-equal "foo_bar" (escape-underscore "foo_bar")) 46 | (test-equal "foo__bar" (escape-underscore "foo__bar")) 47 | (test-equal " _Ok" (escape-underscore " __Ok")) 48 | (test-equal "_Ok" (escape-underscore "__Ok")) 49 | (test-equal "_Ok%0A_Cancel" (escape-underscore "__Ok%0A__Cancel")) 50 | (test-equal "_Ok _Cancel" (escape-underscore "__Ok __Cancel")) 51 | 52 | (test-assert (string-empty? "")) 53 | (test-assert (not (string-empty? "foo"))) 54 | ;; (test-end "utils") 55 | 56 | (test-equal "This is one line\nThis is another%OA" 57 | (hex->char "%54his is one line%0AThis is another%OA")) 58 | 59 | ;; (test-begin "html") 60 | (test-equal "%54his is one line This is another%OA" 61 | (html-newline "%54his is one line%0AThis is another%OA")) 62 | (test-equal "%54his is one line\nThis is another%OA" 63 | (html-newline "%54his is one line\nThis is another%OA")) 64 | 65 | (test-equal "Ok" (html-underline "_Ok")) 66 | (test-equal " Ok" (html-underline " _Ok")) 67 | (test-equal "foo_bar" (html-underline "foo_bar")) 68 | (test-equal "foo__bar" (html-underline "foo__bar")) 69 | (test-equal " __Ok" (html-underline " __Ok")) 70 | (test-equal "__Ok" (html-underline "__Ok")) 71 | (test-equal "Ok%0ACancel" (html-underline "_Ok%0A_Cancel")) 72 | (test-equal "Ok Cancel" (html-underline "_Ok _Cancel")) 73 | 74 | ;; (test-end "html") 75 | 76 | (test-equal "This is one line This is another%OA" 77 | (pango-markup "_%54his is one line%0A_This is another%OA")) 78 | 79 | (test-equal "Ok\nCancel" 80 | (input-string "_Ok\nCancel")) 81 | 82 | (test-equal "Ok\n_Cancel" 83 | (input-string "_Ok\n__Cancel")) 84 | 85 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 86 | (pinentry-set set-pinentry-notok-button! pinentry "Not ok") 87 | (test-equal "Not ok" (pinentry-notok-button pinentry)) 88 | (test-assert (pinentry-ok pinentry))) 89 | 90 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 91 | (test-error #t (pinentry-set pinentry-notok-button pinentry "Not ok"))) 92 | 93 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 94 | (test-assert (pinentry-option pinentry "OPTION default-ok=Okay")) 95 | (test-equal "Okay" (pinentry-ok-button pinentry)) 96 | (test-equal "Cancel" (pinentry-cancel-button pinentry)) 97 | (test-equal "Prompt" (pinentry-prompt pinentry)) 98 | (test-equal "C" (pinentry-lc-ctype pinentry)) 99 | (test-equal "C" (pinentry-lc-messages pinentry)) 100 | (test-assert (pinentry-ok pinentry))) 101 | 102 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 103 | (test-assert (pinentry-option pinentry "OPTION default-cancel=No")) 104 | (test-equal "Ok" (pinentry-ok-button pinentry)) 105 | (test-equal "No" (pinentry-cancel-button pinentry)) 106 | (test-equal "Prompt" (pinentry-prompt pinentry)) 107 | (test-equal "C" (pinentry-lc-ctype pinentry)) 108 | (test-equal "C" (pinentry-lc-messages pinentry)) 109 | (test-assert (pinentry-ok pinentry))) 110 | 111 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 112 | (test-assert (pinentry-option pinentry "OPTION default-prompt=Password:")) 113 | (test-equal "Ok" (pinentry-ok-button pinentry)) 114 | (test-equal "Cancel" (pinentry-cancel-button pinentry)) 115 | (test-equal "Password:" (pinentry-prompt pinentry)) 116 | (test-equal "C" (pinentry-lc-ctype pinentry)) 117 | (test-equal "C" (pinentry-lc-messages pinentry)) 118 | (test-assert (pinentry-ok pinentry))) 119 | 120 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 121 | (test-assert (pinentry-option pinentry "OPTION lc-ctype=en_US.UTF-8")) 122 | (test-equal "Ok" (pinentry-ok-button pinentry)) 123 | (test-equal "Cancel" (pinentry-cancel-button pinentry)) 124 | (test-equal "Prompt" (pinentry-prompt pinentry)) 125 | (test-equal "en_US.UTF-8" (pinentry-lc-ctype pinentry)) 126 | (test-equal "C" (pinentry-lc-messages pinentry)) 127 | (test-assert (pinentry-ok pinentry))) 128 | 129 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 130 | (test-assert (pinentry-option pinentry "OPTION lc-messages=en_US.UTF-8")) 131 | (test-equal "Ok" (pinentry-ok-button pinentry)) 132 | (test-equal "Cancel" (pinentry-cancel-button pinentry)) 133 | (test-equal "Prompt" (pinentry-prompt pinentry)) 134 | (test-equal "C" (pinentry-lc-ctype pinentry)) 135 | (test-equal "en_US.UTF-8" (pinentry-lc-messages pinentry)) 136 | (test-assert (pinentry-ok pinentry))) 137 | 138 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 139 | (test-assert (pinentry-option pinentry "OPTION foo bar"))) 140 | 141 | (let ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 142 | (test-assert (not (pinentry-option pinentry " OPTION foo bar"))) 143 | (test-assert (not (pinentry-option pinentry "OPTION"))) 144 | (test-assert (not (pinentry-option pinentry "Foo")))) 145 | 146 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '())) 147 | (output "") 148 | (fake-port (make-soft-port 149 | (vector 150 | (lambda (c) (set! output (string-append output c))) 151 | (lambda (s) (set! output (string-append output s))) 152 | (lambda () #t) 153 | #f 154 | (lambda () #t)) 155 | "w"))) 156 | (test-assert (pinentry-getinfo pinentry "GETINFO pid" #:port fake-port)) 157 | (test-equal (format #f "D ~a\n" (getpid)) output) 158 | (test-assert (pinentry-getinfo pinentry "GETINFO foo bar")) 159 | (test-assert (not (pinentry-getinfo pinentry " GETINFO foo bar"))) 160 | (test-assert (not (pinentry-getinfo pinentry "GETINFO"))) 161 | (test-assert (not (pinentry-getinfo pinentry "Foo")))) 162 | 163 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 164 | (test-assert (pinentry-setkeyinfo pinentry "SETKEYINFO Foo")) 165 | (test-assert (pinentry-ok pinentry)) 166 | (test-assert (not (pinentry-setkeyinfo pinentry " SETKEYINFO foo bar"))) 167 | (test-assert (not (pinentry-setkeyinfo pinentry "SETKEYINFO"))) 168 | (test-assert (not (pinentry-setkeyinfo pinentry "Foo")))) 169 | 170 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 171 | (test-assert (pinentry-setok pinentry "SETOK Foo")) 172 | (test-equal "Foo" (pinentry-ok-button pinentry)) 173 | (test-assert (pinentry-ok pinentry)) 174 | (test-assert (pinentry-setok pinentry "SETOK _Ok okay")) 175 | (test-equal "Ok okay" (pinentry-ok-button pinentry)) 176 | (test-assert (not (pinentry-setok pinentry " SETOK foo bar"))) 177 | (test-equal "Ok okay" (pinentry-ok-button pinentry)) 178 | (test-assert (not (pinentry-setok pinentry "SETOK"))) 179 | (test-equal "Ok okay" (pinentry-ok-button pinentry)) 180 | (test-assert (not (pinentry-setok pinentry "Foo"))) 181 | (test-equal "Ok okay" (pinentry-ok-button pinentry))) 182 | 183 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 184 | (test-assert (pinentry-setnotok pinentry "SETNOTOK Foo")) 185 | (test-equal "Foo" (pinentry-notok-button pinentry)) 186 | (test-assert (pinentry-ok pinentry)) 187 | (test-assert (pinentry-setnotok pinentry "SETNOTOK Not _Ok")) 188 | (test-equal "Not Ok" (pinentry-notok-button pinentry)) 189 | (test-assert (not (pinentry-setnotok pinentry " SETNOTOK foo bar"))) 190 | (test-equal "Not Ok" (pinentry-notok-button pinentry)) 191 | (test-assert (not (pinentry-setnotok pinentry "SETNOTOK"))) 192 | (test-equal "Not Ok" (pinentry-notok-button pinentry)) 193 | (test-assert (not (pinentry-setnotok pinentry "Foo"))) 194 | (test-equal "Not Ok" (pinentry-notok-button pinentry))) 195 | 196 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "C" '()))) 197 | (test-assert (pinentry-setcancel pinentry "SETCANCEL Foo")) 198 | (test-equal "Foo" (pinentry-cancel-button pinentry)) 199 | (test-assert (pinentry-ok pinentry)) 200 | (test-assert (pinentry-setcancel pinentry "SETCANCEL _Abort")) 201 | (test-equal "Abort" (pinentry-cancel-button pinentry)) 202 | (test-assert (not (pinentry-setcancel pinentry " SETCANCEL foo bar"))) 203 | (test-equal "Abort" (pinentry-cancel-button pinentry)) 204 | (test-assert (not (pinentry-setcancel pinentry "SETCANCEL"))) 205 | (test-equal "Abort" (pinentry-cancel-button pinentry)) 206 | (test-assert (not (pinentry-setcancel pinentry "Foo"))) 207 | (test-equal "Abort" (pinentry-cancel-button pinentry))) 208 | 209 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Desc" ":1" "test.log" "C" "C" '()))) 210 | (test-assert (pinentry-setdesc pinentry "SETDESC Foo")) 211 | (test-equal "Foo" (pinentry-desc pinentry)) 212 | (test-assert (pinentry-ok pinentry)) 213 | (test-assert (pinentry-setdesc pinentry "SETDESC _%54his is a description%0A_On two lines")) 214 | (test-equal "This is a description On two lines" (pinentry-desc pinentry)) 215 | (test-assert (not (pinentry-setdesc pinentry " SETDESC foo bar"))) 216 | (test-equal "This is a description On two lines" (pinentry-desc pinentry)) 217 | (test-assert (not (pinentry-setdesc pinentry "SETDESC"))) 218 | (test-equal "This is a description On two lines" (pinentry-desc pinentry)) 219 | (test-assert (not (pinentry-setdesc pinentry "Foo"))) 220 | (test-equal "This is a description On two lines" (pinentry-desc pinentry))) 221 | 222 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Error" ":1" "test.log" "C" "C" '()))) 223 | (test-assert (pinentry-seterror pinentry "SETERROR Foo")) 224 | (test-equal "Foo" (pinentry-error pinentry)) 225 | (test-assert (pinentry-ok pinentry)) 226 | (test-assert (pinentry-seterror pinentry "SETERROR _%54his is an error%0A_On two lines")) 227 | (test-equal "This is an error On two lines" (pinentry-error pinentry)) 228 | (test-assert (not (pinentry-seterror pinentry " SETERROR foo bar"))) 229 | (test-equal "This is an error On two lines" (pinentry-error pinentry)) 230 | (test-assert (not (pinentry-seterror pinentry "SETERROR"))) 231 | (test-equal "This is an error On two lines" (pinentry-error pinentry)) 232 | (test-assert (not (pinentry-seterror pinentry "Foo"))) 233 | (test-equal "This is an error On two lines" (pinentry-error pinentry))) 234 | 235 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Prompt" ":1" "test.log" "C" "C" '()))) 236 | (test-assert (pinentry-setprompt pinentry "SETPROMPT Foo")) 237 | (test-equal "Foo" (pinentry-prompt pinentry)) 238 | (test-assert (pinentry-ok pinentry)) 239 | (test-assert (pinentry-setprompt pinentry "SETPROMPT _%54his is a prompt%0A_On two lines")) 240 | (test-equal "This is a prompt On two lines" (pinentry-prompt pinentry)) 241 | (test-assert (not (pinentry-setprompt pinentry " SETPROMPT foo bar"))) 242 | (test-equal "This is a prompt On two lines" (pinentry-prompt pinentry)) 243 | (test-assert (not (pinentry-setprompt pinentry "SETPROMPT"))) 244 | (test-equal "This is a prompt On two lines" (pinentry-prompt pinentry)) 245 | (test-assert (not (pinentry-setprompt pinentry "Foo"))) 246 | (test-equal "This is a prompt On two lines" (pinentry-prompt pinentry))) 247 | 248 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Prompt" ":1" "test.log" "C" "C" '()))) 249 | (test-error "(quit #t)" (pinentry-bye pinentry "BYE")) 250 | (test-assert (not (pinentry-bye pinentry "Hej då")))) 251 | 252 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "en_US.UTF-8" '("--foo"))) 253 | (output "") 254 | (fake-port (make-soft-port 255 | (vector 256 | (lambda (c) (set! output (string-append output c))) 257 | (lambda (s) (set! output (string-append output s))) 258 | (lambda () #t) 259 | #f 260 | (lambda () #t)) 261 | "w")) 262 | (description "This is a description") 263 | (error "Something went wrong") 264 | (title "Rofi-pinentry") 265 | (display ":1")) 266 | (set-pinentry-desc! pinentry description) 267 | (set-pinentry-display! pinentry display) 268 | (test-assert (pinentry-getpin pinentry "GETPIN" 269 | (lambda* (#:key (env '()) 270 | visibility 271 | title 272 | (prompt ">") 273 | message 274 | buttons 275 | only-match 276 | extra-options) 277 | (test-equal "Prompt" prompt) 278 | (test-equal description message) 279 | (test-assert (not title)) 280 | (test-assert (not visibility)) 281 | (test-assert (not only-match)) 282 | (test-assert (not buttons)) 283 | (test-equal '("--foo") extra-options) 284 | (test-equal `(("DISPLAY" . ,display) 285 | ("LC_CTYPE" . "C") 286 | ("LC_MESSAGES" . "en_US.UTF-8")) 287 | env) 288 | "password") 289 | #:port fake-port)) 290 | (test-equal (format #f "D password~%") output) 291 | (set-pinentry-error! pinentry error) 292 | (set-pinentry-title! pinentry title) 293 | (set! output "") 294 | (test-assert (pinentry-getpin pinentry "GETPIN" 295 | (lambda* (#:key (env '()) 296 | visibility 297 | title 298 | (prompt ">") 299 | message 300 | buttons 301 | only-match 302 | extra-options) 303 | (test-equal "Prompt" prompt) 304 | (test-equal "Rofi-pinentry" title) 305 | (test-equal (format #f "~a ~a" error description) 306 | message) 307 | (test-assert (not visibility)) 308 | (test-assert (not only-match)) 309 | (test-assert (not buttons)) 310 | (test-assert (list? extra-options)) 311 | (test-equal 1 (length extra-options)) 312 | (test-equal `(("DISPLAY" . ,display) 313 | ("LC_CTYPE" . "C") 314 | ("LC_MESSAGES" . "en_US.UTF-8")) 315 | env) 316 | "password") 317 | #:port fake-port)) 318 | (test-equal (format #f "D password~%") output) 319 | (set! output "") 320 | (test-assert (pinentry-getpin pinentry "GETPIN" 321 | (lambda* (#:key (env '()) 322 | visibility 323 | title 324 | (prompt ">") 325 | message 326 | buttons 327 | only-match 328 | extra-options) 329 | (test-equal "Prompt" prompt) 330 | (test-equal (format #f "~a ~a" error description) 331 | message) 332 | (test-assert (not visibility)) 333 | (test-assert (not only-match)) 334 | (test-assert (not buttons)) 335 | (test-assert (list? extra-options)) 336 | (test-equal 1 (length extra-options)) 337 | (test-equal `(("DISPLAY" . ,display) 338 | ("LC_CTYPE" . "C") 339 | ("LC_MESSAGES" . "en_US.UTF-8")) 340 | env) 341 | "") 342 | #:port fake-port)) 343 | (test-equal (format #f "ERR 83886179 Operation cancelled \n") output) 344 | (set! output "") 345 | (test-assert (pinentry-getpin pinentry "GETPIN" 346 | (lambda* (#:key (env '()) 347 | visibility 348 | title 349 | (prompt ">") 350 | message 351 | buttons 352 | only-match 353 | extra-options) 354 | (test-equal "Prompt" prompt) 355 | (test-equal (format #f "~a ~a" error description) 356 | message) 357 | (test-assert (not visibility)) 358 | (test-assert (not only-match)) 359 | (test-assert (not buttons)) 360 | (test-assert (list? extra-options)) 361 | (test-equal 1 (length extra-options)) 362 | (test-equal `(("DISPLAY" . ,display) 363 | ("LC_CTYPE" . "C") 364 | ("LC_MESSAGES" . "en_US.UTF-8")) 365 | env) 366 | " ") 367 | #:port fake-port)) 368 | (test-equal (format #f "ERR 83886179 Operation cancelled \n") output) 369 | (test-assert (not (pinentry-getinfo pinentry " GETPIN"))) 370 | (test-assert (not (pinentry-getinfo pinentry "Foo")))) 371 | 372 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "en_US.UTF-8" '())) 373 | (description "This is a description") 374 | (error "Something went wrong") 375 | (display ":1")) 376 | (set-pinentry-desc! pinentry description) 377 | (set-pinentry-display! pinentry display) 378 | (test-assert (pinentry-confirm pinentry "CONFIRM" 379 | (lambda* (#:key (env '()) 380 | visibility 381 | (prompt ">") 382 | message 383 | buttons 384 | only-match 385 | extra-options) 386 | (test-equal ">" prompt) 387 | (test-equal description message) 388 | (test-assert visibility) 389 | (test-assert only-match) 390 | (test-assert (null-list? extra-options)) 391 | (test-equal `("Ok" "Cancel") buttons) 392 | (test-equal `(("DISPLAY" . ,display) 393 | ("LC_CTYPE" . "C") 394 | ("LC_MESSAGES" . "en_US.UTF-8")) 395 | env) 396 | "Ok"))) 397 | (test-assert (pinentry-ok pinentry)) 398 | (set-pinentry-error! pinentry error) 399 | (let* ((output "") 400 | (fake-port (make-soft-port 401 | (vector 402 | (lambda (c) (set! output (string-append output c))) 403 | (lambda (s) (set! output (string-append output s))) 404 | (lambda () #t) 405 | #f 406 | (lambda () #t)) 407 | "w"))) 408 | (test-assert (pinentry-confirm 409 | pinentry 410 | "CONFIRM" 411 | (lambda* (#:key (env '()) 412 | visibility 413 | (prompt ">") 414 | message 415 | buttons 416 | only-match 417 | extra-options) 418 | (test-equal ">" prompt) 419 | (test-equal (format #f "~a ~a" error description) 420 | message) 421 | (test-assert visibility) 422 | (test-assert only-match) 423 | (test-equal `("Ok" "Cancel") buttons) 424 | (test-equal `() extra-options) 425 | (test-equal `(("DISPLAY" . ,display) 426 | ("LC_CTYPE" . "C") 427 | ("LC_MESSAGES" . "en_US.UTF-8")) 428 | env) 429 | "Cancel") 430 | #:port fake-port)) 431 | (test-equal (format #f "ERR 277 Operation cancelled\n") output)) 432 | (test-assert (not (pinentry-ok pinentry))) 433 | (test-assert (not (pinentry-getinfo pinentry " CONFIRM"))) 434 | (test-assert (not (pinentry-getinfo pinentry "Foo")))) 435 | 436 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "en_US.UTF-8" '())) 437 | (description "This is a description") 438 | (display ":1")) 439 | (set-pinentry-desc! pinentry description) 440 | (set-pinentry-display! pinentry display) 441 | (test-assert (pinentry-confirm pinentry "CONFIRM --one-button" 442 | (lambda* (#:key (env '()) 443 | visibility 444 | (prompt ">") 445 | message 446 | buttons 447 | only-match) 448 | (test-equal ">" prompt) 449 | (test-equal description message) 450 | (test-assert visibility) 451 | (test-assert only-match) 452 | (test-equal `("Ok") buttons) 453 | (test-equal `(("DISPLAY" . ,display) 454 | ("LC_CTYPE" . "C") 455 | ("LC_MESSAGES" . "en_US.UTF-8")) 456 | env) 457 | "Ok"))) 458 | (test-assert (pinentry-ok pinentry)) 459 | (set-pinentry-ok! pinentry #f) 460 | (test-assert (pinentry-confirm pinentry "MESSAGE" 461 | (lambda* (#:key (env '()) 462 | visibility 463 | (prompt ">") 464 | message 465 | buttons 466 | only-match) 467 | (test-equal ">" prompt) 468 | (test-equal description message) 469 | (test-assert visibility) 470 | (test-assert only-match) 471 | (test-equal `("Ok") buttons) 472 | (test-equal `(("DISPLAY" . ,display) 473 | ("LC_CTYPE" . "C") 474 | ("LC_MESSAGES" . "en_US.UTF-8")) 475 | env) 476 | "Ok"))) 477 | (test-assert (pinentry-ok pinentry)) 478 | (test-assert (not (pinentry-getinfo pinentry " CONFIRM --one-button"))) 479 | (test-assert (not (pinentry-getinfo pinentry "MESSAGE --one-button"))) 480 | (test-assert (not (pinentry-getinfo pinentry " MESSAGE"))) 481 | (test-assert (not (pinentry-getinfo pinentry "Foo")))) 482 | 483 | (let* ((pinentry (make-pinentry #f "Prompt" "Ok" "Cancel" ":1" "test.log" "C" "en_US.UTF-8" '())) 484 | (output "") 485 | (fake-port (make-soft-port 486 | (vector 487 | (lambda (c) (set! output (string-append output c))) 488 | (lambda (s) (set! output (string-append output s))) 489 | (lambda () #t) 490 | #f 491 | (lambda () #t)) 492 | "w"))) 493 | (let ((passwords '("password" 494 | "Pass%word1" 495 | "1|Sb56(Qr=£?-N2GWjx>j=Ju+" 496 | "correct horse battery staple")) 497 | (expectations '("password" 498 | "Pass%25word1" 499 | "1%7CSb56%28Qr%3D%C2%A3%3F-N2GWjx%3Ej%3DJu%2B" 500 | "correct%20horse%20battery%20staple"))) 501 | (for-each (lambda (password expected) 502 | (test-assert (pinentry-getpin pinentry "GETPIN" 503 | (lambda* _ (string-append password "\n")) 504 | #:port fake-port)) 505 | (test-equal (format #f "D ~a~%" expected) output) 506 | (set! output "")) 507 | passwords expectations))) 508 | (test-end "pinentry-rofi") 509 | -------------------------------------------------------------------------------- /LICENSES/GPL-3.0-or-later.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright © 2007 Free Software Foundation, Inc. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies 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 software and other kinds of works. 11 | 12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. 13 | 14 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 15 | 16 | To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. 17 | 18 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 19 | 20 | Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. 21 | 22 | For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. 23 | 24 | Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. 25 | 26 | Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. 27 | 28 | The precise terms and conditions for copying, distribution and modification follow. 29 | 30 | TERMS AND CONDITIONS 31 | 32 | 0. Definitions. 33 | 34 | “This License” refers to version 3 of the GNU General Public License. 35 | 36 | “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 37 | 38 | “The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. 39 | 40 | To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. 41 | 42 | A “covered work” means either the unmodified Program or a work based on the Program. 43 | 44 | To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 45 | 46 | To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 47 | 48 | An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 49 | 50 | 1. Source Code. 51 | The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. 52 | 53 | A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 54 | 55 | The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 56 | 57 | The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. 58 | 59 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 60 | 61 | The Corresponding Source for a work in source code form is that same work. 62 | 63 | 2. Basic Permissions. 64 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 65 | 66 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 67 | 68 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 69 | 70 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 71 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 72 | 73 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 74 | 75 | 4. Conveying Verbatim Copies. 76 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 77 | 78 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 79 | 80 | 5. Conveying Modified Source Versions. 81 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 82 | 83 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 84 | 85 | b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. 86 | 87 | c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 88 | 89 | d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 90 | 91 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 92 | 93 | 6. Conveying Non-Source Forms. 94 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 95 | 96 | a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 97 | 98 | b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 99 | 100 | c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 101 | 102 | d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 103 | 104 | e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 105 | 106 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 107 | 108 | A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 109 | 110 | “Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 111 | 112 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 113 | 114 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 115 | 116 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 117 | 118 | 7. Additional Terms. 119 | “Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 120 | 121 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 122 | 123 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 124 | 125 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 126 | 127 | b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 128 | 129 | c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 130 | 131 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 132 | 133 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 134 | 135 | f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 136 | 137 | All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 138 | 139 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 140 | 141 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 142 | 143 | 8. Termination. 144 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 145 | 146 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 147 | 148 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 149 | 150 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 151 | 152 | 9. Acceptance Not Required for Having Copies. 153 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 154 | 155 | 10. Automatic Licensing of Downstream Recipients. 156 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 157 | 158 | An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 159 | 160 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 161 | 162 | 11. Patents. 163 | A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. 164 | 165 | A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 166 | 167 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 168 | 169 | In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 170 | 171 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 172 | 173 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 174 | 175 | A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 176 | 177 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 178 | 179 | 12. No Surrender of Others' Freedom. 180 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 181 | 182 | 13. Use with the GNU Affero General Public License. 183 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 184 | 185 | 14. Revised Versions of this License. 186 | The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 187 | 188 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. 189 | 190 | If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 191 | 192 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 193 | 194 | 15. Disclaimer of Warranty. 195 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 196 | 197 | 16. Limitation of Liability. 198 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 199 | 200 | 17. Interpretation of Sections 15 and 16. 201 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 202 | 203 | END OF TERMS AND CONDITIONS 204 | 205 | How to Apply These Terms to Your New Programs 206 | 207 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. 208 | 209 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. 210 | 211 | 212 | Copyright (C) 213 | 214 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 215 | 216 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 217 | 218 | You should have received a copy of the GNU General Public License along with this program. If not, see . 219 | 220 | Also add information on how to contact you by electronic and paper mail. 221 | 222 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 223 | 224 | Copyright (C) 225 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 226 | This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. 227 | 228 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. 229 | 230 | You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . 231 | 232 | The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . 233 | --------------------------------------------------------------------------------