001 #!/usr/bin/perl 023 opendir(ISPELL,"/usr/lib/ispell")|| die "No /usr/lib/ispell dir found\n"; 024 @files=readdir(ISPELL); 025 closedir(ISPELL); 026 $index=0; 027 while (($index <= $#files)&&(!$usefile)) 028 { 029 $file=$files[$index]; 030 if ($file =~ /\.hash$/) 031 { 032 $usefile=$file; 033 } 034 $index++; 035 } 039 open(STR1,"/usr/bin/strings /usr/lib/ispell/$usefile|")||die "Cant start strings"; 136 if (-l "/tmp/rident.pid") { 137 print "PANIC: It apears someone has tempored with the pid file /tmp/rident.pid\n"; 138 exit; 139 } 140 if (open(PID,"/tmp/rident.pid")) 141 { 143 $opid=; 144 chomp($opid); 145 close(PID); 146 unless ($opid =~ /^\d+$/) 147 { 149 exit; 150 } 152 open(PS,"/bin/ps -p $opid|"); 153 $killit=0; 154 while () 155 { 156 if (/ridentd.pl/) 157 { 158 $killit=1; 159 } 160 } 161 if ($killit) 162 { 164 kill(9,$opid); 165 sleep(1); 166 } 171 } 180 $pid=fork(); 185 if ($pid) 186 { 187 if (-e "/tmp/rident.pid") { 188 unlink("/tmp/rident.pid"); 192 } 193 open(PID,">/tmp/rident.pid"); 194 print PID "$pid\n"; 197 }