* Dec 17, 1997 - Todd A. Brandys
* Orignal Version Completed.
*
- * $Id: crypt.c,v 1.29 2000/08/27 21:50:18 tgl Exp $
+ * $Id: crypt.c,v 1.30 2001/02/07 23:31:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
char **pwd_cache = NULL;
int pwd_cache_count = 0;
-/*-------------------------------------------------------------------------*/
-
+/*
+ * crypt_getpwdfilename --- get name of password file
+ *
+ * Note that result string is palloc'd, and should be freed by the caller.
+ */
char *
crypt_getpwdfilename(void)
{
return pfnam;
}
-/*-------------------------------------------------------------------------*/
-
+/*
+ * crypt_getpwdreloadfilename --- get name of password-reload-needed flag file
+ *
+ * Note that result string is palloc'd, and should be freed by the caller.
+ */
char *
crypt_getpwdreloadfilename(void)
{
bufsize = strlen(pwdfilename) + strlen(CRYPT_PWD_RELOAD_SUFX) + 1;
rpfnam = (char *) palloc(bufsize);
snprintf(rpfnam, bufsize, "%s%s", pwdfilename, CRYPT_PWD_RELOAD_SUFX);
+ pfree(pwdfilename);
return rpfnam;
}
fprintf(stderr, "Couldn't read %s: %s\n",
filename, strerror(errno));
+ pfree(filename);
+
return pwdfile;
}
static void
crypt_loadpwdfile(void)
{
-
char *filename;
int result;
FILE *pwd_file;
filename = crypt_getpwdreloadfilename();
result = unlink(filename);
+ pfree(filename);
/*
* We want to delete the flag file before reading the contents of the
* successful. This means that a backend performed a COPY of the
* pg_shadow file to pg_pwd. Therefore we must now do a reload.
*/
- if (!pwd_cache || !result)
+ if (!pwd_cache || result == 0)
{
if (pwd_cache)
{ /* free the old data only if this is a