├── .gitea └── ISSUE_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── Makefile ├── README.md ├── setup.cfg └── src ├── install_host_app.bat ├── install_host_app.sh ├── passff.json └── passff.py /.gitea/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### General information. Describe your environment 2 | 3 | 4 | - Versions 5 | - Operating system: 6 | - Browser: 7 | - PassFF: 8 | - Host app: 9 | 10 | - How have you installed the host app? 11 | 12 | 13 | - Your preferences 14 | - In the host app `passff.py`: 15 | 16 | --- 17 | 18 | ### Describe *objectively* your problem 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.2.4] - 2023-12-06 8 | ### Added 9 | - Include debug outputs from GPG to allow improved error messages in PassFF 10 | - Add installer support for gopass 11 | 12 | ## [1.2.3] - 2021-11-03 13 | ### Added 14 | - Add support for LibreWolf 15 | 16 | ## [1.2.2] - 2021-10-06 17 | ### Added 18 | - Add support for gopass when renamed to pass 19 | 20 | ## [1.2.1] - 2019-04-25 21 | ### Fixed 22 | - Python 3.5 support 23 | 24 | ## [1.2.0] - 2019-04-20 25 | ### Added 26 | - Added CHANGELOG 27 | - grepMetaUrls command 28 | 29 | ## [1.1.0] - 2019-02-07 30 | ### Added 31 | - [OTP](https://github.com/tadfisher/pass-otp) support 32 | 33 | ### Changed 34 | - Makefile refactored and [usage](https://codeberg.org/PassFF/passff-host#latest-from-git) updated 35 | 36 | ### Fixed 37 | - Flake8 conformance & documentation improved 38 | - [Passff not comunicating with passff-host](https://codeberg.org/PassFF/passff-host/issues/27) 39 | 40 | ## [1.0.2] - 2018-07-01 41 | ### Added 42 | - Documentation Update 43 | 44 | ### Fixed 45 | - Shellcheck conformance 46 | - Globbing and escaping paths 47 | - Improved OSX/BSD support 48 | - Subprocess on Python >= 3.5 49 | 50 | ## [1.0.1] - 2018-03-24 51 | ### Security 52 | - Prevent code injection by separating positional from optional command line arguments 53 | 54 | ## [1.0.0] - 2018-03-24 55 | ### Added 56 | - Initial Release 57 | 58 | [Unreleased]: https://codeberg.org/PassFF/passff-host/compare/1.2.4...HEAD 59 | [1.2.4]: https://codeberg.org/PassFF/passff-host/compare/1.2.3...1.2.4 60 | [1.2.3]: https://codeberg.org/PassFF/passff-host/compare/1.2.2...1.2.3 61 | [1.2.2]: https://codeberg.org/PassFF/passff-host/compare/1.2.1...1.2.2 62 | [1.2.1]: https://codeberg.org/PassFF/passff-host/compare/1.2.0...1.2.1 63 | [1.2.0]: https://codeberg.org/PassFF/passff-host/compare/1.1.0...1.2.0 64 | [1.1.0]: https://codeberg.org/PassFF/passff-host/compare/1.0.2...1.1.0 65 | [1.0.2]: https://codeberg.org/PassFF/passff-host/compare/1.0.1...1.0.2 66 | [1.0.1]: https://codeberg.org/PassFF/passff-host/compare/1.0...1.0.1 67 | [1.0.0]: https://codeberg.org/PassFF/passff-host/releases/tag/1.0 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | zx2c4 pass manager addon for firefox 294 | Copyright (C) 2013 Johan Venant 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | VERSION ?= testing 3 | BROWSER ?= firefox 4 | 5 | SRC_DIR := ./src 6 | TARGET_DIR := ./bin/$(VERSION) 7 | 8 | INSTALL_WIN_FILE := install_host_app.bat 9 | INSTALL_WIN_SRC := $(SRC_DIR)/$(INSTALL_WIN_FILE) 10 | INSTALL_WIN_TARGET := $(TARGET_DIR)/$(INSTALL_WIN_FILE) 11 | 12 | INSTALL_UNIX_FILE := install_host_app.sh 13 | INSTALL_UNIX_SRC := $(SRC_DIR)/$(INSTALL_UNIX_FILE) 14 | INSTALL_UNIX_TARGET := $(TARGET_DIR)/$(INSTALL_UNIX_FILE) 15 | 16 | HOST_APP_FILES := passff.py passff.json 17 | HOST_APP_SRC := $(addprefix $(SRC_DIR)/,$(HOST_APP_FILES)) 18 | HOST_APP_TARGET := $(addprefix $(TARGET_DIR)/,$(HOST_APP_FILES)) 19 | 20 | HOST_TARGETS := $(INSTALL_WIN_TARGET) $(INSTALL_UNIX_TARGET) $(HOST_APP_TARGET) 21 | 22 | all: $(HOST_TARGETS) 23 | 24 | install: install-unix 25 | install-unix: $(HOST_TARGETS) 26 | $(INSTALL_UNIX_TARGET) --local $(BROWSER) 27 | install-win: $(HOST_TARGETS) 28 | $(INSTALL_WIN_TARGET) --local $(BROWSER) 29 | 30 | %/.d: 31 | mkdir -p $(@D) 32 | @touch $@ 33 | 34 | $(HOST_TARGETS): $(TARGET_DIR)/%: $(SRC_DIR)/% $(TARGET_DIR)/.d 35 | sed -e "s/_VERSIONHOLDER_/$(VERSION)/g" < $(SRC_DIR)/$* > $@ 36 | # Make scripts executable 37 | echo $@ | grep -vq '\(\.sh\|\.py\)$$' || chmod a+x $@ 38 | 39 | clean: 40 | rm -rf $(TARGET_DIR) 41 | 42 | .PRECIOUS: %/.d 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | passff-host 2 | =========== 3 | 4 | Host app for the WebExtension **[PassFF](https://addons.mozilla.org/firefox/addon/passff)** 5 | 6 | ### Overview 7 | This piece of software wraps around the **[zx2c4 pass](http://www.zx2c4.com/projects/password-store/)** shell command. It has to be installed for the PassFF browser extension to work properly. 8 | 9 | ### Dependencies 10 | 11 | #### For the host application 12 | * [`python3`](https://docs.python.org/3.5/) (>= 3.5) 13 | * [`pass`](https://www.passwordstore.org/) 14 | 15 | In most cases, a **graphical *pinentry* program** is also needed for use with the PassFF browser extension. For that, please refer to the instructions given in the [PassFF repository](https://codeberg.org/PassFF/passff#a-graphical-pinentry-program). 16 | 17 | #### For the install script (except Windows) 18 | * `curl` 19 | * `sed` 20 | 21 | ### Installation 22 | 23 | #### Linux, MacOS, * BSD 24 | 25 | Download the latest `install_host_app.sh` script from [our releases page](https://codeberg.org/PassFF/passff-host/releases) and execute it. As an example, Firefox users can do this in one line like so: 26 | 27 | ```bash 28 | curl -sSL https://codeberg.org/PassFF/passff-host/releases/download/latest/install_host_app.sh | bash -s -- firefox 29 | ``` 30 | 31 | Users of other supported browsers need to replace the last argument (`firefox`) by `librewolf`, `chrome`, `opera`, `chromium` or `vivaldi`. 32 | The script will download the host application (a small python script) and the add-on's manifest file (a JSON config file) and put them in the right place. 33 | 34 | If you're concerned about executing a script that downloads files from the web, you can download the files yourself and run the script with the `--local` option instead or link the files yourself. Details below. 35 | 36 | For **OpenBSD** users (cf. [issue #67](https://codeberg.org/PassFF/passff-host/issues/67)), note that Firefox is patched with the [unveil(2)](https://man.openbsd.org/unveil.2) system call to restrict access to the filesystem, in order to make Firefox more secure. Therefore, Firefox on OpenBSD can only execute files for which execution is explicitly permitted in a local configuration file. To allow execution of the PassFF host script, add the following line to the file `/etc/firefox/unveil.main` on your OpenBSD system: 37 | ``` 38 | ~/.mozilla/native-messaging-hosts rx 39 | ``` 40 | Please keep in mind that this does still lessen the security provided by the default OpenBSD settings. Make the change at your own risk! 41 | 42 | #### Windows 43 | Download the `install_host_app.bat` script from [our releases page](https://codeberg.org/PassFF/passff-host/releases) and execute it from within a shell with a correct PATH, mentioning your browser in the last argument (i.e., replace `firefox` by `librewolf`, `chrome`, `opera`, `chromium` or `vivaldi` if necessary). 44 | *The rule of thumb is: if you can execute pass and python from your shell, then your host application will be installed correctly.* 45 | 46 | ``` 47 | install_host_app.bat firefox 48 | ``` 49 | 50 | Note: Older Windows versions might require powershell to be installed manually as the install script uses powershell internally. Windows 10 users should be fine out of the box. 51 | 52 | #### NixOS linux 53 | 54 | Install the version without extensions to pass with: 55 | 56 | environment.systemPackages = with pkgs; [ 57 | ... 58 | (firefox.override { extraNativeMessagingHosts = [passff-host]; }) 59 | ...]; 60 | 61 | The string "..." is to be replaced by the list of all other packages installed by root on your NixOS. The way to add extentions to pass is [below](https://github.com/jidhub/passff-host#preferences). 62 | 63 | 64 | #### Latest from git 65 | 66 | This is not recommended! Only for developers and for testing purposes! 67 | 68 | Clone the repository. Then, run the following command. 69 | 70 | ```bash 71 | make [VERSION=testing|...] [BROWSER=firefox|librewolf|chrome|opera|chromium|vivaldi] install 72 | ``` 73 | 74 | This will generate the host application and installation scripts for the given `VERSION` (`testing` by default), and copy the host application and manifest files to the right place for your `BROWSER` (`firefox` by default). 75 | 76 | This uses the `--local` option of the `install_host_app.sh` script, which instructs it to use the files on disk rather than downloading them from the official git repository. 77 | 78 | If this doesn't work, you can link the files yourself. First, change the `path` value in the `passff.json` file to be the absolute path to the project's `bin/testing/passff.py` file. Then symlink (or copy) the file `bin/testing/passff.json` to the appropriate location for your browser and OS: 79 | 80 | - [Firefox](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_manifests#Manifest_location) 81 | - Linux 82 | - Per-user: `~/.mozilla/native-messaging-hosts/passff.json` 83 | - System-wide: `/usr/{lib,lib64,share}/mozilla/native-messaging-hosts/passff.json` 84 | - OS X 85 | - Per-user: `~/Library/Application Support/Mozilla/NativeMessagingHosts/passff.json` 86 | - System-wide: `/Library/Application Support/Mozilla/NativeMessagingHosts/passff.json` 87 | - Windows 88 | - Per-user: `Path contained in registry key HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts\passff` 89 | - System-wide: `Path contained in registry key HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\passff` 90 | - LibreWolf 91 | - Linux 92 | - Per-user: `~/.librewolf/native-messaging-hosts/passff.json` 93 | - System-wide: `/usr/{lib,lib64,share}/librewolf/native-messaging-hosts/passff.json` 94 | - OS X 95 | - Per-user: `~/Library/Application Support/LibreWolf/NativeMessagingHosts/passff.json` 96 | - System-wide: `/Library/Application Support/LibreWolf/NativeMessagingHosts/passff.json` 97 | - Windows 98 | - Per-user: `Path contained in registry key HKEY_CURRENT_USER\Software\LibreWolf\NativeMessagingHosts\passff` 99 | - System-wide: `Path contained in registry key HKEY_LOCAL_MACHINE\SOFTWARE\LibreWolf\NativeMessagingHosts\passff` 100 | - Chrome 101 | - Linux 102 | - Per-user: `~/.config/google-chrome/NativeMessagingHosts/passff.json` 103 | - System-wide: `/etc/opt/chrome/native-messaging-hosts/passff.json` 104 | - OS X 105 | - Per-user: `~/Library/Application Support/Google/Chrome/NativeMessagingHosts/passff.json` 106 | - System-wide: `/Library/Google/Chrome/NativeMessagingHosts/passff.json` 107 | - Windows 108 | - Per-user: `HKEY_CURRENT_USER\SOFTWARE\Google\Chrome\NativeMessagingHosts\passff` 109 | - System-wide: `HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\NativeMessagingHosts\passff` 110 | - Chromium 111 | - Linux 112 | - Per-user: `~/.config/chromium/NativeMessagingHosts/passff.json` 113 | - System-wide: `/etc/chromium/native-messaging-hosts/passff.json` 114 | - OS X 115 | - Per-user: `~/Library/Application Support/Chromium/NativeMessagingHosts/passff.json` 116 | - System-wide: `/Library/Application Support/Chromium/NativeMessagingHosts/passff.json` 117 | - Opera 118 | - Same as Chrome 119 | - Vivaldi 120 | - Linux 121 | - Per-user: `~/.config/vivaldi/NativeMessagingHosts/passff.json` 122 | - System-wide: `/etc/vivaldi/native-messaging-hosts/passff.json` 123 | - OS X 124 | - Per-user: `~/Library/Application Support/Vivaldi/NativeMessagingHosts/passff.json` 125 | - System-wide: `/Library/Application Support/Vivaldi/NativeMessagingHosts/passff.json` 126 | 127 | ### Troubleshooting 128 | 129 | #### Script execution failed 130 | #### Connection to the host app failed or returned an unexpected result 131 | 132 | > Connection to the host app failed or returned an unexpected result! 133 | > Make sure you have the latest version of the PassFF host app installed by following the installation instructions in the official git repository. 134 | 135 | > Script execution failed. 136 | 137 | You get one of these error messages? Follow the instructions below! 138 | 139 | ###### Remove old installations 140 | *Inappropriate installations can override another one that could work. So, it is simpler to remove everything and restart from scratch.* 141 | * Delete any file `passff.json` in the folders `native-messaging-hosts` and `NativeMessagingHosts` 142 | * For the complete paths of these folders for your OS and browser, see the section above. 143 | * Verify all `passff.json` are deleted by doing a search. 144 | * Use your best file searching tool. For example: `find / -type f -name 'passff.json'` 145 | 146 | ###### Reinstall the host application 147 | See the section above. 148 | 149 | ###### Check that the host application is correctly installed 150 | * Make sure the file `passff.py` is executable 151 | * `ls -l /path/to/passff.py` 152 | * Open `passff.json` and verify `path` is set to the absolute path of the host executable `passff.py`: for example `"path": "/path/to/passff.py"` 153 | 154 | #### PassFF's host application is not working and takes 99% CPU 155 | 156 | ###### Set a correct PATH in the `passff.py` script 157 | When the PATH variable is not set correctly, `pass` will complain about not finding `getopt` and then loop forever. You can reproduce this behavior on the command line: 158 | ```bash 159 | PATH="$(which bash | xargs dirname)" $(which pass) 160 | ``` 161 | 162 | ### Advanced Troubleshooting 163 | If nothing above has worked out your issue... 164 | 165 | #### Gather information in the web browser 166 | In the preferences of PassFF, you can enable the status bar and debug logs in the Web Console (to open the console: Ctrl+Shift+K in Firefox, Ctrl+Shift+J in Chrome/Chromium). Enable the debugging mode in `about:debugging`, and reload the app. 167 | 168 | #### Make sure the version of the host application is supported by PassFF 169 | * Open the `passff.py` file to find its version number 170 | * `head /path/to/passff.py` 171 | 172 | #### Check the output of the host app 173 | * Run `echo -e "\x02\x00\x00\x00[]" | /path/to/passff.py | tail -c +4; echo` 174 | * The typical output for an empty store is: 175 | * `{"stderr": "", "version": "1.0.1", "exitCode": 0, "stdout": "Password Store\n"}` 176 | 177 | #### Check the error code on failure 178 | ```console 179 | $ strace -f --trace=execve --string-limit=256 firefox 2>&1 |grep passff 180 | [pid 73124] execve("/home//.mozilla/native-messaging-hosts/passff.py", ["/home//.mozilla/native-messaging-hosts/passff.py", "/home//.mozilla/native-messaging-hosts/passff.json", "passff@invicem.pro"], 0x7fce6a83e500 /* 77 vars */) = -1 EACCES (Permission denied) 181 | ``` 182 | 183 | #### Check the security module configuration 184 | If your browser is confined by a security module such as AppArmor, then its policies might deny the execution of the host application, resulting in syslog entries like this: 185 | ```console 186 | $ grep passff /var/log/syslog 187 | Apr 22 19:55:24 kernel: [70746.170024] audit: type=1400 audit(1650650124.793:2258): apparmor="DENIED" operation="exec" profile="firefox" name="/home//.mozilla/native-messaging-hosts/passff.py" pid=73124 comm=444F4D20576F726B6572 requested_mask="x" denied_mask="x" fsuid=1000 ouid=1000 188 | ``` 189 | Similarly, OpenBSD has its own ways to restrict execution of scripts by Firefox. See the "Installation" section above for instructions on how to remove those restrictions. 190 | 191 | #### Testing OTP support 192 | ```console 193 | $ echo -e "\x19\x00\x00\x00[\"otp\",\"/www/example.com\"]" | /path/to/passff.py | tail -c +4; echo 194 | {"exitCode": 0, "stderr": "", "stdout": "123456\n", "version": "1.0.1"} 195 | ``` 196 | 197 | ### Preferences 198 | If you use a customized `pass` installation: environment variables, customized repository path or extensions, you may have to customize the *preferences section* in `passff.py`. 199 | 200 | By modifying the *preferences section* in `passff.py`, you will be able to set: 201 | - `COMMAND`: the path to the `pass` script, 202 | - `COMMAND_ARGS`: additional command line arguments that are passed to `pass`, 203 | - `COMMAND_ENV`: additional environment variables, 204 | - `CHARSET`: the shell stdout charset. 205 | 206 | If you are using [NixOS linux](https://github.com/tadfisher/pass-otp#nixnixos), you can install extensions like pass-otp in passff-host with: 207 | 208 | environment.systemPackages = with pkgs; [ 209 | ... 210 | (pass.withExtensions (ext: with ext; [pass-otp])) 211 | (firefox.override { extraNativeMessagingHosts = [(passff-host.overrideAttrs (old: { dontStrip = true; patchPhase = '' 212 | sed -i 's#COMMAND = "pass"#COMMAND = "${pass.withExtensions (ext: with ext; [pass-otp])}/bin/pass"#' src/passff.py 213 | ''; }))]; }) 214 | ...]; 215 | 216 | The string "..." is to be replaced by the list of all other packages installed by root on your NixOS. 217 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = E266 3 | -------------------------------------------------------------------------------- /src/install_host_app.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | SETLOCAL 3 | 4 | SET "APP_NAME=passff" 5 | SET "VERSION=_VERSIONHOLDER_" 6 | SET "HOST_URL=https://codeberg.org/PassFF/passff-host/releases/download/%VERSION%/passff.py" 7 | SET "MANIFEST_URL=https://codeberg.org/PassFF/passff-host/releases/download/%VERSION%/passff.json" 8 | 9 | SET "TARGET_DIR=%APPDATA%\%APP_NAME%" 10 | SET "HOST_MANIFEST=%APP_NAME%.json" 11 | SET "HOST_SCRIPT=%APP_NAME%.py" 12 | SET "HOST_BATCH=%APP_NAME%.bat" 13 | 14 | SET "HOST_MANIFEST_FULL=%TARGET_DIR%\%HOST_MANIFEST%" 15 | SET "HOST_SCRIPT_FULL=%TARGET_DIR%\%HOST_SCRIPT%" 16 | SET "HOST_BATCH_FULL=%TARGET_DIR%\%HOST_BATCH%" 17 | 18 | SET "USE_LOCAL_FILES=" 19 | SET "TARGET_REG=" 20 | 21 | REM check prerequisites: is python installed & in path? 22 | python --version >NUL 2> NUL || ( 23 | ECHO "python not found in PATH. Please execute this command in a shell where python is in PATH" 24 | EXIT /B 25 | ) 26 | 27 | :loop 28 | IF NOT "%1"=="" ( 29 | IF "%1"=="--local" ( 30 | SET "USE_LOCAL_FILES=true" 31 | SHIFT 32 | ) ELSE IF "%1"=="--help" ( 33 | GOTO :help 34 | ) ELSE IF "%1"=="firefox" ( 35 | SET "TARGET_REG=HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\%APP_NAME%" 36 | SHIFT 37 | ) ELSE IF "%1"=="librewolf" ( 38 | SET "TARGET_REG=HKCU\SOFTWARE\LibreWolf\NativeMessagingHosts\%APP_NAME%" 39 | SHIFT 40 | ) ELSE IF "%1"=="chrome" ( 41 | SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" 42 | SHIFT 43 | ) ELSE IF "%1"=="chromium" ( 44 | ECHO Chromium registry key location for Native Messaging Hosts is undocumented. Assuming key for Chrome. Please provide feedback if this worked: https://codeberg.org/PassFF/passff/issues/202 45 | SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" 46 | SHIFT 47 | ) ELSE IF "%1"=="opera" ( 48 | ECHO Opera registry key location for Native Messaging Hosts is undocumented. Assuming key for Chrome. Please provide feedback if this worked: https://codeberg.org/PassFF/passff/issues/202 49 | SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" 50 | SHIFT 51 | ) ELSE IF "%1"=="vivaldi" ( 52 | ECHO Vivaldi registry key location for Native Messaging Hosts is undocumented. Assuming key for Chrome. Please provide feedback if this worked: https://codeberg.org/PassFF/passff/issues/202 53 | SET "TARGET_REG=HKCU\Software\Google\Chrome\NativeMessagingHosts\%APP_NAME%" 54 | SHIFT 55 | ) ELSE ( 56 | SHIFT 57 | ) 58 | GOTO :loop 59 | ) 60 | 61 | IF "%TARGET_REG%"=="" ( 62 | GOTO :help 63 | ) 64 | 65 | IF EXIST "%TARGET_DIR%" ( 66 | dir /AD "%TARGET_DIR%" > nul || ( 67 | ECHO "%TARGET_DIR%" is not a directory 68 | EXIT /B 69 | ) 70 | ) ELSE ( 71 | MKDIR "%TARGET_DIR%" 2> nul 72 | ) 73 | 74 | IF "%USE_LOCAL_FILES%"=="true" ( 75 | IF NOT EXIST "%~dp0%HOST_MANIFEST%" ( 76 | ECHO local file "%~dp0%HOST_MANIFEST%" not found 77 | EXIT /B 78 | ) 79 | IF NOT EXIST "%~dp0%HOST_SCRIPT%" ( 80 | ECHO local file "%~dp0%HOST_SCRIPT%" not found 81 | EXIT /B 82 | ) 83 | COPY /Y "%~dp0%HOST_MANIFEST%" "%HOST_MANIFEST_FULL%" 84 | COPY /Y "%~dp0%HOST_SCRIPT%" "%HOST_SCRIPT_FULL%" 85 | ) ELSE ( 86 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%HOST_URL%', '%HOST_SCRIPT_FULL%')" 87 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%MANIFEST_URL%', '%HOST_MANIFEST_FULL%')" 88 | ) 89 | 90 | powershell -Command "(Get-Content '%HOST_MANIFEST_FULL%') -replace 'PLACEHOLDER', '%HOST_BATCH_FULL:\=/%' | Set-Content '%HOST_MANIFEST_FULL%'" 91 | 92 | ( 93 | ECHO @ECHO OFF 94 | ECHO SET "PATH=%PATH%" 95 | ECHO SET "GNUPGHOME=%GNUPGHOME%" 96 | ECHO python "%HOST_SCRIPT_FULL%" %%* 97 | )>"%HOST_BATCH_FULL%" 98 | 99 | REG ADD "%TARGET_REG%" /ve /d "%HOST_MANIFEST_FULL%" /f || ( 100 | ECHO Adding key to registry failed - maybe you need Administrator rights for this. Please run 101 | ECHO REG ADD "%TARGET_REG%" /ve /d "%HOST_MANIFEST_FULL%" /f 102 | ECHO manually in an administrative shell. 103 | ) 104 | EXIT /B 105 | 106 | :help 107 | ECHO Usage: %0 [OPTION] [chrome^|chromium^|firefox^|opera^|vivaldi^|librewolf] 108 | ECHO 109 | ECHO Options: 110 | ECHO --local Install files from disk instead of downloading them 111 | ECHO --help Show this message" 112 | EXIT /B 113 | -------------------------------------------------------------------------------- /src/install_host_app.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # This script is derived from `install.sh` in Danny van Kooten's "browserpass": 4 | # https://github.com/dannyvankooten/browserpass 5 | 6 | set -e 7 | 8 | APP_NAME="passff" 9 | VERSION="_VERSIONHOLDER_" 10 | HOST_URL="https://codeberg.org/PassFF/passff-host/releases/download/$VERSION/passff.py" 11 | MANIFEST_URL="https://codeberg.org/PassFF/passff-host/releases/download/$VERSION/passff.json" 12 | KERNEL_NAME=$(uname -s) 13 | 14 | # Find target dirs for various browsers & OS'es 15 | # https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location 16 | # https://wiki.mozilla.org/WebExtensions/Native_Messaging 17 | if [ "$KERNEL_NAME" = 'Darwin' ]; then 18 | if [ "$(whoami)" = "root" ]; then 19 | TARGET_DIR_CHROME="/Library/Google/Chrome/NativeMessagingHosts" 20 | TARGET_DIR_CHROMIUM="/Library/Application Support/Chromium/NativeMessagingHosts" 21 | TARGET_DIR_FIREFOX="/Library/Application Support/Mozilla/NativeMessagingHosts" 22 | TARGET_DIR_VIVALDI="/Library/Application Support/Vivaldi/NativeMessagingHosts" 23 | TARGET_DIR_LIBREWOLF="/Library/Application Support/LibreWolf/NativeMessagingHosts" 24 | else 25 | TARGET_DIR_CHROME="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" 26 | TARGET_DIR_CHROMIUM="$HOME/Library/Application Support/Chromium/NativeMessagingHosts" 27 | TARGET_DIR_FIREFOX="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts" 28 | TARGET_DIR_VIVALDI="$HOME/Library/Application Support/Vivaldi/NativeMessagingHosts" 29 | TARGET_DIR_LIBREWOLF="$HOME/Library/Application Support/LibreWolf/NativeMessagingHosts" 30 | fi 31 | else 32 | if [ "$(whoami)" = "root" ]; then 33 | TARGET_DIR_CHROME="/etc/opt/chrome/native-messaging-hosts" 34 | TARGET_DIR_CHROMIUM="/etc/chromium/native-messaging-hosts" 35 | TARGET_DIR_FIREFOX="/usr/lib/mozilla/native-messaging-hosts" 36 | TARGET_DIR_VIVALDI="/etc/vivaldi/native-messaging-hosts" 37 | TARGET_DIR_LIBREWOLF="/usr/lib/librewolf/native-messaging-hosts" 38 | else 39 | TARGET_DIR_CHROME="$HOME/.config/google-chrome/NativeMessagingHosts" 40 | TARGET_DIR_CHROMIUM="$HOME/.config/chromium/NativeMessagingHosts" 41 | TARGET_DIR_FIREFOX="$HOME/.mozilla/native-messaging-hosts" 42 | TARGET_DIR_VIVALDI="$HOME/.config/vivaldi/NativeMessagingHosts" 43 | TARGET_DIR_LIBREWOLF="$HOME/.librewolf/native-messaging-hosts" 44 | fi 45 | fi 46 | 47 | usage() { 48 | echo "Usage: $0 [OPTION] [chrome|chromium|firefox|opera|vivaldi|librewolf] 49 | 50 | Example: 51 | $0 firefox # Install host app for Mozilla Firefox 52 | 53 | Options: 54 | -l, --local Install files from disk instead of downloading them 55 | -h, --help Show this message" 56 | } 57 | 58 | while [ $# -gt 0 ]; do 59 | case $1 in 60 | chrome) 61 | BROWSER_NAME="Chrome" 62 | TARGET_DIR="$TARGET_DIR_CHROME" 63 | ;; 64 | chromium) 65 | BROWSER_NAME="Chromium" 66 | TARGET_DIR="$TARGET_DIR_CHROMIUM" 67 | ;; 68 | firefox) 69 | BROWSER_NAME="Firefox" 70 | TARGET_DIR="$TARGET_DIR_FIREFOX" 71 | ;; 72 | librewolf) 73 | BROWSER_NAME="Librewolf" 74 | TARGET_DIR="$TARGET_DIR_LIBREWOLF" 75 | ;; 76 | opera) 77 | BROWSER_NAME="Opera" 78 | TARGET_DIR="$TARGET_DIR_VIVALDI" 79 | ;; 80 | vivaldi) 81 | BROWSER_NAME="Vivaldi" 82 | TARGET_DIR="$TARGET_DIR_VIVALDI" 83 | ;; 84 | -l|--local) 85 | USE_LOCAL_FILES=true 86 | ;; 87 | -h|--help) 88 | usage 89 | exit 0 90 | ;; 91 | *) 92 | usage 93 | exit 1 94 | ;; 95 | esac 96 | shift 97 | done 98 | 99 | PYTHON3_PATH="$(which python3)" 100 | if [ -x "$PYTHON3_PATH" ]; then 101 | echo "Python 3 executable located at $PYTHON3_PATH" 102 | else 103 | echo "Python 3 executable not found, but Python 3 is required for PassFF to work!" 104 | exit 1 105 | fi 106 | 107 | PASS_PATH="$(which pass || which gopass)" 108 | if [ -x "$PASS_PATH" ]; then 109 | echo "Pass executable located at $PASS_PATH" 110 | else 111 | echo "Pass executable not found, but Pass is required for PassFF to work!" 112 | exit 1 113 | fi 114 | 115 | if [ -z "$TARGET_DIR" ]; then 116 | usage 117 | exit 1 118 | fi 119 | 120 | HOST_FILE_PATH="$TARGET_DIR/$APP_NAME.py" 121 | MANIFEST_FILE_PATH="$TARGET_DIR/$APP_NAME.json" 122 | 123 | echo "Installing $BROWSER_NAME host config" 124 | 125 | # Create config dir if not existing 126 | mkdir -p "$TARGET_DIR" 127 | 128 | PATH_ESC="$(echo "$PATH" | sed -e 's/@/\\@/g')" 129 | PASS_PATH_ESC="$(echo "$PASS_PATH" | sed -e 's/@/\\@/g')" 130 | HOST_FILE_PATH_ESC="$(echo "$HOST_FILE_PATH" | sed -e 's/@/\\@/g')" 131 | PYTHON3_PATH_ESC="$(echo "$PYTHON3_PATH" | sed -e 's/@/\\@/g')" 132 | 133 | # Replace path to python3 executable \ 134 | # Replace path to pass (only in a line starting with "COMMAND =") \ 135 | # Set the PATH to match this script's \ 136 | HOST_SED=" \ 137 | 1 s@.*@#!${PYTHON3_PATH_ESC}@; \ 138 | /^COMMAND *=/s@\"pass\"@\"$PASS_PATH_ESC\"@; \ 139 | s@\"PATH\":.*@\"PATH\": \"$PATH_ESC\"@; \ 140 | " 141 | # Replace path to host \ 142 | MANIFEST_SED=" \ 143 | s@PLACEHOLDER@$HOST_FILE_PATH_ESC@; \ 144 | " 145 | 146 | if [ "$USE_LOCAL_FILES" = true ]; then 147 | sed -e "${HOST_SED}" "$(dirname "$0")/passff.py" > "$HOST_FILE_PATH" 148 | sed -e "${MANIFEST_SED}" "$(dirname "$0")/passff.json" > "$MANIFEST_FILE_PATH" 149 | else 150 | # Download native host script and manifest 151 | curl -sSL "$HOST_URL" | sed -e "${HOST_SED}" > "$HOST_FILE_PATH" 152 | curl -sSL "$MANIFEST_URL" | sed -e "${MANIFEST_SED}" > "$MANIFEST_FILE_PATH" 153 | fi 154 | 155 | # Set permissions for the manifest so that all users can read it. 156 | chmod a+x "$HOST_FILE_PATH" 157 | chmod o+r "$MANIFEST_FILE_PATH" 158 | 159 | echo "Native messaging host for $BROWSER_NAME has been installed to $TARGET_DIR." 160 | -------------------------------------------------------------------------------- /src/passff.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "passff", 3 | "description": "Host for communicating with zx2c4 pass", 4 | "path": "PLACEHOLDER", 5 | "type": "stdio", 6 | "allowed_extensions": [ "passff@invicem.pro" ] 7 | } 8 | -------------------------------------------------------------------------------- /src/passff.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Host application of the browser extension PassFF 4 | that wraps around the zx2c4 pass script. 5 | """ 6 | 7 | import json 8 | import os 9 | import re 10 | import shlex 11 | import struct 12 | import subprocess 13 | import sys 14 | 15 | VERSION = "_VERSIONHOLDER_" 16 | 17 | ############################################################################### 18 | ######################## Begin preferences section ############################ 19 | ############################################################################### 20 | COMMAND = "pass" 21 | COMMAND_ARGS = [] 22 | COMMAND_ENV = { 23 | "TREE_CHARSET": "ISO-8859-1", 24 | "PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", 25 | } 26 | CHARSET = "UTF-8" 27 | 28 | ############################################################################### 29 | ######################### End preferences section ############################# 30 | ############################################################################### 31 | 32 | 33 | def getMessage(): 34 | """ Read a message from stdin and decode it. """ 35 | rawLength = sys.stdin.buffer.read(4) 36 | if len(rawLength) == 0: 37 | sys.exit(0) 38 | messageLength = struct.unpack('@I', rawLength)[0] 39 | message = sys.stdin.buffer.read(messageLength).decode("utf-8") 40 | return json.loads(message) 41 | 42 | 43 | def encodeMessage(messageContent): 44 | """ Encode a message for transmission, given its content. """ 45 | encodedContent = json.dumps(messageContent) 46 | encodedLength = struct.pack('@I', len(encodedContent)) 47 | return {'length': encodedLength, 'content': encodedContent} 48 | 49 | 50 | def sendMessage(encodedMessage): 51 | """ Send an encoded message to stdout. """ 52 | sys.stdout.buffer.write(encodedMessage['length']) 53 | sys.stdout.write(encodedMessage['content']) 54 | sys.stdout.flush() 55 | 56 | 57 | def setPassGpgOpts(env, opts_dict): 58 | """ Add arguments to PASSWORD_STORE_GPG_OPTS. """ 59 | opts = env.get('PASSWORD_STORE_GPG_OPTS', '') 60 | for opt, value in opts_dict.items(): 61 | re_opt = new_opt = opt 62 | if value is not None: 63 | re_opt = rf"{opt}(?:=|\s+)\S*" 64 | new_opt = ( 65 | f"{opt}={shlex.quote(value)}" 66 | if opt.startswith("--") else 67 | f"{opt} {shlex.quote(value)}" 68 | ) 69 | # If the user's environment sets this opt, remove it. 70 | opts = re.sub(re_opt, '', opts) 71 | opts = f"{new_opt} {opts}" 72 | env['PASSWORD_STORE_GPG_OPTS'] = opts.strip() 73 | 74 | 75 | if __name__ == "__main__": 76 | # Read message from standard input 77 | receivedMessage = getMessage() 78 | opt_args = [] 79 | pos_args = [] 80 | std_input = None 81 | 82 | if len(receivedMessage) == 0: 83 | opt_args = ["show"] 84 | pos_args = ["/"] 85 | elif receivedMessage[0] == "insert": 86 | opt_args = ["insert", "-m"] 87 | pos_args = [receivedMessage[1]] 88 | std_input = receivedMessage[2] 89 | elif receivedMessage[0] == "generate": 90 | opt_args = ["generate"] 91 | pos_args = [receivedMessage[1], receivedMessage[2]] 92 | if "-n" in receivedMessage[3:]: 93 | opt_args.append("-n") 94 | elif receivedMessage[0] == "grepMetaUrls" and len(receivedMessage) == 2: 95 | opt_args = ["grep", "-iE"] 96 | url_field_names = receivedMessage[1] 97 | pos_args = ["^({}):".format('|'.join(url_field_names))] 98 | elif receivedMessage[0] == "otp" and len(receivedMessage) == 2: 99 | opt_args = ["otp"] 100 | key = receivedMessage[1] 101 | key = "/" + (key[1:] if key[0] == "/" else key) 102 | pos_args = [key] 103 | else: 104 | opt_args = ["show"] 105 | key = receivedMessage[0] 106 | key = "/" + (key[1:] if key[0] == "/" else key) 107 | pos_args = [key] 108 | opt_args += COMMAND_ARGS 109 | 110 | # Set up (modified) command environment 111 | env = dict(os.environ) 112 | if "HOME" not in env: 113 | env["HOME"] = os.path.expanduser('~') 114 | for key, val in COMMAND_ENV.items(): 115 | env[key] = val 116 | setPassGpgOpts(env, {'--status-fd': '2', '--debug': 'ipc'}) 117 | 118 | # Set up subprocess params 119 | cmd = [COMMAND] + opt_args + ['--'] + pos_args 120 | proc_params = { 121 | 'input': bytes(std_input, CHARSET) if std_input else None, 122 | 'stdout': subprocess.PIPE, 123 | 'stderr': subprocess.PIPE, 124 | 'env': env 125 | } 126 | 127 | # Run and communicate with pass script 128 | proc = subprocess.run(cmd, **proc_params) 129 | 130 | # Send response 131 | sendMessage( 132 | encodeMessage({ 133 | "exitCode": proc.returncode, 134 | "stdout": proc.stdout.decode(CHARSET), 135 | "stderr": proc.stderr.decode(CHARSET), 136 | "version": VERSION 137 | })) 138 | --------------------------------------------------------------------------------