Two little bugs

Maxim Dounin mdounin at mdounin.ru
Thu Dec 9 00:30:30 MSK 2010


Hello!

On Wed, Dec 08, 2010 at 11:42:48PM +0300, Igor Sysoev wrote:

> On Wed, Dec 08, 2010 at 08:42:35PM +0300, Maxim Dounin wrote:
> 
> > Hello!
> > 
> > On Wed, Dec 08, 2010 at 05:29:07PM +0000, Mark Alan wrote:
> > 
> > > On Wed, 8 Dec 2010 17:04:40 +0100, "Piotr Sikora"
> > > <piotr.sikora at frickle.com> wrote:
> > > > > 2. using relative path fails:
> > > > > sudo nginx -c nginx.conf
> > > > > with error:
> > > > > [emerg]: open() "/usr/local/nginx/nginx.conf" failed (2: No such
> > > > > file or directory)
> > > > 
> > > > It's supposed to fail.
> > > 
> > > How come?
> > > 
> > > I we have defined --conf-path=/etc/nginx/nginx.conf and that file
> > > exists at that place;
> > > I would expect that in case of any trouble at opening the
> > > config file stated in the command line,
> > > be it 'nginx -c nginx.conf' or 'nginx
> > > -c /whatever/path/anyfile-nginx.conf',
> > > nginx would try an [emerg]: open() "/etc/nginx/nginx.conf",
> > > not, as it is doing now, an [emerg]: open()
> > > "/usr/local/nginx/nginx.conf"
> > 
> > Relative path in -c is resolved from --prefix, that's why you see 
> > "/usr/local/nginx/" + "nginx.conf".
> > 
> > Note that I don't argue if it breaks POLA or not, it's just how it 
> > currently works.  I personally think that paths in command line 
> > arguments should be resolved from pwd.
> 
> If nginx has been built with empty prefix, i.e, --prefix= then it uses pwd.

Yes.  But I think command line arguments should use pwd regardless 
of prefix.

While resolving paths in config from prefix/conf_prefix is 
somewhat convenient (though conf_prefix semantics is questionable, 
too, it probably should always use dirname of current config 
instead) - using the same logic for command line arguments breaks 
POLA.  People expect both

$ vi test-configs/nginx.conf

and

$ nginx -t -c test-configs/nginx.conf

to work with the same file.

Maxim Dounin



More information about the nginx mailing list