postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
[postgresql-interfaces/psqlodbc] issue #101: Test connection always show password in log file.
2+ messages / 2 participants
[nested] [flat]

* [postgresql-interfaces/psqlodbc] issue #101: Test connection always show password in log file.
@ 2025-04-07 14:21  "omeuid (@omeuid)" <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: omeuid (@omeuid) @ 2025-04-07 14:21 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

If you enable logging in a DSN, when you click on the 'Test connection' button, several log sentences include the connection string without hiding the password property.

In the `drvconn.c` file, the FORCE_PASSWORD_DISPLAY flag is defined:

```
#define	FORCE_PASSWORD_DISPLAY
#define	NULL_IF_NULL(a) (a ? a : "(NULL)")
```

So every time the flag is checked to determine if the password must be hidden, the connection string will not be hidden. 

I found the following three cases:
* In `PGAPI_DriverConnect` method:
```
#ifdef	FORCE_PASSWORD_DISPLAY
	MYLOG(0, "**** fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, connStrIn);
#else
	if (get_mylog())
	{
		char	*hide_str = hide_password(connStrIn);

		MYLOG(0, "**** fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, NULL_IF_NULL(hide_str));
		if (hide_str)
			free(hide_str);
	}
#endif	/* FORCE_PASSWORD_DISPLAY */
```

* Also, the following code appears in the same method
```
#ifdef	FORCE_PASSWORD_DISPLAY
	if (cbConnStrOutMax > 0)
	{
		MYLOG(0, "szConnStrOut = '%s' len=" FORMAT_SSIZE_T ",%d\n", NULL_IF_NULL((char *) szConnStrOut), len, cbConnStrOutMax);
	}
#else
	if (get_mylog())
	{
		char	*hide_str = NULL;

		if (cbConnStrOutMax > 0)
			hide_str = hide_password(szConnStrOut);
		MYLOG(0, "szConnStrOut = '%s' len=%d,%d\n", NULL_IF_NULL(hide_str), len, cbConnStrOutMax);
		if (hide_str)
			free(hide_str);
	}
#endif /* FORCE_PASSWORD_DISPLAY */
```
* And the last occurrence can be found in `dconn_get_attributes` method:
```
#ifdef	FORCE_PASSWORD_DISPLAY
	MYLOG(0, "our_connect_string = '%s'\n", our_connect_string);
#else
	if (get_mylog())
	{
		char	*hide_str = hide_password(our_connect_string);

		MYLOG(0, "our_connect_string = '%s'\n", hide_str);
		free(hide_str);
	}
#endif /* FORCE_PASSWORD_DISPLAY */
```

I assume that this is not the expected behavior.
* Maybe the password could be shown only at a certain log level.

What do you think?

Regard,
Carlos

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [postgresql-interfaces/psqlodbc] issue #101: Test connection always show password in log file.
@ 2025-04-08 14:04  "davecramer (@davecramer)" <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: davecramer (@davecramer) @ 2025-04-08 14:04 UTC (permalink / raw)
  To: postgresql-interfaces/psqlodbc <[email protected]>

I'd be OK with a PR that restricted password to a certain level

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-04-08 14:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-04-07 14:21 [postgresql-interfaces/psqlodbc] issue #101: Test connection always show password in log file. "omeuid (@omeuid)" <[email protected]>
2025-04-08 14:04 Re: [postgresql-interfaces/psqlodbc] issue #101: Test connection always show password in log file. "davecramer (@davecramer)" <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox