]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
parse.y: extending cgroup names with "default"
authorJan Chaloupka <jchaloup@redhat.com>
Mon, 8 Sep 2014 11:28:18 +0000 (13:28 +0200)
committerJan Safranek <jsafrane@redhat.com>
Mon, 8 Sep 2014 11:44:34 +0000 (13:44 +0200)
default is used as a keyword for defining default group permissions. Having "default" as a group name (with double quotes "), parsing is successfull. Howerver, using default without double quotes, parsing fails. This patch modifies parsing rule and lex for default group name without double quotes.

Tested on:

default {
perm {
task {
uid = root;
gid = rgel6610;
fperm = 770;
}
admin {
uid = root;
gid = root;
dperm = 775;
fperm = 744;
}
}
}

group default {
        cpuset {
                cpuset.mems = 0;
                cpuset.cpus = 0;
        }
}

Signed-off-by: Jan Chaloupka <jchaloup@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
src/lex.l
src/parse.y

index d7bf575a64648714eae15d98018a95189f5fe86a..ecd212c4ccd27cb91815922a80cb4736a78c58ef 100644 (file)
--- a/src/lex.l
+++ b/src/lex.l
@@ -42,7 +42,7 @@ jmp_buf parser_error_env;
 "group"                {return GROUP;}
 "namespace"    {return NAMESPACE;}
 "template"     {return TEMPLATE;}
-"default"      {return DEFAULT;}
+"default"      {yylval.name = strdup(yytext); return DEFAULT;}
 [a-zA-Z0-9_\-\/\.\,\%\@\\]+ {yylval.name = strdup(yytext); return ID;}
 \"[^"]*\" {yylval.name = strdup(yytext+1); yylval.name[strlen(yylval.name)-1] = '\0'; return ID; }
 .      {return yytext[0];}
index 9adbc0ef0270bc91716ca6838dd90a2072864b52..98f7699d2c00e7e19aa07f961223cbbc2fb6a684 100644 (file)
@@ -45,9 +45,9 @@ int yywrap(void)
        int val;
        struct cgroup_dictionary *values;
 }
-%type <name> ID
+%type <name> ID DEFAULT
 %type <val> mountvalue_conf mount task_namevalue_conf admin_namevalue_conf
-%type <val> admin_conf task_conf task_or_admin group_conf group start
+%type <val> admin_conf task_conf task_or_admin group_conf group start group_name
 %type <val> namespace namespace_conf default default_conf
 %type <values> namevalue_conf
 %type <val> template template_conf
@@ -99,7 +99,7 @@ default_conf
        }
        ;
 
-group   :       GROUP ID '{' group_conf '}'
+group   :       GROUP group_name '{' group_conf '}'
        {
                $$ = $4;
                if ($$) {
@@ -119,6 +119,16 @@ group   :       GROUP ID '{' group_conf '}'
        }
         ;
 
+group_name
+       :       ID
+       {
+               $$ = $1;
+       }
+       |       DEFAULT
+       {
+               $$ = $1;
+       }
+
 group_conf
         :       ID '{' namevalue_conf '}'
        {