Highly obsolete.
* Unix sockets support "peer" auth.
+- Cleanups
+
+ * Remove **crypt** auth.
+
PgBouncer 1.6.x
---------------
dnl Checks for header files.
AC_USUAL_HEADER_CHECK
-AC_CHECK_HEADERS([crypt.h])
AC_CHECK_HEADERS([sys/resource.h sys/wait.h])
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
AC_USUAL_FUNCTION_CHECK
-AC_SEARCH_LIBS(crypt, crypt)
AC_SEARCH_LIBS(clock_gettime, rt)
AC_SEARCH_LIBS(getsockname, socket)
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(hstrerror, resolv)
-AC_CHECK_FUNCS(crypt lstat)
+AC_CHECK_FUNCS(lstat)
dnl Find libevent
AC_USUAL_LIBEVENT
Use MD5-based password check. `auth_file`_ may contain both MD5-encrypted
or plain-text passwords. This is the default authentication method.
-crypt
- Use crypt(3) based password check. `auth_file`_ must contain plain-text
- passwords. Deprecated, removed in PostgreSQL 8.4.
-
plain
Clear-text password is sent over wire. Deprecated.
#define AUTH_ANY -1 /* same as trust but without username check */
#define AUTH_TRUST 0
#define AUTH_PLAIN 3
-#define AUTH_CRYPT 4
+/* #define AUTH_CRYPT 4 */
#define AUTH_MD5 5
-#define AUTH_CREDS 6
+/* #define AUTH_CREDS 6 */
#define AUTH_CERT 7
#define AUTH_PEER 8
#define AUTH_HBA 9
#include <usual/tls/tls.h>
-#ifdef HAVE_CRYPT_H
-#include <crypt.h>
-#endif
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
#endif
* libc compat functions.
*/
-#ifndef HAVE_CRYPT
-static inline char *crypt(const char *p, const char *s) { return NULL; }
-#endif
#ifndef HAVE_LSTAT
static inline int lstat(const char *path, struct stat *st) { return stat(path, st); }
#endif
static bool check_client_passwd(PgSocket *client, const char *passwd)
{
char md5[MD5_PASSWD_LEN + 1];
- const char *correct;
PgUser *user = client->auth_user;
/* disallow empty passwords */
switch (cf_auth_type) {
case AUTH_PLAIN:
return strcmp(user->passwd, passwd) == 0;
- case AUTH_CRYPT:
- correct = crypt(user->passwd, (char *)client->tmp_login_salt);
- return correct && strcmp(correct, passwd) == 0;
case AUTH_MD5:
if (strlen(passwd) != MD5_PASSWD_LEN)
return false;
return false;
}
-/* mask to get offset into valid_crypt_salt[] */
-#define SALT_MASK 0x3F
-
-static const char valid_crypt_salt[] =
-"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
static bool send_client_authreq(PgSocket *client)
{
uint8_t saltlen = 0;
int res;
int auth = cf_auth_type;
- uint8_t randbuf[2];
-
- if (auth == AUTH_CRYPT) {
- saltlen = 2;
- get_random_bytes(randbuf, saltlen);
- client->tmp_login_salt[0] = valid_crypt_salt[randbuf[0] & SALT_MASK];
- client->tmp_login_salt[1] = valid_crypt_salt[randbuf[1] & SALT_MASK];
- client->tmp_login_salt[2] = 0;
- } else if (cf_auth_type == AUTH_MD5) {
+
+ if (cf_auth_type == AUTH_MD5) {
saltlen = 4;
get_random_bytes((void*)client->tmp_login_salt, saltlen);
} else if (cf_auth_type == AUTH_PLAIN) {
ok = finish_client_login(client);
break;
case AUTH_PLAIN:
- case AUTH_CRYPT:
case AUTH_MD5:
ok = send_client_authreq(client);
break;
{ "any", AUTH_ANY },
{ "trust", AUTH_TRUST },
{ "plain", AUTH_PLAIN },
-#ifdef HAVE_CRYPT
- { "crypt", AUTH_CRYPT },
-#endif
{ "md5", AUTH_MD5 },
{ "cert", AUTH_CERT },
{ "hba", AUTH_HBA },
return send_password(server, user->passwd);
}
-static bool login_crypt_psw(PgSocket *server, const uint8_t *salt)
-{
- char saltbuf[3];
- const char *enc;
- PgUser *user = get_srv_psw(server);
-
- slog_debug(server, "P: send crypt password");
- memcpy(saltbuf, salt, 2);
- saltbuf[2] = 0;
- enc = crypt(user->passwd, saltbuf);
- if (!enc) {
- slog_warning(server, "crypt failed");
- return false;
- }
- return send_password(server, enc);
-}
-
static bool login_md5_psw(PgSocket *server, const uint8_t *salt)
{
char txt[MD5_PASSWD_LEN + 1], *src;
slog_debug(server, "S: req cleartext password");
res = login_clear_psw(server);
break;
- case 4:
- slog_debug(server, "S: req crypt psw");
- if (!mbuf_get_bytes(&pkt->data, 2, &salt))
- return false;
- res = login_crypt_psw(server, salt);
- break;
case 5:
slog_debug(server, "S: req md5-crypted psw");
if (!mbuf_get_bytes(&pkt->data, 4, &salt))