From: smcdow@mojo.ots.utexas.edu (Stuart McDow)
Newsgroups: comp.lang.perl
Subject: Re: Some questions regarding getpw* and gdbm
Date: 22 Jul 92 22:18:55 GMT

tchrist@convex.COM (Tom Christiansen) writes:
> From the keyboard of smcdow@utexas.edu (Stuart McDow):
> :
> :Does perl care about the passwd lookaside files (ie. /etc/passwd.{dir,pag})
> :when doing getpwent(), getpwuid(), or getpwnam() calls? Does perl use these
> :files if they exist? If so, does it matter if perl is linked with gdbm instead
> :of {dbm, ndbm}? I've been checking these things out experimentally and 
> :perl doesn't seem to have any knowledge of the lookaside files. Or maybe
> :it doesn't care about them. Comments?
> 
> Perl knows about them only through the C library calls you mention.
> If C knows automatically, then so should perl.
> 

Actually, I did find something amiss.

Configuration: perl4.019 with gdbm on a dec5000.


here's the program:

----------------------------- cut here --------------------------------------------------
#! /usr/bin/perl

dbmopen(%DBM, "./theDbmFile", 0644) || die;

while((print "\nEnter key<space>value:"), chop($DTrans = <>)) {
   ($key, $value) = split(' ', $DTrans, 2);

   next unless(($key ne "") && ($value ne ""));

   $DBM{$key} = $value;

}

dbmclose(DBM);


print "\n\n";

while((print "\nEnter uname: "), chop($uname = <>)) {
   @pwent = getpwnam($uname);
   print "getpwnam(\"$uname\") returns: ", join(' ', @pwent), "\n";

}

----------------------------- cut here --------------------------------------------------

And here's a log of what happens:

csh>ls -1 /etc/passwd*
/etc/passwd
/etc/passwd.dir
/etc/passwd.pag

csh>dbmpt

Enter key<space>value:smcdow 1234

Enter key<space>value:larry 100

Enter key<space>value:wall 200

Enter key<space>value:^D


Enter uname: nobody
Bad free() ignored at dbmpt line 20, <> line 1.
getpwnam("nobody") returns: nobody * -2 -2 0  anonymous NFS user / /bin/date

Enter uname: fence
Bad free() ignored at dbmpt line 20, <> line 2.
getpwnam("fence") returns: fence * 16383 15 0  UID fence /usr/users/fence /bin/csh

Enter uname: uucp
Bad free() ignored at dbmpt line 20, <> line 3.
getpwnam("uucp") returns:uucp * 4 1 0  UNIX-to-UNIX Copy /usr/spool/uucppublic /usr/lib/uucp/uucico

Enter uname:^D

csh> <at this point I remove the passwd lookaside files>

csh>ls -1 /etc/passwd*
/etc/passwd

csh>dbmpt

Enter key<space>value:smcdow 000

Enter key<space>value:dummy 1010

Enter key<space>value:^D


Enter uname: nobody
getpwnam("nobody") returns: nobody * -2 -2 0  anonymous NFS user / /bin/date

Enter uname: uucp
getpwnam("uucp") returns: uucp * 4 1 0  UNIX-to-UNIX Copy /usr/spool/uucppublic /usr/lib/uucp/uucico

Enter uname:^D

csh>


-----------------------

No errors the second time around.

Any comments? How can I fix this. I'd like to be able to use the lookaside files without getting the
"Bad free()" error. Does later versions of perl fix this. I believe that this may come from the
fact that the DBM dbm is accessed by gdbm and the lookaside files necessarily must be built using
vanilla dbm.

Any help would be appreciated.

smcdow@utexas.edu




-- 
 smcdow@utexas.edu    | 1. Theatre is Life.         |      Less Jesus       |
    I disclaim,       | 2. Film is Art.             |     More Madonna      |
  therefore I am.     | 3. television is furniture. |    **************     |
           There is no such thing as software `engineering'.
Newsgroups: comp.lang.perl