PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <unistd.h>
#include <fcntl.h>
#include <limits.h>
#include <pwd.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) |
PGresult * | PQchangePassword (PGconn *conn, const char *user, const char *passwd) |
#define MAX_ALGORITHM_NAME_LEN 50 |
|
static |
Definition at line 795 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 830 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 1255 of file fe-auth.c.
References pg_fe_getusername().
Referenced by conninfo_add_defaults(), and pqConnectOptions2().
char* pg_fe_getusername | ( | uid_t | user_id, |
PQExpBuffer | errorMessage | ||
) |
Definition at line 1197 of file fe-auth.c.
References buf, libpq_append_error(), name, and username.
Referenced by pg_fe_getauthname(), and PQconnectPoll().
int pg_fe_sendauth | ( | AuthRequest | areq, |
int | payloadlen, | ||
PGconn * | conn | ||
) |
Definition at line 989 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 723 of file fe-auth.c.
References AUTH_REQ_MD5, AUTH_REQ_PASSWORD, AUTH_RESPONSE_PASSWORD, conn, pg_conn::current_auth_response, free, pg_conn::inBuffer, pg_conn::inStart, libpq_append_conn_error(), malloc, MD5_PASSWD_LEN, password, pg_conn::Pfdebug, pg_md5_encrypt(), pg_conn::pguser, pqGetnchar(), PqMsg_PasswordMessage, pqPacketSend(), pqTraceOutputMessage(), and STATUS_ERROR.
Referenced by pg_fe_sendauth().
|
static |
Definition at line 645 of file fe-auth.c.
References AUTH_RESPONSE_SASL, conn, pg_conn::current_auth_response, pg_fe_sasl_mech::exchange, free, pg_conn::inBuffer, pg_conn::inStart, libpq_append_conn_error(), malloc, output, pg_conn::Pfdebug, pqGetnchar(), PqMsg_SASLResponse, pqPacketSend(), pqTraceOutputMessage(), res, pg_conn::sasl, SASL_CONTINUE, SASL_FAILED, pg_conn::sasl_state, STATUS_ERROR, and STATUS_OK.
Referenced by pg_fe_sendauth().
|
static |
Definition at line 433 of file fe-auth.c.
References appendPQExpBufferStr(), Assert, AUTH_RESPONSE_SASL_INITIAL, pg_conn::channel_binding, conn, pg_conn::connhost, pg_conn::current_auth_response, PQExpBufferData::data, error(), pg_conn::errorMessage, pg_fe_sasl_mech::exchange, free, pg_conn::inBuffer, pg_fe_sasl_mech::init, initPQExpBuffer(), pg_conn::inStart, libpq_append_conn_error(), password, pg_conn_host::password, pg_conn::password_needed, pg_conn::Pfdebug, pg_scram_mech, pg_conn::pgpass, PQExpBufferDataBroken, pqFlush(), pqGets(), PqMsg_SASLInitialResponse, PQnoPasswordSupplied, pqPutInt(), pqPutMsgEnd(), pqPutMsgStart(), pqPutnchar(), pqPuts(), pqTraceOutputMessage(), pg_conn::sasl, SASL_FAILED, pg_conn::sasl_state, SCRAM_SHA_256_NAME, SCRAM_SHA_256_PLUS_NAME, pg_conn::ssl_in_use, STATUS_ERROR, STATUS_OK, termPQExpBuffer(), and pg_conn::whichhost.
Referenced by pg_fe_sendauth().
Definition at line 1442 of file fe-auth.c.
References buf, conn, initPQExpBuffer(), PQencryptPasswordConn(), PQescapeIdentifier(), PQescapeLiteral(), PQexec(), PQfreemem(), printfPQExpBuffer(), res, termPQExpBuffer(), and user.
Referenced by exec_command_password().
char* PQencryptPassword | ( | const char * | passwd, |
const char * | user | ||
) |
Definition at line 1274 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 1317 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 main(), and PQchangePassword().