Index: trunk/extensions/OpenStackManager/special/SpecialNovaKey.php |
— | — | @@ -182,11 +182,27 @@ |
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
| 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 | + /** |
186 | 202 | * Converts a public ssh key to openssh format, using puttygen. |
187 | 203 | * @param $keydata SSH public/private key in some format |
188 | 204 | * @return mixed Public key in openssh format or false |
189 | 205 | */ |
190 | | - static function opensshFormatKey($keydata) { |
| 206 | + static function opensshFormatKeyPuttygen($keydata) { |
191 | 207 | global $wgPuttygen; |
192 | 208 | if ( wfIsWindows() || !$wgPuttygen ) |
193 | 209 | return false; |
— | — | @@ -233,11 +249,14 @@ |
234 | 250 | return $data; |
235 | 251 | } |
236 | 252 | |
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 ) |
242 | 261 | return false; |
243 | 262 | |
244 | 263 | $descriptorspec = array( |
— | — | @@ -246,14 +265,14 @@ |
247 | 266 | 2 => array("file", wfGetNull(), "a") |
248 | 267 | ); |
249 | 268 | |
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 ); |
251 | 270 | if ( $process === false ) |
252 | 271 | return false; |
253 | 272 | |
254 | 273 | fwrite( $pipes[0], $keydata ); |
255 | 274 | fclose( $pipes[0] ); |
256 | 275 | $data = stream_get_contents( $pipes[1] ); |
257 | | - var_dump($data); |
| 276 | + |
258 | 277 | fclose( $pipes[1] ); |
259 | 278 | proc_close( $process ); |
260 | 279 | |
— | — | @@ -262,8 +281,8 @@ |
263 | 282 | |
264 | 283 | return $data; |
265 | 284 | } |
266 | | - */ |
267 | 285 | |
| 286 | + |
268 | 287 | /** |
269 | 288 | * @param $formData |
270 | 289 | * @param string $entryPoint |
Index: trunk/extensions/OpenStackManager/OpenStackManager.php |
— | — | @@ -83,6 +83,11 @@ |
84 | 84 | $wgOpenStackManagerNovaDefaultProject = ""; |
85 | 85 | |
86 | 86 | /** |
| 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 | +/** |
87 | 92 | * Path to the puttygen utility. Used for converting ssh key formats. False to disable its use. |
88 | 93 | */ |
89 | 94 | $wgPuttygen = 'puttygen'; |