9
9
* Dec 17, 1997 - Todd A. Brandys
10
10
* Orignal Version Completed.
11
11
*
12
- * $Id: crypt.c,v 1.29 2000/08/27 21:50:18 tgl Exp $
12
+ * $Id: crypt.c,v 1.30 2001/02/07 23:31:38 tgl Exp $
13
13
*
14
14
*-------------------------------------------------------------------------
15
15
*/
30
30
char * * pwd_cache = NULL ;
31
31
int pwd_cache_count = 0 ;
32
32
33
- /*-------------------------------------------------------------------------*/
34
-
33
+ /*
34
+ * crypt_getpwdfilename --- get name of password file
35
+ *
36
+ * Note that result string is palloc'd, and should be freed by the caller.
37
+ */
35
38
char *
36
39
crypt_getpwdfilename (void )
37
40
{
@@ -45,8 +48,11 @@ crypt_getpwdfilename(void)
45
48
return pfnam ;
46
49
}
47
50
48
- /*-------------------------------------------------------------------------*/
49
-
51
+ /*
52
+ * crypt_getpwdreloadfilename --- get name of password-reload-needed flag file
53
+ *
54
+ * Note that result string is palloc'd, and should be freed by the caller.
55
+ */
50
56
char *
51
57
crypt_getpwdreloadfilename (void )
52
58
{
@@ -58,6 +64,7 @@ crypt_getpwdreloadfilename(void)
58
64
bufsize = strlen (pwdfilename ) + strlen (CRYPT_PWD_RELOAD_SUFX ) + 1 ;
59
65
rpfnam = (char * ) palloc (bufsize );
60
66
snprintf (rpfnam , bufsize , "%s%s" , pwdfilename , CRYPT_PWD_RELOAD_SUFX );
67
+ pfree (pwdfilename );
61
68
62
69
return rpfnam ;
63
70
}
@@ -77,6 +84,8 @@ crypt_openpwdfile(void)
77
84
fprintf (stderr , "Couldn't read %s: %s\n" ,
78
85
filename , strerror (errno ));
79
86
87
+ pfree (filename );
88
+
80
89
return pwdfile ;
81
90
}
82
91
@@ -119,22 +128,22 @@ compar_user(const void *user_a, const void *user_b)
119
128
static void
120
129
crypt_loadpwdfile (void )
121
130
{
122
-
123
131
char * filename ;
124
132
int result ;
125
133
FILE * pwd_file ;
126
134
char buffer [256 ];
127
135
128
136
filename = crypt_getpwdreloadfilename ();
129
137
result = unlink (filename );
138
+ pfree (filename );
130
139
131
140
/*
132
141
* We want to delete the flag file before reading the contents of the
133
142
* pg_pwd file. If result == 0 then the unlink of the reload file was
134
143
* successful. This means that a backend performed a COPY of the
135
144
* pg_shadow file to pg_pwd. Therefore we must now do a reload.
136
145
*/
137
- if (!pwd_cache || ! result )
146
+ if (!pwd_cache || result == 0 )
138
147
{
139
148
if (pwd_cache )
140
149
{ /* free the old data only if this is a
0 commit comments