-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Neovim compatibility (for terminal pinentry prompts) #32
Comments
FWIW, I'm a long time vim-gnupg user and have been using it with neovim since day 1. I never had problems because I use gpg-agent which by defaults displays a x11 prompt to get the password(The GPG_TTY warning can be safely ignored). With that said, it should be easy to make vim-gnupg compatible with neovim: You simply need to call let s:Shell = {}
function s:Shell.on_stdout(jobid, data)
let self.output .= a:data[0]
for str in a:data[1:]
let self.output .= "\n".str
endfor
endfunction
let s:Shell.on_stderr = s:Shell.on_stdout
function! PTYSystem(cmd, ...)
let s = extend({'output': '', 'pty': 1}, s:Shell)
let job = jobstart(a:cmd, s)
if a:0
" send data plus newline plus ctrl+d to the terminal
call jobsend(job, a:1."\n\x04")
endif
let [g:shell_error] = jobwait([job])
return s.output
endfunction This would require prompting the passwords with the |
Thanks for the tips, @tarruda. I'll take another look at this after I finish packaging neovim for Debian. |
Hello! I was wondering if there is any progress with this issue? I am using neovim via tmux so the x11 prompt often does not work in this case and neovim hangs an entire window when asking for passpharse. Thanks for the great plugin anyway! |
Ok, I finally got Neovim packaged in Debian and will start taking a look at this. Just as an FYI, neovim isn't actually hung. When encrypting a new file, you can type into the gpg prompt but you aren't going to see what's being typed. Other than that, it works fine. I've successfully created new encrypted files and opened existing files just fine. Yes, it's not optimal but it is functional. |
Any update on this? Yes, of course, I can help test this on Fedora/CentOS/Ubuntu ☺ |
I've been playing around with the job control and pseudo terminal for a while now but I still didn't get it to work. I just wanted to point out that using pinentry-curses in a non-login shell, I need to keep an eye on the wildcards and count them: apart from the fact that the letters aren't always input into dialogue, some characters are also put into the decrypted file 😧. (I don't call that functional.) Maybe the keys are passed through and the input is result of normal mode "i" command? (not sure) This is likely insecure, and may not work, but I wanted to share the idea all the same: using pexpect in a remote plugin one could wait for the the spawned process (started with |
As a complement/clarification to tarruda's comment, I would like to add that one can make vim-gnupg to work with NeoViM if one does not set gpg-agent to use Kind of a workaround of course but worth to be mentioned in my opinion. |
Thanks but rather not, running a terminal using a compositor for Wayland, I would prefer to stick to a curses interface. If I can use it from other curses programs and for other uses, like signing commits and email, it feels like it should be possible to have a curses pinentry work from neovim. The issue, I think, for me with neovim is that |
I'm using NeoVim on my mac |
Thanks to all the suggestions so far. I've already pushed some commits to fix issues related to the
Agreed. I don't know if I was just lucky before or didn't notice it, but it is essentially non-functional. The input randomly makes it to either nvim or the pinentry process.
I really don't like the idea of doing the password prompting in the plugin and passing it through. I removed a bunch of code that was just shuttling data between Vim and gpg when I took over maintenance of the plugin. I don't see a reason to reimplement what gpg already does just fine, and has the ability to do more securely. That being said, I know that something needs to be done here and I'll be trying to focus my available FOSS time on this. |
@jamessan I, for one, really appreciate all your hard work. Thank you very much. |
One issue I encountered on Fedora 25 (GNOME with X, not Wayland) is that by default gnupg would not try to use the graphical password prompt, which seems to be the recommended workaround for this bug at the moment. I think this is due to this part of the script.
On my system, vim-gnupg tries to use gpg version 1.4 by default and the GPG_AGENT_INFO variable was unset so it falls into the "--no-use-agent" branch of the code. A workaround that worked for me was to edit my .config/nvim/init.vim to tell vim-gnupg that it should use gpg 2.1 instead:
I hope this information might be helpful. |
I'm kinda a GPG newbie, and can't quite suss out a tl;dr from this Issue — is there a current path to editing GPG-encrypted messages in Neovim (well, VimR, for me) instead of Vim 8, on macOS? (It sounds like some of you got it to work, but perhaps only on Linuxes?) |
@ELLIOTTCABLE If you have access to an X11 display, you can use the GPG graphical prompt. If not, you have to use |
kierun's advice is correct. The longer term solution is to use |
Any update on this? Using |
I don't see how |
Is there any workaround for a headless server, where using an X11 pinentry program is not possible? |
@goerz Look into |
I've been following this thread and I don't believe that this is an issue
that vim-gnupg needs to address as it's native to the gpg-agent, and should
be handled by the used. However; here is a possible solution,
https://askubuntu.com/questions/858347/disable-gnome-from-asking-passphrase-in-gui-when-using-ssh-and-gpg-from-terminal
Specifically:
~/.local/bin/my-smart-pinentry:
#!/bin/sh
set -eu
# Configuration -- adjust these to your liking
PINENTRY_TERMINAL='/usr/bin/pinentry-curses'
PINENTRY_X11='/usr/bin/pinentry-x11'
# Action happens below!
if [ -n "${DISPLAY-}" -a -z "${TERM-}" ]; then
exec "$PINENTRY_X11" "$@"
else
exec "$PINENTRY_TERMINAL" "$@"
fi
…On Tue, Mar 26, 2019, 06:35 Bart De Roy ***@***.***> wrote:
@kierun <https://github.com/kierun> @goerz <https://github.com/goerz>
note that pinentry-curses from vim in a non-login shell still seems
problematic (see my comment above). I'm not sure how this works through ssh
in a login shell.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#32 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAfRzM4Ovp1gWPF6C5W1mpxtrDNXDQcmks5vaiIngaJpZM4EEMFy>
.
|
It's not necessary for vim-gnupg to address it, but the biggest problem with Neovim support is that both pinentry and neovim are trying to use the same tty at the same time. The current workaround is to use an X11 pinentry, which doesn't work when you're SSHing (unless you do X forwarding). |
It's enough to do a gpg-agent forwarding, you don't have to have X on the remote system: |
I’ve tried the plugin with Neovim running inside Kitty and Termux. In Kitty, about every 2nd and 3rd keypress is registered by the passphrase prompt, while in Termux, the prompt doesn’t appear at all; instead, I receive a “Message could not be decrypted!” error in Neovim’s status bar. Since using an X11-based prompt on Termux is a no-go (at least locally), I went down a different road and tried running
|
macOS 11.5.2
In my ~/.profile: export "GPG_TTY=$(tty)" I'm experiencing the same issue described above by several users: Some of my keystrokes on passphrase input are randomly not received. If I'm extremely patient and press some keys over and over until it's received I can eventually get through my whole passphrase. If I successfully open the text file, the passphrase keystrokes that weren't received by the pin entry are inserted into my text file. If I kill the pin entry capture, the missing keystrokes appear in my terminal prompt. This seems like particularly poor security given that many of the characters of my passphrase I'm typing are being piped to god-knows-where. Setting Reading through the above comments I didn't find a workaround for my situation. I don't have X since I'm on macOS. Is the only solution to just not use the neovim terminal pin entry to unlock the gpg agent, as suggested by @maxigaz? |
@xanderdunn at least I got everything working locally with |
@kblcuk Setting |
@kblcuk and @xanderdunn, when using |
@molleweide if I recall correctly, it prompted for the password first time, and there was an option to save password to MacOS keychain, which I did. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@wakatara Please open a new issue, since this one is specific to the use of terminal pinentry prompts. |
A working solution: (perhaps vim-gnupg can script this, possibly as an exception handler) $nvim /tmp/README.asc |
See this for more details: jamessan/vim-gnupg#32
Is this still an issue? I'm running NVIM 0.10.2 and it works fine with pinentry-curses: I get successfully prompted for my passphrase in full screen/tty. I have not tried vim-gnupg on nvim for a while so I can't say how recently this started working. Here's the process stack to show how it's executed and wrapped in the shell:
|
on NVIM 0.10.1 its still not working for me, neither pinentry-curses nor pinentry-tty. I'm on desktop with a GUI so will continue using the pinentry-gnome3 which works fine. Wondering what part of your setup makes the curses method work. |
Thanks @ckjoris for trying it out. I might have spoken too fast. Even with NVIM 0.10.2, the tty pinentry is still losing some characters which tells me both NVIM and pinentry are still reading from the same tty. Typing really slow seems to allow pinentry to win most of the time but that might just be my luck. It was too good to be true. |
Perhaps gpg-agent can be "seeded" by running a dummy decrypt inside For a POSIX
dummy.gpg should be encrypted for the same recipient(s) as the file vim-gnupg is ultimately trying to decrypt. |
neovim spawns shell commands connected to pipes, which prevents vim-gnupg from receiving input when asking for passphrase.
To make vim-gnupg work with neovim it would be great to see an updated version using
termopen
.The text was updated successfully, but these errors were encountered: