EDB installer should check for valid %COMSPEC%

Lists: pgsql-general
From: Craig Ringer <craig(at)2ndQuadrant(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Cc: Sachin Srivastava <sachin(dot)srivastava(at)enterprisedb(dot)com>, Dave Page <dpage(at)pgadmin(dot)org>
Subject: EDB installer should check for valid %COMSPEC%
Date: 2012-11-19 04:29:02
Message-ID: 50A9B58E.5030200@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi folks

Some recent discussion on Stack Overflow has revealed another exciting
way for Windows computers to be subtly broken.

For as yet unknown reasons - probably related to security/virus scanner
software, since everything else seems to be - some Windows machines have
an invalid COMSPEC environment variable.

Two variants have been sighted in the wild:

%SystemRoot%\system32\cmd.exe;

(note the trailing semicolon), and:

C:\Windows\System32

Both will produce the delightfully helpful initdb failure:

initdb: could not execute command ""C:/Program
Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error

while running:

cscript //NoLogo "C:\Program
Files\PostgreSQL\9.2/installer/server/initcluster.vbs" "NT
AUTHORITY\NetworkService" "postgres" "****" "C:\Program
Files\PostgreSQL\9.2" "C:\Program Files\PostgreSQL\9.2\data" 5432 "DEFAULT"

which will exit with:

Script exit code: 1

In the one I was looking into, fixing COMSPEC in the System control
panel's Environment Variables page by removing the trailing semicolon
corrected the issue. It can be verified as correct by opening a new
command prompt after you've changed the variable (not just re-using an
existing already-open one) and running:

"%COMSPEC%" /C "echo test ok"

which should print:

test ok

not something like:

'"C:\Windows\System32\cmd.exe;"' is not recognized as an internal or
external command,
operable program or batch file."

Since I can find several reports of this spanning over a couple of
years, I'd love to see a test for this integrated into the EDB
installer. Just verify that popen() actually works before running the
initdb script, and if it doesn't, check %COMSPEC% to see if it really
points to cmd.exe .

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Dave Page <dpage(at)pgadmin(dot)org>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Sachin Srivastava <sachin(dot)srivastava(at)enterprisedb(dot)com>, Sandeep Thakkar <sandeep(dot)thakkar(at)enterprisedb(dot)com>
Subject: Re: EDB installer should check for valid %COMSPEC%
Date: 2012-11-19 09:14:31
Message-ID: CA+OCxow9cXEexZYfVWHHWXWXzd4gVwXQ32O_BvVBBL2+ryjkqQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi

On Mon, Nov 19, 2012 at 4:29 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:
> Hi folks
>
> Some recent discussion on Stack Overflow has revealed another exciting
> way for Windows computers to be subtly broken.
>
> For as yet unknown reasons - probably related to security/virus scanner
> software, since everything else seems to be - some Windows machines have
> an invalid COMSPEC environment variable.
>
> Two variants have been sighted in the wild:
>
> %SystemRoot%\system32\cmd.exe;
>
> (note the trailing semicolon), and:
>
> C:\Windows\System32
>
> Both will produce the delightfully helpful initdb failure:
>
> initdb: could not execute command ""C:/Program
> Files/PostgreSQL/9.2/bin/postgres.exe" --boot -x1 -F ": No error
>
> while running:
>
> cscript //NoLogo "C:\Program
> Files\PostgreSQL\9.2/installer/server/initcluster.vbs" "NT
> AUTHORITY\NetworkService" "postgres" "****" "C:\Program
> Files\PostgreSQL\9.2" "C:\Program Files\PostgreSQL\9.2\data" 5432 "DEFAULT"
>
> which will exit with:
>
> Script exit code: 1
>
> In the one I was looking into, fixing COMSPEC in the System control
> panel's Environment Variables page by removing the trailing semicolon
> corrected the issue. It can be verified as correct by opening a new
> command prompt after you've changed the variable (not just re-using an
> existing already-open one) and running:
>
> "%COMSPEC%" /C "echo test ok"
>
> which should print:
>
> test ok
>
> not something like:
>
> '"C:\Windows\System32\cmd.exe;"' is not recognized as an internal or
> external command,
> operable program or batch file."
>
>
>
> Since I can find several reports of this spanning over a couple of
> years, I'd love to see a test for this integrated into the EDB
> installer. Just verify that popen() actually works before running the
> initdb script, and if it doesn't, check %COMSPEC% to see if it really
> points to cmd.exe .

Interesting - thanks for the info Craig. Sandeep; can you please look
into adding such a check to the installer. We already test the
VBscript interpreter, so this should go in the same place.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, Sachin Srivastava <sachin(dot)srivastava(at)enterprisedb(dot)com>, Sandeep Thakkar <sandeep(dot)thakkar(at)enterprisedb(dot)com>
Subject: Re: EDB installer should check for valid %COMSPEC%
Date: 2013-03-08 05:58:42
Message-ID: 51397E12.8040807@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On 11/19/2012 05:14 PM, Dave Page wrote:
>> check %COMSPEC% to see if it really
>> > points to cmd.exe .
> Interesting - thanks for the info Craig. Sandeep; can you please look
> into adding such a check to the installer. We already test the
> VBscript interpreter, so this should go in the same place.
I've just seen a Stack Overflow report related to this that might be of
interest. The user reports that the installer fails with:

" The environment variable COMPSPEC does not seem to point to the
cmd.exe or there is a trailing semi colon present."

This appears to be a new message and they're using 9.2, so I'm guessing
this was the test added. It doesn't appear to actually *mention the
value of the COMSPEC environment variable* though. I've asked them for
the installer log, but it'd be good to identify this in the message if
possible.

The question of interest:
http://stackoverflow.com/questions/15287207/problems-installing-postgresql-9-2

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Sandeep Thakkar <sandeep(dot)thakkar(at)enterprisedb(dot)com>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>
Cc: Dave Page <dpage(at)pgadmin(dot)org>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: EDB installer should check for valid %COMSPEC%
Date: 2013-03-08 06:41:28
Message-ID: CANFyU96iFfNRFFZLLzyOMw42OU-nWfBUCXV+=nE66h4VH3AwVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

We may make the changes in the installer so that it displays the COMSPEC
value in the error message itself. Currently, we can get it's value from
the installer log.

But, I wonder why the installer threw the error when the manual run
"%COMSPEC%" /c echo "test ok" returned fine. Let's see what the installer
log says.

On Fri, Mar 8, 2013 at 11:28 AM, Craig Ringer <craig(at)2ndquadrant(dot)com> wrote:

> On 11/19/2012 05:14 PM, Dave Page wrote:
>
> check %COMSPEC% to see if it really> points to cmd.exe .
>
> Interesting - thanks for the info Craig. Sandeep; can you please look
> into adding such a check to the installer. We already test the
> VBscript interpreter, so this should go in the same place.
>
> I've just seen a Stack Overflow report related to this that might be of
> interest. The user reports that the installer fails with:
>
> " The environment variable COMPSPEC does not seem to point to the cmd.exe
> or there is a trailing semi colon present."
>
> This appears to be a new message and they're using 9.2, so I'm guessing
> this was the test added. It doesn't appear to actually *mention the value
> of the COMSPEC environment variable* though. I've asked them for the
> installer log, but it'd be good to identify this in the message if possible.
>
> The question of interest:
> http://stackoverflow.com/questions/15287207/problems-installing-postgresql-9-2
>
> --
> Craig Ringer http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>
>

--
Sandeep Thakkar
Senior Software Engineer
EnterpriseDB Corporation
The Enterprise Postgres Company
Phone: +91.20.30589523

Website: www.enterprisedb.com
EnterpriseDB Blog: http://blogs.enterprisedb.com/
Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the
individual or entity to whom it is addressed. This message contains
information from EnterpriseDB Corporation that may be privileged,
confidential, or exempt from disclosure under applicable law. If you are
not the intended recipient or authorized to receive this for the intended
recipient, any use, dissemination, distribution, retention, archiving, or
copying of this communication is strictly prohibited. If you have received
this e-mail in error, please notify the sender immediately by reply e-mail
and delete this message.