]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Use cache when reading /etc/passwd file
authorPeter Schiffer <pschiffe@redhat.com>
Tue, 25 Jun 2013 04:37:41 +0000 (06:37 +0200)
committerPeter Schiffer <pschiffe@redhat.com>
Tue, 25 Jun 2013 04:37:41 +0000 (06:37 +0200)
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 <pschiffe@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
src/pam/pam_cgroup.c

index c4ce633a3295c47a13561a9d4aff659f96068ebf..1d78b814e63a99969fb4fbee94413f0f6aac38c1 100644 (file)
@@ -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"