projects
/
gnucomo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5f5e3f2
)
Cleanup abuse records only for subnets smaller than /16.
author
arjen
<arjen>
Thu, 24 Mar 2011 09:49:20 +0000
(09:49 +0000)
committer
arjen
<arjen>
Thu, 24 Mar 2011 09:49:20 +0000
(09:49 +0000)
src/gcm_daemon/gcm_maintenance.php
patch
|
blob
|
history
diff --git
a/src/gcm_daemon/gcm_maintenance.php
b/src/gcm_daemon/gcm_maintenance.php
index
0bbb56a
..
a36c4af
100755
(executable)
--- a/
src/gcm_daemon/gcm_maintenance.php
+++ b/
src/gcm_daemon/gcm_maintenance.php
@@
-13,7
+13,10
@@
Andromeda Technology & Automation
$Log: gcm_maintenance.php,v $
Andromeda Technology & Automation
$Log: gcm_maintenance.php,v $
- Revision 1.1 2007-12-12 09:06:21 arjen
+ Revision 1.2 2011-03-24 09:49:20 arjen
+ Cleanup abuse records only for subnets smaller than /16.
+
+ Revision 1.1 2007/12/12 09:06:21 arjen
Added a new script gcm_maintenance.php to cleanup the database
and check referential integrity. Purging old log entries is
removed from the gcm_daemon script.
Added a new script gcm_maintenance.php to cleanup the database
and check referential integrity. Purging old log entries is
removed from the gcm_daemon script.
@@
-21,7
+24,7
@@
*/
*/
-// $Id: gcm_maintenance.php,v 1.
1 2007-12-12 09:06:21
arjen Exp $
+// $Id: gcm_maintenance.php,v 1.
2 2011-03-24 09:49:20
arjen Exp $
ini_set('include_path', '.:./classes:../phpclasses');
ini_set('html_errors', 'false');
ini_set('include_path', '.:./classes:../phpclasses');
ini_set('html_errors', 'false');
@@
-105,34
+108,34
@@
if ($dbms->have_db_connection() == "FALSE")
$abuse_result = $dbms->query("select source, nr_abuses, masklen(source) from object_abuse
$abuse_result = $dbms->query("select source, nr_abuses, masklen(source) from object_abuse
- where
status='dropped' and masklen(source)=32 and objectid=
1 order by source");
+ where
(status='dropped' or status='') and masklen(source)>16 and objectid=1
1 order by source");
for ($ab = 0; $ab < $dbms->num_rows($abuse_result); $ab++)
{
$logentries = 0;
$abuse = $dbms->fetch_object($abuse_result, $ab);
$nr_abuses = $abuse->nr_abuses;
for ($ab = 0; $ab < $dbms->num_rows($abuse_result); $ab++)
{
$logentries = 0;
$abuse = $dbms->fetch_object($abuse_result, $ab);
$nr_abuses = $abuse->nr_abuses;
- $log_res = $dbms->query("select logid from log_abuse where source='" . $abuse->source . "' and objectid=1");
+ $log_res = $dbms->query("select logid from log_abuse where source='" . $abuse->source . "' and objectid=1
1
");
if ($dbms->num_rows($log_res) != $nr_abuses)
{
echo "Mismatch in nr of abuses. Corrected.\n";
$dbms->query("update object_abuse set nr_abuses=" . $dbms->num_rows($log_res) .
if ($dbms->num_rows($log_res) != $nr_abuses)
{
echo "Mismatch in nr of abuses. Corrected.\n";
$dbms->query("update object_abuse set nr_abuses=" . $dbms->num_rows($log_res) .
- " where source='" . $abuse->source . "' and objectid=1");
+ " where source='" . $abuse->source . "' and objectid=1
1
");
}
if ($dbms->num_rows($log_res) == 0)
{
echo " Removing ", $abuse->source, "\n";
}
if ($dbms->num_rows($log_res) == 0)
{
echo " Removing ", $abuse->source, "\n";
- $dbms->query("delete from object_abuse where source='". $abuse->source . "' and objectid=1");
+ $dbms->query("delete from object_abuse where source='". $abuse->source . "' and objectid=1
1
");
}
else
{
$logref_res = $dbms->query("select logid from log where logid in
}
else
{
$logref_res = $dbms->query("select logid from log where logid in
- (select logid from log_abuse where source='" . $abuse->source . "' and objectid=1)");
+ (select logid from log_abuse where source='" . $abuse->source . "' and objectid=1
1
)");
$logentries = $dbms->num_rows($logref_res);
if ($logentries == 0)
{
echo "All references to log entries are lost. Purging log_abuse table.\n";
$logentries = $dbms->num_rows($logref_res);
if ($logentries == 0)
{
echo "All references to log entries are lost. Purging log_abuse table.\n";
- $dbms->query("delete from log_abuse where source='" . $abuse->source . "' and objectid=1");
+ $dbms->query("delete from log_abuse where source='" . $abuse->source . "' and objectid=1
1
");
}
}
}
}
@@
-195,7
+198,7
@@
function purge_old_logs($purge_date)
// Clean up abuses that are left without reference to the log.
// Clean up abuses that are left without reference to the log.
- $r = $dbms->query("select source from log_abuse where logid in
+ $r = $dbms->query("select source from log_abuse where
masklen(source) > 16 and
logid in
(select logid from gcm_deamon_old_log) group by source");
echo "Abusing IP addresses that may be affected:\n";
$abusers = array();
(select logid from gcm_deamon_old_log) group by source");
echo "Abusing IP addresses that may be affected:\n";
$abusers = array();
@@
-215,7
+218,7
@@
function purge_old_logs($purge_date)
if ($c->count == 0)
{
echo "Cleaning up abusing address $src.\n";
if ($c->count == 0)
{
echo "Cleaning up abusing address $src.\n";
- $dbms->query("delete from object_abuse where source='$src'");
+ $dbms->query("delete from object_abuse where source='$src'
and (status='' or status='dropped')
");
}
}
}
}