r113409 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113408‎ | r113409 | r113410 >
Date:21:48, 8 March 2012
Author:platonides
Status:ok
Tags:
Comment:
Follow-up r113405. Add support for changing ssh key formats
using ssh-keygen, too.
Fixes bug 33324: Automatically convert uploaded keys from
RFC 4251 to openssh format.
Modified paths:
  • /trunk/extensions/OpenStackManager/OpenStackManager.php (modified) (history)
  • /trunk/extensions/OpenStackManager/special/SpecialNovaKey.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenStackManager/special/SpecialNovaKey.php
@@ -182,11 +182,27 @@
183183 }
184184
185185 /**
 186+ * Converts a public ssh key to openssh format.
 187+ * @param $keydata SSH public/private key in some format
 188+ * @return mixed Public key in openssh format or false
 189+ */
 190+ static function opensshFormatKey($keydata) {
 191+ global $wgSshKeygen, $wgPuttygen;
 192+
 193+ $public = self::opensshFormatKeySshKeygen( $keydata );
 194+
 195+ if ( !$public )
 196+ $public = self::opensshFormatKeyPuttygen( $keydata );
 197+
 198+ return $public;
 199+ }
 200+
 201+ /**
186202 * Converts a public ssh key to openssh format, using puttygen.
187203 * @param $keydata SSH public/private key in some format
188204 * @return mixed Public key in openssh format or false
189205 */
190 - static function opensshFormatKey($keydata) {
 206+ static function opensshFormatKeyPuttygen($keydata) {
191207 global $wgPuttygen;
192208 if ( wfIsWindows() || !$wgPuttygen )
193209 return false;
@@ -233,11 +249,14 @@
234250 return $data;
235251 }
236252
237 - /*
238 - // This alternative function uses only pipes, but doesn't work due to puttygen opening the input file several times.
239 - static function opensshFormatKey($keydata) {
240 - global $wgPuttygen;
241 - if ( wfIsWindows() || !$wgPuttygen )
 253+ /**
 254+ * Converts a public ssh key to openssh format, using ssh-keygen.
 255+ * @param $keydata SSH public/private key in some format
 256+ * @return mixed Public key in openssh format or false
 257+ */
 258+ static function opensshFormatKeySshKeygen($keydata) {
 259+ global $wgSshKeygen;
 260+ if ( wfIsWindows() || !$wgSshKeygen )
242261 return false;
243262
244263 $descriptorspec = array(
@@ -246,14 +265,14 @@
247266 2 => array("file", wfGetNull(), "a")
248267 );
249268
250 - $process = proc_open( escapeshellcmd( $wgPuttygen ) . ' -O public-openssh -o /dev/stdout /dev/stdin', $descriptorspec, $pipes );
 269+ $process = proc_open( escapeshellcmd( $wgSshKeygen ) . ' -i -f /dev/stdin', $descriptorspec, $pipes );
251270 if ( $process === false )
252271 return false;
253272
254273 fwrite( $pipes[0], $keydata );
255274 fclose( $pipes[0] );
256275 $data = stream_get_contents( $pipes[1] );
257 - var_dump($data);
 276+
258277 fclose( $pipes[1] );
259278 proc_close( $process );
260279
@@ -262,8 +281,8 @@
263282
264283 return $data;
265284 }
266 - */
267285
 286+
268287 /**
269288 * @param $formData
270289 * @param string $entryPoint
Index: trunk/extensions/OpenStackManager/OpenStackManager.php
@@ -83,6 +83,11 @@
8484 $wgOpenStackManagerNovaDefaultProject = "";
8585
8686 /**
 87+ * Path to the ssh-keygen utility. Used for converting ssh key formats. False to disable its use.
 88+ */
 89+$wgSshKeygen = 'ssh-keygen';
 90+
 91+/**
8792 * Path to the puttygen utility. Used for converting ssh key formats. False to disable its use.
8893 */
8994 $wgPuttygen = 'puttygen';

Follow-up revisions

RevisionCommit summaryAuthorDate
r113410Also support with ssh-keygen the not-to-be-used feature of...platonides22:00, 8 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113405I'm fed up of new labs users having problems on initial login...platonides21:22, 8 March 2012

Status & tagging log