On Monday 07 September 2009 19:49:02 Ossama Khayat wrote:
> it's -t or --test
>
> # cherokee -t
> Test on /etc/cherokee/cherokee.conf: OK
>

huhu great thanks guys!

I was testing how reliable this mechanism is and I've experienced some quirks 
:S

scenario 1:
        Change or insert an invalid command in the config file: 
                
                server!bind!1!port = 80
                seddsdrver!bind!1!tls = 0 <---- Changed
                w00t                                      <---- Added
                server!bind!2!port = 443
        Test on /var/www/inkzee/config/cherokee.conf: OK

scenario 2: Removed a part of a config line:

                server!bind!!tls = 0 <--- Removed a '1'
        PID 22294: received a signal=11

scenario 3: Remove the arguments of some lines:

                server!bind!1!port = <---- Removed the port number
        PID 22299: received a signal=11

It seems the checker needs some extra checks :S 

I took a look at the code but the parser stuff is slightly more complex than I 
was expecting, but from what I learned, it blindly loads the config file 
following some basic rules and creates all the nodes. So for example, in the 
case of the server port, it loads the config file, and the blindly uses srv-
>listeners[x]->port (not exactly like that but u get the point) to bind to 
that port without a single safe check.

Some offending code:
cherokee_config_node_read_int (cherokee_config_node_t *conf, const char *key, 
int *num)
{
        ret_t                   ret;
        cherokee_config_node_t *tmp;

        ret = cherokee_config_node_get (conf, key, &tmp);
        if (ret != ret_ok) return ret;

        *num = atoi (tmp->val.buf); <--- hu hu w00t, we should check here
        return ret_ok;
}

I don't know how the node structure goes (if I did I would gladly fix it 
myself), but I'm sure this is a quick fix for someone with a deeper knowledge 
than mine of the code.

Do you guys want me to fill this is a bug/request? 

Alex

PS: server!bind!1!port=80 <-- this fails, imho the parser should detect this 
situation: key + '=' and be smart about it. It's easy to forget a space :(

> regards,
> Ossama
>
>
>
>
> ________________________________
> From: Juan José Amor <[email protected]>
> To: [email protected]
> Cc: Cherokee Mailing List <[email protected]>
> Sent: Monday, September 7, 2009 8:32:33 PM
> Subject: Re: [Cherokee] Small config question
>
> Alejandro Barrera escribió:
> > Hey guys,
> >     Just wondering, is there a cmdline switch to test a config file? I
> > mean, is there a way I can of do a dry run of a config file:
> >
> >     cherokee --check-config myTesting.config
> >     ERRRR!!: Couldn't parse line 34: Invalid command
> >
> >     Some like that hehe
>
> May be:
>
> cherokee --test --config=MyTesting.config
>
>
> Best regards
>
> >     If it doesn't exists, it would be a great feature :)
> >     Alex

-- 
http://www.neurosecurity.com

"We must be the change we wish to see in the world"
Mahatma Gandhi
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee

Reply via email to