This file is indexed.

/usr/share/vim/cream/addons/cream-encrypt-gpg.vim is in cream 0.43-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
"
" cream-encrypt-gpg.vim
"
" Cream -- An easy-to-use configuration of the famous Vim text editor
" [ http://cream.sourceforge.net ] Copyright (C) 2001-2011 Steve Hall
" 
" License:
" 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.
" [ http://www.gnu.org/licenses/gpl.html ]
" 
" 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.
" 
" You should have received a copy of the GNU General Public License
" along with this program; if not, write to the Free Software
" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
" 02111-1307, USA.
"

" register as a Cream add-on
if exists("$CREAM")
	call Cream_addon_register(
	\ 'Encrypt, GPG', 
	\ 'Encrypt, GnuPG', 
	\ 'Encrypt a selection with GnuPG.', 
	\ 'Encrypt.GnuPG', 
	\ 'call Cream_encrypt_gpg()', 
	\ '<C-u>call Cream_encrypt_gpg("v")'
	\ )
endif

function! Cream_encrypt_gpg(...)
" Encrypt with GNU GPG
" o Arguments:
"   "silent" quiets operation
"   "v" implies a visual mode selection
"   (nothing) implies to do the entire file

	" verify gpg is on the system
	if !executable("gpg")
		call confirm(
			\ "GPG program not found, quitting.\n" .
			\ "\n", "&Ok", 1, "Info")
		return
	endif

	" find arguments
	if a:0 > 0
		let i = 0
		while i < a:0
			let i = i + 1
			execute "let myarg = a:" . i
			if     myarg == "v"
				let dofile = 0
			elseif myarg == "silent"
				let silent = 1
			endif
		endwhile
	endif

	" handle not-founds
	if !exists("dofile")
		let dofile = 1
	endif

	" get current cursor position
	let line = line('.')
	if line < 1
		let line = 1
	endif

	" select
	if dofile == 0
		" reselect previous selection
		normal gv
	else
		if !exists("silent")
			let n = confirm(
				\ "Encrypt/Unencrypt entire file?\n" .
				\ "\n", "&Ok\n&Cancel", 1, "Info")
			if n != 1
				" quit
				return
			endif
		endif
		" remember position
		let mypos_orig = Cream_pos()
		" select all
		call Cream_select_all(1)
	endif

	" OPTION 1: using temp files {{{1
	" cut selection into register
	normal "xx
	" write register to tmpfile
	let tmpfile = Cream_path_fullsystem(tempname())

	" decrypt
	if @x =~ '^\s*-\+BEGIN PGP '

		" write register to file
		call Cream_str_tofile(@x, tmpfile.".gpg")

		if Cream_has("ms")
			let q = '"'
		else
			let q = ''
		endif

		" TAKE 1
		" command
		" TODO: on GNU/Linux, this fails due to TTY problems
		let cmd = "!gpg --output " . q.tmpfile.q . " --decrypt " . q.tmpfile.".gpg".q
		let @+ = cmd
		silent execute cmd
		" read in encrypted file (at point of cut)
		silent execute "silent! " . line-1 . "read " . tmpfile
		let bufnr = bufnr("$")
		" close buffer
		silent execute "silent! bwipeout! " . bufnr

		"""" TAKE 2
		"""redir @y
		"""execute "!gpg --decrypt " . q.tmpfile.".gpg".q
		"""redir END
		"""put y

		"""" TAKE 3
		"""" command
		"""" TODO: on GNU/Linux, this fails due to TTY problems
		"""let cmd = "!gpg --decrypt " . q.tmpfile.".gpg".q
		"""execute cmd
		"""" read in encrypted file (at point of cut)
		"""silent execute "silent! " . line-1 . "read " . tmpfile

		"" clean up temp files
		"call delete(tmpfile)
		"call delete(tmpfile . ".gpg")

	" encrypt
	else
		" write register to file
		call Cream_str_tofile(@x, tmpfile)

		" command
		"silent execute 'silent! !gpg --armor --output "' . tmpfile . '.gpg" --encrypt "' . tmpfile . '"'
		if Cream_has("ms")
			let q = '"'
		else
			let q = ''
		endif
		" TODO: on GNU/Linux, this fails due to TTY problems and
		"       requesting recipient if "--default-recipient-self"
		"       option isn't used.
		silent execute "silent! !gpg -q --armor --default-recipient-self --output " . q.tmpfile.".gpg".q . " --encrypt " . q.tmpfile.q

		" read in encrypted file (at point of cut)
		silent execute "silent! " . line-1 . "read " . escape(tmpfile, ' \') . ".gpg"
		let bufnr = bufnr("$")
		" close buffer
		silent execute "silent! bwipeout! " . bufnr

		" clean up temp files
		call delete(tmpfile)
		call delete(tmpfile . ".gpg")

	endif

	" OPTION 2: no temp files, only streams {{{1
	"""" copy selection into register
	"""normal "xy
	"""" re-select for paste over
	"""normal gv
	"""
	"""" decrypt
	"""if @x =~ '^\s*-\+BEGIN PGP '
	"""
	"""    " command
	"""    execute '!echo ' . @x . '> !gpg --output "' . tmpfile . '" --decrypt "' . tmpfile . '.gpg"'
	"""
	"""" encrypt
	"""else
	"""
	"""    " command
	"""    call system('echo "' . @x . '" | gpg --armor --encrypt')
	"""
	"""endif

	" 1}}}

endfunction
" vim:foldmethod=marker