diff --git a/server/plugins-available/shelluser_base_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php index d3376f10ca37477a31a0375ecba3784ce86739ed..74c6fa364f77611c77096ef7b53570690e1c00c1 100755 --- a/server/plugins-available/shelluser_base_plugin.inc.php +++ b/server/plugins-available/shelluser_base_plugin.inc.php @@ -461,7 +461,7 @@ class shelluser_base_plugin { if(is_file('/root/.ssh/authorized_keys')) $app->system->file_put_contents($sshkeys, $app->system->file_get_contents('/root/.ssh/authorized_keys')); // Remove duplicate keys - $existing_keys = @file($sshkeys); + $existing_keys = @file($sshkeys, FILE_IGNORE_NEW_LINES); $new_keys = explode("\n", $userkey); $final_keys_arr = @array_merge($existing_keys, $new_keys); $new_final_keys_arr = array(); @@ -479,7 +479,7 @@ class shelluser_base_plugin { } //* Get the keys - $existing_keys = file($sshkeys); + $existing_keys = file($sshkeys, FILE_IGNORE_NEW_LINES); $new_keys = explode("\n", $sshrsa); $old_keys = explode("\n", $this->data['old']['ssh_rsa']); @@ -487,7 +487,9 @@ class shelluser_base_plugin { if(is_array($old_keys)) { foreach($old_keys as $key => $val) { $k = array_search(trim($val), $existing_keys); - unset($existing_keys[$k]); + if ($k !== false) { + unset($existing_keys[$k]); + } } } diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php index 291c771e6c4568eb23ffc93346fa0d9ed1204423..69a041c037e4c2f96907ae2bd58b3ff8c09ee287 100755 --- a/server/plugins-available/shelluser_jailkit_plugin.inc.php +++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php @@ -480,7 +480,7 @@ class shelluser_jailkit_plugin { if(is_file('/root/.ssh/authorized_keys')) $app->system->file_put_contents($sshkeys, $app->system->file_get_contents('/root/.ssh/authorized_keys')); // Remove duplicate keys - $existing_keys = @file($sshkeys); + $existing_keys = @file($sshkeys, FILE_IGNORE_NEW_LINES); $new_keys = explode("\n", $userkey); $final_keys_arr = @array_merge($existing_keys, $new_keys); $new_final_keys_arr = array(); @@ -497,7 +497,7 @@ class shelluser_jailkit_plugin { $this->app->log("ssh-rsa authorisation keyfile created in ".$sshkeys, LOGLEVEL_DEBUG); } //* Get the keys - $existing_keys = file($sshkeys); + $existing_keys = file($sshkeys, FILE_IGNORE_NEW_LINES); $new_keys = explode("\n", $sshrsa); $old_keys = explode("\n", $this->data['old']['ssh_rsa']); @@ -505,7 +505,9 @@ class shelluser_jailkit_plugin { if(is_array($old_keys)) { foreach($old_keys as $key => $val) { $k = array_search(trim($val), $existing_keys); - unset($existing_keys[$k]); + if ($k !== false) { + unset($existing_keys[$k]); + } } }