[Samba4] [FreeBSD] Conflicting definition of MACHINE macro
Timur I. Bakeyev
timur at com.bat.ru
Mon Oct 8 02:44:59 GMT 2007
Hi!
Here is another problem. Compilation of the policy subsystem fails due
to the conflict of the system-wide definition of the MACHINE macro and
local MACHINE macro in the lib/policy/lex.l. In the recent SVN versions
this was fixed by renaming macro into CLASS_MACHINE, but usage of the
simple name macros like CLASS, DEFAULT, etc. is asking for troubles, as
these names are too common and may be used somewhere else. The best
practice here is to give more application specific names to the macros,
let's say prepend them with the POL_ prefix in this case.
Here is the patch that implements this, feel free to make prefix even
more uniq :)
With regards,
Timur.
-------------- next part --------------
--- lib/policy/lex.l.orig Sun Sep 16 05:01:10 2007
+++ lib/policy/lex.l Sun Sep 16 05:07:34 2007
@@ -46,36 +46,36 @@
%%
-ACTIONLIST { return ACTIONLIST; }
-CATEGORY { return CATEGORY; }
-CHECKBOX { return CHECKBOX; }
-CLASS { return CLASS; }
-DELETE { return DEL; }
-DEFAULT { return DEFAULT; }
-DROPDOWNLIST { return DROPDOWNLIST; }
-EDITTEXT { return EDITTEXT; }
-END { return END; }
-EXPLAIN { return EXPLAIN; }
-ITEMLIST { return ITEMLIST; }
-KEYNAME { return KEYNAME; }
-MACHINE { return CLASS_MACHINE; }
-MIN { return MINIMUM; }
-MAX { return MAXIMUM; }
-NAME { return NAME; }
-NUMERIC { return NUMERIC; }
-PART { return PART; }
-POLICY { return POLICY; }
-REQUIRED { return REQUIRED; }
-SPIN { return SPIN; }
-SUPPORTED { return SUPPORTED; }
-TEXT { return TEXT; }
-USER { return CLASS_USER; }
-VALUE { return VALUE; }
-VALUENAME { return VALUENAME; }
-VALUEON { return VALUEON; }
-VALUEOFF { return VALUEOFF; }
-= { return EQUALS; }
-\[strings\] { return STRINGSSECTION; }
+ACTIONLIST { return POL_ACTIONLIST; }
+CATEGORY { return POL_CATEGORY; }
+CHECKBOX { return POL_CHECKBOX; }
+CLASS { return POL_CLASS; }
+DELETE { return POL_DEL; }
+DEFAULT { return POL_DEFAULT; }
+DROPDOWNLIST { return POL_DROPDOWNLIST; }
+EDITTEXT { return POL_EDITTEXT; }
+END { return POL_END; }
+EXPLAIN { return POL_EXPLAIN; }
+ITEMLIST { return POL_ITEMLIST; }
+KEYNAME { return POL_KEYNAME; }
+MACHINE { return POL_CLASS_MACHINE; }
+MIN { return POL_MINIMUM; }
+MAX { return POL_MAXIMUM; }
+NAME { return POL_NAME; }
+NUMERIC { return POL_NUMERIC; }
+PART { return POL_PART; }
+POLICY { return POL_POLICY; }
+REQUIRED { return POL_REQUIRED; }
+SPIN { return POL_SPIN; }
+SUPPORTED { return POL_SUPPORTED; }
+TEXT { return POL_TEXT; }
+USER { return POL_CLASS_USER; }
+VALUE { return POL_VALUE; }
+VALUENAME { return POL_VALUENAME; }
+VALUEON { return POL_VALUEON; }
+VALUEOFF { return POL_VALUEOFF; }
+= { return POL_EQUALS; }
+\[strings\] { return POL_STRINGSSECTION; }
[0-9]+ {
char *e, *y = yytext;
@@ -83,22 +83,22 @@
if(e == y)
error_message("malformed constant (%s)", yytext);
else
- return INTEGER;
+ return POL_INTEGER;
}
[A-Za-z\\{}][{}\-\\A-Za-z0-9_]* {
yylval.text = strdup ((const char *)yytext);
- return LITERAL;
+ return POL_LITERAL;
}
"!!"[A-Za-z][-A-Za-z0-9_]* {
yylval.text = strdup ((const char *)yytext);
- return LOOKUPLITERAL;
+ return POL_LOOKUPLITERAL;
}
[ \t]+
\n { lineno++; }
;[^\n]*\n { lineno++; }
-\"([^\n]+)\n { lineno++; yylval.text = strdup((const char *)yytext); return LITERAL; }
+\"([^\n]+)\n { lineno++; yylval.text = strdup((const char *)yytext); return POL_LITERAL; }
%%
#ifndef yywrap /* XXX */
-------------- next part --------------
Index: parse_adm.y
===================================================================
--- lib/policy/parse_adm.y (revision 25185)
+++ lib/policy/parse_adm.y (working copy)
@@ -35,34 +35,34 @@
int integer;
}
-%token CATEGORY
-%token CLASS
-%token CLASS_USER
-%token CLASS_MACHINE
-%token POLICY
-%token KEYNAME
-%token EXPLAIN
-%token VALUENAME
-%token VALUEON VALUEOFF
-%token PART
-%token ITEMLIST
-%token NAME
-%token VALUE
-%token NUMERIC EDITTEXT TEXT DROPDOWNLIST CHECKBOX
-%token MINIMUM MAXIMUM DEFAULT
-%token END
-%token ACTIONLIST
-%token DEL
-%token SUPPORTED
-%token <text> LITERAL
-%token <integer> INTEGER
-%token <text> LOOKUPLITERAL
-%token CLIENTEXT
-%token REQUIRED
-%token NOSORT
-%token SPIN
-%token EQUALS
-%token STRINGSSECTION
+%token POL_CATEGORY
+%token POL_CLASS
+%token POL_CLASS_USER
+%token POL_CLASS_MACHINE
+%token POL_POLICY
+%token POL_KEYNAME
+%token POL_EXPLAIN
+%token POL_VALUENAME
+%token POL_VALUEON POL_VALUEOFF
+%token POL_PART
+%token POL_ITEMLIST
+%token POL_NAME
+%token POL_VALUE
+%token POL_NUMERIC POL_EDITTEXT POL_TEXT POL_DROPDOWNLIST POL_CHECKBOX
+%token POL_MINIMUM POL_MAXIMUM POL_DEFAULT
+%token POL_END
+%token POL_ACTIONLIST
+%token POL_DEL
+%token POL_SUPPORTED
+%token <text> POL_LITERAL
+%token <integer> POL_INTEGER
+%token <text> POL_LOOKUPLITERAL
+%token POL_CLIENTEXT
+%token POL_REQUIRED
+%token POL_NOSORT
+%token POL_SPIN
+%token POL_EQUALS
+%token POL_STRINGSSECTION
%start admfile
@@ -72,59 +72,59 @@
classes: /* empty */ | class classes;
-class: CLASS classvalue categories;
-classvalue: CLASS_USER|CLASS_MACHINE;
+class: POL_CLASS classvalue categories;
+classvalue: POL_CLASS_USER|POL_CLASS_MACHINE;
categories: /* empty */ | category categories;
-string: LITERAL | LOOKUPLITERAL;
+string: POL_LITERAL | POL_LOOKUPLITERAL;
-category: CATEGORY string categoryitems END CATEGORY;
+category: POL_CATEGORY string categoryitems POL_END POL_CATEGORY;
categoryitem: explain | category | policy | keyname;
categoryitems: categoryitem categoryitems | /* empty */ ;
-policy: POLICY string policyitems END POLICY;
+policy: POL_POLICY string policyitems POL_END POL_POLICY;
policyitem: explain | keyname | valuename | valueon | valueoff | min | max | defaultvalue | supported | part;
policyitems: policyitem policyitems | /* empty */;
-valuetype: NUMERIC | EDITTEXT | TEXT | DROPDOWNLIST | CHECKBOX;
+valuetype: POL_NUMERIC | POL_EDITTEXT | POL_TEXT | POL_DROPDOWNLIST | POL_CHECKBOX;
-part: PART string valuetype partitems END PART;
+part: POL_PART string valuetype partitems POL_END POL_PART;
-spin: SPIN INTEGER;
+spin: POL_SPIN POL_INTEGER;
-partitem: keyname | valuename | valueon | valueoff | min | max | defaultvalue | itemlist | REQUIRED | spin;
+partitem: keyname | valuename | valueon | valueoff | min | max | defaultvalue | itemlist | POL_REQUIRED | spin;
partitems: partitem partitems | /* empty */;
-min: MINIMUM INTEGER;
-max: MAXIMUM INTEGER;
-defaultvalue: DEFAULT INTEGER;
+min: POL_MINIMUM POL_INTEGER;
+max: POL_MAXIMUM POL_INTEGER;
+defaultvalue: POL_DEFAULT POL_INTEGER;
-explain: EXPLAIN string;
-value: DEL | NUMERIC INTEGER;
+explain: POL_EXPLAIN string;
+value: POL_DEL | POL_NUMERIC POL_INTEGER;
-valueon: VALUEON value;
-valueoff: VALUEOFF value;
+valueon: POL_VALUEON value;
+valueoff: POL_VALUEOFF value;
-valuename: VALUENAME string;
-keyname: KEYNAME string;
+valuename: POL_VALUENAME string;
+keyname: POL_KEYNAME string;
-itemlist: ITEMLIST items END ITEMLIST;
-itemname: NAME string;
-itemvalue: VALUE value;
+itemlist: POL_ITEMLIST items POL_END POL_ITEMLIST;
+itemname: POL_NAME string;
+itemvalue: POL_VALUE value;
-item: itemname | itemvalue | DEFAULT | actionlist;
+item: itemname | itemvalue | POL_DEFAULT | actionlist;
items: /* empty */ | item items;
-supported: SUPPORTED string;
+supported: POL_SUPPORTED string;
-actionlist: ACTIONLIST actions END ACTIONLIST;
+actionlist: POL_ACTIONLIST actions POL_END POL_ACTIONLIST;
actions: valuename actions | itemvalue actions | /* empty */;
-variable: LITERAL EQUALS LITERAL;
+variable: POL_LITERAL POL_EQUALS POL_LITERAL;
variables: variable variables | /* empty */;
-strings: STRINGSSECTION variables;
+strings: POL_STRINGSSECTION variables;
%%
More information about the samba-technical
mailing list