From: Michael Tremer Date: Wed, 10 Dec 2025 17:20:29 +0000 (+0000) Subject: exporters: Create expressions and urls files for squidguard X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f496c21fb506ce2e358604f02f4701e2f0ff6e4;p=dbl.git exporters: Create expressions and urls files for squidguard Signed-off-by: Michael Tremer --- diff --git a/src/dnsbl/exporters.py b/src/dnsbl/exporters.py index c2ffd33..d413054 100644 --- a/src/dnsbl/exporters.py +++ b/src/dnsbl/exporters.py @@ -270,17 +270,32 @@ class SquidGuardExporter(Exporter): # Write all domains to the buffer exporter(f) + # Write the file + self._write_file(tarball, file, f) + + # squidguard is also expecting some more files + for name in ("expressions", "urls"): + file = tarfile.TarInfo(name="%s/%s" % (self.list.slug, name)) + + self._write_file(tarball, file) + + def _write_file(self, tarball, file, f=None): + """ + A helper function to set some commonly used metadata + """ # Assign the list to be owned by nobody file.uname = file.gname = "nobody" - # Set the length - file.size = f.tell() - # Set the mtime file.mtime = self.list.updated_at.timestamp() - # Reset the buffer - f.seek(0) + # Set the length + if f: + file.size = f.tell() + + # Ensure we read the payload from the beginning + if f: + f.seek(0) # Write the buffer to the tarball tarball.addfile(file, fileobj=f)