Skip to content

Commit b28f194

Browse files
authored
Merge pull request #375 from macvim-dev/feature/askpass
Introduce Askpass dialog script for sudo and ssh
2 parents 96dc4e1 + a550884 commit b28f194

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

src/MacVim/MacVim.xcodeproj/project.pbxproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
6969
52B7ED9B1C4A4D6900AFFF15 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 52B7ED9A1C4A4D6900AFFF15 /* dsa_pub.pem */; };
7070
52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */ = {isa = PBXBuildFile; fileRef = 52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
71+
528DA66A1426D4F9003380F1 /* macvim-askpass in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 528DA6691426D4EB003380F1 /* macvim-askpass */; };
7172
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };
7273
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
7374
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
@@ -153,6 +154,17 @@
153154
name = "Copy QuickLookPlugin";
154155
runOnlyForDeploymentPostprocessing = 0;
155156
};
157+
528DA6671426D456003380F1 /* Copy Scripts */ = {
158+
isa = PBXCopyFilesBuildPhase;
159+
buildActionMask = 2147483647;
160+
dstPath = "";
161+
dstSubfolderSpec = 6;
162+
files = (
163+
528DA66A1426D4F9003380F1 /* macvim-askpass in Copy Scripts */,
164+
);
165+
name = "Copy Scripts";
166+
runOnlyForDeploymentPostprocessing = 0;
167+
};
156168
/* End PBXCopyFilesBuildPhase section */
157169

158170
/* Begin PBXFileReference section */
@@ -237,6 +249,7 @@
237249
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
238250
32CA4F630368D1EE00C91783 /* MacVim_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacVim_Prefix.pch; sourceTree = "<group>"; };
239251
52818AFA1C1C075300F59085 /* QuickLookStephen.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = QuickLookStephen.xcodeproj; path = qlstephen/QuickLookStephen.xcodeproj; sourceTree = "<group>"; };
252+
528DA6691426D4EB003380F1 /* macvim-askpass */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "macvim-askpass"; sourceTree = "<group>"; };
240253
52A364721C4A5789005757EC /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
241254
52B7ED9A1C4A4D6900AFFF15 /* dsa_pub.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dsa_pub.pem; sourceTree = "<group>"; };
242255
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
@@ -454,6 +467,14 @@
454467
name = Products;
455468
sourceTree = "<group>";
456469
};
470+
528DA6681426D477003380F1 /* Scripts */ = {
471+
isa = PBXGroup;
472+
children = (
473+
528DA6691426D4EB003380F1 /* macvim-askpass */,
474+
);
475+
name = Scripts;
476+
sourceTree = "<group>";
477+
};
457478
/* End PBXGroup section */
458479

459480
/* Begin PBXNativeTarget section */
@@ -469,6 +490,7 @@
469490
52818B021C1C088000F59085 /* Copy QuickLookPlugin */,
470491
1DE608B80C58807F0055263D /* Copy Vim Runtime Files */,
471492
1D1C31F00EFFBFD6003FE9A5 /* Make Document Icons */,
493+
528DA6671426D456003380F1 /* Copy Scripts */,
472494
);
473495
buildRules = (
474496
);

src/MacVim/gvimrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@ endif " exists("macvim_hig_shift_movement")
105105
" Restore the previous value of 'cpoptions'.
106106
let &cpo = s:cpo_save
107107
unlet s:cpo_save
108+
109+
" askpass
110+
let $SSH_ASKPASS = simplify($VIM . '/../../MacOS') . '/macvim-askpass'
111+
let $SUDO_ASKPASS = $SSH_ASKPASS

src/MacVim/macvim-askpass

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /bin/sh
2+
3+
#
4+
# An SSH_ASKPASS command for MacOS X
5+
#
6+
# Author: Joseph Mocker, Sun Microsystems
7+
#
8+
# http://blog.retep.org/2009/04/09/ssh-askpass-on-osx-10-5/
9+
10+
#
11+
# To use this script:
12+
# setenv SSH_ASKPASS "macos-askpass"
13+
# setenv DISPLAY ":0"
14+
#
15+
16+
TITLE=${MACOS_ASKPASS_TITLE:-"SSH"}
17+
18+
DIALOG="display dialog \"$@\" default answer \"\" with title \"$TITLE\""
19+
DIALOG="$DIALOG with icon caution with hidden answer"
20+
21+
result=`osascript -e 'tell application "Finder"' -e "activate" -e "$DIALOG" -e "text returned of result" -e 'end tell'`
22+
osascript -e 'tell application "MacVim"' -e "activate" -e 'end tell'
23+
24+
if [ "$result" = "" ]; then
25+
exit 1
26+
else
27+
echo "$result"
28+
exit 0
29+
fi

0 commit comments

Comments
 (0)