]> granicus.if.org Git - shadow/commitdiff
* NEWS, src/userdel.c: Check the existence of the user's mail
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 4 Jun 2011 22:38:57 +0000 (22:38 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sat, 4 Jun 2011 22:38:57 +0000 (22:38 +0000)
spool before trying to remove it. If it does not exist, a warning
is issued, but no failure.

ChangeLog
NEWS
src/userdel.c

index e40db48a5747e7df2fa5d8bfe55fcb2eaf577001..55362860e3058aeb6791047726e7432085e44a3c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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()
diff --git a/NEWS b/NEWS
index d6698c76e3f38d1d0921799ceb8fab071f8928a5..0dd821073d2ebd68348f4691f82f0cab1bd7e69b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
 
index 49edac707dd94b71162b78dbcbb89d04df896387..7c9463ca551a6aea1a5f321b4ae4baba6bfd023e 100644 (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,