Re: [PATCH] PGSERVICEFILE as part of a normal connection string

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Ryo Kanbayashi <kanbayashi(dot)dev(at)gmail(dot)com>
Cc: Torsten Förtsch <tfoertsch123(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] PGSERVICEFILE as part of a normal connection string
Date: 2025-07-10 05:21:38
Message-ID: aG9N4jtuyVK284NP@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 09, 2025 at 04:31:31PM +0900, Michael Paquier wrote:
> Attached is a rebased version of the rest, with the recent stanza
> related to fef6da9e9c87 taken into account. 0002 still has a change
> that should be in 0001: I have not really touched the structure of the
> two remaining patches yet.

+ /* If service was found successfully, set servicefile option if not already set */
+ if (*group_found && result == 0)
+ {
+ for (i = 0; options[i].keyword; i++)
+ {
+ if (strcmp(options[i].keyword, "servicefile") != 0)
+ continue;
+
+ if (options[i].val != NULL)
+ break;
+
+ options[i].val = strdup(serviceFile);
+ if (options[i].val == NULL)
+ {
+ libpq_append_error(errorMessage, "out of memory");
+ return 3;
+ }
+ break;

There was a bug here: if the new value cannot be strdup'd, we would
miss the fclose() of the exit path, so this cannot return directly.
It is possible to set the status to a new value instead, then break.

After that, I have applied a few cosmetic tweaks here and there, and
attached is what I have staged for commit, minus proper commit
messages. The new TAP tests have some WIN32-specific things, and I
won't be able to look at the buildfarm if I were to apply things
today, so this will have to wait until the beginning of next week.
The CI is happy with it, so at least we are one checkbox down.
--
Michael

Attachment Content-Type Size
v13-0001-libpq-Add-servicefile-connection-option.patch text/x-diff 9.6 KB
v13-0002-psql-Add-SERVICEFILE-variable.patch text/x-diff 2.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-07-10 05:22:29 Re: Replace remaining getpwuid() calls with getpwuid_r()?
Previous Message Dilip Kumar 2025-07-10 05:18:45 Re: CHECKPOINT unlogged data