Two patches regarding hash driver
Peter Williams <[email protected]> Sat, 12 Nov 2011 17:43:53 -0800
| Newsgroups | gmane.mail.spam.dspam.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Attached are two simple patches regarding the hash driver. The first adds a comment to the top of the dspam_clean manual page mentioning that cssclean and csscompress should be used instead of dspam_clean when the hash driver is in use -- this fact often seems to surprise people. The second patch causes csscompress to preserve the ownership and mode of the CSS file after compression. This duplicates functionality already in cssclean (with nearly identical code). If they look OK to commit, it'd be great if someone could do so. (I can set up a dspam fork on Github if that's the preferred way of doing these things.) Cheers, Peter -- Peter Williams / [email protected] ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Dspam-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dspam-devel
manpage.diff
(text/x-patch, 720 B)
commit e6587d82c47b969b880fef52bda88613daa704c4 Author: Peter Williams <[email protected]> Date: Sat Nov 12 16:46:05 2011 -0800 man: document that dspam_clean does nothing with hash driver diff --git a/man/dspam_clean.1 b/man/dspam_clean.1 index 15afb36..36a9460 100644 --- a/man/dspam_clean.1 +++ b/man/dspam_clean.1 @@ -41,6 +41,14 @@ dspam_clean \- perform periodic maintenance of metadata is used to perform periodic housecleaning on DSPAM's metadata dictionary by deleting old or useless data. +.B dspam_clean +has no effect if you use the "hash" storage driver. In that case, you should use +the tools +.B cssclean +and +.B csscompress +(which do not currently have manual pages). + .SH OPTIONS .LP
perms.diff
(text/x-patch, 1.6 KB)
commit 8cbee31a9d80c5c38fc13ac99d1b6d7bf77dfb09 Author: Peter Williams <[email protected]> Date: Sat Nov 12 16:52:47 2011 -0800 csscompress: preserve ownership and permissions as in cssclean diff --git a/src/tools.hash_drv/csscompress.c b/src/tools.hash_drv/csscompress.c index 43192c3..b4c72df 100644 --- a/src/tools.hash_drv/csscompress.c +++ b/src/tools.hash_drv/csscompress.c @@ -103,6 +103,7 @@ int csscompress(const char *filename) { hash_drv_spam_record_t rec; unsigned long filepos; char newfile[128]; + struct stat st; char *filenamecopy; unsigned long max_seek = HASH_SEEK_MAX; unsigned long max_extents = 0; @@ -136,6 +137,9 @@ int csscompress(const char *filename) { snprintf(newfile, sizeof(newfile), "/%s/.dspam%u.css", dirname((char *)filenamecopy), (unsigned int) getpid()); + if (stat(filename, &st) < 0) + return EFAILURE; + if (_hash_drv_open(filename, &old, 0, max_seek, max_extents, extent_size, pctincrease, flags)) { @@ -162,6 +166,23 @@ int csscompress(const char *filename) { return EFAILURE; } + /* preserve counters, permissions, and ownership */ + memcpy(&(new.header->totals), &(old.header->totals), sizeof(new.header->totals)); + + if (fchown(new.fd, st.st_uid, st.st_gid) < 0) { + _hash_drv_close(&new); + _hash_drv_close(&old); + unlink(newfile); + return EFAILURE; + } + + if (fchmod(new.fd, st.st_mode) < 0) { + _hash_drv_close(&new); + _hash_drv_close(&old); + unlink(newfile); + return EFAILURE; + } + filepos = sizeof(struct _hash_drv_header); header = old.addr; while(filepos < old.file_len) {