Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fPyDk-0006ZB-Oe for pgsql-general@arkaria.postgresql.org; Mon, 04 Jun 2018 22:45:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fPyDj-0007vr-Jx for pgsql-general@arkaria.postgresql.org; Mon, 04 Jun 2018 22:44:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fPyDi-0007vi-Tt for pgsql-general@lists.postgresql.org; Mon, 04 Jun 2018 22:44:59 +0000 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fPyDg-0002j5-2p for pgsql-general@lists.postgresql.org; Mon, 04 Jun 2018 22:44:57 +0000 Received: by mail-oi0-x242.google.com with SMTP id l22-v6so295432oib.4 for ; Mon, 04 Jun 2018 15:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=KNPH9lFhh25Jbga2FKaJOjJ666z5iTl2wQ61OdeItgY=; b=rPbvG0J+ht5ijmsmcJC9yZP4+126lO4l7Np5/WqPLKQ0TRyRQAjzcteBgR/4KJgPDq DUgbbxfJ8GOdgkOxtAwtDlELHGdWbQh5OPqc9YzvjmaKAUCDacGeRC5IseZhSgNm6zbh 2zeS/oefRjpiYt6ESZYErEG8Z7A/WIZIFxvy5UsZ05wRxOTIYmu7PVe59+0EyFQevF1r rstOT4y1oFQ6YvPqG4/sMnjHxvFHetfPl4ysgrBF0719tRchXqYRoPIU5C5p7URs6LjB MgKERmwTdaFq+wdSH4BXaxnn8JiTZCatGQlAPuLybrAJfsSVF0tkAzldDTBO8I4edYw6 gE4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=KNPH9lFhh25Jbga2FKaJOjJ666z5iTl2wQ61OdeItgY=; b=IIQ0Bc2KECWp+FSGSFrtwbiF9GtnvkxiStd0AFEm9cTz+H2S7yPuVXNQZVPuBbrDuU 8YLstvt9JLnBjDwR7ZRJj96fEFQDDyhFrf2bLYWvdChslbAf+0oZs/uyuF7OwBsQy+mi h+pzAWLil038z0TsRd92enKszlp6jRzYIui6dvJlzMG98Mbqtdtrya4GiYhsCtTWjbUp GsHDr+rwTd4lo0zapIOgqtOP2ne1wR1kwIaNi2RXzB4wUBsCrofwGi5bBYdt32CRn7p5 bI6hKhJP9i/jBX+ZtUbaHRv931LOS0u6glkR4bqpaaHC3MJUlkT0J6/RZ7fBzAw8Yw2J nlOQ== X-Gm-Message-State: APt69E0A7IQSFqvCMblQL50esFgZLCTsYO2WcTB9sQslmL7nDihK7wA1 TPb5D7lEv4tbasmZsMv0bbE2Bw== X-Google-Smtp-Source: ADUXVKLD+3PGY4RrfV5wQ6N/2WGGGwWLArPYhV+ReTakQ/psZm44ntgnXqRfJq7+L2QZW0H12UwQ1A== X-Received: by 2002:aca:1701:: with SMTP id j1-v6mr4489927oii.113.1528152294702; Mon, 04 Jun 2018 15:44:54 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id 187-v6sm26719019oii.40.2018.06.04.15.44.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 15:44:53 -0700 (PDT) Subject: Re: Pgagent is not reading pgpass file either in Windows or Linux. To: pgsql-general@lists.postgresql.org References: <5595335e-32e8-80da-9c65-8d79fce554a7@aklaver.com> From: Ron Message-ID: Date: Mon, 4 Jun 2018 17:44:53 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------14AEB7D73E3E3D73C61D0724" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------14AEB7D73E3E3D73C61D0724 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit I've noticed that .pgpass is case sensitive, so am not surprised that it also wouldn't note the difference between 127.0.0.1 and localhost. On 06/04/2018 05:31 PM, nageswara Bandla wrote: > I have figured out the issue with pgAgent both in Windows and Linux. > > PgAgent seems to ignore pgpass.conf/.pgpass whenever it has 127.0.0.1 > (127.0.0.1:5432:*:postgres:postgres) throws an error: > > *DEBUG: Creating DB connection: user=postgres port=5432 hostaddr=127.0.0.1 > dbname=linuxpostgresdb* > > *WARNING: Couldn't create the primary connection (attempt 1): fe_sendauth: > no password supplied* > > * > * > > The solution could be update .pgpass to have ( > localhost:5432:*:postgres:postgres ) and then pgagent works fine without > issues. > > > I think, pgagent is not inline with libpq.dll while passing host address > parameter. I have raised this concern with pgagent github where exactly > they need to change > > the code in order for pgagent to be in line with psql program. > > > https://github.com/postgres/pgagent/issues/14 > > > On Fri, Jun 1, 2018 at 9:43 AM, nageswara Bandla > wrote: > > > > On Thu, May 31, 2018 at 5:16 PM, George Neuner > wrote: > > On Thu, 31 May 2018 15:40:21 -0500, nageswara Bandla > > wrote: > > >On Thu, May 31, 2018 at 12:57 PM, George Neuner > > > >wrote: > > > >> It just occurred to me that you said PGPASSFILE was set to > >> > >>     %APPDATA%/postgresql/pgpass.conf > >> > >> > >> The problem may be that when LocalSystem expands %APPDATA%, it is > >> finding its own directory, which might be any of: > >> > >>    C:\Windows\ServiceProfiles\LocalService\appdata > >>    C:\Windows\System32\config\systemprofile\AppData > >>    C:\Windows\SysWOW64\config\systemprofile\AppData > >> > >> depending on your Windows version, policies (if any), and > whether the > >> executable is 32 or 64 bit. > >> > >> > >> I wouldn't try messing with any of these directories. Instead try > >> setting PGPASSFILE to the full path to your file. > >> > >> > >I have tried all of them, pgagent is not recognizing any of the above > >locations. In fact, I have tried both options > > > > #1. By defining PGPASSFILE to the above locations one after the > other. > > #2. By copying pgpass.conf to all the three locations by creating > >Roaming/postgresql directories. > > > >And also I have defined PGPASSFILE=C:\pgpass.conf; I think, this > should be > >accessible to any system account. This also not working. > > > One more stupid question and then I'm out of ideas ... > > > Have you rebooted after changing the environment variable? > > Global environment changes normally don't take effect until the user > logs out/in again.  LocalSystem is not an interactive user - you have > to restart the system to let it see environment changes.  PITA. > > > Yes, I did. But no luck..I guess, we have to live with this problem > for pgagent running as a Local System account. > We need to run pgagent service as  "Logon user account" and provide > user logon credentials for running pgagent service. > > In Linux case, pgagent is not even reading .pgpass itself. The issue > here is that the logs (debug level log) are no help. It don't have > much information. > Which password file it is trying to read. > > > > > George > > > > -- Angular momentum makes the world go 'round. --------------14AEB7D73E3E3D73C61D0724 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit I've noticed that .pgpass is case sensitive, so am not surprised that it also wouldn't note the difference between 127.0.0.1 and localhost.

On 06/04/2018 05:31 PM, nageswara Bandla wrote:
I have figured out the issue with pgAgent both in Windows and Linux. 

PgAgent seems to ignore pgpass.conf/.pgpass whenever it has 127.0.0.1 (127.0.0.1:5432:*:postgres:postgres) throws an error:

    DEBUG: Creating DB connection: user=postgres port=5432 hostaddr=127.0.0.1 dbname=linuxpostgresdb

    WARNING: Couldn't create the primary connection (attempt 1): fe_sendauth: no password supplied


The solution could be update .pgpass to have ( localhost:5432:*:postgres:postgres ) and then pgagent works fine without issues.


I think, pgagent is not inline with libpq.dll while passing host address parameter. I have raised this concern with pgagent github where exactly they need to change

the code in order for pgagent to be in line with psql program. 




On Fri, Jun 1, 2018 at 9:43 AM, nageswara Bandla <nag.bandla@gmail.com> wrote:


On Thu, May 31, 2018 at 5:16 PM, George Neuner <gneuner2@comcast.net> wrote:
On Thu, 31 May 2018 15:40:21 -0500, nageswara Bandla
<nag.bandla@gmail.com> wrote:

>On Thu, May 31, 2018 at 12:57 PM, George Neuner <gneuner2@comcast.net>
>wrote:
>
>> It just occurred to me that you said PGPASSFILE was set to
>>
>>     %APPDATA%/postgresql/pgpass.conf
>>
>>
>> The problem may be that when LocalSystem expands %APPDATA%, it is
>> finding its own directory, which might be any of:
>>
>>    C:\Windows\ServiceProfiles\LocalService\appdata
>>    C:\Windows\System32\config\systemprofile\AppData
>>    C:\Windows\SysWOW64\config\systemprofile\AppData
>>
>> depending on your Windows version, policies (if any), and whether the
>> executable is 32 or 64 bit.
>>
>>
>> I wouldn't try messing with any of these directories. Instead try
>> setting PGPASSFILE to the full path to your file.
>>
>>
>I have tried all of them, pgagent is not recognizing any of the above
>locations. In fact, I have tried both options
>
> #1. By defining PGPASSFILE to the above locations one after the other.
> #2. By copying pgpass.conf to all the three locations by creating
>Roaming/postgresql directories.
>
>And also I have defined PGPASSFILE=C:\pgpass.conf; I think, this should be
>accessible to any system account. This also not working.


One more stupid question and then I'm out of ideas ...


Have you rebooted after changing the environment variable? 

Global environment changes normally don't take effect until the user
logs out/in again.  LocalSystem is not an interactive user - you have
to restart the system to let it see environment changes.  PITA.


Yes, I did. But no luck..I guess, we have to live with this problem for pgagent running as a Local System account.
We need to run pgagent service as  "Logon user account" and provide user logon credentials for running pgagent service.

In Linux case, pgagent is not even reading .pgpass itself. The issue here is that the logs (debug level log) are no help. It don't have much information. 
Which password file it is trying to read. 
 




 
George





--
Angular momentum makes the world go 'round.
--------------14AEB7D73E3E3D73C61D0724--