* lib/prototypes.h, libmisc/audit_help.c: Define new type

shadow_audit_result for the result argument of audit_logger().
	This permits stronger type checking and a better readability of
	the results (SHADOW_AUDIT_FAILURE/SHADOW_AUDIT_SUCCESS constants).
	* src/groupadd.c, src/groupdel.c, src/useradd.c, src/userdel.c:
	Use the SHADOW_AUDIT_FAILURE/SHADOW_AUDIT_SUCCESS results instead
	of 0 or 1 in audit_logger().
This commit is contained in:
nekral-guest 2008-09-04 19:35:48 +00:00
parent 3dcaaf87e7
commit a21809cdae
6 changed files with 142 additions and 70 deletions

View File

@ -136,8 +136,12 @@ extern int audit_fd;
extern void audit_help_open (void); extern void audit_help_open (void);
/* Use AUDIT_NO_ID when a name is provided to audit_logger instead of an ID */ /* Use AUDIT_NO_ID when a name is provided to audit_logger instead of an ID */
#define AUDIT_NO_ID ((unsigned int) -1) #define AUDIT_NO_ID ((unsigned int) -1)
typedef enum {
SHADOW_AUDIT_FAILURE = 0,
SHADOW_AUDIT_SUCCESS = 1} shadow_audit_result;
extern void audit_logger (int type, const char *pgname, const char *op, extern void audit_logger (int type, const char *pgname, const char *op,
const char *name, unsigned int id, int result); const char *name, unsigned int id,
shadow_audit_result result);
#endif #endif
/* limits.c */ /* limits.c */

View File

@ -76,13 +76,14 @@ void audit_help_open (void)
* result - 1 is "success" and 0 is "failed" * result - 1 is "success" and 0 is "failed"
*/ */
void audit_logger (int type, const char *pgname, const char *op, void audit_logger (int type, const char *pgname, const char *op,
const char *name, unsigned int id, int result) const char *name, unsigned int id,
shadow_audit_result result)
{ {
if (audit_fd < 0) { if (audit_fd < 0) {
return; return;
} else { } else {
audit_log_acct_message (audit_fd, type, NULL, op, name, id, audit_log_acct_message (audit_fd, type, NULL, op, name, id,
NULL, NULL, NULL, result); NULL, NULL, NULL, (int) result);
} }
} }

View File

@ -217,7 +217,8 @@ static void grp_update (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group", "adding group",
group_name, (unsigned int) group_id, 1); group_name, (unsigned int) group_id,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, "new group: name=%s, GID=%u", SYSLOG ((LOG_INFO, "new group: name=%s, GID=%u",
group_name, (unsigned int) group_id)); group_name, (unsigned int) group_id));
@ -264,7 +265,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking group file", "unlocking group file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -283,7 +285,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking gshadow file", "unlocking gshadow file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -306,7 +309,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"locking group file", "locking group file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -317,7 +321,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"opening group file", "opening group file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -330,7 +335,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"locking gshadow file", "locking gshadow file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -342,7 +348,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"opening gshadow file", "opening gshadow file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -362,7 +369,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking group file", "unlocking group file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -375,7 +383,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking gshadow file", "unlocking gshadow file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -386,7 +395,8 @@ static void fail_exit (int code)
if (code != E_SUCCESS) { if (code != E_SUCCESS) {
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group", "adding group",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
} }
#endif #endif

View File

@ -101,7 +101,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking group file", "unlocking group file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -114,7 +115,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking gshadow file", "unlocking gshadow file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -124,7 +126,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group", "deleting group",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
exit (code); exit (code);
@ -170,7 +173,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group", "deleting group",
group_name, (unsigned int) group_id, 1); group_name, (unsigned int) group_id,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, "remove group '%s'\n", group_name)); SYSLOG ((LOG_INFO, "remove group '%s'\n", group_name));
@ -185,7 +189,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking group file", "unlocking group file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -205,7 +210,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking gshadow file", "unlocking gshadow file",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -376,7 +382,8 @@ int main (int argc, char **argv)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group", "deleting group",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
exit (E_NOTFOUND); exit (E_NOTFOUND);
} }
@ -398,7 +405,8 @@ int main (int argc, char **argv)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group", "deleting group",
group_name, AUDIT_NO_ID, 0); group_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
if (!yp_get_default_domain (&nis_domain) && if (!yp_get_default_domain (&nis_domain) &&
!yp_master (nis_domain, "group.byname", &nis_master)) { !yp_master (nis_domain, "group.byname", &nis_master)) {

View File

@ -205,7 +205,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking shadow file", "unlocking shadow file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -217,7 +218,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking passwd file", "unlocking passwd file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -229,7 +231,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking group file", "unlocking group file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -242,7 +245,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking gshadow file", "unlocking gshadow file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -252,7 +256,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user", "adding user",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
SYSLOG ((LOG_INFO, "failed adding user '%s', data deleted", user_name)); SYSLOG ((LOG_INFO, "failed adding user '%s', data deleted", user_name));
exit (code); exit (code);
@ -582,7 +587,8 @@ static int set_defaults (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_USYS_CONFIG, Prog, audit_logger (AUDIT_USYS_CONFIG, Prog,
"changing useradd defaults", "changing useradd defaults",
NULL, AUDIT_NO_ID, 1); NULL, AUDIT_NO_ID,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, SYSLOG ((LOG_INFO,
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, " "useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
@ -838,7 +844,8 @@ static void grp_update (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user to group", "adding user to group",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); /* XXX */ fail_exit (E_GRP_UPDATE); /* XXX */
} }
@ -856,14 +863,16 @@ static void grp_update (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user to group", "adding user to group",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user to group", "adding user to group",
user_name, AUDIT_NO_ID, 1); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, "add '%s' to group '%s'", SYSLOG ((LOG_INFO, "add '%s' to group '%s'",
user_name, ngrp->gr_name)); user_name, ngrp->gr_name));
@ -905,7 +914,8 @@ static void grp_update (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user to shadow group", "adding user to shadow group",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); /* XXX */ fail_exit (E_GRP_UPDATE); /* XXX */
} }
@ -923,14 +933,16 @@ static void grp_update (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user to shadow group", "adding user to shadow group",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user to shadow group", "adding user to shadow group",
user_name, AUDIT_NO_ID, 1); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, "add '%s' to shadow group '%s'", SYSLOG ((LOG_INFO, "add '%s' to shadow group '%s'",
user_name, nsgrp->sg_name)); user_name, nsgrp->sg_name));
@ -1224,7 +1236,8 @@ static void process_flags (int argc, char **argv)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user", "adding user",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
exit (E_BAD_ARG); exit (E_BAD_ARG);
} }
@ -1299,7 +1312,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking shadow file", "unlocking shadow file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -1311,7 +1325,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking passwd file", "unlocking passwd file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -1322,7 +1337,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking group file", "unlocking group file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -1335,7 +1351,8 @@ static void close_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"unlocking gshadow file", "unlocking gshadow file",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -1480,7 +1497,8 @@ static void grp_add (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group", "adding group",
grp.gr_name, AUDIT_NO_ID, 0); grp.gr_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -1495,7 +1513,8 @@ static void grp_add (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group", "adding group",
grp.gr_name, AUDIT_NO_ID, 0); grp.gr_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -1504,7 +1523,8 @@ static void grp_add (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog, audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group", "adding group",
grp.gr_name, AUDIT_NO_ID, 1); grp.gr_name, AUDIT_NO_ID,
SHADOW_AUDIT_SUCCESS);
#endif #endif
do_grp_update = true; do_grp_update = true;
} }
@ -1618,14 +1638,16 @@ static void usr_update (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding shadow password", "adding shadow password",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_PW_UPDATE); fail_exit (E_PW_UPDATE);
} }
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user", "adding user",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
#endif #endif
/* /*
@ -1655,7 +1677,8 @@ static void create_home (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding home directory", "adding home directory",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_HOMEDIR); fail_exit (E_HOMEDIR);
} }
@ -1666,7 +1689,8 @@ static void create_home (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding home directory", "adding home directory",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
#endif #endif
} }
} }
@ -1813,7 +1837,8 @@ int main (int argc, char **argv)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user", "adding user",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_NAME_IN_USE); fail_exit (E_NAME_IN_USE);
} }
@ -1833,7 +1858,8 @@ int main (int argc, char **argv)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding group", "adding group",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_NAME_IN_USE); fail_exit (E_NAME_IN_USE);
} }
@ -1867,7 +1893,8 @@ int main (int argc, char **argv)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog, audit_logger (AUDIT_ADD_USER, Prog,
"adding user", "adding user",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_UID_IN_USE); fail_exit (E_UID_IN_USE);
} }

View File

@ -179,7 +179,8 @@ static void update_groups (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting user from group", "deleting user from group",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, "delete '%s' from group '%s'\n", SYSLOG ((LOG_INFO, "delete '%s' from group '%s'\n",
user_name, ngrp->gr_name)); user_name, ngrp->gr_name));
@ -235,7 +236,8 @@ static void update_groups (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog, audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group", "deleting group",
grp->gr_name, AUDIT_NO_ID, 1); grp->gr_name, AUDIT_NO_ID,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, SYSLOG ((LOG_INFO,
"removed group '%s' owned by '%s'\n", "removed group '%s' owned by '%s'\n",
@ -293,7 +295,8 @@ static void update_groups (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting user from shadow group", "deleting user from shadow group",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, "delete '%s' from shadow group '%s'\n", SYSLOG ((LOG_INFO, "delete '%s' from shadow group '%s'\n",
user_name, nsgrp->sg_name)); user_name, nsgrp->sg_name));
@ -416,7 +419,8 @@ static void fail_exit (int code)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting user", "deleting user",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
exit (code); exit (code);
@ -437,7 +441,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"locking password file", "locking password file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_PW_UPDATE); fail_exit (E_PW_UPDATE);
} }
@ -448,7 +453,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"opening password file", "opening password file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_PW_UPDATE); fail_exit (E_PW_UPDATE);
} }
@ -460,7 +466,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"locking shadow password file", "locking shadow password file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_PW_UPDATE); fail_exit (E_PW_UPDATE);
} }
@ -472,7 +479,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"opening shadow password file", "opening shadow password file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_PW_UPDATE); fail_exit (E_PW_UPDATE);
} }
@ -484,7 +492,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"locking group file", "locking group file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -494,7 +503,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"opening group file", "opening group file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -507,7 +517,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"locking shadow group file", "locking shadow group file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -518,7 +529,8 @@ static void open_files (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"opening shadow group file", "opening shadow group file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
@ -549,7 +561,8 @@ static void update_user (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting user entries", "deleting user entries",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
#endif #endif
SYSLOG ((LOG_INFO, "delete user '%s'\n", user_name)); SYSLOG ((LOG_INFO, "delete user '%s'\n", user_name));
} }
@ -591,7 +604,8 @@ static void user_busy (const char *name, uid_t uid)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting user logged in", "deleting user logged in",
name, AUDIT_NO_ID, 0); name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
exit (E_USER_BUSY); exit (E_USER_BUSY);
} }
@ -701,7 +715,8 @@ static void remove_mailbox (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file", "deleting mail file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -710,7 +725,8 @@ static void remove_mailbox (void)
{ {
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file", "deleting mail file",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
} }
#endif #endif
return; return;
@ -724,7 +740,8 @@ static void remove_mailbox (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file", "deleting mail file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
return; return;
} else if (i == -1) { } else if (i == -1) {
@ -736,7 +753,8 @@ static void remove_mailbox (void)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file", "deleting mail file",
user_name, (unsigned int) user_id, 0); user_name, (unsigned int) user_id,
SHADOW_AUDIT_FAILURE);
#endif #endif
/* continue */ /* continue */
} }
@ -745,7 +763,8 @@ static void remove_mailbox (void)
{ {
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file", "deleting mail file",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
} }
#endif #endif
} }
@ -855,7 +874,8 @@ int main (int argc, char **argv)
#ifdef WITH_AUDIT #ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting user not found", "deleting user not found",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
#endif #endif
exit (E_NOTFOUND); exit (E_NOTFOUND);
} }
@ -951,7 +971,8 @@ int main (int argc, char **argv)
{ {
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting home directory", "deleting home directory",
user_name, (unsigned int) user_id, 1); user_name, (unsigned int) user_id,
SHADOW_AUDIT_SUCCESS);
} }
#endif #endif
} }
@ -959,7 +980,8 @@ int main (int argc, char **argv)
if (0 != errors) { if (0 != errors) {
audit_logger (AUDIT_DEL_USER, Prog, audit_logger (AUDIT_DEL_USER, Prog,
"deleting home directory", "deleting home directory",
user_name, AUDIT_NO_ID, 0); user_name, AUDIT_NO_ID,
SHADOW_AUDIT_FAILURE);
} }
#endif #endif