Skip to content

Commit fefb0ae

Browse files
author
Sergey Volkov
committed
Added password prompt
1 parent f0bfd16 commit fefb0ae

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

deploy.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
skip = false
66
user = example
7-
pass = password
87
host = example.com
98
port = 21
109
path = /path/to/installation
1110
passive = true
1211

1312
; If that seemed too long for you, you can specify servers like this:
14-
[ftp://example:password@example.com:21/path/to/installation]
13+
[ftp://example:password@example.com:21/path/to/installation]

git-deploy

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ class Config {
617617
'host' => '',
618618
'user' => '',
619619
'branch' => null,
620-
'pass' => '',
621620
'port' => 21,
622621
'path' => '/',
623622
'passive' => true,
@@ -626,6 +625,8 @@ class Config {
626625
'upload_untracked' => array()
627626
), $options);
628627

628+
$options['pass'] = self::promptPassword();
629+
629630
if ($options['skip']) {
630631
continue;
631632
} else {
@@ -639,6 +640,24 @@ class Config {
639640
return $return;
640641
}
641642

643+
public static function promptPassword() {
644+
$prompt = 'Enter ftp password: ';
645+
646+
$command = "/usr/bin/env bash -c 'echo OK'";
647+
if (rtrim(shell_exec($command)) !== 'OK') {
648+
trigger_error("Can't invoke bash");
649+
return;
650+
}
651+
652+
$command = "/usr/bin/env bash -c 'read -s -p \""
653+
. addslashes($prompt)
654+
. "\" mypassword && echo \$mypassword'";
655+
$password = rtrim(shell_exec($command));
656+
echo "\n";
657+
658+
return $password;
659+
}
660+
642661
}
643662

644663
#### PHP SEC LIB 0.3.5
@@ -32098,4 +32117,4 @@ class Net_SSH2 {
3209832117
}
3209932118
}
3210032119

32101-
main();
32120+
main();

0 commit comments

Comments
 (0)