From e488aea931a3928ab7747ac831661c516c30bca2 Mon Sep 17 00:00:00 2001 From: Markus Braun Date: Wed, 27 May 2009 07:10:20 -0400 Subject: [PATCH] releasing gnupg.vim 2773 - fix a bug in detecting windows platforms - added g:GPGPreferSign to sign encrypted files by default (thanks to Tim Swast). --- plugin/gnupg.vim | 84 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/plugin/gnupg.vim b/plugin/gnupg.vim index 39dbca2..9e1b24c 100644 --- a/plugin/gnupg.vim +++ b/plugin/gnupg.vim @@ -1,5 +1,5 @@ " Name: gnupg.vim -" Version: $Id: gnupg.vim 2276 2008-08-15 12:50:33Z mbr $ +" Version: $Id: gnupg.vim 2773 2009-05-27 07:10:20Z mbr $ " Author: Markus Braun " Summary: Vim plugin for transparent editing of gpg encrypted files. " Licence: This program is free software; you can redistribute it and/or @@ -7,7 +7,7 @@ " See http://www.gnu.org/copyleft/gpl.txt " Section: Documentation {{{1 " Description: -" +" " This script implements transparent editing of gpg encrypted files. The " filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening such " a file the content is decrypted, when opening a new file the script will @@ -15,7 +15,7 @@ " encrypted to all recipients before it is written. The script turns off " viminfo and swapfile to increase security. " -" Installation: +" Installation: " " Copy the gnupg.vim file to the $HOME/.vim/plugin directory. " Refer to ':help add-plugin', ':help add-global-plugin' and ':help @@ -27,7 +27,7 @@ " You should always add the following lines to your .bashrc or whatever " initialization file is used for all shell invocations: " -" GPG_TTY=‘tty‘ +" GPG_TTY=`tty` " export GPG_TTY " " It is important that this environment variable always reflects the out‐ @@ -68,22 +68,49 @@ " g:GPGPreferArmor " If set to 1 armored data is preferred for new files. Defaults to 0. " +" g:GPGPreferSign +" If set to 1 signed data is preferred for new files. Defaults to 0. +" " g:GPGDefaultRecipients " If set, these recipients are used as defaults when no other recipient is " defined. This variable is a Vim list. Default is unset. " +" Known Issues: +" +" In some cases gvim can't decryt files + +" This is caused by the fact that a running gvim has no TTY and thus gpg is +" not able to ask for the passphrase by itself. This is a problem for Windows +" and Linux versions of gvim and could not be solved unless a "terminal +" emulation" is implemented for gvim. To circumvent this you have to use any +" combination of gpg-agent and a graphical pinentry program: +" +" - gpg-agent only: +" you need to provide the passphrase for the needed key to gpg-agent +" in a terminal before you open files with gvim which require this key. +" +" - pinentry only: +" you will get a popup window every time you open a file that needs to +" be decrypted. +" +" - gpgagent and pinentry: +" you will get a popup window the first time you open a file that +" needs to be decrypted. +" " Credits: -" - Mathieu Clabaut for inspirations through his vimspell.vim script. -" - Richard Bronosky for patch to enable ".pgp" suffix. -" - Erik Remmelzwaal for patch to enable windows support and patient beta -" testing. -" - Lars Becker for patch to make gpg2 working. -" - Thomas Arendsen Hein for patch to convert encoding of gpg output -" - Karl-Heinz Ruskowski for patch to fix unknown recipients and trust model -" and patient beta testing. -" - Giel van Schijndel for patch to get GPG_TTY dynamically. -" - Sebastian Luettich for patch to fix issue with symmetric encryption an set -" recipients. +" +" - Mathieu Clabaut for inspirations through his vimspell.vim script. +" - Richard Bronosky for patch to enable ".pgp" suffix. +" - Erik Remmelzwaal for patch to enable windows support and patient beta +" testing. +" - Lars Becker for patch to make gpg2 working. +" - Thomas Arendsen Hein for patch to convert encoding of gpg output +" - Karl-Heinz Ruskowski for patch to fix unknown recipients and trust model +" and patient beta testing. +" - Giel van Schijndel for patch to get GPG_TTY dynamically. +" - Sebastian Luettich for patch to fix issue with symmetric encryption an set +" recipients. +" - Tim Swast for patch to generate signed files " " Section: Plugin header {{{1 if (v:version < 700) @@ -95,7 +122,7 @@ if (exists("g:loaded_gnupg") || &cp || exists("#BufReadPre#*.\(gpg\|asc\|pgp\)") finish endif -let g:loaded_gnupg = "$Revision: 2276 $" +let g:loaded_gnupg = "$Revision: 2773 $" " Section: Autocmd setup {{{1 augroup GnuPG @@ -132,7 +159,7 @@ highlight default link GPGHighlightUnknownRecipient ErrorMsg function s:GPGInit() " first make sure nothing is written to ~/.viminfo while editing " an encrypted file. - set viminfo= + set viminfo= " we don't want a swap file, as it writes unencrypted data to disk set noswapfile @@ -157,6 +184,11 @@ function s:GPGInit() let g:GPGPreferArmor = 0 endif + " check if signed files are preferred + if (!exists("g:GPGPreferSign")) + let g:GPGPreferSign = 0 + endif + " check if debugging is turned on if (!exists("g:GPGDefaultRecipients")) let g:GPGDefaultRecipients = [] @@ -197,17 +229,17 @@ function s:GPGInit() " setup shell environment for unix and windows let s:shellredirsave = &shellredir let s:shellsave = &shell - if (match(&shell,"\\(cmd\\|command\\).execute") >= 0) - " windows specific settings - let s:shellredir = '>%s' - let s:shell = &shell - let s:stderrredirnull = '2>nul' - else + if (has("unix")) " unix specific settings let s:shellredir = &shellredir let s:shell = 'sh' let s:stderrredirnull = '2>/dev/null' let s:GPGCommand = "LANG=C LC_ALL=C " . s:GPGCommand + else + " windows specific settings + let s:shellredir = '>%s' + let s:shell = &shell + let s:stderrredirnull = '2>nul' endif " find the supported algorithms @@ -390,6 +422,9 @@ function s:GPGEncrypt() if (exists("g:GPGPreferArmor") && g:GPGPreferArmor == 1) let b:GPGOptions += ["armor"] endif + if (exists("g:GPGPreferSign") && g:GPGPreferSign == 1) + let b:GPGOptions += ["sign"] + endif call s:GPGDebug(1, "no options set, so using default options: " . string(b:GPGOptions)) endif @@ -1012,4 +1047,5 @@ if (has("menu")) amenu Plugin.GnuPG.View\ Options :GPGViewOptions amenu Plugin.GnuPG.Edit\ Options :GPGEditOptions endif -" vim600: foldmethod=marker:foldlevel=0 + +" vim600: set foldmethod=marker foldlevel=0 :