Thread: Re: [HACKERS] heads up -- subtle change of behavior of new initdb

Re: [HACKERS] heads up -- subtle change of behavior of new initdb

From
Andrew Dunstan
Date:
darnit!

patch attached.

(Thinks - do we need to worry about suid sgid and sticky bits on data dir?)

andrew

Tom Lane wrote:

>Joe Conway <mail@joeconway.com> writes:
>
>
>>I just noticed tonight that the new initdb introduced a subtle change of
>>behavior. I use a shell script to automate the process of
>>- rm old data directory
>>- mkdir new data directory
>>- initdb
>>- load from pgdumpall
>>Now, that second step is not needed, but as of today it produces an
>>installation that won't start due to improper permissions on data
>>
>>
>
>That's a bug --- evidently the "fix permissions" path of control is
>wrong; can you take a look?
>
>
>
>
? .deps
? initdb
Index: initdb.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.7
diff -c -w -r1.7 initdb.c
*** initdb.c    13 Nov 2003 23:46:31 -0000    1.7
--- initdb.c    14 Nov 2003 06:47:50 -0000
***************
*** 2345,2350 ****
--- 2345,2359 ----

          made_new_pgdata = true;
      }
+     else
+     {
+         printf("fixing permissions on existing directory %s... ",pg_data);
+         fflush(stdout);
+         if (!chmod(pg_data,0700))
+             exit_nicely();
+         else
+             check_ok();
+     }

      /* Create required subdirectories */


Re: [HACKERS] heads up -- subtle change of behavior of new initdb

From
Tom Lane
Date:
Andrew Dunstan <andrew@dunslane.net> writes:
> darnit!
> patch attached.

Applied with correction (you got the return-value check backwards)
and further work to deal reasonably with error conditions occurring
in check_data_dir.

            regards, tom lane

Re: [HACKERS] heads up -- subtle change of behavior of new initdb

From
Bruce Momjian
Date:
Patch applied.  Thanks.

---------------------------------------------------------------------------


Andrew Dunstan wrote:
>
> darnit!
>
> patch attached.
>
> (Thinks - do we need to worry about suid sgid and sticky bits on data dir?)
>
> andrew
>
> Tom Lane wrote:
>
> >Joe Conway <mail@joeconway.com> writes:
> >
> >
> >>I just noticed tonight that the new initdb introduced a subtle change of
> >>behavior. I use a shell script to automate the process of
> >>- rm old data directory
> >>- mkdir new data directory
> >>- initdb
> >>- load from pgdumpall
> >>Now, that second step is not needed, but as of today it produces an
> >>installation that won't start due to improper permissions on data
> >>
> >>
> >
> >That's a bug --- evidently the "fix permissions" path of control is
> >wrong; can you take a look?
> >
> >
> >
> >

> ? .deps
> ? initdb
> Index: initdb.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
> retrieving revision 1.7
> diff -c -w -r1.7 initdb.c
> *** initdb.c    13 Nov 2003 23:46:31 -0000    1.7
> --- initdb.c    14 Nov 2003 06:47:50 -0000
> ***************
> *** 2345,2350 ****
> --- 2345,2359 ----
>
>           made_new_pgdata = true;
>       }
> +     else
> +     {
> +         printf("fixing permissions on existing directory %s... ",pg_data);
> +         fflush(stdout);
> +         if (!chmod(pg_data,0700))
> +             exit_nicely();
> +         else
> +             check_ok();
> +     }
>
>       /* Create required subdirectories */
>

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] heads up -- subtle change of behavior of new

From
Bruce Momjian
Date:
Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
> > darnit!
> > patch attached.
>
> Applied with correction (you got the return-value check backwards)
> and further work to deal reasonably with error conditions occurring
> in check_data_dir.

Tom applied it before I could.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: [HACKERS] heads up -- subtle change of behavior of

From
Andrew Dunstan
Date:
Tom Lane wrote:

>Andrew Dunstan <andrew@dunslane.net> writes:
>
>
>>darnit!
>>patch attached.
>>
>>
>
>Applied with correction (you got the return-value check backwards)
>and further work to deal reasonably with error conditions occurring
>in check_data_dir.
>

darnit again.

I'm taking a break - my head is swimming with Java, JavaScript, Perl,
HTML and XML/XSL from my real (i.e. paying) work, and context switching
is causing massive mental thrashing.

cheers

andrew