Skip site navigation (1) Skip section navigation (2)

Re: pg_ctl -D canonicalization

From: "Magnus Hagander" <mha(at)sollentuna(dot)net>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: pg_ctl -D canonicalization
Date: 2004-10-27 08:04:57
Message-ID: 6BCB9D8A16AC4241919521715F4D8BCE476024@algol.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-patches
> > It seems pg_ctl calls canonicalize_path() only on the path as being 
> > used to access for example the pid file, and not the path 
> that is sent 
> > along to the postmaster.
> > Specifically, this causes failure on win32 when a path is 
> passed with 
> > a trailing backslash, when it's inside quotes such as:
> > pg_ctl start -D "c:\program fiels\postgresql\data\"
> > 
> > The quotes are of course necessary since there are spaces in the 
> > filename. In my specific case the trailing backslash is 
> automatically 
> > added by windows installer. but other cases when the backslash is 
> > added can easily be seen...
> > 
> > Attached patch makes pg_ctl call canonicalize_path() on the path as 
> > passed on the commandline as well.
> > 
> > I have only tested this on win32, where it appears to work fine. I 
> > think it would be good on other platsforms as well which is why I 
> > didn't #ifdef it. If not, then please add #ifdefs.
> 
> Uh, isn't the proper fix to fix the postmaster's handling of -D paths?

Nope.

The problem is that in this case, pg_ctl gets the path:
c:\program files\postgresql\data\"

(not unbalanced quotes). Yes, win32 commandline quoting is horrible.
Anyway. then it properly quotes this for the commandline:
"c:\program files\postgresql\data\""

and you can see where that breaks down...

Another option would be simple check to simply strip the " (and the
trailing backslash too, probably, to make things safer at the next
step). I just thought it'd be cleaner to use canonicalize_path(). But
it's just the trailing quote stuff that causes the problem. (See the
second step in canonicalize_path() where this has been noticed befoer,
followed by the trim-trailing part which would also be nice).

(Everything works if you register it as a service because then it uses
pg_data and not pgdata_opt. This is just when you start things manually,
which is why we missed it before...)

//Magnus


Responses

pgsql-patches by date

Next:From: Peter EisentrautDate: 2004-10-27 10:13:06
Subject: Re: Update 7 zh_TW message files for 8.0
Previous:From: Neil ConwayDate: 2004-10-27 06:22:01
Subject: port/ build fix

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group