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().
extern void audit_help_open (void);
/* Use AUDIT_NO_ID when a name is provided to audit_logger instead of an ID */
#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,
- const char *name, unsigned int id, int result);
+ const char *name, unsigned int id,
+ shadow_audit_result result);
#endif
/* limits.c */
* result - 1 is "success" and 0 is "failed"
*/
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) {
return;
} else {
audit_log_acct_message (audit_fd, type, NULL, op, name, id,
- NULL, NULL, NULL, result);
+ NULL, NULL, NULL, (int) result);
}
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group",
- group_name, (unsigned int) group_id, 1);
+ group_name, (unsigned int) group_id,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "new group: name=%s, GID=%u",
group_name, (unsigned int) group_id));
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking group file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking gshadow file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"locking group file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"opening group file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"locking gshadow file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"opening gshadow file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking group file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"unlocking gshadow file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
if (code != E_SUCCESS) {
audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
}
#endif
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking group file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking gshadow file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
exit (code);
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group",
- group_name, (unsigned int) group_id, 1);
+ group_name, (unsigned int) group_id,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "remove group '%s'\n", group_name));
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking group file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"unlocking gshadow file",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
exit (E_NOTFOUND);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group",
- group_name, AUDIT_NO_ID, 0);
+ group_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
if (!yp_get_default_domain (&nis_domain) &&
!yp_master (nis_domain, "group.byname", &nis_master)) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking shadow file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking passwd file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking group file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking gshadow file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
SYSLOG ((LOG_INFO, "failed adding user '%s', data deleted", user_name));
exit (code);
#ifdef WITH_AUDIT
audit_logger (AUDIT_USYS_CONFIG, Prog,
"changing useradd defaults",
- NULL, AUDIT_NO_ID, 1);
+ NULL, AUDIT_NO_ID,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO,
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user to group",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE); /* XXX */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user to group",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user to group",
- user_name, AUDIT_NO_ID, 1);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "add '%s' to group '%s'",
user_name, ngrp->gr_name));
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user to shadow group",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE); /* XXX */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user to shadow group",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user to shadow group",
- user_name, AUDIT_NO_ID, 1);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "add '%s' to shadow group '%s'",
user_name, nsgrp->sg_name));
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
exit (E_BAD_ARG);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking shadow file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking passwd file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking group file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"unlocking gshadow file",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group",
- grp.gr_name, AUDIT_NO_ID, 0);
+ grp.gr_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group",
- grp.gr_name, AUDIT_NO_ID, 0);
+ grp.gr_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_GROUP, Prog,
"adding group",
- grp.gr_name, AUDIT_NO_ID, 1);
+ grp.gr_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_SUCCESS);
#endif
do_grp_update = true;
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding shadow password",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
#endif
/*
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding home directory",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_HOMEDIR);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding home directory",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
#endif
}
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_NAME_IN_USE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding group",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_NAME_IN_USE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_ADD_USER, Prog,
"adding user",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_UID_IN_USE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user from group",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "delete '%s' from group '%s'\n",
user_name, ngrp->gr_name));
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_GROUP, Prog,
"deleting group",
- grp->gr_name, AUDIT_NO_ID, 1);
+ grp->gr_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO,
"removed group '%s' owned by '%s'\n",
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user from shadow group",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "delete '%s' from shadow group '%s'\n",
user_name, nsgrp->sg_name));
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
exit (code);
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking password file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening password file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking shadow password file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening shadow password file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_PW_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking group file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening group file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"locking shadow group file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"opening shadow group file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user entries",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
#endif
SYSLOG ((LOG_INFO, "delete user '%s'\n", user_name));
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user logged in",
- name, AUDIT_NO_ID, 0);
+ name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
exit (E_USER_BUSY);
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
{
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
}
#endif
return;
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
return;
} else if (i == -1) {
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id, 0);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_FAILURE);
#endif
/* continue */
}
{
audit_logger (AUDIT_DEL_USER, Prog,
"deleting mail file",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
}
#endif
}
#ifdef WITH_AUDIT
audit_logger (AUDIT_DEL_USER, Prog,
"deleting user not found",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
#endif
exit (E_NOTFOUND);
}
{
audit_logger (AUDIT_DEL_USER, Prog,
"deleting home directory",
- user_name, (unsigned int) user_id, 1);
+ user_name, (unsigned int) user_id,
+ SHADOW_AUDIT_SUCCESS);
}
#endif
}
if (0 != errors) {
audit_logger (AUDIT_DEL_USER, Prog,
"deleting home directory",
- user_name, AUDIT_NO_ID, 0);
+ user_name, AUDIT_NO_ID,
+ SHADOW_AUDIT_FAILURE);
}
#endif