Critical. System realm can somethimes be erased.

2 views
Skip to first unread message

Martin Foster

unread,
May 3, 2006, 6:14:38 PM5/3/06
to Ethereal Realms Code
This would apply to all PostgreSQL database run variants of Ethereal
Realms. Version using MySQL are not affected because that database does
not care about referential integrity.

It seems that the impossible can happen from time to time. Normally
the system realm cannot be entered by normal means, used and as such is
never removed during nightly cleanups because it simply cannot and will
not show up in the Posts table.

However, apparently this is not necessarily 100% accurate and requires
some more checks to make sure otherwise. A quick fix is available for
this by replacing the following entry in the
[/mgmt/commandline/erealms.pl] file used to run nightly maintenance.

# Clear out
$database->Write("DELETE FROM Realm
WHERE Realm.RealmName IN (SELECT Realm.RealmName
FROM Realm
WHERE Realm.RealmPublic='no'
AND Realm.RealmTimestamp <
getInterval('$system{SetTimeoutRealm} days')
AND NOT EXISTS (SELECT DISTINCT Post.RealmName
FROM Post
WHERE Post.RealmName=Realm.RealmName)
AND NOT EXISTS (SELECT DISTINCT Offline.RealmName
FROM Offline
WHERE Offline.RealmName=Realm.RealmName))");


-- REPLACE WITH --

# Clear out
$database->Write("DELETE FROM Realm
WHERE Realm.RealmName IN (SELECT Realm.RealmName
FROM Realm
WHERE Realm.RealmPublic='no'
AND Realm.RealmName <> 'system'
AND Realm.RealmTimestamp <
getInterval('$system{SetTimeoutRealm} days')
AND NOT EXISTS (SELECT DISTINCT Post.RealmName
FROM Post
WHERE Post.RealmName=Realm.RealmName)
AND NOT EXISTS (SELECT DISTINCT Offline.RealmName
FROM Offline
WHERE Offline.RealmName=Realm.RealmName))");

The above will explicitly add a rule stating that system is never to be
touched. From that point forward the removal of that table should be a
manual affair only, since it will never appear in the administrative
panel unless the code has been played with.

Martin Foster
Creator/Designer Ethereal Realms
mar...@ethereal-realms.org

Reply all
Reply to author
Forward
0 new messages