lib / pq

Pure Go Postgres driver for database/sql
https://pkg.go.dev/github.com/lib/pq
MIT License
9.01k stars 910 forks source link

PGPASSFILE on Windows can't work #940

Open Radranic opened 4 years ago

Radranic commented 4 years ago

It seems the implementation from #75 can't work on windows due to some file permissions limitations in go.

Line 204 of conn.go checks permissions to ensure there is no group/other permissions set (also should it be 077 instead of 0x77?).

Unfortunately due to windows not supporting unix permissions the permissions are always have all the user/group/other bits set to the same values. Relevant source

While ideally the windows permission mapping would be fixed, it would be nice if this worked in the mean time. I'm not sure what the exact expected behavior is given we can't check the bits correctly, but I can make a PR if I know what the goal (aside from working) is.

Also if someone more familiar with unix permision bits could verify the 0x77 vs 077?

matrosov-nikita commented 3 years ago

Confirms that issue is still relevant, providing PGPASSFILE env variable doesn't work on Windows because of incorrect permissions check here ( https://github.com/lib/pq/blob/9eb3fc897d6fd97dd4aad3d0404b54e2f7cc56be/conn.go#L204)