+2008-09-03 Nicolas François <nicolas.francois@centraliens.net>
+
+ * src/userdel.c: Log failures to remove the mailbox to syslog and
+ audit.
+ * src/userdel.c: Log successful removal of home directory to audit
+ only in case of success.
+ * src/userdel.c: Move the audit log of failure to remove the home
+ directory before the call to function that may exit.
+ * src/userdel.c: Document that errors is only used to count errors
+ during the removal of the home directory.
+
2008-09-03 Nicolas François <nicolas.francois@centraliens.net>
* src/useradd.c: Log errors to syslog in grp_update() since
}
snprintf (mailfile, sizeof mailfile, "%s/%s", maildir, user_name);
if (fflg) {
- unlink (mailfile); /* always remove, ignore errors */
+ if (unlink (mailfile) != 0) {
+ fprintf (stderr, _("%s: warning: can't remove %s: %s"), 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, 1);
+ audit_logger (AUDIT_DEL_USER, Prog,
+ "deleting mail file",
+ user_name, (unsigned int) user_id, 0);
+#endif
+ /* continue */
+ }
+#ifdef WITH_AUDIT
+ else
+ {
+ audit_logger (AUDIT_DEL_USER, Prog,
+ "deleting mail file",
+ user_name, (unsigned int) user_id, 1);
+ }
#endif
return;
}
/* continue */
}
#ifdef WITH_AUDIT
- else {
+ else
+ {
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
user_name, (unsigned int) user_id, 1);
*/
int main (int argc, char **argv)
{
- int errors = 0;
+ int errors = 0; /* Error in the removal of the home directory */
#ifdef USE_PAM
pam_handle_t *pamh = NULL;
Prog, user_home, user_name);
rflg = 0;
errors++;
+ /* continue */
}
#ifdef EXTRA_CHECK_HOME_DIR
Prog, user_home, pwd->pw_name);
rflg = false;
errors++;
+ /* continue */
break;
}
}
fprintf (stderr,
_("%s: error removing directory %s\n"),
Prog, user_home);
+ errors++;
+ /* continue */
+ }
#ifdef WITH_AUDIT
+ else
+ {
audit_logger (AUDIT_DEL_USER, Prog,
"deleting home directory",
- user_name, (unsigned int) user_id, 0);
-#endif
- errors++;
+ user_name, (unsigned int) user_id, 1);
}
+#endif
+ }
#ifdef WITH_AUDIT
+ if (0 != errors) {
audit_logger (AUDIT_DEL_USER, Prog,
"deleting home directory",
- user_name, (unsigned int) user_id, 1);
-#endif
+ user_name, AUDIT_NO_ID, 0);
}
+#endif
/*
* Cancel any crontabs or at jobs. Have to do this before we remove
#ifdef USE_PAM
(void) pam_end (pamh, PAM_SUCCESS);
#endif /* USE_PAM */
-#ifdef WITH_AUDIT
- if (0 != errors) {
- audit_logger (AUDIT_DEL_USER, Prog,
- "deleting home directory",
- user_name, AUDIT_NO_ID, 0);
- }
-#endif
exit ((0 != errors) ? E_HOMEDIR : E_SUCCESS);
/* NOT REACHED */
}