[Patch] - Fix for bug #2558, InitDB failed to run on windows 2003

Started by drorabout 20 years ago15 messageshackerspatches
Jump to latest
#1dror
dror_b@hotmail.com
hackerspatches

Hi All,

As some of you already noticed and as mentioned in pgsql-hackers before,
the initDB process failed to run on some windows 2003 machines.

Although this issue was already discussed by James Hughes,Martijn,Jim Nasby and others I didn't no patch was created and
no fix was committed to the CVS.

Description:

On some windows 2003 machine there is no access to the nul device for non administrator's users.
The initDB.c redirect the output to > DEVNUL which on windows defined has "nul".

There were two options to solve this issue:

Create a new file , grant a write permission for the Postgres user and redirect the output to that file. (EnterpriseDB use this method)
Canceling the redirection at all.

I choose the second option and omit the redirection in any case that it windows machine and the redirection was sent to DEVNULL.

The only files that I changed are: initDB.c, exec.c and pg_ctl.c

I think postgres must solve this issue, as more and more windows 2003 machine will be discovered with this limitation which prevent from the users to install (actually to initialize ) the DB.

One more comment:
As today we have and MSI installer which redirect the initDB output to a log file by default (and we can also run it in the background) there is no point to use redirection at all.

The fixed files are attached.

Regards
Dror Bar-Gil

_________________________________________________________________
Try Live.com: where your online world comes together - with news, sports, weather, and much more.
http://www.live.com/getstarted

Attachments:

initDb patch.zipapplication/x-zip-compressedDownload+1-0
#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: dror (#1)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run on windows 2003

dror wrote:

There were two options to solve this issue:

Create a new file , grant a write permission for the Postgres user
and redirect the output to that file. (EnterpriseDB use this method)
Canceling the redirection at all.

I choose the second option and omit the redirection in any case that
it windows machine and the redirection was sent to DEVNULL.

The only files that I changed are: initDB.c, exec.c and pg_ctl.c

Please submit the changes as patches, instead of the whole files. Also,
please specify which branch do these patches apply -- is this for 8.1,
or for the current development code? When checked against the 8.1
pg_ctl.c, the file you sent only contains a regression for a bug fix,
and no change related to what you describe above.

On the other hand, it may be useful to lose the redirection only on the
cases where it fails, so we still have reasonable behavior on non-broken
platforms. Or maybe there's a better solution.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Alvaro Herrera (#2)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Alvaro Herrera wrote:

dror wrote:

There were two options to solve this issue:

Create a new file , grant a write permission for the Postgres user
and redirect the output to that file. (EnterpriseDB use this method)
Canceling the redirection at all.

I choose the second option and omit the redirection in any case that
it windows machine and the redirection was sent to DEVNULL.

The only files that I changed are: initDB.c, exec.c and pg_ctl.c

Please submit the changes as patches, instead of the whole files. Also,
please specify which branch do these patches apply -- is this for 8.1,
or for the current development code? When checked against the 8.1
pg_ctl.c, the file you sent only contains a regression for a bug fix,
and no change related to what you describe above.

On the other hand, it may be useful to lose the redirection only on the
cases where it fails, so we still have reasonable behavior on non-broken
platforms. Or maybe there's a better solution.

I am inclined to say we should make it into a runtime test and use a
tmpfile on Windows if the test fails. I am more than somewhat perplexed
as to why the NUL device should be a security risk ... what are they
thinking??

The case that bothers me more is where input is redirected - will that
also work?

cheers

andrew

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#3)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Andrew Dunstan <andrew@dunslane.net> writes:

I am more than somewhat perplexed as to why the NUL device should be a
security risk ... what are they thinking??

Frankly, I don't believe it; even Microsoft can't be that stupid.
And I can't find any suggestion that they've done this in a google
search. I think the OP is misdiagnosing his problem.

regards, tom lane

#5dror
dror_b@hotmail.com
In reply to: Tom Lane (#4)
patches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

When saying:"Please submit the changes as patches, instead of the whole files". Do you mean to send each file seperately? or other issues as well?

The change was test and design for 8.1.14, but as far as I see it is also true for any other version.Of course merge is needed in case that the files were changed since then, however , due to the fact that it is only few rows it will be easy to do it.

Alvaro wrote: "it may be useful to lose the redirection only on the cases where it fails, so we still have reasonable behavior on non-broken platforms"Nice idea, but it is really doesn't matter: on other platform than win32, the code left unchanged! the fix is only relevant for win32 on which (as I explained) the MSI installer (if used) redirect the output by default to a log file.
Regards
Dror

Date: Mon, 14 Aug 2006 12:40:25 -0400> From: alvherre@commandprompt.com> To: dror_b@hotmail.com> CC: pgsql-patches@postgresql.org> Subject: Re: [PATCHES] [Patch] - Fix for bug #2558, InitDB failed to run on windows 2003> > dror wrote:> > > There were two options to solve this issue:> > > > Create a new file , grant a write permission for the Postgres user> > and redirect the output to that file. (EnterpriseDB use this method)> > Canceling the redirection at all.> > > > I choose the second option and omit the redirection in any case that> > it windows machine and the redirection was sent to DEVNULL.> > > > The only files that I changed are: initDB.c, exec.c and pg_ctl.c> > Please submit the changes as patches, instead of the whole files. Also,> please specify which branch do these patches apply -- is this for 8.1,> or for the current development code? When checked against the 8.1> pg_ctl.c, the file you sent only contains a regression for a bug fix,> and no change related to what you describe above.> > On the other hand, it may be useful to lose the redirection only on the> cases where it fails, so we still have reasonable behavior on non-broken> platforms. Or maybe there's a better solution.> > -- > Alvaro Herrera http://www.CommandPrompt.com/&gt; PostgreSQL Replication, Consulting, Custom Development, 24x7 support

_________________________________________________________________
Try Live.com - your fast, personalized homepage with all the things you care about in one place.
http://www.live.com/getstarted

#6Andrew Dunstan
andrew@dunslane.net
In reply to: dror (#5)
patches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

1. a patch is generated by the program "diff"
2. before we do anything, as Tom Lane says, we need verification of the
problem, preferably in writing from Microsoft.

cheers

andrew

dror wrote:

Show quoted text

1.
When saying:
"Please submit the changes as patches, instead of the whole files".
Do you mean to send each file seperately? or other issues as well?
2.
The change was test and design for 8.1.14, but as far as I see
it is also true for any other version.
Of course merge is needed in case that the files were changed
since then, however , due to the fact that it is only few rows
it will be easy to do it.
3.
Alvaro wrote:
"it may be useful to lose the redirection only on the
cases where it fails, so we still have reasonable behavior on non-broken
platforms"

Nice idea, but it is really doesn't matter: on other platform
than win32, the code left unchanged! the fix is only relevant
for win32 on which (as I explained) the MSI installer (if used)
redirect the output by default to a log file.

Regards
Dror
------------------------------------------------------------------------

Date: Mon, 14 Aug 2006 12:40:25 -0400
From: alvherre@commandprompt.com
To: dror_b@hotmail.com
CC: pgsql-patches@postgresql.org
Subject: Re: [PATCHES] [Patch] - Fix for bug #2558, InitDB failed to

run on windows 2003

dror wrote:

There were two options to solve this issue:

Create a new file , grant a write permission for the Postgres user
and redirect the output to that file. (EnterpriseDB use this method)
Canceling the redirection at all.

I choose the second option and omit the redirection in any case that
it windows machine and the redirection was sent to DEVNULL.

The only files that I changed are: initDB.c, exec.c and pg_ctl.c

Please submit the changes as patches, instead of the whole files. Also,
please specify which branch do these patches apply -- is this for 8.1,
or for the current development code? When checked against the 8.1
pg_ctl.c, the file you sent only contains a regression for a bug fix,
and no change related to what you describe above.

On the other hand, it may be useful to lose the redirection only on the
cases where it fails, so we still have reasonable behavior on non-broken
platforms. Or maybe there's a better solution.

--

Alvaro Herrera http://www.CommandPrompt.com/

PostgreSQL Replication, Consulting, Custom Development, 24x7 support

------------------------------------------------------------------------
Express yourself instantly with Windows Live Messenger! Windows Live
Messenger!
<http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&amp;source=joinmsncom/messenger&gt;

#7dror
dror_b@hotmail.com
In reply to: Tom Lane (#4)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Hi Andrew, Regarding to your comments: > 1. a patch is generated by the program "diff"I will do it ,if needed> 2. before we do anything, as Tom Lane says, we need verification of the > problem, preferably in writing from Microsoft.I do understand that, but, de-facto, the current implementation does not work, canceling the redirection (or open a log file) is not a matter of changing the OS behavior, therefore I don't see why a formal verification from Microsoft is needed.When this issue will be revealed in more and more system, it can be harmless to postgress reputation and critical problems for the end users.In addition to the above, as James Hughes have already mention before at item #2268 (http://archives.postgresql.org/pgsql-hackers/2006-03/msg00012.php):He tried to get answers from microsoft but didn't get any respond. Anyway, For my own version, I solve the issue and built a private version, if you still want me to publish the patch (Just in case) I will do the diff and the effort needed, I don't think that Microsoft respond is needed in this case because it is implementation decision. Regards; Dror

Date: Mon, 14 Aug 2006 17:42:58 -0400> From: andrew@dunslane.net> To: dror_b@hotmail.com> CC: alvherre@commandprompt.com; pgsql-patches@postgresql.org> Subject: Re: [PATCHES] [Patch] - Fix for bug #2558, InitDB failed to run> > > > 1. a patch is generated by the program "diff"> 2. before we do anything, as Tom Lane says, we need verification of the > problem, preferably in writing from Microsoft.> > cheers> > andrew> > > dror wrote:> >> > 1.> > When saying:> > "Please submit the changes as patches, instead of the whole files". > > Do you mean to send each file seperately? or other issues as well?> > 2.> > The change was test and design for 8.1.14, but as far as I see> > it is also true for any other version.> > Of course merge is needed in case that the files were changed> > since then, however , due to the fact that it is only few rows> > it will be easy to do it.> > 3.> > Alvaro wrote:> > "it may be useful to lose the redirection only on the> > cases where it fails, so we still have reasonable behavior on non-broken> > platforms"> >> > Nice idea, but it is really doesn't matter: on other platform> > than win32, the code left unchanged! the fix is only relevant> > for win32 on which (as I explained) the MSI installer (if used)> > redirect the output by default to a log file.> >> > Regards> > Dror> > ------------------------------------------------------------------------> >> > > Date: Mon, 14 Aug 2006 12:40:25 -0400> > > From: alvherre@commandprompt.com> > > To: dror_b@hotmail.com> > > CC: pgsql-patches@postgresql.org> > > Subject: Re: [PATCHES] [Patch] - Fix for bug #2558, InitDB failed to > > run on windows 2003> > >> > > dror wrote:> > >> > > > There were two options to solve this issue:> > > > > > > > Create a new file , grant a write permission for the Postgres user> > > > and redirect the output to that file. (EnterpriseDB use this method)> > > > Canceling the redirection at all.> > > > > > > > I choose the second option and omit the redirection in any case that> > > > it windows machine and the redirection was sent to DEVNULL.> > > > > > > > The only files that I changed are: initDB.c, exec.c and pg_ctl.c> > >> > > Please submit the changes as patches, instead of the whole files. Also,> > > please specify which branch do these patches apply -- is this for 8.1,> > > or for the current development code? When checked against the 8.1> > > pg_ctl.c, the file you sent only contains a regression for a bug fix,> > > and no change related to what you describe above.> > >> > > On the other hand, it may be useful to lose the redirection only on the> > > cases where it fails, so we still have reasonable behavior on non-broken> > > platforms. Or maybe there's a better solution.> > >> > > -- > > > > > Alvaro Herrera http://www.CommandPrompt.com/&gt; > > PostgreSQL Replication, Consulting, Custom Development, 24x7 support> >> >> > ------------------------------------------------------------------------> > Express yourself instantly with Windows Live Messenger! Windows Live > > Messenger! > > <http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&amp;source=joinmsncom/messenger&gt;&gt;

_________________________________________________________________
Try Live.com: where your online world comes together - with news, sports, weather, and much more.
http://www.live.com/getstarted

#8Andreas Pflug
pgadmin@pse-consulting.de
In reply to: Tom Lane (#4)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

I am more than somewhat perplexed as to why the NUL device should be a
security risk ... what are they thinking??

Frankly, I don't believe it; even Microsoft can't be that stupid.
And I can't find any suggestion that they've done this in a google
search. I think the OP is misdiagnosing his problem.

An older message suggests that a service pack induced this problem, per
MS. I just tried it as non-admin on a W2K3 machine with recent hotfixes,
and the command "dir >nul" _did_ work for me.
Though neglected, it still sounds like a virus scanner issue to me.

Regards,
Andreas

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: dror (#7)
hackerspatches
Re: [PATCHES] [Patch] - Fix for bug #2558, InitDB failed to run

"dror" <dror_b@hotmail.com> writes:

Hi Andrew, Regarding to your comments: > 1. a patch is generated by the pro=
gram "diff"I will do it ,if needed> 2. before we do anything, as Tom Lane s=
ays, we need verification of the > problem, preferably in writing from Micr=
osoft.I do understand that, but, de-facto, the current implementation does=
not work, canceling the redirection (or open a log file) is not a matter o=
f changing the OS behavior, therefore I don't see why a formal verificatio=
n from Microsoft is needed.When this issue will be revealed in more and mor=
e system, it can be harmless to postgress reputation and critical problems =
for the end users.

The difficulty we're having is that this is a very ugly fix for a problem
that's been reported by no one except you. I tend to agree with
Andreas' theory that what you are seeing is misbehavior of some
antivirus software on your machine, rather than a change of Windows' own
behavior. We are not going to accept this patch without more evidence
that there really has been a change on Microsoft's part.

regards, tom lane

#10Bruce Momjian
bruce@momjian.us
In reply to: Andreas Pflug (#8)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Andreas Pflug wrote:

Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

I am more than somewhat perplexed as to why the NUL device should be a
security risk ... what are they thinking??

Frankly, I don't believe it; even Microsoft can't be that stupid.
And I can't find any suggestion that they've done this in a google
search. I think the OP is misdiagnosing his problem.

An older message suggests that a service pack induced this problem, per
MS. I just tried it as non-admin on a W2K3 machine with recent hotfixes,
and the command "dir >nul" _did_ work for me.
Though neglected, it still sounds like a virus scanner issue to me.

Yes, it seems we will need more information on this. We need someone at
a win32 command prompt to show us a "> nul" failure.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#11Andreas Pflug
pgadmin@pse-consulting.de
In reply to: Bruce Momjian (#10)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Bruce Momjian wrote:

Andreas Pflug wrote:

Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

I am more than somewhat perplexed as to why the NUL device should be a
security risk ... what are they thinking??

Frankly, I don't believe it; even Microsoft can't be that stupid.
And I can't find any suggestion that they've done this in a google
search. I think the OP is misdiagnosing his problem.

An older message suggests that a service pack induced this problem, per
MS. I just tried it as non-admin on a W2K3 machine with recent hotfixes,
and the command "dir >nul" _did_ work for me.
Though neglected, it still sounds like a virus scanner issue to me.

Yes, it seems we will need more information on this. We need someone at
a win32 command prompt to show us a "> nul" failure.

OTOH,
what issues might arise if the output is redirected to a legal tmp file?

Regards,
Andreas

#12Bruce Momjian
bruce@momjian.us
In reply to: Andreas Pflug (#11)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Andreas Pflug wrote:

Bruce Momjian wrote:

Andreas Pflug wrote:

Tom Lane wrote:

Andrew Dunstan <andrew@dunslane.net> writes:

I am more than somewhat perplexed as to why the NUL device should be a
security risk ... what are they thinking??

Frankly, I don't believe it; even Microsoft can't be that stupid.
And I can't find any suggestion that they've done this in a google
search. I think the OP is misdiagnosing his problem.

An older message suggests that a service pack induced this problem, per
MS. I just tried it as non-admin on a W2K3 machine with recent hotfixes,
and the command "dir >nul" _did_ work for me.
Though neglected, it still sounds like a virus scanner issue to me.

Yes, it seems we will need more information on this. We need someone at
a win32 command prompt to show us a "> nul" failure.

OTOH,
what issues might arise if the output is redirected to a legal tmp file?

No idea, but we aren't going to change the code without more facts. We
don't have the resources to be making code changes without concrete
information.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#13Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andreas Pflug (#11)
hackerspatches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Andreas Pflug <pgadmin@pse-consulting.de> writes:

what issues might arise if the output is redirected to a legal tmp file?

Well, (1) finding a place to put the temp file, ie a writable directory;
(2) ensuring the file is removed afterwards; (3) not exposing the user
to security hazards due to unsafe use of a temp file (ye olde
overwrite-a-symlink risk). Perhaps a few more I didn't think of.

It's not a trivial change, and the evidence presented so far hasn't
convinced me that we need to put in the effort.

regards, tom lane

#14Andreas Pflug
pgadmin@pse-consulting.de
In reply to: Tom Lane (#13)
hackerspatches
Re: [PATCHES] [Patch] - Fix for bug #2558, InitDB failed to run

Tom Lane wrote:

Andreas Pflug <pgadmin@pse-consulting.de> writes:

what issues might arise if the output is redirected to a legal tmp file?

Well, (1) finding a place to put the temp file, ie a writable directory;
(2) ensuring the file is removed afterwards; (3) not exposing the user
to security hazards due to unsafe use of a temp file (ye olde
overwrite-a-symlink risk). Perhaps a few more I didn't think of.

AFAICS all DEVNULL usages result from redirecting postmaster's output,
which usually goes to $DATADIR/serverlog at runtime. If this would be
used here too, (1) is as safe as any $DATADIR, (2) is as safe as
cleaning up after failure usually is, (3) can't happen because the
directory is checked to be empty before initdb anyway. Additionally,
there's might be cases when a meaningful logfile from initdb is
desirable too. So why no redirection to initlog or so?

Regards,
Andreas

#15SenTnel
epwise0707@yahoo.com
In reply to: Andrew Dunstan (#6)
patches
Re: [Patch] - Fix for bug #2558, InitDB failed to run

Sorry, Im not an expert, and I have the same win 2003 server installation
problem, but dont know what to do with the tree .c files downloaded as a
patch, can you please direct me on how to use the patch?
Thanks !

Andrew Dunstan wrote:

1. a patch is generated by the program "diff"
2. before we do anything, as Tom Lane says, we need verification of the
problem, preferably in writing from Microsoft.

cheers

andrew

dror wrote:

1.
When saying:
"Please submit the changes as patches, instead of the whole files".
Do you mean to send each file seperately? or other issues as well?
2.
The change was test and design for 8.1.14, but as far as I see
it is also true for any other version.
Of course merge is needed in case that the files were changed
since then, however , due to the fact that it is only few rows
it will be easy to do it.
3.
Alvaro wrote:
"it may be useful to lose the redirection only on the
cases where it fails, so we still have reasonable behavior on
non-broken
platforms"

Nice idea, but it is really doesn't matter: on other platform
than win32, the code left unchanged! the fix is only relevant
for win32 on which (as I explained) the MSI installer (if used)
redirect the output by default to a log file.

Regards
Dror
------------------------------------------------------------------------

Date: Mon, 14 Aug 2006 12:40:25 -0400
From: alvherre@commandprompt.com
To: dror_b@hotmail.com
CC: pgsql-patches@postgresql.org
Subject: Re: [PATCHES] [Patch] - Fix for bug #2558, InitDB failed to

run on windows 2003

dror wrote:

There were two options to solve this issue:

Create a new file , grant a write permission for the Postgres user
and redirect the output to that file. (EnterpriseDB use this method)
Canceling the redirection at all.

I choose the second option and omit the redirection in any case that
it windows machine and the redirection was sent to DEVNULL.

The only files that I changed are: initDB.c, exec.c and pg_ctl.c

Please submit the changes as patches, instead of the whole files.

Also,

please specify which branch do these patches apply -- is this for 8.1,
or for the current development code? When checked against the 8.1
pg_ctl.c, the file you sent only contains a regression for a bug fix,
and no change related to what you describe above.

On the other hand, it may be useful to lose the redirection only on the
cases where it fails, so we still have reasonable behavior on

non-broken

platforms. Or maybe there's a better solution.

--

Alvaro Herrera
http://www.CommandPrompt.com/

PostgreSQL Replication, Consulting, Custom Development, 24x7 support

------------------------------------------------------------------------
Express yourself instantly with Windows Live Messenger! Windows Live
Messenger!
<http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&amp;source=joinmsncom/messenger&gt;

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

--
View this message in context: http://www.nabble.com/-Patch----Fix-for-bug---2558%2C--InitDB-failed-to-run-on-windows-2003-tf2103710.html#a8164273
Sent from the PostgreSQL - patches mailing list archive at Nabble.com.