pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_basebackup fails with Could not stat file or directory "./.pg_hba.conf.un~"
4+ messages / 4 participants
[nested] [flat]

* pg_basebackup fails with Could not stat file or directory "./.pg_hba.conf.un~"
@ 2023-03-07 20:14  Stephens, Gary <Gary.Stephens@ehi.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Stephens, Gary @ 2023-03-07 20:14 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi,

I'm writing to report a bug with pg_basebackup. It fails with this error:

pg_basebackup: error: could not initiate base backup: ERROR:  could not stat file or directory "./.pg_hba.conf.un~": Permission denied

The file in question is a temporary file created by vim, and has the same permissions and security context as the file that it was editing (pg_hba.conf).

It's unclear to me why pg_basebackup is trying to read this file. It's also unclear why it's failing when it does try to read it, since the file has the same permissions and security context that should allow the instance to read it (even though the backup really shouldn't need to read it).

The directory where it resides is /var/lib/pgsql/data (this is where pg_hba.conf resides as well).

Please note: After I removed the file, the backup ran normally. I have not tested to see whether other temp files in the same directory would cause a similar failure.

Database version:
postgres=# select version();
                                                   version
-------------------------------------------------------------------------------------------------------------
PostgreSQL 13.7 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-10), 64-bit

Thanks,

Gary Stephens
Enterprise Holdings, Incorporated

________________________________

CONFIDENTIALITY NOTICE: This e-mail and any files transmitted with it are intended solely for the use of the individual or entity to whom they are addressed and may contain confidential and privileged information protected by law. If you received this e-mail in error, any review, use, dissemination, distribution, or copying of the e-mail is strictly prohibited. Please notify the sender immediately by return e-mail and delete all copies from your system.

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

* Re: pg_basebackup fails with Could not stat file or directory "./.pg_hba.conf.un~"
@ 2023-03-07 21:32  David G. Johnston <david.g.johnston@gmail.com>
  parent: Stephens, Gary <Gary.Stephens@ehi.com>
  0 siblings, 1 reply; 4+ messages in thread

From: David G. Johnston @ 2023-03-07 21:32 UTC (permalink / raw)
  To: Stephens, Gary <Gary.Stephens@ehi.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Tue, Mar 7, 2023 at 1:37 PM Stephens, Gary <Gary.Stephens@ehi.com> wrote:

>
> It's unclear to me why pg_basebackup is trying to read this file.
>

Because that is what it is documented to do:

https://www.postgresql.org/docs/current/app-pgbasebackup.html

> The backup will include all files in the data directory and tablespaces,
including the configuration files and any additional files placed in the
directory by third parties, except certain temporary files managed by
PostgreSQL.


> It's also unclear why it's failing when it does try to read it, since the
> file has the same permissions and security context that should allow the
> instance to read it (even though the backup really shouldn’t need to read
> it).
>

Understandable, but not a pg_basebackup bug that it is being told it lacks
permission.  But I suspect there is file locking involved and it isn't a
file permission problem.

David J.

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

* Re: pg_basebackup fails with Could not stat file or directory "./.pg_hba.conf.un~"
@ 2023-03-08 09:55  Francisco Olarte <folarte@peoplecall.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Francisco Olarte @ 2023-03-08 09:55 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Stephens, Gary <Gary.Stephens@ehi.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi David:

On Tue, 7 Mar 2023 at 22:32, David G. Johnston
<david.g.johnston@gmail.com> wrote:
> Understandable, but not a pg_basebackup bug that it is being told it lacks permission.  But I suspect there is file locking involved and it isn't a file permission problem.

Besides locking I've encountered this kind of problems with people
having a habit of editing non-root-owned config files as root with
editors which do not take care of setting permissions. An ls -l of the
offending file is normally useful, or the version with all extended
acl/attrs which I'm unable to recall now.

Francisco Olarte.





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

* Re: pg_basebackup fails with Could not stat file or directory "./.pg_hba.conf.un~"
@ 2023-03-08 15:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Francisco Olarte <folarte@peoplecall.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2023-03-08 15:50 UTC (permalink / raw)
  To: Francisco Olarte <folarte@peoplecall.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Stephens, Gary <Gary.Stephens@ehi.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Francisco Olarte <folarte@peoplecall.com> writes:
> Besides locking I've encountered this kind of problems with people
> having a habit of editing non-root-owned config files as root with
> editors which do not take care of setting permissions. An ls -l of the
> offending file is normally useful, or the version with all extended
> acl/attrs which I'm unable to recall now.

Yeah, "ls -lZ" to see SELinux labels.  It's easy to forget about those
if you're not pretty used to them.

			regards, tom lane





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


end of thread, other threads:[~2023-03-08 15:50 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 20:14 pg_basebackup fails with Could not stat file or directory "./.pg_hba.conf.un~" Stephens, Gary <Gary.Stephens@ehi.com>
2023-03-07 21:32 ` David G. Johnston <david.g.johnston@gmail.com>
2023-03-08 09:55   ` Francisco Olarte <folarte@peoplecall.com>
2023-03-08 15:50     ` 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