From 746b5ee2e2eb941d39bba1f8f78498e8fcb518cb Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sun, 17 Jul 2005 19:43:11 +0000 Subject: [PATCH] If any of the /etc/ssh/ files are corrupted then remove them so they will be forced to regenerate. --- etc/sshd | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/etc/sshd b/etc/sshd index b2ecf6eb21..af3e9e4dd4 100755 --- a/etc/sshd +++ b/etc/sshd @@ -32,6 +32,23 @@ $stderr = fopen("php://stderr", "w"); + function file_size($file) { + $size = filesize($file); + if ( $size == 0) + $size = exec("ls -l $file | awk '{print $5}'"); + return $size; + } + + /* if any of these files are 0 bytes then they are corrupted. + * remove them + */ + $files_to_check = array('ssh_host_dsa_key','ssh_host_dsa_key.pub','ssh_host_key','ssh_host_key.pub','ssh_host_rsa_key','ssh_host_rsa_key.pub'); + foreach($files_to_check as $f2c) { + if(file_size($f2c)==0) { + mwexec("rm /etc/ssh_host*"); + } + } + if($argv[1] == "stop" || $argv[0] == "stop") { if(file_exists("/root/.authorized_keys")) { $ak = return_filename_as_string("/root/.authorized_keys");