Remove the use of the pg_auth flat file for client authentication.
(That flat file is now completely useless, but removal will come later.) To do this, postpone client authentication into the startup transaction that's run by InitPostgres. We still collect the startup packet and do SSL initialization (if needed) at the same time we did before. The AuthenticationTimeout is applied separately to startup packet collection and the actual authentication cycle. (This is a bit annoying, since it means a couple extra syscalls; but the signal handling requirements inside and outside a transaction are sufficiently different that it seems best to treat the timeouts as completely independent.) A small security disadvantage is that if the given database name is invalid, this will be reported to the client before any authentication happens. We could work around that by connecting to database "postgres" instead, but consensus seems to be that it's not worth introducing such surprising behavior. Processing of all command-line switches and GUC options received from the client is now postponed until after authentication. This means that PostAuthDelay is much less useful than it used to be --- if you need to investigate problems during InitPostgres you'll have to set PreAuthDelay instead. However, allowing an unauthenticated user to set any GUC options whatever seems a bit too risky, so we'll live with that.
Showing
- src/backend/libpq/auth.c 15 additions, 7 deletionssrc/backend/libpq/auth.c
- src/backend/libpq/crypt.c 49 additions, 34 deletionssrc/backend/libpq/crypt.c
- src/backend/libpq/hba.c 32 additions, 131 deletionssrc/backend/libpq/hba.c
- src/backend/libpq/pqsignal.c 20 additions, 20 deletionssrc/backend/libpq/pqsignal.c
- src/backend/postmaster/postmaster.c 57 additions, 152 deletionssrc/backend/postmaster/postmaster.c
- src/backend/tcop/postgres.c 245 additions, 220 deletionssrc/backend/tcop/postgres.c
- src/backend/utils/init/flatfiles.c 1 addition, 6 deletionssrc/backend/utils/init/flatfiles.c
- src/backend/utils/init/postinit.c 102 additions, 2 deletionssrc/backend/utils/init/postinit.c
- src/backend/utils/misc/guc.c 3 additions, 18 deletionssrc/backend/utils/misc/guc.c
- src/include/libpq/hba.h 2 additions, 3 deletionssrc/include/libpq/hba.h
- src/include/libpq/pqsignal.h 3 additions, 3 deletionssrc/include/libpq/pqsignal.h
- src/include/miscadmin.h 2 additions, 1 deletionsrc/include/miscadmin.h
- src/include/storage/pmsignal.h 1 addition, 2 deletionssrc/include/storage/pmsignal.h
- src/include/tcop/tcopprot.h 1 addition, 2 deletionssrc/include/tcop/tcopprot.h
- src/include/utils/guc.h 1 addition, 2 deletionssrc/include/utils/guc.h
Loading
Please register or sign in to comment