From 132ccd66fb7f7bf583a6ddbed031a2bf5eef473c Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Thu, 5 Mar 2009 15:39:26 -0500 Subject: Implement GetCachedUsers in the InfoPipe This function allows a caller to retrieve a list of users who have logged in on the system, specifying an optional minimum last login time to trim the list. I modified sysdb_enumpwent to accept an optional search argument. GetCachedUsers takes advantage of this argument to limit the search by the last login time. I also found and fixed a few additional low-memory conditions around D-BUS message replies. --- server/db/sysdb.h | 3 +++ server/db/sysdb_search.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'server/db') diff --git a/server/db/sysdb.h b/server/db/sysdb.h index 544a81f5..1302cddb 100644 --- a/server/db/sysdb.h +++ b/server/db/sysdb.h @@ -84,6 +84,8 @@ #define SYSDB_INITGR_LEGACY_FILTER "(&(objectclass="SYSDB_GROUP_CLASS")("SYSDB_LEGACY_MEMBER"=%s))" +#define SYSDB_GETCACHED_FILTER "(&(objectclass="SYSDB_USER_CLASS")("SYSDB_USER_ATTR_LAST_LOGIN">=%llu))" + #define SYSDB_PW_ATTRS {SYSDB_PW_NAME, SYSDB_PW_UIDNUM, \ SYSDB_PW_GIDNUM, SYSDB_PW_FULLNAME, \ SYSDB_PW_HOMEDIR, SYSDB_PW_SHELL, \ @@ -199,6 +201,7 @@ int sysdb_enumpwent(TALLOC_CTX *mem_ctx, struct sysdb_ctx *ctx, const char *domain, bool legacy, + const char *expression, sysdb_callback_t fn, void *ptr); int sysdb_getgrnam(TALLOC_CTX *mem_ctx, diff --git a/server/db/sysdb_search.c b/server/db/sysdb_search.c index ff18419e..8b14221d 100644 --- a/server/db/sysdb_search.c +++ b/server/db/sysdb_search.c @@ -264,6 +264,7 @@ int sysdb_enumpwent(TALLOC_CTX *mem_ctx, struct sysdb_ctx *ctx, const char *domain, bool legacy, + const char *expression, sysdb_callback_t fn, void *ptr) { static const char *attrs[] = SYSDB_PW_ATTRS; @@ -278,7 +279,11 @@ int sysdb_enumpwent(TALLOC_CTX *mem_ctx, return ENOMEM; } - sctx->expression = SYSDB_PWENT_FILTER; + if (expression) + sctx->expression = expression; + else + sctx->expression = SYSDB_PWENT_FILTER; + sctx->attrs = attrs; return sysdb_operation(mem_ctx, ctx, user_search, sctx); -- cgit