I am in the process of trying to write a crude web interface so that people who are 
not Linux-savvy can administer their own lists on their filtering boxes (limited add 
and delete functions).

Rather than messing with .diff files, I am working with the db files directly.  
Reading from them, per the instructions at the SG, Sleepycat, and other websites, 
works just great.

I am, however, finding that I am unable to delete keys from the db files.  Using 
DB_File, for Perl, I am doing the following:

my %database;
my $path = /path/to/some/category/domains.db;
my $db = tie(%database, "DB_File", $path, O_CREAT|O_RDWR, 0664, $DB_BTREE) || 
die("Error: Could not open $path!");  

my $statusDel = $db->del("cnn.com");
my $statusSync = $db->sync;  
undef($db);
untie(%database);

All of this seems to work (i.e., connecting and closing the connection).  However, I 
get a result status of 1 when I check the result of the $db->del("cnn.com") operation. 
 According the the Sleepycat documentation, a nonzero status indicates some sort of 
error in carrying out the delete operation.

Also, when I search the db file for cnn.com, I notice that the key still exists in the 
database.

Now, for the funky part.

If I do the above to connect, but then do:

my $statusAdd = $db->put(".anyolddomain.com","");
my $statusSync = $db->sync;
etc. . .

I get successful manipulation of the database ($statusAdd = 0).  Searching through the 
database file indicates that the entry has been added succesfully.

Then, if I try to do the delete shown above (on "anyolddomain.com"), it doesn't work.  
However, if I try the key delete on ".anyolddomain.com", it works as expected.  
Prepending the period to domains that exist but that I didn't create myself results in 
failure to remove the record.

Note also that the code above is exactly what is shown on the SG FAQ page.  For me, it 
doesn't work!

Any ideas?  Anyone had this experience and know what's going on?

I am using the Berkeley DB version 2.7.7, SquidGuard version 1.1.4 (both installed via 
RPM), and DB_File version 1.78.  I am attempting to work with the latest version of 
the blacklists, downloaded on the same day this email is being composed.

Thanks in advance for your help.


Henry Barker

Reply via email to