Fixed error in the cron job if a key has a bad format.
This commit is contained in:
parent
336faa4503
commit
e31f10e648
@ -84,7 +84,7 @@ class IDF_Key extends Pluf_Model
|
|||||||
return array('ssh', $m[2], $m[1]);
|
return array('ssh', $m[2], $m[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception('invalid or unknown key data detected');
|
throw new Exception(__('Invalid or unknown key data detected.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,13 @@ class IDF_Plugin_SyncGit_Cron
|
|||||||
$out = '';
|
$out = '';
|
||||||
$keys = Pluf::factory('IDF_Key')->getList(array('view'=>'join_user'));
|
$keys = Pluf::factory('IDF_Key')->getList(array('view'=>'join_user'));
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if ($key->getType() == 'ssh' and preg_match('/^[a-zA-Z][a-zA-Z0-9_.-]*(@[a-zA-Z][a-zA-Z0-9.-]*)?$/', $key->login)) {
|
try {
|
||||||
|
$key_type = $key->getType();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// The key is a bad key, skip it
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($key_type == 'ssh' and preg_match('/^[a-zA-Z][a-zA-Z0-9_.-]*(@[a-zA-Z][a-zA-Z0-9.-]*)?$/', $key->login)) {
|
||||||
$content = trim(str_replace(array("\n", "\r"), '', $key->content));
|
$content = trim(str_replace(array("\n", "\r"), '', $key->content));
|
||||||
$out .= sprintf($template, $cmd, $key->login, $content)."\n";
|
$out .= sprintf($template, $cmd, $key->login, $content)."\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user