pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM.
6+ messages / 2 participants
[nested] [flat]

* pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM.
@ 2016-04-04 22:05 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-04 22:05 UTC (permalink / raw)
  To: pgsql-committers

Disallow newlines in parameter values to be set in ALTER SYSTEM.

As noted by Julian Schauder in bug #14063, the configuration-file parser
doesn't support embedded newlines in string literals.  While there might
someday be a good reason to remove that restriction, there doesn't seem
to be one right now.  However, ALTER SYSTEM SET could accept strings
containing newlines, since many of the variable-specific value-checking
routines would just see a newline as whitespace.  This led to writing a
postgresql.auto.conf file that was broken and had to be removed manually.

Pending a reason to work harder, just throw an error if someone tries this.

In passing, fix several places in the ALTER SYSTEM logic that failed to
provide an errcode() for an ereport(), and thus would falsely log the
failure as an internal XX000 error.

Back-patch to 9.4 where ALTER SYSTEM was introduced.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/99f3b5613bd1f145b5dbbe86000337bbe37fb094

Modified Files
--------------
src/backend/utils/misc/guc.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM.
@ 2016-04-04 22:05 Tom Lane <tgl@sss.pgh.pa.us>
  2016-04-05 06:05 ` Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Oleg Bartunov <obartunov@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2016-04-04 22:05 UTC (permalink / raw)
  To: pgsql-committers

Disallow newlines in parameter values to be set in ALTER SYSTEM.

As noted by Julian Schauder in bug #14063, the configuration-file parser
doesn't support embedded newlines in string literals.  While there might
someday be a good reason to remove that restriction, there doesn't seem
to be one right now.  However, ALTER SYSTEM SET could accept strings
containing newlines, since many of the variable-specific value-checking
routines would just see a newline as whitespace.  This led to writing a
postgresql.auto.conf file that was broken and had to be removed manually.

Pending a reason to work harder, just throw an error if someone tries this.

In passing, fix several places in the ALTER SYSTEM logic that failed to
provide an errcode() for an ereport(), and thus would falsely log the
failure as an internal XX000 error.

Back-patch to 9.4 where ALTER SYSTEM was introduced.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/f3d17491c49362b78da0c1a5b0691821dcc8c435

Modified Files
--------------
src/backend/utils/misc/guc.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM.
  2016-04-04 22:05 pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-04-05 06:05 ` Oleg Bartunov <obartunov@gmail.com>
  2016-04-05 06:08   ` Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Oleg Bartunov <obartunov@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Oleg Bartunov @ 2016-04-05 06:05 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers

On Tue, Apr 5, 2016 at 1:05 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Disallow newlines in parameter values to be set in ALTER SYSTEM.
>

it's also fixed problem with setting parameter to ''. Before

alter system SET shared_preload_libraries = '';

produced wrong postgresql.auto.conf and the only way was to use RESET

alter system RESET shared_preload_libraries;



> As noted by Julian Schauder in bug #14063, the configuration-file parser
> doesn't support embedded newlines in string literals.  While there might
> someday be a good reason to remove that restriction, there doesn't seem
> to be one right now.  However, ALTER SYSTEM SET could accept strings
> containing newlines, since many of the variable-specific value-checking
> routines would just see a newline as whitespace.  This led to writing a
> postgresql.auto.conf file that was broken and had to be removed manually.
>
> Pending a reason to work harder, just throw an error if someone tries this.
>
> In passing, fix several places in the ALTER SYSTEM logic that failed to
> provide an errcode() for an ereport(), and thus would falsely log the
> failure as an internal XX000 error.
>
> Back-patch to 9.4 where ALTER SYSTEM was introduced.
>
> Branch
> ------
> REL9_5_STABLE
>
> Details
> -------
>
> http://git.postgresql.org/pg/commitdiff/f3d17491c49362b78da0c1a5b0691821dcc8c435
>
> Modified Files
> --------------
> src/backend/utils/misc/guc.c | 23 ++++++++++++++++++++---
> 1 file changed, 20 insertions(+), 3 deletions(-)
>
>
> --
> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-committers
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM.
  2016-04-04 22:05 pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Tom Lane <tgl@sss.pgh.pa.us>
  2016-04-05 06:05 ` Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Oleg Bartunov <obartunov@gmail.com>
@ 2016-04-05 06:08   ` Oleg Bartunov <obartunov@gmail.com>
  2016-04-05 20:02     ` Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Oleg Bartunov @ 2016-04-05 06:08 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers

On Tue, Apr 5, 2016 at 9:05 AM, Oleg Bartunov <obartunov@gmail.com> wrote:

>
>
> On Tue, Apr 5, 2016 at 1:05 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>> Disallow newlines in parameter values to be set in ALTER SYSTEM.
>>
>
> it's also fixed problem with setting parameter to ''. Before
>
> alter system SET shared_preload_libraries = '';
>
> produced wrong postgresql.auto.conf and the only way was to use RESET
>
> alter system RESET shared_preload_libraries;
>
>
Ooops,  it doesn't :(

FATAL:  could not access file "": No such file or directory

cat /usr/local/pgsql-head/data/postgresql.auto.conf
# Do not edit this file manually!
# It will be overwritten by ALTER SYSTEM command.
shared_preload_libraries = '""'





>
>
>> As noted by Julian Schauder in bug #14063, the configuration-file parser
>> doesn't support embedded newlines in string literals.  While there might
>> someday be a good reason to remove that restriction, there doesn't seem
>> to be one right now.  However, ALTER SYSTEM SET could accept strings
>> containing newlines, since many of the variable-specific value-checking
>> routines would just see a newline as whitespace.  This led to writing a
>> postgresql.auto.conf file that was broken and had to be removed manually.
>>
>> Pending a reason to work harder, just throw an error if someone tries
>> this.
>>
>> In passing, fix several places in the ALTER SYSTEM logic that failed to
>> provide an errcode() for an ereport(), and thus would falsely log the
>> failure as an internal XX000 error.
>>
>> Back-patch to 9.4 where ALTER SYSTEM was introduced.
>>
>> Branch
>> ------
>> REL9_5_STABLE
>>
>> Details
>> -------
>>
>> http://git.postgresql.org/pg/commitdiff/f3d17491c49362b78da0c1a5b0691821dcc8c435
>>
>> Modified Files
>> --------------
>> src/backend/utils/misc/guc.c | 23 ++++++++++++++++++++---
>> 1 file changed, 20 insertions(+), 3 deletions(-)
>>
>>
>> --
>> Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-committers
>>
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM.
  2016-04-04 22:05 pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Tom Lane <tgl@sss.pgh.pa.us>
  2016-04-05 06:05 ` Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Oleg Bartunov <obartunov@gmail.com>
  2016-04-05 06:08   ` Re: pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Oleg Bartunov <obartunov@gmail.com>
@ 2016-04-05 20:02     ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-05 20:02 UTC (permalink / raw)
  To: obartunov@gmail.com; +Cc: pgsql-committers

Oleg Bartunov <obartunov@gmail.com> writes:
> On Tue, Apr 5, 2016 at 9:05 AM, Oleg Bartunov <obartunov@gmail.com> wrote:
>> it's also fixed problem with setting parameter to ''. Before
>> alter system SET shared_preload_libraries = '';

> Ooops,  it doesn't :(
> FATAL:  could not access file "": No such file or directory

> cat /usr/local/pgsql-head/data/postgresql.auto.conf
> # Do not edit this file manually!
> # It will be overwritten by ALTER SYSTEM command.
> shared_preload_libraries = '""'

I do not think this is a bug, or at least not an ALTER SYSTEM bug.
What you wrote there means a single list entry that is an empty string,
and ALTER SYSTEM reproduced that faithfully.

We do have a shortcoming here, which is that the SET syntax lacks any
way to explicitly set a GUC_LIST_INPUT variable to an empty list.
It's been like that for a long time with few complaints, but maybe
we should do something about it.

			regards, tom lane


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM.
@ 2016-04-04 22:05 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2016-04-04 22:05 UTC (permalink / raw)
  To: pgsql-committers

Disallow newlines in parameter values to be set in ALTER SYSTEM.

As noted by Julian Schauder in bug #14063, the configuration-file parser
doesn't support embedded newlines in string literals.  While there might
someday be a good reason to remove that restriction, there doesn't seem
to be one right now.  However, ALTER SYSTEM SET could accept strings
containing newlines, since many of the variable-specific value-checking
routines would just see a newline as whitespace.  This led to writing a
postgresql.auto.conf file that was broken and had to be removed manually.

Pending a reason to work harder, just throw an error if someone tries this.

In passing, fix several places in the ALTER SYSTEM logic that failed to
provide an errcode() for an ereport(), and thus would falsely log the
failure as an internal XX000 error.

Back-patch to 9.4 where ALTER SYSTEM was introduced.

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/28148e25823a42877b2f2ee0961afcb8b5243a72

Modified Files
--------------
src/backend/utils/misc/guc.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2016-04-05 20:02 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-04-04 22:05 pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Tom Lane <tgl@sss.pgh.pa.us>
2016-04-04 22:05 pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Tom Lane <tgl@sss.pgh.pa.us>
2016-04-05 06:05 ` Oleg Bartunov <obartunov@gmail.com>
2016-04-05 06:08   ` Oleg Bartunov <obartunov@gmail.com>
2016-04-05 20:02     ` Tom Lane <tgl@sss.pgh.pa.us>
2016-04-04 22:05 pgsql: Disallow newlines in parameter values to be set in ALTER SYSTEM. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox