[syslog-ng] Config parse error in syslog-ng 2.0.0

Balazs Scheidler bazsi at balabit.hu
Mon Nov 27 12:01:29 CET 2006


On Sun, 2006-11-26 at 13:15 +0100, Jacek Kalinski wrote:
> Hi,
> 
> I have a config file working fine with syslog-ng-1.6.11.
> But the same config won't work with 2.0.0.
> 
> Problem (as I've checked, compiling syslog-ng with YYDEBUG) is in:
> dir_owner(0); dir_group(0); owner(0); group(0);
> 
> 2 first lines of config:
> options { dir_perm(0700); perm(0600); chain_hostnames(no); stats(1200);
>           keep_hostname(yes); dir_owner(0); dir_group(0); owner(0);
> group(0); };
> 
> 
> Debug from checking syntax:
> ...
> Reducing stack by rule 212 (line 731), KW_STATS_FREQ '(' NUMBER ')' ->
> options_item
> Stack now 0 4 18 73 156 73 156 73 156
> Entering state 73
> Reading a token: Next token is token ';' ()
> Shifting token ';' ()
> Entering state 156
> Reading a token: Next token is token KW_KEEP_HOSTNAME ()
> Shifting token KW_KEEP_HOSTNAME ()
> Entering state 42
> Reading a token: Next token is token '(' ()
> Shifting token '(' ()
> Entering state 125
> Reading a token: Next token is token KW_YES ()
> Shifting token KW_YES ()
> Entering state 206
> Reducing stack by rule 271 (line 868), KW_YES -> yesno
> Stack now 0 4 18 73 156 73 156 73 156 73 156 42 125
> Entering state 211
> Reading a token: Next token is token ')' ()
> Shifting token ')' ()
> Entering state 308
> Reducing stack by rule 217 (line 736), KW_KEEP_HOSTNAME '(' yesno ')' ->
> options_item
> Stack now 0 4 18 73 156 73 156 73 156 73 156
> Entering state 73
> Reading a token: Next token is token ';' ()
> Shifting token ';' ()
> Entering state 156
> Reading a token: Next token is token KW_DIR_OWNER ()
> Shifting token KW_DIR_OWNER ()
> Entering state 66
> Reading a token: Next token is token '(' ()
> Shifting token '(' ()
> Entering state 149
> Reading a token: Next token is token NUMBER ()
> syntax error at 2
> Error: popping token '(' ()
> Stack now 0 4 18 73 156 73 156 73 156 73 156 73 156 66
> Error: popping token KW_DIR_OWNER ()
> Stack now 0 4 18 73 156 73 156 73 156 73 156 73 156
> Error: popping token ';' ()
> Stack now 0 4 18 73 156 73 156 73 156 73 156 73
> Error: popping nterm options_item ()
> Stack now 0 4 18 73 156 73 156 73 156 73 156
> Error: popping token ';' ()
> Stack now 0 4 18 73 156 73 156 73 156 73
> Error: popping nterm options_item ()
> Stack now 0 4 18 73 156 73 156 73 156
> Error: popping token ';' ()
> Stack now 0 4 18 73 156 73 156 73
> Error: popping nterm options_item ()
> Stack now 0 4 18 73 156 73 156
> Error: popping token ';' ()
> Stack now 0 4 18 73 156 73
> Error: popping nterm options_item ()
> Stack now 0 4 18 73 156
> Error: popping token ';' ()
> Stack now 0 4 18 73
> Error: popping nterm options_item ()
> Stack now 0 4 18
> Error: popping token '{' ()
> Stack now 0 4
> Error: popping token KW_OPTIONS ()
> Stack now 0
> Cleanup: discarding lookahead token NUMBER ()
> 
> 
> When I change 'dir_owner' to:
> dir_owner(root)
> next error found is on 'dir_group':
> 
> Reading a token: Next token is token KW_DIR_GROUP ()
> Shifting token KW_DIR_GROUP ()
> Entering state 67
> Reading a token: Next token is token '(' ()
> Shifting token '(' ()
> Entering state 150
> Reading a token: Next token is token NUMBER ()
> syntax error at 2
> 
> 
> BUT manual, says:
>        dir_owner(uid)
>               User id.
> documantecion says:
> â                       â            â              âThe default owner
> of     â
> âdir_owner()            âuserid      âroot          ânewly
> created            â
> â                       â            â             
> âdirectories.             â
> 
> The same problem with: owner and group options (so all options working
> with UID/GID).
> 
> Is it an error in my configuration, or in docs? :)
> Is it possible to keep compatibility with syslog-1.6 (so use UID/GID
> instead of username)?

Can you check if this patch fixes this problem? (tomorrow's snapshot
should also be ok)


--- orig/src/cfg-grammar.y
+++ mod/src/cfg-grammar.y
@@ -183,6 +183,7 @@ gint last_addr_family = AF_INET;
 %type   <num> dnsmode
 
 %type  <cptr> string
+%type  <cptr> string_or_number
 
 %%
 
@@ -339,8 +340,8 @@ source_afunix_options
        ;
 
 source_afunix_option
-       : KW_OWNER '(' string ')'               { afunix_sd_set_uid(last_driver, $3); free($3); }
-       | KW_GROUP '(' string ')'               { afunix_sd_set_gid(last_driver, $3); free($3); }
+       : KW_OWNER '(' string_or_number ')'     { afunix_sd_set_uid(last_driver, $3); free($3); }
+       | KW_GROUP '(' string_or_number ')'     { afunix_sd_set_gid(last_driver, $3); free($3); }
        | KW_PERM '(' NUMBER ')'                { afunix_sd_set_perm(last_driver, $3); }
        | KW_OPTIONAL '(' yesno ')'             { last_driver->optional = $3; }
        | source_afsocket_stream_params         {}
@@ -494,11 +495,11 @@ dest_affile_option
        | KW_COMPRESS '(' yesno ')'             { affile_dd_set_compress(last_driver, $3); }
        | KW_ENCRYPT '(' yesno ')'              { affile_dd_set_encrypt(last_driver, $3); }
 */
-       | KW_OWNER '(' string ')'               { affile_dd_set_file_uid(last_driver, $3); free($3); }
-       | KW_GROUP '(' string ')'               { affile_dd_set_file_gid(last_driver, $3); free($3); }
+       | KW_OWNER '(' string_or_number ')'     { affile_dd_set_file_uid(last_driver, $3); free($3); }
+       | KW_GROUP '(' string_or_number ')'     { affile_dd_set_file_gid(last_driver, $3); free($3); }
        | KW_PERM '(' NUMBER ')'                { affile_dd_set_file_perm(last_driver, $3); }
-       | KW_DIR_OWNER '(' string ')'           { affile_dd_set_dir_uid(last_driver, $3); free($3); }
-       | KW_DIR_GROUP '(' string ')'           { affile_dd_set_dir_gid(last_driver, $3); free($3); }
+       | KW_DIR_OWNER '(' string_or_number ')' { affile_dd_set_dir_uid(last_driver, $3); free($3); }
+       | KW_DIR_GROUP '(' string_or_number ')' { affile_dd_set_dir_gid(last_driver, $3); free($3); }
        | KW_DIR_PERM '(' NUMBER ')'            { affile_dd_set_dir_perm(last_driver, $3); }
        | KW_CREATE_DIRS '(' yesno ')'          { affile_dd_set_create_dirs(last_driver, $3); }
        | KW_REMOVE_IF_OLDER '(' NUMBER ')'     { affile_dd_set_remove_if_older(last_driver, $3); }
@@ -526,8 +527,8 @@ dest_afpipe_options
 
 dest_afpipe_option
        : dest_writer_option
-       | KW_OWNER '(' string ')'               { affile_dd_set_file_uid(last_driver, $3); free($3); }
-       | KW_GROUP '(' string ')'               { affile_dd_set_file_gid(last_driver, $3); free($3); }
+       | KW_OWNER '(' string_or_number ')'     { affile_dd_set_file_uid(last_driver, $3); free($3); }
+       | KW_GROUP '(' string_or_number ')'     { affile_dd_set_file_gid(last_driver, $3); free($3); }
        | KW_PERM '(' NUMBER ')'                { affile_dd_set_file_perm(last_driver, $3); }
        ;
 
@@ -760,11 +761,11 @@ options_item
        | KW_GC_BUSY_THRESHOLD '(' NUMBER ')'   { /* ignored */; }
        | KW_GC_IDLE_THRESHOLD '(' NUMBER ')'   { /* ignored */; }
        | KW_CREATE_DIRS '(' yesno ')'          { configuration->create_dirs = $3; }
-       | KW_OWNER '(' string ')'               { cfg_file_owner_set(configuration, $3); free($3); }
-       | KW_GROUP '(' string ')'               { cfg_file_group_set(configuration, $3); free($3); }
+       | KW_OWNER '(' string_or_number ')'     { cfg_file_owner_set(configuration, $3); free($3); }
+       | KW_GROUP '(' string_or_number ')'     { cfg_file_group_set(configuration, $3); free($3); }
        | KW_PERM '(' NUMBER ')'                { cfg_file_perm_set(configuration, $3); }
-       | KW_DIR_OWNER '(' string ')'           { cfg_dir_owner_set(configuration, $3); free($3); }
-       | KW_DIR_GROUP '(' string ')'           { cfg_dir_group_set(configuration, $3); free($3); }
+       | KW_DIR_OWNER '(' string_or_number ')' { cfg_dir_owner_set(configuration, $3); free($3); }
+       | KW_DIR_GROUP '(' string_or_number ')' { cfg_dir_group_set(configuration, $3); free($3); }
        | KW_DIR_PERM '(' NUMBER ')'            { cfg_dir_perm_set(configuration, $3); }
        | KW_DNS_CACHE '(' yesno ')'            { configuration->use_dns_cache = $3; }
        | KW_DNS_CACHE_SIZE '(' NUMBER ')'      { configuration->dns_cache_size = $3; }
@@ -881,6 +882,10 @@ string
        | STRING
        ;
 
+string_or_number
+        : STRING                                { $$ = $1; }
+        | NUMBER                                { char buf[16]; snprintf(buf, sizeof(buf), "%d", $1); $$ = strdup(buf); }
+
 %%
 
 extern int linenum;





-- 
Bazsi



More information about the syslog-ng mailing list