* NEWS, src/userdel.c: Check the existence of the user's mail

spool before trying to remove it. If it does not exist, a warning
	is issued, but no failure.
This commit is contained in:
nekral-guest 2011-06-04 22:38:57 +00:00
parent c9281b5bb9
commit 14f44bd9c9
3 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2011-06-04 Nicolas François <nicolas.francois@centraliens.net>
* NEWS, src/userdel.c: Check the existence of the user's mail
spool before trying to remove it. If it does not exist, a warning
is issued, but no failure.
2011-06-03 Nicolas François <nicolas.francois@centraliens.net>
* src/sulogin.c: Added Prog, needed because of the last xmalloc()

3
NEWS
View File

@ -44,6 +44,9 @@ shadow-4.1.4.3 -> shadow-4.1.5 UNRELEASED
- useradd
* If the skeleton directory contained hardlinked files, copies of the
hardlink were removed from the skeleton directory.
- userdel
* Check the existence of the user's mail spool before trying to remove
it. If it does not exist, a warning is issued, but no failure.
- usermod
* Accept options in any order (username not necessarily at the end)

View File

@ -2,7 +2,7 @@
* Copyright (c) 1991 - 1994, Julianne Frances Haugh
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
* Copyright (c) 2000 - 2006, Tomasz Kłoczko
* Copyright (c) 2007 - 2010, Nicolas François
* Copyright (c) 2007 - 2011, Nicolas François
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -668,6 +668,28 @@ static int remove_mailbox (void)
return 0;
}
snprintf (mailfile, sizeof mailfile, "%s/%s", maildir, user_name);
if (access (mailfile, F_OK) != 0) {
if (ENOENT == errno) {
fprintf (stderr,
_("%s: %s mail spool (%s) not found\n"),
Prog, user_name, user_home);
return 0;
} else {
fprintf (stderr,
_("%s: warning: can't remove %s: %s\n"),
Prog, mailfile, strerror (errno));
SYSLOG ((LOG_ERR, "Cannot remove %s: %s", mailfile, strerror (errno)));
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif /* WITH_AUDIT */
return -1;
}
}
if (fflg) {
if (unlink (mailfile) != 0) {
fprintf (stderr,