|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.85 2002/08/27 16:21:50 momjian Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.86 2002/08/29 03:22:01 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
|
37 | 37 |
|
38 | 38 |
|
39 | 39 | static void sendAuthRequest(Port *port, AuthRequest areq); |
40 | | -static int old_be_recvauth(Port *port); |
41 | | -static int map_old_to_new(Port *port, UserAuth old, int status); |
42 | 40 | static void auth_failed(Port *port, int status); |
43 | 41 | static int recv_and_check_password_packet(Port *port); |
44 | | -static int recv_and_check_passwordv0(Port *port); |
45 | 42 |
|
46 | 43 | char *pg_krb_server_keyfile; |
47 | 44 |
|
@@ -318,86 +315,6 @@ pg_krb5_recvauth(Port *port) |
318 | 315 | #endif /* KRB5 */ |
319 | 316 |
|
320 | 317 |
|
321 | | -/* |
322 | | - * Handle a v0 password packet. |
323 | | - */ |
324 | | -static int |
325 | | -recv_and_check_passwordv0(Port *port) |
326 | | -{ |
327 | | - int32 len; |
328 | | - char *buf; |
329 | | - PasswordPacketV0 *pp; |
330 | | - char *user, |
331 | | - *password, |
332 | | - *cp, |
333 | | - *start; |
334 | | - int status; |
335 | | - |
336 | | - if (pq_getint(&len, 4) == EOF) |
337 | | - return STATUS_EOF; |
338 | | - len -= 4; |
339 | | - buf = palloc(len); |
340 | | - if (pq_getbytes(buf, len) == EOF) |
341 | | - { |
342 | | - pfree(buf); |
343 | | - return STATUS_EOF; |
344 | | - } |
345 | | - |
346 | | - pp = (PasswordPacketV0 *) buf; |
347 | | - |
348 | | - /* |
349 | | - * The packet is supposed to comprise the user name and the password |
350 | | - * as C strings. Be careful to check that this is the case. |
351 | | - */ |
352 | | - user = password = NULL; |
353 | | - |
354 | | - len -= sizeof(pp->unused); |
355 | | - |
356 | | - cp = start = pp->data; |
357 | | - |
358 | | - while (len-- > 0) |
359 | | - if (*cp++ == '\0') |
360 | | - { |
361 | | - if (user == NULL) |
362 | | - user = start; |
363 | | - else |
364 | | - { |
365 | | - password = start; |
366 | | - break; |
367 | | - } |
368 | | - |
369 | | - start = cp; |
370 | | - } |
371 | | - |
372 | | - if (user == NULL || password == NULL) |
373 | | - { |
374 | | - elog(LOG, "pg_password_recvauth: badly formed password packet"); |
375 | | - status = STATUS_ERROR; |
376 | | - } |
377 | | - else |
378 | | - { |
379 | | - UserAuth saved; |
380 | | - |
381 | | - /* Check the password. */ |
382 | | - |
383 | | - saved = port->auth_method; |
384 | | - port->auth_method = uaPassword; |
385 | | - |
386 | | - status = md5_crypt_verify(port, user, password); |
387 | | - |
388 | | - port->auth_method = saved; |
389 | | - |
390 | | - /* Adjust the result if necessary. */ |
391 | | - if (map_old_to_new(port, uaPassword, status) != STATUS_OK) |
392 | | - status = STATUS_ERROR; |
393 | | - } |
394 | | - |
395 | | - pfree(buf); |
396 | | - |
397 | | - return status; |
398 | | -} |
399 | | - |
400 | | - |
401 | 318 | /* |
402 | 319 | * Tell the user the authentication failed, but not (much about) why. |
403 | 320 | * |
@@ -481,16 +398,6 @@ ClientAuthentication(Port *port) |
481 | 398 | if (hba_getauthmethod(port) != STATUS_OK) |
482 | 399 | elog(FATAL, "Missing or erroneous pg_hba.conf file, see postmaster log for details"); |
483 | 400 |
|
484 | | - /* Handle old style authentication. */ |
485 | | - if (PG_PROTOCOL_MAJOR(port->proto) == 0) |
486 | | - { |
487 | | - status = old_be_recvauth(port); |
488 | | - if (status != STATUS_OK) |
489 | | - auth_failed(port, status); |
490 | | - return; |
491 | | - } |
492 | | - |
493 | | - /* Handle new style authentication. */ |
494 | 401 | switch (port->auth_method) |
495 | 402 | { |
496 | 403 | case uaReject: |
@@ -828,90 +735,3 @@ recv_and_check_password_packet(Port *port) |
828 | 735 | pfree(buf.data); |
829 | 736 | return result; |
830 | 737 | } |
831 | | - |
832 | | - |
833 | | -/* |
834 | | - * Server demux routine for incoming authentication information for protocol |
835 | | - * version 0. |
836 | | - */ |
837 | | -static int |
838 | | -old_be_recvauth(Port *port) |
839 | | -{ |
840 | | - int status; |
841 | | - MsgType msgtype = (MsgType) port->proto; |
842 | | - |
843 | | - /* Handle the authentication that's offered. */ |
844 | | - switch (msgtype) |
845 | | - { |
846 | | - case STARTUP_KRB4_MSG: |
847 | | - status = map_old_to_new(port, uaKrb4, pg_krb4_recvauth(port)); |
848 | | - break; |
849 | | - |
850 | | - case STARTUP_KRB5_MSG: |
851 | | - status = map_old_to_new(port, uaKrb5, pg_krb5_recvauth(port)); |
852 | | - break; |
853 | | - |
854 | | - case STARTUP_MSG: |
855 | | - status = map_old_to_new(port, uaTrust, STATUS_OK); |
856 | | - break; |
857 | | - |
858 | | - case STARTUP_PASSWORD_MSG: |
859 | | - status = recv_and_check_passwordv0(port); |
860 | | - break; |
861 | | - |
862 | | - default: |
863 | | - elog(LOG, "Invalid startup message type: %u", msgtype); |
864 | | - |
865 | | - return STATUS_ERROR; |
866 | | - } |
867 | | - |
868 | | - return status; |
869 | | -} |
870 | | - |
871 | | - |
872 | | -/* |
873 | | - * The old style authentication has been done. Modify the result of this (eg. |
874 | | - * allow the connection anyway, disallow it anyway, or use the result) |
875 | | - * depending on what authentication we really want to use. |
876 | | - */ |
877 | | -static int |
878 | | -map_old_to_new(Port *port, UserAuth old, int status) |
879 | | -{ |
880 | | - switch (port->auth_method) |
881 | | - { |
882 | | - case uaMD5: |
883 | | - case uaCrypt: |
884 | | - case uaReject: |
885 | | -#ifdef USE_PAM |
886 | | - case uaPAM: |
887 | | -#endif /* USE_PAM */ |
888 | | - status = STATUS_ERROR; |
889 | | - break; |
890 | | - |
891 | | - case uaKrb4: |
892 | | - if (old != uaKrb4) |
893 | | - status = STATUS_ERROR; |
894 | | - break; |
895 | | - |
896 | | - case uaKrb5: |
897 | | - if (old != uaKrb5) |
898 | | - status = STATUS_ERROR; |
899 | | - break; |
900 | | - |
901 | | - case uaTrust: |
902 | | - status = STATUS_OK; |
903 | | - break; |
904 | | - |
905 | | - case uaIdent: |
906 | | - status = authident(port); |
907 | | - break; |
908 | | - |
909 | | - case uaPassword: |
910 | | - if (old != uaPassword) |
911 | | - status = STATUS_ERROR; |
912 | | - |
913 | | - break; |
914 | | - } |
915 | | - |
916 | | - return status; |
917 | | -} |
0 commit comments