PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netdb.h>
#include "common/md5.h"
#include "common/scram-common.h"
#include "fe-auth.h"
#include "fe-auth-sasl.h"
#include "libpq-fe.h"
Go to the source code of this file.
Macros | |
#define | auth_method_allowed(conn, type) (((conn)->allowed_auth_methods & (1 << (type))) != 0) |
#define | MAX_ALGORITHM_NAME_LEN 50 |
Functions | |
static int | pg_SASL_init (PGconn *conn, int payloadlen) |
static int | pg_SASL_continue (PGconn *conn, int payloadlen, bool final) |
static int | pg_password_sendauth (PGconn *conn, const char *password, AuthRequest areq) |
static const char * | auth_method_description (AuthRequest areq) |
static bool | check_expected_areq (AuthRequest areq, PGconn *conn) |
int | pg_fe_sendauth (AuthRequest areq, int payloadlen, PGconn *conn) |
char * | pg_fe_getusername (uid_t user_id, PQExpBuffer errorMessage) |
char * | pg_fe_getauthname (PQExpBuffer errorMessage) |
char * | PQencryptPassword (const char *passwd, const char *user) |
char * | PQencryptPasswordConn (PGconn *conn, const char *passwd, const char *user, const char *algorithm) |
#define MAX_ALGORITHM_NAME_LEN 50 |
|
static |
Definition at line 768 of file fe-auth.c.
References AUTH_REQ_GSS, AUTH_REQ_GSS_CONT, AUTH_REQ_MD5, AUTH_REQ_PASSWORD, AUTH_REQ_SASL, AUTH_REQ_SASL_CONT, AUTH_REQ_SASL_FIN, AUTH_REQ_SSPI, and libpq_gettext.
Referenced by check_expected_areq().
|
static |
Definition at line 803 of file fe-auth.c.
References pg_conn::allowed_auth_methods, auth_method_allowed, auth_method_description(), AUTH_REQ_GSS, AUTH_REQ_GSS_CONT, AUTH_REQ_MAX, AUTH_REQ_MD5, AUTH_REQ_OK, AUTH_REQ_PASSWORD, AUTH_REQ_SASL, AUTH_REQ_SASL_CONT, AUTH_REQ_SASL_FIN, AUTH_REQ_SSPI, pg_conn::auth_required, pg_conn::channel_binding, pg_fe_sasl_mech::channel_bound, pg_conn::client_finished_auth, conn, libpq_append_conn_error(), libpq_gettext, pg_conn::require_auth, pg_conn::sasl, pg_conn::sasl_state, pg_conn::ssl_cert_requested, pg_conn::ssl_cert_sent, pg_conn::sslcertmode, and StaticAssertDecl.
Referenced by pg_fe_sendauth().
char* pg_fe_getauthname | ( | PQExpBuffer | errorMessage | ) |
Definition at line 1215 of file fe-auth.c.
References pg_fe_getusername().
Referenced by connectOptions2(), and conninfo_add_defaults().
char* pg_fe_getusername | ( | uid_t | user_id, |
PQExpBuffer | errorMessage | ||
) |
Definition at line 1170 of file fe-auth.c.
References appendPQExpBuffer(), libpq_append_error(), name, pg_get_user_name(), and username.
Referenced by pg_fe_getauthname(), and PQconnectPoll().
int pg_fe_sendauth | ( | AuthRequest | areq, |
int | payloadlen, | ||
PGconn * | conn | ||
) |
Definition at line 962 of file fe-auth.c.
References appendPQExpBufferStr(), AUTH_REQ_CRYPT, AUTH_REQ_GSS, AUTH_REQ_GSS_CONT, AUTH_REQ_KRB4, AUTH_REQ_KRB5, AUTH_REQ_MD5, AUTH_REQ_OK, AUTH_REQ_PASSWORD, AUTH_REQ_SASL, AUTH_REQ_SASL_CONT, AUTH_REQ_SASL_FIN, AUTH_REQ_SSPI, check_expected_areq(), pg_conn::client_finished_auth, conn, pg_conn::connhost, pg_conn::errorMessage, pg_conn::gsslib, PQExpBufferData::len, libpq_append_conn_error(), password, pg_conn_host::password, pg_conn::password_needed, pg_password_sendauth(), pg_SASL_continue(), pg_SASL_init(), pg_strcasecmp(), pglock_thread, pg_conn::pgpass, pgunlock_thread, PQnoPasswordSupplied, pg_conn::sasl_state, STATUS_ERROR, STATUS_OK, and pg_conn::whichhost.
Referenced by PQconnectPoll().
|
static |
Definition at line 702 of file fe-auth.c.
References AUTH_REQ_MD5, AUTH_REQ_PASSWORD, conn, free, libpq_append_conn_error(), malloc, MD5_PASSWD_LEN, password, pg_md5_encrypt(), pg_conn::pguser, pqGetnchar(), pqPacketSend(), and STATUS_ERROR.
Referenced by pg_fe_sendauth().
Definition at line 628 of file fe-auth.c.
References conn, pg_fe_sasl_mech::exchange, free, libpq_append_conn_error(), malloc, output, pqGetnchar(), pqPacketSend(), res, pg_conn::sasl, pg_conn::sasl_state, STATUS_ERROR, STATUS_OK, and success.
Referenced by pg_fe_sendauth().
|
static |
Definition at line 422 of file fe-auth.c.
References appendPQExpBufferStr(), Assert(), pg_conn::channel_binding, conn, pg_conn::connhost, PQExpBufferData::data, error(), pg_conn::errorMessage, pg_fe_sasl_mech::exchange, free, pg_fe_sasl_mech::init, initPQExpBuffer(), libpq_append_conn_error(), password, pg_conn_host::password, pg_conn::password_needed, pg_scram_mech, pg_conn::pgpass, PQExpBufferDataBroken, pqFlush(), pqGets(), PqMsg_SASLInitialResponse, PQnoPasswordSupplied, pqPutInt(), pqPutMsgEnd(), pqPutMsgStart(), pqPutnchar(), pqPuts(), pg_conn::sasl, pg_conn::sasl_state, SCRAM_SHA_256_NAME, SCRAM_SHA_256_PLUS_NAME, pg_conn::ssl_in_use, STATUS_ERROR, STATUS_OK, success, termPQExpBuffer(), and pg_conn::whichhost.
Referenced by pg_fe_sendauth().
char* PQencryptPassword | ( | const char * | passwd, |
const char * | user | ||
) |
Definition at line 1234 of file fe-auth.c.
References free, malloc, MD5_PASSWD_LEN, pg_md5_encrypt(), and user.
char* PQencryptPasswordConn | ( | PGconn * | conn, |
const char * | passwd, | ||
const char * | user, | ||
const char * | algorithm | ||
) |
Definition at line 1277 of file fe-auth.c.
References conn, free, libpq_append_conn_error(), malloc, MAX_ALGORITHM_NAME_LEN, MD5_PASSWD_LEN, pg_fe_scram_build_secret(), pg_md5_encrypt(), PGRES_TUPLES_OK, PQclear(), pqClearConnErrorState, PQexec(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), res, pg_conn::scram_sha_256_iterations, user, and val.
Referenced by exec_command_password(), and main().