Re: Add pg_file_sync() to adminpack

Michael Paquier <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.general
Message-ID <[email protected]>
On Mon, Jan 06, 2020 at 03:20:13PM +0900, Arthur Zakirov wrote:
> It isn't case if a file doesn't exist. But if there are no permissions on
> the file:
> 
> PANIC:  could not open file "testfile": Permissions denied
> server closed the connection unexpectedly
> 
> It could be fixed by implementing a function like pg_file_sync_internal() or
> by making the function fsync_fname_ext() external.

The patch uses stat() to make sure that the file exists and has no
issues.  Though it could be a problem with any kind of TOCTOU-like
issues (looking at you, Windows, for ENOPERM), so I agree that it
would make more sense to use pg_fsync() here with a fd opened first.
--
Michael
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl4S1t8ACgkQnvQgOdby
QH0p+g/9H1v5SE2fnkPvM3iJ5eigbKU9B0qyT5Rcq6xoxdCnacRfMurtHOyD8om6
MOMRp+Z+ct7VsnOPXTRYbvdih/S7Yc9b/a9t3PFbCcNZshGdinkzF/Xq6LSrXNYw
/0F29Ww22XjggNcZJi8oiyLH1m1FXXR0ZiAgj++PuRNTcazRGGMa89CNtmUr1hkO
/YxKpHtNY65EF39z6By6lN8ocDgFpfrTaf57fKKW7UdvCWEeewwCykftCVju+dBn
Wu6PIwuLU8Ltu+AVeRAb/BR+QysYvFQ/WyWyRrRIUfnStAVWfCN7k4SAXAMqz98h
Vaq0svvYmynLjAS58OKtJ3AKudGmU+LynbUl2mlk+AZ9PYWpzY9fKgFUWnsaA/nn
FqIHoyodu0T+aH6onW41Tqsj/iozdxgr0CAiTVFAeDMeEX5QVEtGcviqDXZIeWtp
gkz+SyMtHUwvQgC/fTTz3iuIlgQueC/0vivvHa6CQ5gd11UGls2CJy8wqklxEcvY
Ynco6kk2ZnvEwKXxXhj7ieefzPA3gazzFTVntiiwT+bSeY0vd4qIJ/RbeSIqLgK6
4kqC1DGgdShr4BtbWmZOG2k2IoCugPE2f7846sXcVKjA5ZPV91ne062uPjyy85JJ
fTIqdC522jCE6XmRv3cNymEmn0nMul6kOpVAW3FGYftMqheO/qY=
=05/O
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.