From ac6173f74922b7dbc46e87370b9bc42cd0fa892d Mon Sep 17 00:00:00 2001 From: Peter Schiffer Date: Tue, 25 Jun 2013 06:37:41 +0200 Subject: [PATCH] Use cache when reading /etc/passwd file Currently, libcgroup code reads /etc/passwd file once for every line in the cgrules.conf file, what can have performance impact on the login times if system contains thousands of users and cgrules.conf contains thousands of lines. This patch adds CGFLAG_USECACHE flag to the cgroup_change_cgroup_uid_gid() function call which enables cache usage, and thus speeds up login times on those systems. Signed-off-by: Peter Schiffer Acked-by: Jan Safranek Acked-by: Ivana Hutarova Varekova --- src/pam/pam_cgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pam/pam_cgroup.c b/src/pam/pam_cgroup.c index c4ce633a..1d78b814 100644 --- a/src/pam/pam_cgroup.c +++ b/src/pam/pam_cgroup.c @@ -137,7 +137,8 @@ PAM_EXTERN int pam_sm_open_session(pam_handle_t *pamh, int flags, /* Note: We are using default gid here. Is there a way to determine * under what egid service will be provided? */ - ret = cgroup_change_cgroup_uid_gid(pwd->pw_uid, pwd->pw_gid, pid); + ret = cgroup_change_cgroup_uid_gid_flags(pwd->pw_uid, + pwd->pw_gid, pid, CGFLAG_USECACHE); if (ret) { if (ctrl & PAM_DEBUG_ARG) pam_syslog(pamh, LOG_ERR, "Change of cgroup for process" -- 2.47.2