Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)

From: Ryan Murphy <ryanfmurphy(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)
Date: 2016-08-17 15:21:03
Message-ID: CAHeEsBeZxq10cv+Xaz6NgqP=AWsXrn+rEkK+-nXFq3juq2CHNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I have created a better patch (attached) that correctly escapes the shell
arguments using PQExpBufferStr and the appendShellString function, as per
Michael and Andres' suggestions.

Further suggestions welcome of course.

Ryan

On Wed, Aug 17, 2016 at 8:28 AM, Ryan Murphy <ryanfmurphy(at)gmail(dot)com> wrote:

> That makes sense, Michael and Andres.
>
> I started to make a solution that uses a PQExpBuffer, appendShellString,
> etc. I think it will work just fine, but I think I need to alter the
> Makefile as well, to get initdb.c to be compiled using
> -L../../../src/fe_utils -lpgfeutils. Otherwise I am having issues linking:
>
> gcc -Wall -Wmissing-prototypes -Wpointer-arith
> -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute
> -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument
> -O2 initdb.o findtimezone.o localtime.o encnames.o -L../../../src/port
> -L../../../src/common -Wl,-dead_strip_dylibs -lpgcommon -lpgport -lz
> -lreadline -lm -o initdb
> Undefined symbols for architecture x86_64:
> "_appendPQExpBufferStr", referenced from:
> _main in initdb.o
> "_appendShellString", referenced from:
> _main in initdb.o
> "_createPQExpBuffer", referenced from:
> _main in initdb.o
> "_destroyPQExpBuffer", referenced from:
> _main in initdb.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
>
> On Tue, Aug 16, 2016 at 10:00 PM, Michael Paquier <
> michael(dot)paquier(at)gmail(dot)com> wrote:
>
>> On Wed, Aug 17, 2016 at 8:05 AM, Andres Freund <andres(at)anarazel(dot)de>
>> wrote:
>> > ISTM that the correct fix would be to actually introduce something like
>> > quote_path_for_shell() which either adds proper quotes, or fails if
>> > that'd be hard (e.g. if the path contains quotes, and we're on
>> > windows).
>>
>> You are looking for appendShellString in fe_utils/string_utils.c.
>> --
>> Michael
>>
>
>

Attachment Content-Type Size
0001-initdb-quote-shell-args-in-final-pg_ctl-command.patch application/octet-stream 3.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-08-17 15:22:46 Re: Are these supported??
Previous Message Robert Haas 2016-08-17 15:20:46 Re: [GENERAL] C++ port of Postgres