On 14.9.2011, at 18.05, dovecot@lists.grepular.com wrote:
The LD_PRELOAD way would be simple. Probably 10-20 lines of C code for something that would replace unlink()s to mail files with fork+exec to /usr/bin/shred.
Simple for somebody who can code in C you mean :)
I have no idea if this works (or even compiles), it's based on a web page I found:
#define _GNU_SOURCE
#include
int unlink(const char *path) { static int (*libc_unlink)(const char *) = NULL; char *args[3]; int status;
if (libc_unlink == NULL) *(void **)(&libc_unlink) = dlsym(RTLD_NEXT, "unlink"); if (strstr(path, "Maildir/") != NULL) { args[0] = "/usr/bin/shred"; args[1] = path; args[2] = NULL; switch (fork()) { case -1: return -1; case 0: execve(args[0], args); exit(99); default: if (wait(&status) < 0) return -1; } if (WIFEXITED(status) && WEXITSTATUS(status) == 0) return 0; errno = ENOENT; /* not really correct, should maybe check it properly */ return -1; } else { libc_unlink(path); } }