Ejemplo n.º 1
0
 function doSignImport($command, $options, $params)
 {
     if (count($params) !== 1) {
         return $this->raiseError("bad parameter(s), try \"help {$command}\"");
     }
     require_once 'PEAR/Gnupg.php';
     $gnupg = new PEAR_Gnupg($this->config);
     $cmd = $gnupg->createGpgCmd();
     if (PEAR::isError($cmd)) {
         return $cmd;
     }
     $key = @file_get_contents($params[0]);
     if ($key === false) {
         return $this->raiseError("could not load keys from {$key}");
     }
     $cmd .= " --import";
     $gpg = popen($cmd, "w");
     if (!$gpg) {
         return $this->raiseError("gpg command failed");
     }
     fwrite($gpg, "{$key}\n");
     if (pclose($gpg)) {
         return $this->raiseError("gpg import failed");
     }
     $this->ui->outputData("Key(s) imported.", $command);
     return true;
 }