|
10 | 10 | * |
11 | 11 | * |
12 | 12 | * IDENTIFICATION |
13 | | - * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.173 2008/11/2009:29:36 mha Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.174 2008/11/2011:48:26 mha Exp $ |
14 | 14 | * |
15 | 15 | *------------------------------------------------------------------------- |
16 | 16 | */ |
@@ -858,6 +858,12 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) |
858 | 858 | parsedline->auth_method=uaLDAP; |
859 | 859 | #else |
860 | 860 | unsupauth="ldap"; |
| 861 | +#endif |
| 862 | +elseif (strcmp(token, "cert")==0) |
| 863 | +#ifdefUSE_SSL |
| 864 | +parsedline->auth_method=uaCert; |
| 865 | +#else |
| 866 | +unsupauth="cert"; |
861 | 867 | #endif |
862 | 868 | else |
863 | 869 | { |
@@ -893,6 +899,17 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) |
893 | 899 | return false; |
894 | 900 | } |
895 | 901 |
|
| 902 | +if (parsedline->conntype!=ctHostSSL&& |
| 903 | +parsedline->auth_method==uaCert) |
| 904 | +{ |
| 905 | +ereport(LOG, |
| 906 | +(errcode(ERRCODE_CONFIG_FILE_ERROR), |
| 907 | +errmsg("cert authentication is only supported on hostssl connections"), |
| 908 | +errcontext("line %d of configuration file \"%s\"", |
| 909 | +line_num,HbaFileName))); |
| 910 | +return false; |
| 911 | +} |
| 912 | + |
896 | 913 | /* Parse remaining arguments */ |
897 | 914 | while ((line_item=lnext(line_item))!=NULL) |
898 | 915 | { |
@@ -923,8 +940,9 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) |
923 | 940 | if (parsedline->auth_method!=uaIdent&& |
924 | 941 | parsedline->auth_method!=uaKrb5&& |
925 | 942 | parsedline->auth_method!=uaGSS&& |
926 | | -parsedline->auth_method!=uaSSPI) |
927 | | -INVALID_AUTH_OPTION("map","ident, krb5, gssapi and sspi"); |
| 943 | +parsedline->auth_method!=uaSSPI&& |
| 944 | +parsedline->auth_method!=uaCert) |
| 945 | +INVALID_AUTH_OPTION("map","ident, krb5, gssapi, sspi and cert"); |
928 | 946 | parsedline->usermap=pstrdup(c); |
929 | 947 | } |
930 | 948 | elseif (strcmp(token,"clientcert")==0) |
@@ -957,7 +975,18 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) |
957 | 975 | parsedline->clientcert= true; |
958 | 976 | } |
959 | 977 | else |
| 978 | +{ |
| 979 | +if (parsedline->auth_method==uaCert) |
| 980 | +{ |
| 981 | +ereport(LOG, |
| 982 | +(errcode(ERRCODE_CONFIG_FILE_ERROR), |
| 983 | +errmsg("clientcert can not be set to 0 when using \"cert\" authentication"), |
| 984 | +errcontext("line %d of configuration file \"%s\"", |
| 985 | +line_num,HbaFileName))); |
| 986 | +return false; |
| 987 | +} |
960 | 988 | parsedline->clientcert= false; |
| 989 | +} |
961 | 990 | } |
962 | 991 | elseif (strcmp(token,"pamservice")==0) |
963 | 992 | { |
@@ -1021,6 +1050,14 @@ parse_hba_line(List *line, int line_num, HbaLine *parsedline) |
1021 | 1050 | { |
1022 | 1051 | MANDATORY_AUTH_ARG(parsedline->ldapserver,"ldapserver","ldap"); |
1023 | 1052 | } |
| 1053 | + |
| 1054 | +/* |
| 1055 | + * Enforce any parameters implied by other settings. |
| 1056 | + */ |
| 1057 | +if (parsedline->auth_method==uaCert) |
| 1058 | +{ |
| 1059 | +parsedline->clientcert= true; |
| 1060 | +} |
1024 | 1061 |
|
1025 | 1062 | return true; |
1026 | 1063 | } |
|