(unnamed)

text/plain

Filename: (unnamed)
Type: text/plain
Part: 1
Message: Re: [BUGS] Bug #756: suggestion: file with password instead
Index: src/bin/psql/input.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/input.c,v
retrieving revision 1.20
diff -c -c -r1.20 input.c
*** src/bin/psql/input.c	5 Sep 2002 22:05:50 -0000	1.20
--- src/bin/psql/input.c	6 Sep 2002 02:27:37 -0000
***************
*** 30,36 ****
  static void finishInput(int, void *);
  #endif
  
! #define PSQLHISTORY	"/.psql_history"
  
  
  /*
--- 30,36 ----
  static void finishInput(int, void *);
  #endif
  
! #define PSQLHISTORY	".psql_history"
  
  
  /*
***************
*** 144,155 ****
  		home = getenv("HOME");
  		if (home)
  		{
! 			char	   *psql_history = (char *) malloc(strlen(home) +
  												strlen(PSQLHISTORY) + 1);
  
  			if (psql_history)
  			{
! 				sprintf(psql_history, "%s" PSQLHISTORY, home);
  				read_history(psql_history);
  				free(psql_history);
  			}
--- 144,155 ----
  		home = getenv("HOME");
  		if (home)
  		{
! 			char	   *psql_history = (char *) malloc(strlen(home) + 1 +
  												strlen(PSQLHISTORY) + 1);
  
  			if (psql_history)
  			{
! 				sprintf(psql_history, "%s/%s", home, PSQLHISTORY);
  				read_history(psql_history);
  				free(psql_history);
  			}
***************
*** 204,210 ****
  		home = getenv("HOME");
  		if (home)
  		{
! 			psql_history = (char *) malloc(strlen(home) +
  									strlen(PSQLHISTORY) + 1);
  			if (psql_history)
  			{
--- 204,210 ----
  		home = getenv("HOME");
  		if (home)
  		{
! 			psql_history = (char *) malloc(strlen(home) + 1 +
  									strlen(PSQLHISTORY) + 1);
  			if (psql_history)
  			{
***************
*** 212,218 ****
  
  				if (var)
  					stifle_history(atoi(var));
! 				sprintf(psql_history, "%s" PSQLHISTORY, home);
  				write_history(psql_history);
  				free(psql_history);
  			}
--- 212,218 ----
  
  				if (var)
  					stifle_history(atoi(var));
! 				sprintf(psql_history, "%s/%s", home, PSQLHISTORY);
  				write_history(psql_history);
  				free(psql_history);
  			}
Index: src/bin/psql/startup.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/startup.c,v
retrieving revision 1.65
diff -c -c -r1.65 startup.c
*** src/bin/psql/startup.c	5 Sep 2002 22:05:50 -0000	1.65
--- src/bin/psql/startup.c	6 Sep 2002 02:27:39 -0000
***************
*** 42,48 ****
   */
  PsqlSettings pset;
  
! #define PSQLRC "/.psqlrc"
  
  /*
   * Structures to pass information between the option parsing routine
--- 42,48 ----
   */
  PsqlSettings pset;
  
! #define PSQLRC ".psqlrc"
  
  /*
   * Structures to pass information between the option parsing routine
***************
*** 605,611 ****
  
  	if (home)
  	{
! 		psqlrc = malloc(strlen(home) + strlen(PSQLRC) + 1 +
  				 strlen(PG_VERSION) + 1);
  		if (!psqlrc)
  		{
--- 605,611 ----
  
  	if (home)
  	{
! 		psqlrc = malloc(strlen(home) + 1 + strlen(PSQLRC) + 1 +
  				 strlen(PG_VERSION) + 1);
  		if (!psqlrc)
  		{
***************
*** 613,624 ****
  			exit(EXIT_FAILURE);
  		}
  
! 		sprintf(psqlrc, "%s" PSQLRC "-" PG_VERSION, home);
  		if (access(psqlrc, R_OK) == 0)
  			process_file(psqlrc);
  		else
  		{
! 			sprintf(psqlrc, "%s" PSQLRC, home);
  			if (access(psqlrc, R_OK) == 0)
  				process_file(psqlrc);
  		}
--- 613,624 ----
  			exit(EXIT_FAILURE);
  		}
  
! 		sprintf(psqlrc, "%s/%s-%s", home, PSQLRC, PG_VERSION);
  		if (access(psqlrc, R_OK) == 0)
  			process_file(psqlrc);
  		else
  		{
! 			sprintf(psqlrc, "%s/%s", home, PSQLRC);
  			if (access(psqlrc, R_OK) == 0)
  				process_file(psqlrc);
  		}
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.203
diff -c -c -r1.203 fe-connect.c
*** src/interfaces/libpq/fe-connect.c	5 Sep 2002 22:24:23 -0000	1.203
--- src/interfaces/libpq/fe-connect.c	6 Sep 2002 02:27:50 -0000
***************
*** 66,72 ****
  #define NOTIFYLIST_INITIAL_SIZE 10
  #define NOTIFYLIST_GROWBY 10
  
! #define PGPASSFILE "/.pgpass"
  
  /* ----------
   * Definition of the conninfo parameters and their fallback resources.
--- 66,72 ----
  #define NOTIFYLIST_INITIAL_SIZE 10
  #define NOTIFYLIST_GROWBY 10
  
! #define PGPASSFILE ".pgpass"
  
  /* ----------
   * Definition of the conninfo parameters and their fallback resources.
***************
*** 2927,2944 ****
  	home = getenv("HOME");
  	if (home)
  	{
! 		pgpassfile = malloc(strlen(home) + strlen(PGPASSFILE) + 1);
  		if (!pgpassfile)
  		{
- 						  
  			fprintf(stderr, libpq_gettext("out of memory\n"));
! 			exit(EXIT_FAILURE);
  		}
  	}
  	else
  		return NULL;
  
! 	sprintf(pgpassfile, "%s" PGPASSFILE, home);
  
  	/* If password file cannot be opened, ignore it. */
  	if (stat(pgpassfile, &stat_buf) == -1)
--- 2927,2943 ----
  	home = getenv("HOME");
  	if (home)
  	{
! 		pgpassfile = malloc(strlen(home) + 1 + strlen(PGPASSFILE) + 1);
  		if (!pgpassfile)
  		{
  			fprintf(stderr, libpq_gettext("out of memory\n"));
! 			return NULL;
  		}
  	}
  	else
  		return NULL;
  
! 	sprintf(pgpassfile, "%s/%s", home, PGPASSFILE);
  
  	/* If password file cannot be opened, ignore it. */
  	if (stat(pgpassfile, &stat_buf) == -1)