3
3
*
4
4
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
5
5
*
6
- * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.156 2005/12/18 02:17:16 petere Exp $
6
+ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.157 2005/12/23 01:16:38 tgl Exp $
7
7
*/
8
8
#include "postgres_fe.h"
9
9
#include "command.h"
12
12
#undef mkdir
13
13
#endif
14
14
15
- #include <errno.h>
16
15
#include <ctype.h>
17
16
#ifdef HAVE_PWD_H
18
17
#include <pwd.h>
35
34
36
35
#include "libpq-fe.h"
37
36
#include "pqexpbuffer.h"
38
- #include "libpq/crypt.h"
39
37
#include "dumputils.h"
40
38
41
39
#include "common.h"
@@ -638,14 +636,16 @@ exec_command(const char *cmd,
638
636
{
639
637
char * opt0 = psql_scan_slash_option (scan_state , OT_SQLID , NULL , true);
640
638
char * user ;
641
- char encrypted_password [ MD5_PASSWD_LEN + 1 ] ;
639
+ char * encrypted_password ;
642
640
643
641
if (opt0 )
644
642
user = opt0 ;
645
643
else
646
644
user = PQuser (pset .db );
647
645
648
- if (!pg_md5_encrypt (pw1 , user , strlen (user ), encrypted_password ))
646
+ encrypted_password = pg_make_encrypted_password (pw1 , user );
647
+
648
+ if (!encrypted_password )
649
649
{
650
650
fprintf (stderr , _ ("Password encryption failed.\n" ));
651
651
success = false;
@@ -656,14 +656,15 @@ exec_command(const char *cmd,
656
656
PGresult * res ;
657
657
658
658
initPQExpBuffer (& buf );
659
- printfPQExpBuffer (& buf , "ALTER ROLE %s PASSWORD '%s';" ,
659
+ printfPQExpBuffer (& buf , "ALTER USER %s PASSWORD '%s';" ,
660
660
fmtId (user ), encrypted_password );
661
661
res = PSQLexec (buf .data , false);
662
662
termPQExpBuffer (& buf );
663
663
if (!res )
664
664
success = false;
665
665
else
666
666
PQclear (res );
667
+ PQfreemem (encrypted_password );
667
668
}
668
669
}
669
670
0 commit comments