aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Jackson <Ian.Jackson@eu.citrix.com>2011-01-11 19:31:41 +0000
committerIan Jackson <Ian.Jackson@eu.citrix.com>2011-01-11 19:31:41 +0000
commit54fbaf446bb350aff4dd5c4b0f44557186dd7d31 (patch)
tree935bc0f929a867e75ad01a6d21cc97ea8f1c02da
parent3e58e5d9c1fdc16dee74b891403f30e987965877 (diff)
downloadxen-54fbaf446bb350aff4dd5c4b0f44557186dd7d31.tar.gz
xen-54fbaf446bb350aff4dd5c4b0f44557186dd7d31.tar.bz2
xen-54fbaf446bb350aff4dd5c4b0f44557186dd7d31.zip
libxl: config parser: print warning for apparent arbitrary python
The characters - + . ( ) : are not legal in xl config files but are valid Python and use of at least one of them is almost essential for writing arbitrary Python in the config file. So if we see one of these during lexing, note it, and then after the parse is complete if it failed we print a special extra warning. Currently this warning refers to the nonexistent wiki page http://wiki.xen.org/xenwiki/PythonInXlConfig which will have to be written (and/or given a better name) before the actual 4.1 release. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r--tools/libxl/libxlu_cfg.c9
-rw-r--r--tools/libxl/libxlu_cfg_i.h2
-rw-r--r--tools/libxl/libxlu_cfg_l.c86
-rw-r--r--tools/libxl/libxlu_cfg_l.h2
-rw-r--r--tools/libxl/libxlu_cfg_l.l6
-rw-r--r--tools/libxl/libxlu_internal.h2
6 files changed, 63 insertions, 44 deletions
diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c
index 821b8c04c4..663fdf9a02 100644
--- a/tools/libxl/libxlu_cfg.c
+++ b/tools/libxl/libxlu_cfg.c
@@ -24,6 +24,7 @@ static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg) {
ctx->cfg= cfg;
ctx->err= 0;
ctx->lexerrlineno= -1;
+ ctx->likely_python= 0;
ctx->scanner= 0;
e= xlu__cfg_yylex_init_extra(ctx, &ctx->scanner);
@@ -44,6 +45,14 @@ static void parse(CfgParseContext *ctx) {
int r;
r= xlu__cfg_yyparse(ctx);
if (r) assert(ctx->err);
+
+ if (ctx->err && ctx->likely_python) {
+ fputs(
+ "warning: Config file looks like it contains Python code.\n"
+ "warning: Arbitrary Python is no longer supported.\n"
+ "warning: See http://wiki.xen.org/xenwiki/PythonInXlConfig\n",
+ ctx->cfg->report);
+ }
}
int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) {
diff --git a/tools/libxl/libxlu_cfg_i.h b/tools/libxl/libxlu_cfg_i.h
index f6b241cf09..88d2a02811 100644
--- a/tools/libxl/libxlu_cfg_i.h
+++ b/tools/libxl/libxlu_cfg_i.h
@@ -16,6 +16,8 @@ char *xlu__cfgl_dequote(CfgParseContext*, const char *src);
void xlu__cfg_yyerror(YYLTYPE *locp, CfgParseContext*, char const *msg);
void xlu__cfgl_lexicalerror(CfgParseContext*, char const *msg);
+void xlu__cfgl_likely_python(CfgParseContext *ctx);
+
/* Why oh why does bison not declare this in its autogenerated .h ? */
diff --git a/tools/libxl/libxlu_cfg_l.c b/tools/libxl/libxlu_cfg_l.c
index 917a156701..710ac8f2d0 100644
--- a/tools/libxl/libxlu_cfg_l.c
+++ b/tools/libxl/libxlu_cfg_l.c
@@ -370,8 +370,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 15
-#define YY_END_OF_BUFFER 16
+#define YY_NUM_RULES 16
+#define YY_END_OF_BUFFER 17
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -392,17 +392,17 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 4, 5, 1, 1, 1, 6, 1,
- 1, 1, 1, 7, 1, 1, 1, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 1, 9, 1,
- 10, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 4, 5, 1, 1, 1, 6, 7,
+ 7, 1, 7, 8, 7, 7, 1, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 7, 10, 1,
+ 11, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 11, 12, 13, 1, 14, 1, 15, 15, 15, 15,
+ 12, 13, 14, 1, 15, 1, 16, 16, 16, 16,
- 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 15,
- 16, 16, 1, 1, 1, 1, 1, 1, 1, 1,
+ 16, 16, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 16,
+ 17, 17, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -419,54 +419,56 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst flex_int32_t yy_meta[17] =
+static yyconst flex_int32_t yy_meta[18] =
{ 0,
- 1, 2, 3, 1, 1, 1, 1, 4, 1, 1,
- 1, 1, 1, 4, 4, 4
+ 1, 2, 3, 1, 1, 1, 1, 1, 4, 1,
+ 1, 1, 1, 1, 4, 4, 4
} ;
-static yyconst flex_int16_t yy_base[40] =
+static yyconst flex_int16_t yy_base[41] =
{ 0,
- 0, 0, 15, 17, 51, 54, 54, 54, 17, 45,
- 16, 54, 15, 54, 54, 54, 54, 0, 0, 54,
- 54, 20, 54, 0, 37, 54, 19, 54, 0, 18,
- 0, 0, 54, 33, 37, 41, 45, 23, 49
+ 0, 0, 16, 18, 50, 56, 56, 56, 18, 39,
+ 17, 56, 56, 16, 56, 56, 56, 56, 0, 0,
+ 56, 56, 20, 56, 0, 26, 56, 21, 56, 0,
+ 19, 0, 0, 56, 35, 39, 43, 47, 22, 51
} ;
-static yyconst flex_int16_t yy_def[40] =
+static yyconst flex_int16_t yy_def[41] =
{ 0,
- 33, 1, 34, 34, 33, 33, 33, 33, 35, 36,
- 37, 33, 33, 33, 33, 33, 33, 38, 39, 33,
- 33, 35, 33, 35, 36, 33, 37, 33, 37, 33,
- 38, 39, 0, 33, 33, 33, 33, 33, 33
+ 34, 1, 35, 35, 34, 34, 34, 34, 36, 37,
+ 38, 34, 34, 34, 34, 34, 34, 34, 39, 40,
+ 34, 34, 36, 34, 36, 37, 34, 38, 34, 38,
+ 34, 39, 40, 0, 34, 34, 34, 34, 34, 34
} ;
-static yyconst flex_int16_t yy_nxt[71] =
+static yyconst flex_int16_t yy_nxt[74] =
{ 0,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 6, 17, 6, 18, 18, 20, 21, 20, 21,
- 23, 28, 30, 23, 28, 30, 31, 29, 24, 30,
- 29, 24, 30, 19, 19, 19, 19, 22, 22, 26,
- 22, 25, 25, 25, 25, 27, 27, 26, 27, 32,
- 33, 33, 32, 5, 33, 33, 33, 33, 33, 33,
- 33, 33, 33, 33, 33, 33, 33, 33, 33, 33
+ 16, 17, 6, 18, 6, 19, 19, 21, 22, 21,
+ 22, 24, 29, 24, 31, 32, 29, 31, 27, 30,
+ 25, 31, 25, 30, 31, 20, 20, 20, 20, 23,
+ 23, 27, 23, 26, 26, 26, 26, 28, 28, 34,
+ 28, 33, 34, 34, 33, 5, 34, 34, 34, 34,
+ 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
+ 34, 34, 34
} ;
-static yyconst flex_int16_t yy_chk[71] =
+static yyconst flex_int16_t yy_chk[74] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 3, 3, 4, 4,
- 9, 11, 13, 22, 27, 30, 38, 11, 9, 13,
- 27, 22, 30, 34, 34, 34, 34, 35, 35, 25,
- 35, 36, 36, 36, 36, 37, 37, 10, 37, 39,
- 5, 0, 39, 33, 33, 33, 33, 33, 33, 33,
- 33, 33, 33, 33, 33, 33, 33, 33, 33, 33
+ 1, 1, 1, 1, 1, 1, 1, 3, 3, 4,
+ 4, 9, 11, 23, 14, 39, 28, 31, 26, 11,
+ 9, 14, 23, 28, 31, 35, 35, 35, 35, 36,
+ 36, 10, 36, 37, 37, 37, 37, 38, 38, 5,
+ 38, 40, 0, 0, 40, 34, 34, 34, 34, 34,
+ 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
+ 34, 34, 34
} ;
/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[16] =
+static yyconst flex_int32_t yy_rule_can_match_eol[17] =
{ 0,
-0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, };
+0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
@@ -496,7 +498,7 @@ int xlu__cfg_yyget_column(yyscan_t yyscanner);
void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner);
-#line 500 "libxlu_cfg_l.c"
+#line 502 "libxlu_cfg_l.c"
#define INITIAL 0
#define lexerr 1
@@ -744,7 +746,7 @@ YY_DECL
#line 37 "libxlu_cfg_l.l"
-#line 748 "libxlu_cfg_l.c"
+#line 750 "libxlu_cfg_l.c"
yylval = yylval_param;
@@ -2094,4 +2096,4 @@ void xlu__cfg_yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
-#line 82 "libxlu_cfg_l.l"
+#line 88 "libxlu_cfg_l.l"
diff --git a/tools/libxl/libxlu_cfg_l.h b/tools/libxl/libxlu_cfg_l.h
index 26f6dd63d1..02a0803737 100644
--- a/tools/libxl/libxlu_cfg_l.h
+++ b/tools/libxl/libxlu_cfg_l.h
@@ -350,7 +350,7 @@ extern int xlu__cfg_yylex \
#undef YY_DECL
#endif
-#line 82 "libxlu_cfg_l.l"
+#line 88 "libxlu_cfg_l.l"
#line 356 "libxlu_cfg_l.h"
#undef xlu__cfg_yyIN_HEADER
diff --git a/tools/libxl/libxlu_cfg_l.l b/tools/libxl/libxlu_cfg_l.l
index ac6b0112c2..21c11ff747 100644
--- a/tools/libxl/libxlu_cfg_l.l
+++ b/tools/libxl/libxlu_cfg_l.l
@@ -64,6 +64,12 @@ void xlu__cfg_yyset_column(int column_no, yyscan_t yyscanner);
GOT(STRING);
}
+[+-.():] {
+ ctx->likely_python= 1;
+ BEGIN(lexerr);
+ yymore();
+ }
+
. {
BEGIN(lexerr);
yymore();
diff --git a/tools/libxl/libxlu_internal.h b/tools/libxl/libxlu_internal.h
index fd7addcfd6..e251a639a8 100644
--- a/tools/libxl/libxlu_internal.h
+++ b/tools/libxl/libxlu_internal.h
@@ -41,7 +41,7 @@ struct XLU_Config {
typedef struct {
XLU_Config *cfg;
- int err, lexerrlineno;
+ int err, lexerrlineno, likely_python;
void *scanner;
} CfgParseContext;