aboutsummaryrefslogtreecommitdiff
path: root/src/bin/scripts/createuser.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-12-23 01:16:38 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-12-23 01:16:38 +0000
commitea9b028dc77e961b290087972b9bfbe8e91ce82f (patch)
treeb71ed0d93dfd0f180020275ca3906c2f50aa94d8 /src/bin/scripts/createuser.c
parente80f9dfa8095656c0d671d89663439c66b806288 (diff)
downloadpostgresql-ea9b028dc77e961b290087972b9bfbe8e91ce82f.tar.gz
postgresql-ea9b028dc77e961b290087972b9bfbe8e91ce82f.zip
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.
Diffstat (limited to 'src/bin/scripts/createuser.c')
-rw-r--r--src/bin/scripts/createuser.c10
1 files changed, 6 insertions, 4 deletions
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);