Hi Jan,

Thank you for review.

Jan Safranek wrote:
>> [snip]
>> @@ -486,8 +488,20 @@ static int cgroup_parse_rules(bool cache, uid_t
>> muid, gid_t mgid)
>>              matched = true;
>>          }
>>  
>> -        if (!cache && !matched)
>> -            continue;
>> +        if (!cache) {
>> +            if (!matched)
>> +                continue;
>> +            if (len_procname) {
>> +                /*
>> +                 * If there is a rule based on process name,
>> +                 * it should be matched with mprocname.
>> +                 */
>> +                if (!mprocname)
>> +                    continue;
>> +                if (strncmp(mprocname, procname, len_procname))
>> +                    continue;
> 
> Why not strcmp? procname can be "/usr/bin/at" and mprocname e.g.
> "/usr/bin/attr"...

Right, I will fix it.


>> [snip]
>> +retry:
>>      while (ret) {
>>          /* The wildcard rule always matches. */
>>          if ((ret->uid == CGRULE_WILD) && (ret->gid == CGRULE_WILD)) {
>> -            goto finished;
>> +            goto found_uid_gid_rule;
>>          }
>>  
>>          /* This is the simple case of the UID matching. */
>>          if (ret->uid == uid) {
>> -            goto finished;
>> +            goto found_uid_gid_rule;
>>          }
>>  
>>          /* This is the simple case of the GID matching. */
>>          if (ret->gid == gid) {
>> -            goto finished;
>> +            goto found_uid_gid_rule;
>>          }
>>  
>>          /* If this is a group rule, the UID might be a member. */
>> @@ -1861,7 +1877,7 @@ static struct cgroup_rule
>> *cgroup_find_matching_rule_uid_gid(const uid_t uid,
>>              /* If UID is a member of group, we matched. */
>>              for (i = 0; grp->gr_mem[i]; i++) {
>>                  if (!(strcmp(usr->pw_name, grp->gr_mem[i])))
>> -                    goto finished;
>> +                    goto found_uid_gid_rule;
>>              }
>>          }
>>  
>> @@ -1872,6 +1888,16 @@ static struct cgroup_rule
>> *cgroup_find_matching_rule_uid_gid(const uid_t uid,
>>      /* If we get here, no rules matched. */
>>      ret = NULL;
>>  
>> +found_uid_gid_rule:
>> +    if (ret && procname) {
>> +        if (!ret->procname)
>> +            /* If no process name in a rule, that means wildcard */
>> +            goto finished;
>> +        if (!strcmp(ret->procname, procname))
>> +            goto finished;
>> +        ret = ret->next;
>> +        goto retry;
> 
> It is extremely ugly to leave the loop to compare procname and enter it
> again if it does not match! I admit the original code was not much
> better, all these gotos and labels... What's wrong with good old break ?

I see.
I will change this code without using gotos and labels.


Thanks
Ken'ichi Ohmichi


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to