]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
use getgrnam() for groups
authorBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 16 Apr 2008 11:59:32 +0000 (11:59 +0000)
committerBalbir Singh <balbir@linux.vnet.ibm.com>
Wed, 16 Apr 2008 11:59:32 +0000 (11:59 +0000)
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/branches/balbir@17 4f4bb910-9a46-0410-90c8-c897d4f1cd53

tests/libcg_ba.cpp

index 6406dda6c401ae2495e18a09f827d5a7f9f58692..a820196f77530a7513723b9ccc3dc84839da59a6 100644 (file)
@@ -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);