]> granicus.if.org Git - pgbouncer/commitdiff
Make crypt authentication optional.
authorMarko Kreen <markokr@gmail.com>
Sat, 22 Nov 2008 09:41:32 +0000 (09:41 +0000)
committerMarko Kreen <markokr@gmail.com>
Sat, 22 Nov 2008 09:41:32 +0000 (09:41 +0000)
It was removed from PostgreSQL 8.4 sources.

configure.ac
include/system.h
src/client.c
src/main.c
src/proto.c

index 901bd886f1ad45318ff887dc9fac584fefc8810e..515237200acd6666eac92d67ee84013f7a992a68 100644 (file)
@@ -108,11 +108,12 @@ m4_ifdef([AC_TYPE_UINT8_T], [
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS(strlcpy strlcat getpeereid getpeerucred basename)
-AC_SEARCH_LIBS(crypt, crypt, [], AC_MSG_ERROR([crypt not found]))
+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)
 
 dnl Find libevent
 AC_MSG_CHECKING([for libevent])
index a106f1706263ce182de35192e4efba0c9c5fab4e..24c75a9f35ac1eb68363ac4cdc047cd62cbe5bf6 100644 (file)
@@ -164,6 +164,9 @@ int getpeereid(int fd, uid_t *uid_p, gid_t *gid_p) _MUSTCHECK;
 #ifndef HAVE_BASENAME
 const char *basename(const char *path);
 #endif
+#ifndef HAVE_CRYPT
+#define crypt(p,s) (NULL)
+#endif
 
 void change_user(const char *user);
 
index 583bdeefde54478d5eaae2296abde21988ac708c..809d96340c76944e311d5c129cfbdb74cedb9760 100644 (file)
@@ -37,7 +37,7 @@ static bool check_client_passwd(PgSocket *client, const char *passwd)
                return strcmp(user->passwd, passwd) == 0;
        case AUTH_CRYPT:
                correct = crypt(user->passwd, (char *)client->tmp_login_salt);
-               return strcmp(correct, passwd) == 0;
+               return correct && strcmp(correct, passwd) == 0;
        case AUTH_MD5:
                if (strlen(passwd) != MD5_PASSWD_LEN)
                        return false;
index 152f071cc15e557a2e7dbd0271210f213134e3d8..7e31b3b6cd554371a4f449bf9fa221e10d77b493 100644 (file)
@@ -232,8 +232,10 @@ static bool set_auth(ConfElem *elem, const char *val, PgSocket *console)
                cf_auth_type = AUTH_TRUST;
        else if (strcasecmp(val, "plain") == 0)
                cf_auth_type = AUTH_PLAIN;
+#ifdef HAVE_CRYPT
        else if (strcasecmp(val, "crypt") == 0)
                cf_auth_type = AUTH_CRYPT;
+#endif
        else if (strcasecmp(val, "md5") == 0)
                cf_auth_type = AUTH_MD5;
        else {
index cb3f64647908695e5fedf3bb3476ce76d8cba42c..2fbca8f6d9c74f46079c7c6e12b6bb63a947e9dc 100644 (file)
@@ -243,6 +243,10 @@ static bool login_crypt_psw(PgSocket *server, const uint8_t *salt)
        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);
 }