From 0789973a4b487961f70c5eb6c31bb3c1e1589b71 Mon Sep 17 00:00:00 2001 From: Balbir Singh Date: Wed, 16 Apr 2008 11:59:32 +0000 Subject: [PATCH] use getgrnam() for groups Signed-off-by: Balbir Singh git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/branches/balbir@17 4f4bb910-9a46-0410-90c8-c897d4f1cd53 --- tests/libcg_ba.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/libcg_ba.cpp b/tests/libcg_ba.cpp index 6406dda6..a820196f 100644 --- a/tests/libcg_ba.cpp +++ b/tests/libcg_ba.cpp @@ -55,6 +55,7 @@ struct cgroup *cg::makenode(const string &name, const string &task_uid, gid_t tgid, cgid; struct cgroup *ccg; struct passwd *passwd; + struct group *grp; int ret; ccg = (struct cgroup *)malloc(sizeof(*ccg)); @@ -64,20 +65,20 @@ struct cgroup *cg::makenode(const string &name, const string &task_uid, return NULL; tuid = passwd->pw_uid; - passwd = getpwnam(task_gid.c_str()); - if (!passwd) + grp = getgrnam(task_gid.c_str()); + if (!grp) return NULL; - tgid = passwd->pw_gid; + tgid = grp->gr_gid; passwd = getpwnam(control_uid.c_str()); if (!passwd) return NULL; cuid = passwd->pw_uid; - passwd = getpwnam(control_gid.c_str()); - if (!passwd) + grp = getgrnam(control_gid.c_str()); + if (!grp) return NULL; - cgid = passwd->pw_gid; + cgid = grp->gr_gid; dbg("tuid %d, tgid %d, cuid %d, cgid %d\n", tuid, tgid, cuid, cgid); -- 2.47.2