forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite3f99e0
committed
Fix libpq's code for searching .pgpass; rationalize empty-list-item cases.
Before v10, we always searched ~/.pgpass using the host parameter,and nothing else, to match to the "hostname" field of ~/.pgpass.(However, null host or host matching DEFAULT_PGSOCKET_DIR was replaced by"localhost".) In v10, this got broken by commit274bb2b, repaired bycommitbdac983, and broken again by commit7b02ba6; in the codeactually shipped, we'd search with hostaddr if both that and host werespecified --- though oddly, *not* if only hostaddr were specified.Since this is directly contrary to the documentation, and notbackwards-compatible, it's clearly a bug.However, the change wasn't totally without justification, even though itwasn't done quite right, because the pre-v10 behavior has arguably beenbuggy since we added hostaddr. If hostaddr is specified and host isn't,the pre-v10 code will search ~/.pgpass for "localhost", and ship thatpassword off to a server that most likely isn't local at all. That'sunhelpful at best, and could be a security breach at worst.Therefore, rather than just revert to that old behavior, let's definethe behavior as "search with host if provided, else with hostaddr ifprovided, else search for localhost". (As before, a host name matchingDEFAULT_PGSOCKET_DIR is replaced by localhost.) This matches thebehavior of the actual connection code, so that we don't pick up aninappropriate password; and it allows useful searches to happen whenonly hostaddr is given.While we're messing around here, ensure that empty elements within ahost or hostaddr list select the same behavior as a totally-emptyfield would; for instance "host=a,,b" is equivalent to "host=a,/tmp,b"if DEFAULT_PGSOCKET_DIR is /tmp. Things worked that way in some casesalready, but not consistently so, which contributed to the confusionabout what key ~/.pgpass would get searched with.Update documentation accordingly, and also clarify some nearby text.Back-patch to v10 where the host/hostaddr list functionality wasintroduced.Discussion:https://postgr.es/m/30805.1532749137@sss.pgh.pa.us1 parente80f2b3 commite3f99e0
2 files changed
+84
-56
lines changedLines changed: 38 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
938 | 938 |
| |
939 | 939 |
| |
940 | 940 |
| |
941 |
| - | |
942 |
| - | |
| 941 | + | |
| 942 | + | |
943 | 943 |
| |
944 | 944 |
| |
945 | 945 |
| |
| |||
961 | 961 |
| |
962 | 962 |
| |
963 | 963 |
| |
964 |
| - | |
| 964 | + | |
965 | 965 |
| |
966 | 966 |
| |
967 | 967 |
| |
968 | 968 |
| |
969 | 969 |
| |
970 | 970 |
| |
971 | 971 |
| |
972 |
| - | |
| 972 | + | |
| 973 | + | |
973 | 974 |
| |
974 | 975 |
| |
975 | 976 |
| |
| |||
1020 | 1021 |
| |
1021 | 1022 |
| |
1022 | 1023 |
| |
1023 |
| - | |
| 1024 | + | |
| 1025 | + | |
1024 | 1026 |
| |
1025 | 1027 |
| |
1026 | 1028 |
| |
1027 | 1029 |
| |
1028 | 1030 |
| |
1029 | 1031 |
| |
1030 |
| - | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
1031 | 1035 |
| |
1032 | 1036 |
| |
1033 | 1037 |
| |
| |||
1047 | 1051 |
| |
1048 | 1052 |
| |
1049 | 1053 |
| |
1050 |
| - | |
1051 |
| - | |
1052 |
| - | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1053 | 1060 |
| |
1054 | 1061 |
| |
1055 | 1062 |
| |
| |||
1683 | 1690 |
| |
1684 | 1691 |
| |
1685 | 1692 |
| |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
1686 | 1704 |
| |
1687 | 1705 |
| |
1688 | 1706 |
| |
| |||
7521 | 7539 |
| |
7522 | 7540 |
| |
7523 | 7541 |
| |
7524 |
| - | |
7525 |
| - | |
7526 |
| - | |
7527 |
| - | |
| 7542 | + | |
| 7543 | + | |
| 7544 | + | |
| 7545 | + | |
| 7546 | + | |
| 7547 | + | |
| 7548 | + | |
| 7549 | + | |
| 7550 | + | |
7528 | 7551 |
| |
7529 |
| - | |
7530 |
| - | |
| 7552 | + | |
| 7553 | + | |
7531 | 7554 |
| |
7532 | 7555 |
| |
7533 | 7556 |
| |
|
Lines changed: 46 additions & 41 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
901 | 901 |
| |
902 | 902 |
| |
903 | 903 |
| |
| 904 | + | |
| 905 | + | |
904 | 906 |
| |
905 | 907 |
| |
906 | 908 |
| |
| |||
920 | 922 |
| |
921 | 923 |
| |
922 | 924 |
| |
923 |
| - | |
| 925 | + | |
924 | 926 |
| |
925 | 927 |
| |
926 | 928 |
| |
927 |
| - | |
928 | 929 |
| |
929 | 930 |
| |
930 | 931 |
| |
| |||
933 | 934 |
| |
934 | 935 |
| |
935 | 936 |
| |
936 |
| - | |
937 |
| - | |
938 | 937 |
| |
939 | 938 |
| |
940 | 939 |
| |
| |||
948 | 947 |
| |
949 | 948 |
| |
950 | 949 |
| |
951 |
| - | |
952 | 950 |
| |
953 | 951 |
| |
954 | 952 |
| |
| |||
957 | 955 |
| |
958 | 956 |
| |
959 | 957 |
| |
960 |
| - | |
961 |
| - | |
962 |
| - | |
963 |
| - | |
964 |
| - | |
965 |
| - | |
966 |
| - | |
967 |
| - | |
968 |
| - | |
969 |
| - | |
970 | 958 |
| |
| 959 | + | |
| 960 | + | |
971 | 961 |
| |
972 | 962 |
| |
973 | 963 |
| |
| |||
979 | 969 |
| |
980 | 970 |
| |
981 | 971 |
| |
982 |
| - | |
| 972 | + | |
| 973 | + | |
983 | 974 |
| |
984 |
| - | |
985 |
| - | |
| 975 | + | |
986 | 976 |
| |
987 |
| - | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
988 | 984 |
| |
989 |
| - | |
990 |
| - | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
991 | 996 |
| |
992 |
| - | |
993 |
| - | |
| 997 | + | |
| 998 | + | |
994 | 999 |
| |
995 |
| - | |
996 |
| - | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
997 | 1003 |
| |
998 | 1004 |
| |
999 | 1005 |
| |
1000 | 1006 |
| |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
1001 | 1011 |
| |
1002 | 1012 |
| |
1003 | 1013 |
| |
1004 |
| - | |
1005 | 1014 |
| |
1006 | 1015 |
| |
1007 | 1016 |
| |
| |||
1065 | 1074 |
| |
1066 | 1075 |
| |
1067 | 1076 |
| |
1068 |
| - | |
1069 |
| - | |
| 1077 | + | |
| 1078 | + | |
1070 | 1079 |
| |
1071 | 1080 |
| |
1072 | 1081 |
| |
| |||
1089 | 1098 |
| |
1090 | 1099 |
| |
1091 | 1100 |
| |
1092 |
| - | |
1093 |
| - | |
1094 | 1101 |
| |
1095 | 1102 |
| |
1096 | 1103 |
| |
1097 |
| - | |
1098 |
| - | |
1099 |
| - | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
1100 | 1107 |
| |
1101 |
| - | |
| 1108 | + | |
1102 | 1109 |
| |
1103 |
| - | |
1104 |
| - | |
1105 |
| - | |
| 1110 | + | |
1106 | 1111 |
| |
1107 | 1112 |
| |
1108 | 1113 |
| |
| |||
6385 | 6390 |
| |
6386 | 6391 |
| |
6387 | 6392 |
| |
6388 |
| - | |
| 6393 | + | |
6389 | 6394 |
| |
6390 | 6395 |
| |
6391 |
| - | |
| 6396 | + | |
6392 | 6397 |
| |
6393 | 6398 |
| |
6394 | 6399 |
| |
6395 |
| - | |
| 6400 | + | |
6396 | 6401 |
| |
6397 | 6402 |
| |
6398 | 6403 |
| |
| |||
6403 | 6408 |
| |
6404 | 6409 |
| |
6405 | 6410 |
| |
6406 |
| - | |
| 6411 | + | |
6407 | 6412 |
| |
6408 | 6413 |
| |
6409 | 6414 |
| |
|
0 commit comments
Comments
(0)