|
|
020281 |
From 72962208c42ea202f1e31f2f3ac1b523cd545b06 Mon Sep 17 00:00:00 2001
|
|
|
020281 |
From: Steve Grubb <sgrubb@redhat.com>
|
|
|
020281 |
Date: Fri, 3 Aug 2018 11:33:05 +0200
|
|
|
020281 |
Subject: [PATCH] Add audit events around user life cycle
|
|
|
020281 |
|
|
|
020281 |
---
|
|
|
020281 |
Makefile.am | 18 ++++++-------
|
|
|
020281 |
apps/lchage.c | 5 ++++
|
|
|
020281 |
apps/lchsh.c | 7 +++++
|
|
|
020281 |
apps/lgroupadd.c | 5 ++++
|
|
|
020281 |
apps/lgroupdel.c | 6 +++++
|
|
|
020281 |
apps/lgroupmod.c | 36 +++++++++++++++++++++++++
|
|
|
020281 |
apps/luseradd.c | 16 +++++++++++
|
|
|
020281 |
apps/luserdel.c | 17 ++++++++++++
|
|
|
020281 |
apps/lusermod.c | 38 +++++++++++++++++++++++++-
|
|
|
020281 |
configure.ac | 17 ++++++++++++
|
|
|
020281 |
lib/common.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
020281 |
lib/user_private.h | 15 +++++++++++
|
|
|
020281 |
12 files changed, 235 insertions(+), 11 deletions(-)
|
|
|
020281 |
|
|
|
020281 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
020281 |
index 080f97e8cc81a77dd0413c3b6fe7fe8002499393..9f099bd71941a869274a502a3130802731d83c24 100644
|
|
|
020281 |
--- a/Makefile.am
|
|
|
020281 |
+++ b/Makefile.am
|
|
|
020281 |
@@ -116,7 +116,7 @@ apps_libapputil_la_LDFLAGS = $(GOBJECT_LIBS) -lpam -lpam_misc $(SELINUX_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_lchage_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lchage_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_lchage_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_lchage_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_lchfn_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lchfn_LDADD = apps/libapputil.la lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
@@ -124,19 +124,19 @@ apps_lchfn_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
|
|
|
020281 |
apps_lchsh_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lchsh_LDADD = apps/libapputil.la lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_lchsh_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_lchsh_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_lgroupadd_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lgroupadd_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_lgroupadd_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_lgroupadd_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_lgroupdel_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lgroupdel_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_lgroupdel_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_lgroupdel_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_lgroupmod_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lgroupmod_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_lgroupmod_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_lgroupmod_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_lid_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lid_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
@@ -152,15 +152,15 @@ apps_lpasswd_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
|
|
|
020281 |
apps_luseradd_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_luseradd_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_luseradd_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_luseradd_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_luserdel_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_luserdel_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_luserdel_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_luserdel_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
apps_lusermod_CPPFLAGS = $(AM_CPPFLAGS) $(LOCALEDIR_CPPFLAGS)
|
|
|
020281 |
apps_lusermod_LDADD = lib/libuser.la $(LTLIBINTL)
|
|
|
020281 |
-apps_lusermod_LDFLAGS = $(GMODULE_LIBS) -lpopt
|
|
|
020281 |
+apps_lusermod_LDFLAGS = $(GMODULE_LIBS) -lpopt $(AUDIT_LIBS)
|
|
|
020281 |
|
|
|
020281 |
lib_libuser_la_SOURCES = lib/common.c lib/config.c lib/entity.c lib/error.c \
|
|
|
020281 |
lib/fs.c lib/getdate.y lib/internal.h lib/misc.c lib/modules.c \
|
|
|
020281 |
@@ -170,7 +170,7 @@ lib_libuser_la_CPPFLAGS = $(GMODULE_CFLAGS) -Ilib $(LOCALEDIR_CPPFLAGS) \
|
|
|
020281 |
-DMODULEDIR='"$(pkglibdir)"' -DNSCD='"$(NSCD)"' \
|
|
|
020281 |
-DSYSCONFDIR='"$(sysconfdir)"'
|
|
|
020281 |
lib_libuser_la_LDFLAGS = $(GMODULE_LIBS) $(CRYPT_LIBS) $(SELINUX_LIBS) \
|
|
|
020281 |
- -version-info 6:2:5
|
|
|
020281 |
+ $(AUDIT_LIBS) -version-info 6:2:5
|
|
|
020281 |
lib_libuser_la_LIBADD = $(LTLIBINTL)
|
|
|
020281 |
|
|
|
020281 |
modules_libuser_files_la_SOURCES = modules/files.c
|
|
|
020281 |
diff --git a/apps/lchage.c b/apps/lchage.c
|
|
|
020281 |
index bad296ccf0755dd6781b1a2e6397dccb1f7dbd12..1a4f04883062cb11f15a2e34d37e127fef2a374e 100644
|
|
|
020281 |
--- a/apps/lchage.c
|
|
|
020281 |
+++ b/apps/lchage.c
|
|
|
020281 |
@@ -29,6 +29,7 @@
|
|
|
020281 |
#include <popt.h>
|
|
|
020281 |
#include <glib.h>
|
|
|
020281 |
#include "../lib/user.h"
|
|
|
020281 |
+#include "../lib/user_private.h"
|
|
|
020281 |
#include "apputil.h"
|
|
|
020281 |
|
|
|
020281 |
#define INVALID_LONG LONG_MIN
|
|
|
020281 |
@@ -239,8 +240,12 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("Failed to modify aging information for %s: "
|
|
|
020281 |
"%s\n"), user, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "change-age", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 3;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "change-age", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
|
|
|
020281 |
lu_nscd_flush_cache(LU_NSCD_CACHE_PASSWD);
|
|
|
020281 |
}
|
|
|
020281 |
diff --git a/apps/lchsh.c b/apps/lchsh.c
|
|
|
020281 |
index 7c8a9246d4548a7f6fbacce91cdfdf4372799943..555ed2ea7b0d5a90bf37a7f23c398b382ac45a38 100644
|
|
|
020281 |
--- a/apps/lchsh.c
|
|
|
020281 |
+++ b/apps/lchsh.c
|
|
|
020281 |
@@ -26,6 +26,7 @@
|
|
|
020281 |
#include <string.h>
|
|
|
020281 |
#include <unistd.h>
|
|
|
020281 |
#include "../lib/user.h"
|
|
|
020281 |
+#include "../lib/user_private.h"
|
|
|
020281 |
#include "apputil.h"
|
|
|
020281 |
|
|
|
020281 |
int
|
|
|
020281 |
@@ -120,6 +121,8 @@ main(int argc, const char **argv)
|
|
|
020281 |
NULL, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Shell not changed: %s\n"),
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "change-shell", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 1;
|
|
|
020281 |
}
|
|
|
020281 |
/* Modify the in-memory structure's shell attribute. */
|
|
|
020281 |
@@ -132,9 +135,13 @@ main(int argc, const char **argv)
|
|
|
020281 |
if (lu_user_modify(ctx, ent, &error)) {
|
|
|
020281 |
g_print(_("Shell changed.\n"));
|
|
|
020281 |
lu_nscd_flush_cache(LU_NSCD_CACHE_PASSWD);
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "change-shell", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
} else {
|
|
|
020281 |
fprintf(stderr, _("Shell not changed: %s\n"),
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "change-shell", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 1;
|
|
|
020281 |
}
|
|
|
020281 |
}
|
|
|
020281 |
diff --git a/apps/lgroupadd.c b/apps/lgroupadd.c
|
|
|
020281 |
index d73ee864adac9e5dbc7d98392190db225d116143..3fa2a1df5ac5838ef256541c07ae6028e4f6a80b 100644
|
|
|
020281 |
--- a/apps/lgroupadd.c
|
|
|
020281 |
+++ b/apps/lgroupadd.c
|
|
|
020281 |
@@ -118,6 +118,8 @@ main(int argc, const char **argv)
|
|
|
020281 |
if (lu_group_add(ctx, ent, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Group creation failed: %s\n"),
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_ADD_GROUP, "add-group", name,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 2;
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
@@ -127,5 +129,8 @@ main(int argc, const char **argv)
|
|
|
020281 |
|
|
|
020281 |
lu_end(ctx);
|
|
|
020281 |
|
|
|
020281 |
+ lu_audit_logger(AUDIT_ADD_GROUP, "add-group", name,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
+
|
|
|
020281 |
return 0;
|
|
|
020281 |
}
|
|
|
020281 |
diff --git a/apps/lgroupdel.c b/apps/lgroupdel.c
|
|
|
020281 |
index e0fd6c6d42f55eef82f0790f551721972c129b5f..c5ccbed95cb834719cd109a81e6f979bb737dc71 100644
|
|
|
020281 |
--- a/apps/lgroupdel.c
|
|
|
020281 |
+++ b/apps/lgroupdel.c
|
|
|
020281 |
@@ -24,6 +24,7 @@
|
|
|
020281 |
#include <locale.h>
|
|
|
020281 |
#include <popt.h>
|
|
|
020281 |
#include "../lib/user.h"
|
|
|
020281 |
+#include "../lib/user_private.h"
|
|
|
020281 |
#include "apputil.h"
|
|
|
020281 |
|
|
|
020281 |
int
|
|
|
020281 |
@@ -90,6 +91,8 @@ main(int argc, const char **argv)
|
|
|
020281 |
if (lu_group_delete(ctx, ent, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Group %s could not be deleted: %s\n"),
|
|
|
020281 |
group, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_DEL_GROUP, "delete-group", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 3;
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
@@ -99,5 +102,8 @@ main(int argc, const char **argv)
|
|
|
020281 |
|
|
|
020281 |
lu_end(ctx);
|
|
|
020281 |
|
|
|
020281 |
+ lu_audit_logger(AUDIT_DEL_GROUP, "delete-group", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
+
|
|
|
020281 |
return 0;
|
|
|
020281 |
}
|
|
|
020281 |
diff --git a/apps/lgroupmod.c b/apps/lgroupmod.c
|
|
|
020281 |
index 21170e06f37370d7b2f2d936048ae7abf24fd181..0ad0ae4f39d32435b4668ef15ec678d8ea319e5c 100644
|
|
|
020281 |
--- a/apps/lgroupmod.c
|
|
|
020281 |
+++ b/apps/lgroupmod.c
|
|
|
020281 |
@@ -138,8 +138,14 @@ main(int argc, const char **argv)
|
|
|
020281 |
== FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Failed to set password for group "
|
|
|
020281 |
"%s: %s\n"), group, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-passwd", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 4;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-passwd", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
if (cryptedUserPassword) {
|
|
|
020281 |
@@ -147,8 +153,14 @@ main(int argc, const char **argv)
|
|
|
020281 |
&error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Failed to set password for group "
|
|
|
020281 |
"%s: %s\n"), group, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-passwd", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 5;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-passwd", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
if (lock) {
|
|
|
020281 |
@@ -156,8 +168,14 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("Group %s could not be locked: %s\n"), group,
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-lock", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 6;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-lock", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
if (unlock) {
|
|
|
020281 |
@@ -165,8 +183,14 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("Group %s could not be unlocked: %s\n"),
|
|
|
020281 |
group, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-lock", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 7;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-lock", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
change = gid || addAdmins || remAdmins || addMembers || remMembers;
|
|
|
020281 |
@@ -241,8 +265,14 @@ main(int argc, const char **argv)
|
|
|
020281 |
if (change && lu_group_modify(ctx, ent, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Group %s could not be modified: %s\n"),
|
|
|
020281 |
group, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-members", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 8;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-members", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
if (gidNumber != LU_VALUE_INVALID_ID) {
|
|
|
020281 |
users = lu_users_enumerate_by_group_full(ctx, gid, &error);
|
|
|
020281 |
|
|
|
020281 |
@@ -256,8 +286,14 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("Group %s could not be modified: %s\n"),
|
|
|
020281 |
group, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-id", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 8;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_GRP_MGMT,
|
|
|
020281 |
+ "changing-group-id", group,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
lu_ent_free(ent);
|
|
|
020281 |
diff --git a/apps/luseradd.c b/apps/luseradd.c
|
|
|
020281 |
index 7839183c00f892ad50f77f5aed6ada07cd3c125b..9d7f4f10a9c6f849e551f017f05c2e67e4a56259 100644
|
|
|
020281 |
--- a/apps/luseradd.c
|
|
|
020281 |
+++ b/apps/luseradd.c
|
|
|
020281 |
@@ -210,8 +210,12 @@ main(int argc, const char **argv)
|
|
|
020281 |
lu_error_free(&error);
|
|
|
020281 |
}
|
|
|
020281 |
lu_end(ctx);
|
|
|
020281 |
+ lu_audit_logger(AUDIT_ADD_GROUP, "add-group", name,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 1;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_ADD_GROUP, "add-group", name,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
/* Retrieve the group ID. */
|
|
|
020281 |
@@ -259,9 +263,13 @@ main(int argc, const char **argv)
|
|
|
020281 |
if (lu_user_add(ctx, ent, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Account creation failed: %s.\n"),
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_ADD_USER, "add-user", name,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
+
|
|
|
020281 |
return 3;
|
|
|
020281 |
}
|
|
|
020281 |
lu_nscd_flush_cache(LU_NSCD_CACHE_PASSWD);
|
|
|
020281 |
+ lu_audit_logger(AUDIT_ADD_USER, "add-user", name, AUDIT_NO_ID, 1);
|
|
|
020281 |
|
|
|
020281 |
/* If we don't have the the don't-create-home flag, create the user's
|
|
|
020281 |
* home directory. */
|
|
|
020281 |
@@ -282,8 +290,12 @@ main(int argc, const char **argv)
|
|
|
020281 |
&error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Error creating %s: %s.\n"),
|
|
|
020281 |
homeDirectory, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "add-home-dir", name,
|
|
|
020281 |
+ uidNumber, 0);
|
|
|
020281 |
return 7;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "add-home-dir", name,
|
|
|
020281 |
+ uidNumber, 1);
|
|
|
020281 |
|
|
|
020281 |
/* Create a mail spool for the user. */
|
|
|
020281 |
if (lu_mail_spool_create(ctx, ent, &error) != TRUE) {
|
|
|
020281 |
@@ -311,8 +323,12 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr, _("Error setting password for user "
|
|
|
020281 |
"%s: %s.\n"), name,
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK, "updating-password",
|
|
|
020281 |
+ name, uidNumber, 0);
|
|
|
020281 |
return 3;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK, "updating-password",
|
|
|
020281 |
+ name, uidNumber, 1);
|
|
|
020281 |
}
|
|
|
020281 |
lu_nscd_flush_cache(LU_NSCD_CACHE_PASSWD);
|
|
|
020281 |
|
|
|
020281 |
diff --git a/apps/luserdel.c b/apps/luserdel.c
|
|
|
020281 |
index 2f39a4ffb8ae47ac5dc3c84270b54a8ca68c7403..7e20fa7ea9bf4082967bc6931a8557936bfda0a2 100644
|
|
|
020281 |
--- a/apps/luserdel.c
|
|
|
020281 |
+++ b/apps/luserdel.c
|
|
|
020281 |
@@ -26,6 +26,7 @@
|
|
|
020281 |
#include <string.h>
|
|
|
020281 |
#include <unistd.h>
|
|
|
020281 |
#include "../lib/user.h"
|
|
|
020281 |
+#include "../lib/user_private.h"
|
|
|
020281 |
#include "apputil.h"
|
|
|
020281 |
|
|
|
020281 |
int
|
|
|
020281 |
@@ -93,8 +94,12 @@ main(int argc, const char **argv)
|
|
|
020281 |
if (lu_user_delete(ctx, ent, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("User %s could not be deleted: %s.\n"),
|
|
|
020281 |
user, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_DEL_USER, "delete-user", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 3;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_DEL_USER, "delete-user", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
|
|
|
020281 |
lu_nscd_flush_cache(LU_NSCD_CACHE_PASSWD);
|
|
|
020281 |
|
|
|
020281 |
@@ -126,9 +131,15 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr, _("Group %s could not be "
|
|
|
020281 |
"deleted: %s.\n"), tmp,
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger_with_group (AUDIT_DEL_GROUP,
|
|
|
020281 |
+ "delete-group", user, AUDIT_NO_ID,
|
|
|
020281 |
+ tmp, 0);
|
|
|
020281 |
return 7;
|
|
|
020281 |
}
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger_with_group (AUDIT_DEL_GROUP,
|
|
|
020281 |
+ "delete-group", user,
|
|
|
020281 |
+ AUDIT_NO_ID, tmp, 1);
|
|
|
020281 |
lu_ent_free(group_ent);
|
|
|
020281 |
lu_nscd_flush_cache(LU_NSCD_CACHE_GROUP);
|
|
|
020281 |
}
|
|
|
020281 |
@@ -138,8 +149,14 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("Error removing home directory: %s.\n"),
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT,
|
|
|
020281 |
+ "deleting-home-directory", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 0);
|
|
|
020281 |
return 9;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "deleting-home-directory", user,
|
|
|
020281 |
+ AUDIT_NO_ID, 1);
|
|
|
020281 |
+
|
|
|
020281 |
/* Delete the user's mail spool. */
|
|
|
020281 |
if (lu_mail_spool_remove(ctx, ent, &error) != TRUE) {
|
|
|
020281 |
fprintf(stderr, _("Error removing mail spool: %s"),
|
|
|
020281 |
diff --git a/apps/lusermod.c b/apps/lusermod.c
|
|
|
020281 |
index afec147475736f0b814b5e1f30c77064f3915c20..143157f114c93960fb879d9e6e0c1fb914f3ffcb 100644
|
|
|
020281 |
--- a/apps/lusermod.c
|
|
|
020281 |
+++ b/apps/lusermod.c
|
|
|
020281 |
@@ -179,8 +179,13 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("Failed to set password for user %s: %s.\n"),
|
|
|
020281 |
user, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK,
|
|
|
020281 |
+ "updating-password", user,
|
|
|
020281 |
+ uidNumber, 0);
|
|
|
020281 |
return 5;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK, "updating-password",
|
|
|
020281 |
+ user, uidNumber, 0);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
/* If we need to change a user's crypted password, try to change it,
|
|
|
020281 |
@@ -192,8 +197,13 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("Failed to set password for user %s: %s.\n"),
|
|
|
020281 |
user, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK,
|
|
|
020281 |
+ "updating-password", user,
|
|
|
020281 |
+ uidNumber, 0);
|
|
|
020281 |
return 6;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK, "updating-password",
|
|
|
020281 |
+ user, uidNumber, 0);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
/* If we need to lock/unlock the user's account, do that. */
|
|
|
020281 |
@@ -202,16 +212,26 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("User %s could not be locked: %s.\n"),
|
|
|
020281 |
user, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK,
|
|
|
020281 |
+ "locking-account", user,
|
|
|
020281 |
+ uidNumber, 0);
|
|
|
020281 |
return 7;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK, "locking-account",
|
|
|
020281 |
+ user, uidNumber, 0);
|
|
|
020281 |
}
|
|
|
020281 |
if (unlock) {
|
|
|
020281 |
if (lu_user_unlock(ctx, ent, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr,
|
|
|
020281 |
_("User %s could not be unlocked: %s.\n"),
|
|
|
020281 |
user, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK,
|
|
|
020281 |
+ "unlocking-account", user,
|
|
|
020281 |
+ uidNumber, 0);
|
|
|
020281 |
return 8;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_CHAUTHTOK, "unlocking-account",
|
|
|
020281 |
+ user, uidNumber, 0);
|
|
|
020281 |
}
|
|
|
020281 |
|
|
|
020281 |
/* Determine if we actually need to change anything. */
|
|
|
020281 |
@@ -274,8 +294,13 @@ main(int argc, const char **argv)
|
|
|
020281 |
if (change && (lu_user_modify(ctx, ent, &error) == FALSE)) {
|
|
|
020281 |
fprintf(stderr, _("User %s could not be modified: %s.\n"),
|
|
|
020281 |
user, lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT,
|
|
|
020281 |
+ "modify-account", user,
|
|
|
020281 |
+ uidNumber, 0);
|
|
|
020281 |
return 9;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "modify-account",
|
|
|
020281 |
+ user, uidNumber, 1);
|
|
|
020281 |
lu_nscd_flush_cache(LU_NSCD_CACHE_PASSWD);
|
|
|
020281 |
|
|
|
020281 |
/* If the user's name changed, we need to update supplemental
|
|
|
020281 |
@@ -322,12 +347,19 @@ main(int argc, const char **argv)
|
|
|
020281 |
}
|
|
|
020281 |
}
|
|
|
020281 |
/* Save the changes to the group. */
|
|
|
020281 |
- if (lu_group_modify(ctx, group, &error) == FALSE)
|
|
|
020281 |
+ if (lu_group_modify(ctx, group, &error) == FALSE) {
|
|
|
020281 |
fprintf(stderr, _("Group %s could not be "
|
|
|
020281 |
"modified: %s.\n"),
|
|
|
020281 |
lu_ent_get_first_string(group,
|
|
|
020281 |
LU_GROUPNAME),
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger_with_group(AUDIT_USER_MGMT,
|
|
|
020281 |
+ "update-member-in-group", user, uidNumber,
|
|
|
020281 |
+ lu_ent_get_first_string(group, LU_GROUPNAME),0);
|
|
|
020281 |
+ } else
|
|
|
020281 |
+ lu_audit_logger_with_group(AUDIT_USER_MGMT,
|
|
|
020281 |
+ "update-member-in-group", user, uidNumber,
|
|
|
020281 |
+ lu_ent_get_first_string(group, LU_GROUPNAME),1);
|
|
|
020281 |
lu_ent_free(group);
|
|
|
020281 |
}
|
|
|
020281 |
g_ptr_array_free(groups, TRUE);
|
|
|
020281 |
@@ -353,8 +385,12 @@ main(int argc, const char **argv)
|
|
|
020281 |
fprintf(stderr, _("Error moving %s to %s: %s.\n"),
|
|
|
020281 |
oldHomeDirectory, homeDirectory,
|
|
|
020281 |
lu_strerror(error));
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "moving-home-dir",
|
|
|
020281 |
+ user, uidNumber, 0);
|
|
|
020281 |
return 12;
|
|
|
020281 |
}
|
|
|
020281 |
+ lu_audit_logger(AUDIT_USER_MGMT, "moving-home-dir",
|
|
|
020281 |
+ user, uidNumber, 1);
|
|
|
020281 |
}
|
|
|
020281 |
g_free(oldHomeDirectory);
|
|
|
020281 |
|
|
|
020281 |
diff --git a/configure.ac b/configure.ac
|
|
|
020281 |
index 3e68b16a1f65ff5e5e3e905c1ffce8993e562176..0bd4a67d4c77fa1b701d74dbeab908a192dbf4d7 100644
|
|
|
020281 |
--- a/configure.ac
|
|
|
020281 |
+++ b/configure.ac
|
|
|
020281 |
@@ -118,6 +118,23 @@ if test "x$selinux" != xno ; then
|
|
|
020281 |
fi
|
|
|
020281 |
AC_SUBST(SELINUX_LIBS)
|
|
|
020281 |
|
|
|
020281 |
+AC_ARG_WITH(audit,
|
|
|
020281 |
+AS_HELP_STRING([--with-audit],[log using Linux Audit in addition to syslog]),
|
|
|
020281 |
+use_audit=$withval,
|
|
|
020281 |
+use_audit=auto)
|
|
|
020281 |
+if test x$use_audit != xno ; then
|
|
|
020281 |
+ AC_SEARCH_LIBS([audit_open], [audit])
|
|
|
020281 |
+ if test x$ac_cv_search_audit_open = xno ; then
|
|
|
020281 |
+ if test x$use_audit != xauto ; then
|
|
|
020281 |
+ AC_MSG_ERROR([requested Linux Audit, but libaudit was not found])
|
|
|
020281 |
+ fi
|
|
|
020281 |
+ else
|
|
|
020281 |
+ AC_DEFINE(WITH_AUDIT,1,[Define if you want to use Linux Audit.])
|
|
|
020281 |
+ AUDIT_LIBS=-laudit
|
|
|
020281 |
+ fi
|
|
|
020281 |
+fi
|
|
|
020281 |
+AC_SUBST(AUDIT_LIBS)
|
|
|
020281 |
+
|
|
|
020281 |
AC_C_CONST
|
|
|
020281 |
AC_TYPE_UID_T
|
|
|
020281 |
AC_TYPE_MODE_T
|
|
|
020281 |
diff --git a/lib/common.c b/lib/common.c
|
|
|
020281 |
index fc5df7461111908ff3eae59608ce0a51d62e155e..dce7e570ec9c92b56b28f15ab503fb7a641b660e 100644
|
|
|
020281 |
--- a/lib/common.c
|
|
|
020281 |
+++ b/lib/common.c
|
|
|
020281 |
@@ -16,9 +16,10 @@
|
|
|
020281 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
020281 |
*/
|
|
|
020281 |
|
|
|
020281 |
-#include <config.h>
|
|
|
020281 |
+#include "config.h"
|
|
|
020281 |
#include <glib.h>
|
|
|
020281 |
#include <string.h>
|
|
|
020281 |
+#include <stdlib.h>
|
|
|
020281 |
|
|
|
020281 |
#include "internal.h"
|
|
|
020281 |
#include "user_private.h"
|
|
|
020281 |
@@ -111,3 +112,66 @@ lu_common_sgroup_default(struct lu_module *module,
|
|
|
020281 |
g_return_val_if_fail(name != NULL, FALSE);
|
|
|
020281 |
return lu_common_group_default(module, name, is_system, ent, error);
|
|
|
020281 |
}
|
|
|
020281 |
+
|
|
|
020281 |
+#ifdef WITH_AUDIT
|
|
|
020281 |
+static int audit_fd = 0;
|
|
|
020281 |
+
|
|
|
020281 |
+/* result - 1 is "success" and 0 is "failed" */
|
|
|
020281 |
+void lu_audit_logger(int type, const char *op, const char *name,
|
|
|
020281 |
+ unsigned int id, unsigned int result)
|
|
|
020281 |
+{
|
|
|
020281 |
+ if (audit_fd == 0) {
|
|
|
020281 |
+ /* First time through */
|
|
|
020281 |
+ audit_fd = audit_open();
|
|
|
020281 |
+ if (audit_fd < 0) {
|
|
|
020281 |
+ /* You get these only when the kernel doesn't have
|
|
|
020281 |
+ * audit compiled in. */
|
|
|
020281 |
+ if ( (errno == EINVAL)
|
|
|
020281 |
+ || (errno == EPROTONOSUPPORT)
|
|
|
020281 |
+ || (errno == EAFNOSUPPORT))
|
|
|
020281 |
+ return;
|
|
|
020281 |
+ fputs("Cannot open audit interface - aborting.\n", stderr);
|
|
|
020281 |
+ exit(EXIT_FAILURE);
|
|
|
020281 |
+ }
|
|
|
020281 |
+ }
|
|
|
020281 |
+ if (audit_fd < 0)
|
|
|
020281 |
+ return;
|
|
|
020281 |
+ audit_log_acct_message(audit_fd, type, NULL, op, name, id,
|
|
|
020281 |
+ NULL, NULL, NULL, (int) result);
|
|
|
020281 |
+}
|
|
|
020281 |
+
|
|
|
020281 |
+/* result - 1 is "success" and 0 is "failed" */
|
|
|
020281 |
+void lu_audit_logger_with_group (int type, const char *op, const char *name,
|
|
|
020281 |
+ unsigned int id, const char *grp, unsigned int result)
|
|
|
020281 |
+{
|
|
|
020281 |
+ int len;
|
|
|
020281 |
+ char enc_group[(LOGIN_NAME_MAX*2)+1], buf[1024];
|
|
|
020281 |
+
|
|
|
020281 |
+ if (audit_fd == 0) {
|
|
|
020281 |
+ /* First time through */
|
|
|
020281 |
+ audit_fd = audit_open();
|
|
|
020281 |
+ if (audit_fd < 0) {
|
|
|
020281 |
+ /* You get these only when the kernel doesn't have
|
|
|
020281 |
+ * audit compiled in. */
|
|
|
020281 |
+ if ( (errno == EINVAL)
|
|
|
020281 |
+ || (errno == EPROTONOSUPPORT)
|
|
|
020281 |
+ || (errno == EAFNOSUPPORT))
|
|
|
020281 |
+ return;
|
|
|
020281 |
+ fputs("Cannot open audit interface - aborting.\n", stderr);
|
|
|
020281 |
+ exit(EXIT_FAILURE);
|
|
|
020281 |
+ }
|
|
|
020281 |
+ }
|
|
|
020281 |
+ if (audit_fd < 0)
|
|
|
020281 |
+ return;
|
|
|
020281 |
+ len = strnlen(grp, sizeof(enc_group)/2);
|
|
|
020281 |
+ if (audit_value_needs_encoding(grp, len)) {
|
|
|
020281 |
+ snprintf(buf, sizeof(buf), "%s grp=%s", op,
|
|
|
020281 |
+ audit_encode_value(enc_group, grp, len));
|
|
|
020281 |
+ } else {
|
|
|
020281 |
+ snprintf(buf, sizeof(buf), "%s grp=\"%s\"", op, grp);
|
|
|
020281 |
+ }
|
|
|
020281 |
+ audit_log_acct_message(audit_fd, type, NULL, buf, name, id,
|
|
|
020281 |
+ NULL, NULL, NULL, (int) result);
|
|
|
020281 |
+}
|
|
|
020281 |
+#endif
|
|
|
020281 |
+
|
|
|
020281 |
diff --git a/lib/user_private.h b/lib/user_private.h
|
|
|
020281 |
index a4869c138d51519539b6939406cdb0fee23ab7f6..02b813c47ee359db774bb85a2aa7aa12e18d3067 100644
|
|
|
020281 |
--- a/lib/user_private.h
|
|
|
020281 |
+++ b/lib/user_private.h
|
|
|
020281 |
@@ -34,6 +34,9 @@
|
|
|
020281 |
#ifdef WITH_SELINUX
|
|
|
020281 |
#include <selinux/selinux.h>
|
|
|
020281 |
#endif
|
|
|
020281 |
+#ifdef WITH_AUDIT
|
|
|
020281 |
+#include <libaudit.h>
|
|
|
020281 |
+#endif
|
|
|
020281 |
#include "user.h"
|
|
|
020281 |
|
|
|
020281 |
G_BEGIN_DECLS
|
|
|
020281 |
@@ -357,6 +360,18 @@ id_t lu_get_first_unused_id(struct lu_context *ctx, enum lu_entity_type type,
|
|
|
020281 |
/* Append a copy of VALUES to DEST */
|
|
|
020281 |
void lu_util_append_values(GValueArray *dest, GValueArray *values);
|
|
|
020281 |
|
|
|
020281 |
+#ifdef WITH_AUDIT
|
|
|
020281 |
+void lu_audit_logger(int type, const char *op, const char *name,
|
|
|
020281 |
+ unsigned int id, unsigned int result);
|
|
|
020281 |
+void lu_audit_logger_with_group(int type, const char *op, const char *name,
|
|
|
020281 |
+ unsigned int id, const char *grp,
|
|
|
020281 |
+ unsigned int result);
|
|
|
020281 |
+#else
|
|
|
020281 |
+#define lu_audit_logger(a, b, c, d, e)
|
|
|
020281 |
+#define lu_audit_logger_with_group(a, b, c, d, e, f)
|
|
|
020281 |
+#endif
|
|
|
020281 |
+#define AUDIT_NO_ID ((unsigned int) -1)
|
|
|
020281 |
+
|
|
|
020281 |
G_END_DECLS
|
|
|
020281 |
|
|
|
020281 |
#endif
|
|
|
020281 |
--
|
|
|
020281 |
2.17.1
|
|
|
020281 |
|