From ea9b028dc77e961b290087972b9bfbe8e91ce82f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 23 Dec 2005 01:16:38 +0000 Subject: Add an officially exported libpq function to encrypt passwords, and modify the previous \password patch to use it instead of depending on a not-officially-exported function. Per discussion. --- src/bin/scripts/createuser.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/bin/scripts/createuser.c') diff --git a/src/bin/scripts/createuser.c b/src/bin/scripts/createuser.c index adf9c41b3a2..9bd7d8d873c 100644 --- a/src/bin/scripts/createuser.c +++ b/src/bin/scripts/createuser.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.24 2005/12/18 02:17:16 petere Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/createuser.c,v 1.25 2005/12/23 01:16:38 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -13,7 +13,6 @@ #include "postgres_fe.h" #include "common.h" #include "dumputils.h" -#include "libpq/crypt.h" static void help(const char *progname); @@ -250,14 +249,17 @@ main(int argc, char *argv[]) if (encrypted != TRI_NO) { - char encrypted_password[MD5_PASSWD_LEN + 1]; + char *encrypted_password; - if (!pg_md5_encrypt(newpassword, newuser, strlen(newuser), encrypted_password)) + encrypted_password = pg_make_encrypted_password(newpassword, + newuser); + if (!encrypted_password) { fprintf(stderr, _("Password encryption failed.\n")); exit(1); } appendStringLiteral(&sql, encrypted_password, false); + PQfreemem(encrypted_password); } else appendStringLiteral(&sql, newpassword, false); -- cgit v1.2.3