diff options
| author | 2012-01-14 19:35:31 +0000 | |
|---|---|---|
| committer | 2012-01-14 19:35:31 +0000 | |
| commit | bc19d0e9dfa6633b2e82eca067209904d985ea60 (patch) | |
| tree | 71851807213d7b09e3611257513fe124584fb06d /usr.sbin/smtpd/queue_fsqueue.c | |
| parent | Add missing header needed by PRI format string (diff) | |
| download | wireguard-openbsd-bc19d0e9dfa6633b2e82eca067209904d985ea60.tar.xz wireguard-openbsd-bc19d0e9dfa6633b2e82eca067209904d985ea60.zip | |
When moving a message to the corrupt/ directory, give it an alternate name
if there is already an entry with the same name.
ok gilles@ chl@
Diffstat (limited to 'usr.sbin/smtpd/queue_fsqueue.c')
| -rw-r--r-- | usr.sbin/smtpd/queue_fsqueue.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/queue_fsqueue.c b/usr.sbin/smtpd/queue_fsqueue.c index 2e30425559e..963a6191c65 100644 --- a/usr.sbin/smtpd/queue_fsqueue.c +++ b/usr.sbin/smtpd/queue_fsqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_fsqueue.c,v 1.33 2012/01/14 12:56:49 eric Exp $ */ +/* $OpenBSD: queue_fsqueue.c,v 1.34 2012/01/14 19:35:31 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -362,11 +362,21 @@ fsqueue_message_delete(enum queue_kind qkind, u_int32_t msgid) static int fsqueue_message_corrupt(enum queue_kind qkind, u_int32_t msgid) { + struct stat sb; char rootdir[MAXPATHLEN]; char corruptdir[MAXPATHLEN]; + char buf[64]; + int retry = 0; fsqueue_message_path(qkind, msgid, rootdir, sizeof(rootdir)); fsqueue_message_path(Q_CORRUPT, msgid, corruptdir, sizeof(corruptdir)); +again: + if (stat(corruptdir, &sb) != -1 || errno != ENOENT) { + fsqueue_message_path(Q_CORRUPT, msgid, corruptdir, sizeof(corruptdir)); + snprintf(buf, sizeof(buf), ".%i", retry++); + strlcat(corruptdir, buf, sizeof(corruptdir)); + goto again; + } if (rename(rootdir, corruptdir) == -1) fatalx("fsqueue_message_corrupt: rename"); |
