On Sun, Apr 15, 2001 at 09:01:21PM -0500, Mark Stosberg wrote:
> Giles Lean wrote:
> > 
> > > The crux of it seems to be this line:
> > >
> > >   $user = $ENV{DBI_USER} unless $user eq "";
> > 
> > Here's one way to fix it.
> 
> Thanks for the patch, Giles. I think your solution is a bit flawed too
> because you test for truth instead of definedness. For example, in your
> case if $user was equal to "0", a valid Postgres username, your code
> would improperly default to $ENV{DBI_USER} because 0 is _false_ 
> although it is _defined_. 

If you only test for defined-ness, then you would allow a username of the
null string.  You should probably test for defined-ness and length:

$user = $ENV{DBI_USER} unless defined $user and length $user;


Ronald

Reply via email to