From 90ae19b3c16125ca46f9e9109ef1ed789fda1809 Mon Sep 17 00:00:00 2001 From: Jacek Masiulaniec Date: Sat, 6 Dec 2008 23:49:41 +0000 Subject: Make queue_delete_incoming_message not fatal on ENOENT condition. Also, fix function name in fatals. ok gilles@ --- usr.sbin/smtpd/queue.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 45d0c597c5b..5aff098f0fd 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.20 2008/12/06 14:30:51 jacekm Exp $ */ +/* $OpenBSD: queue.c,v 1.21 2008/12/06 23:49:40 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -813,30 +813,34 @@ queue_delete_incoming_message(char *message_id) } dirp = opendir(evpdir); - if (dirp == NULL) + if (dirp == NULL) { + if (errno == ENOENT) + goto delroot; fatal("queue_delete_incoming_message: opendir"); + } while ((dp = readdir(dirp)) != NULL) { if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; spret = snprintf(evppath, MAXPATHLEN, "%s/%s", evpdir, dp->d_name); if (spret == -1 || spret >= MAXPATHLEN) - fatal("queue_create_incoming_message: snprintf"); + fatal("queue_delete_incoming_message: snprintf"); if (unlink(evppath) == -1) { if (errno != ENOENT) - fatal("queue_create_incoming_message: unlink"); + fatal("queue_delete_incoming_message: unlink"); } } closedir(dirp); if (rmdir(evpdir) == -1) if (errno != ENOENT) - fatal("queue_create_incoming_message: rmdir"); + fatal("queue_delete_incoming_message: rmdir"); +delroot: if (rmdir(rootdir) == -1) if (errno != ENOENT) - fatal("queue_create_incoming_message: rmdir"); + fatal("queue_delete_incoming_message: rmdir"); return; } -- cgit v1.2.3