Skip to content

Instantly share code, notes, and snippets.

@atton
Last active October 6, 2019 08:27
Show Gist options
  • Save atton/db007474075b47f6917933cc2aee924a to your computer and use it in GitHub Desktop.
Save atton/db007474075b47f6917933cc2aee924a to your computer and use it in GitHub Desktop.
[root@9015bf44beee /]# dnf search askpass
Fedora Modular 30 - x86_64 1.5 MB/s | 1.9 MB 00:01
Fedora Modular 30 - x86_64 - Updates 2.0 MB/s | 2.8 MB 00:01
Fedora 30 - x86_64 - Updates 5.0 MB/s | 23 MB 00:04
Fedora 30 - x86_64 5.2 MB/s | 61 MB 00:11
Last metadata expiration check: 0:00:01 ago on Sat Aug 31 00:41:37 2019.
=============================== Name & Summary Matched: askpass ================================
lxqt-openssh-askpass-l10n.x86_64 : Translations for lxqt-openssh-askpass
lxqt-openssh-askpass.x86_64 : Askpass openssh transition dialog for LXQt desktop suite
==================================== Name Matched: askpass =====================================
R-askpass.x86_64 : Safe Password Entry for R, Git, and SSH
ksshaskpass.x86_64 : A ssh-add helper that uses kwallet and kpassworddialog
openssh-askpass.x86_64 : A passphrase dialog for OpenSSH and X
x11-ssh-askpass.x86_64 : A passphrase dialog for X and not only for OpenSSH
# dnf install -y ksshaskpass
# find . -name '*askpass*' -type f
./etc/xdg/plasma-workspace/env/ksshaskpass.sh
./usr/share/locale/en_GB/LC_MESSAGES/ksshaskpass.mo
./usr/bin/ksshaskpass
/usr/bin/ksshaskpass
# /usr/bin/ksshaskpass --help
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
Aborted
# dnf remove -y ksshaskpass
# dnf install -y openssh-askpass
# find . -name '*askpass*' -type f
./etc/profile.d/gnome-ssh-askpass.csh
./etc/profile.d/gnome-ssh-askpass.sh
./usr/libexec/openssh/gnome-ssh-askpass
# /usr/libexec/openssh/gnome-ssh-askpass
(gnome-ssh-askpass:112): Gtk-WARNING **: 00:51:47.072: cannot open display:
# /usr/libexec/openssh/gnome-ssh-askpass --help
(gnome-ssh-askpass:113): Gtk-WARNING **: 00:52:10.596: cannot open display:
# dnf remove -y openssh-askpass
# dnf install -y x11-ssh-askpass
# find . -name '*askpass*' -type f
./etc/profile.d/x11-ssh-askpass.sh
./etc/profile.d/x11-ssh-askpass.csh
./usr/libexec/openssh/x11-ssh-askpass
# /usr/libexec/openssh/x11-ssh-askpass
Error: Can't open display:
# /usr/libexec/openssh/x11-ssh-askpass --help
Error: Can't open display:
# dnf remove -y x11-ssh-askpass
function! s:sudo_write_current_buffer() abort
if has('nvim')
let s:askpass_path = '/tmp/askpass'
let s:password = inputsecret("Enter Password: ")
let $SUDO_ASKPASS = s:askpass_path
try
call delete(s:askpass_path)
call writefile(['#!/bin/sh'], s:askpass_path, 'a')
call writefile(["echo '" . s:password . "'"], s:askpass_path, 'a')
call setfperm(s:askpass_path, "rwx------")
write ! sudo -A tee % > /dev/null
finally
unlet s:password
call delete(s:askpass_path)
endtry
else
write ! sudo tee % > /dev/null
endif
endfunction
command! SudoWriteCurrentBuffer call s:sudo_write_current_buffer()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment