Article View: news.software.nntp
Article #68877Re: Perl5.8.2 NDBM_File + ckpasswd script appears to corrupt passwd DB
From: none
Date: Wed, 31 Mar 2004 07:58
Date: Wed, 31 Mar 2004 07:58
292 lines
12569 bytes
12569 bytes
Using "gen.passwd" script from CKPASSWD manual page:
#!/usr/bin/perl
use NDBM_File;
use Fcntl;
tie (%db, 'NDBM_File', '/usr/local/news/db/gen.passwd', O_RDWR | O_CREAT, 0640)
or die "Cannot open /usr/local/news/db/gen.passwd: $!\n";
$| = 1;
print "Username: ";
my $user = <STDIN>;
chomp $user;
print "Password: ";
my $passwd = <STDIN>;
chomp $passwd;
my @alphabet = ('.', '/', 0..9, 'A'..'Z', 'a'..'z');
my $salt = join '', @alphabet[rand 64, rand 64];
$db{$user} = crypt ($passwd, $salt);
untie %db;
shows the following results from "strings:"
strings ../db/gen.passwd.db
IXUSR S_IRWXU
S_IRGRP S_IWGRP S_IXGRP S_IRWXG
S_IROTH S_IWOTH S_IXOTH S_IRWXO
S_IREAD S_IWRITE S_IEXEC
S_ISREG S_ISDIR S_ISLNK S_ISSOCK
S_ISBLK S_ISCHR S_ISFIFO
S_ISWHT S_ISENFMT
S_IFMT S_IMODE
)],
sub S_IFMT { @_ ? ( $_[0] & _S_IFMT() ) : _S_IFMT() }
sub S_IMODE { $_[0] & 07777 }
sub S_ISREG { ( $_[0] & _S_IFMT() ) == S_IFREG() }
sub S_ISDIR { ( $_[0] & _S_IFMT() ) == S_IFDIR() }
sub S_ISLNK { ( $_[0] & _S_IFMT() ) == S_IFLNK() }
sub S_ISSOCK { ( $_[0] & _S_IFMT() ) == S_IFSOCK() }
sub S_ISBLK { ( $_[0] & _S_IFMT() ) == S_IFBLK() }
sub S_ISCHR { ( $_[0] & _S_IFMT() ) == S_IFCHR() }
sub S_ISFIFO { ( $_[0] & _S_IFMT() ) == S_IFIFO() }
sub S_ISWHT { ( $_[0] & _S_IFMT() ) == S_IFWHT() }
sub S_ISENFMT { ( $_[0] & _S_IFMT() ) == S_IFENFMT() }
sub AUTOLOAD {
(my $constname = $AUTOLOAD) =~ s/.*:://;
die "&Fcntl::constant not defined" if $constname eq 'constant';
my ($error, $val) = constant($constname);
if ($error) {
my (undef,$file,$line) = caller;
die "$error at $file line $line.\n";
}
*$AUTOLOAD = sub { $val };
goto &$AUTOLOAD;
XSLoader::load 'Fcntl', $VERSION;
= shift;
$pkg->TIEHASH(@_);
# Grandfather "new"
sub TIEHASH {
my $pkg = shift;
if (defined &{"${pkg}::new"}) {
warnings::warnif("WARNING: calling ${pkg}->new since ${pkg}->TIEHASH is missing");
$pkg->new(@_);
}
else {
croak "$pkg doesn't define a TIEHASH method";
}
sub EXISTS {
my $pkg = ref $_[0];
croak "$pkg doesn't define an EXISTS method";
sub CLEAR {
my $self = shift;
my $key = $self->FIRSTKEY(@_);
my @keys;
while (defined $key) {
push @keys, $key;
$key = $self->NEXTKEY(@_, $key);
}
foreach $key (@keys) {
$self->DELETE(@_, $key);
}
# The Tie::StdHash package implements standard perl hash behaviour.
# It exists to act as a base class for classes which only wish to
# alter some parts of their behaviour.
package Tie::StdHash;
# @ISA = qw(Tie::Hash); # would inherit new() only
sub TIEHASH { bless {}, $_[0] }
sub STORE { $_[0]->{$_[1]} = $_[2] }
sub FETCH { $_[0]->{$_[1]} }
sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} }
sub NEXTKEY { each %{$_[0]} }
sub EXISTS { exists $_[0]->{$_[1]} }
sub DELETE { delete $_[0]->{$_[1]} }
sub CLEAR { %{$_[0]} = () }
package Tie::ExtraHash;
sub TIEHASH { my $p = shift; bless [{}, @_], $p }
sub STORE { $_[0][0]{$_[1]} = $_[2] }
sub FETCH { $_[0][0]{$_[1]} }
sub FIRSTKEY { my $a = scalar keys %{$_[0][0]}; each %{$_[0][0]} }
sub NEXTKEY { each %{$_[0][0]} }
sub EXISTS { exists $_[0][0]->{$_[1]} }
sub DELETE { delete $_[0][0]->{$_[1]} }
sub CLEAR { %{$_[0][0]} = () }
Te1EqjUOJFWfoabcdefg
where perl -V:
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=freebsd, osvers=4.9-release, archname=i386-freebsd
uname='freebsd localhost 4.9-release freebsd 4.9-release #0: mon jan
19 13:47:35 cst 2004 genuser@localhost:usrsrcsyscompilexsystem
i386 ' config_args='-sde -Dprefix=/usr/local
-Darchlib=/usr/local/lib/perl5/5.8.2/mach
-Dprivlib=/usr/local/lib/perl5/5.8.2
-Dman3dir=/usr/local/lib/perl5/5.8.2/man/man3
-Dman1dir=/usr/local/man/man1
-Dsitearch=/usr/local/lib/perl5/site_perl/5.8.2/mach
-Dsitelib=/usr/local/lib/perl5/site_perl/5.8.2
-Dscriptdir=/usr/local/bin -Ui_malloc -Ui_iconv -Uinstallusrbinperl
-Dcc=cc -Doptimize=-O -mcpu=pentiumpro -march=pentiumpro -Duseshrplib
-Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.2/BSDPAN" -Ud_dosuid
-Ui_gdbm -Dusethreads=n -Dusemymalloc=y' hint=recommended,
useposix=true, d_sigaction=define usethreads=undef
use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=y,
bincompat5005=undef
Compiler:
cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.2/BSDPAN"
-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing
-I/usr/local/include', optimize='-O -mcpu=pentiumpro -march=pentiumpro
', cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.2/BSDPAN"
-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing
-I/usr/local/include' ccversion='', gccversion='2.95.4 20020320
[FreeBSD]', gccosandvers='' intsize=4, longsize=4, ptrsize=4,
doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8,
d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4,
nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4,
prototype=define
Linker and Libraries:
ld='cc', ldflags ='-Wl,-E -L/usr/local/lib' libpth=/usr/lib
/usr/local/lib
libs=-lgdbm -lm -lcrypt -lutil -lc
perllibs=-lm -lcrypt -lutil -lc
libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='
-Wl,-R/usr/local/lib/perl5/5.8.2/mach/CORE' cccdlflags='-DPIC -fPIC',
lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES Built under freebsd Compiled at
Mar 27 2004 16:45:13
@INC:
/usr/local/lib/perl5/site_perl/5.8.2/mach
/usr/local/lib/perl5/site_perl/5.8.2
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.2/BSDPAN
/usr/local/lib/perl5/5.8.2/mach
/usr/local/lib/perl5/5.8.2
Interestingly enough, under Solaris8/9-sparc, (with both perl-5.6.1 and
-5.8.2 installed) I get different results:
gen.passwd.dir
gen.passwd.pag
strings gen.passwd.pag
<crypt password><userid>
Solaris8-Sparc Perl config:
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris
uname='sunos sparc8host 5.8 generic_108528-14 sun4u sparc sunw,ultra-5_10 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include',
optimize='-O',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.2 19991024 (release)', gccosandvers='solaris2.8'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options:
Built under solaris
Compiled at Mar 26 2004 15:30:31
@INC:
/usr/local/lib/perl5/5.8.2/sun4-solaris
/usr/local/lib/perl5/5.8.2
/usr/local/lib/perl5/site_perl/5.8.2/sun4-solaris
/usr/local/lib/perl5/site_perl/5.8.2
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl
Solaris9-Sparc Perl-5.8.2 config:
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=solaris, osvers=2.9, archname=sun4-solaris
uname='sunos sparc9host 5.9 generic_112233-11 sun4u sparc sunw,ultraax-i2 '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include',
optimize='-O',
cppflags='-fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='2.95.3 20010315 (release)', gccosandvers='solaris2.9'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=4
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/opt/sfw/lib /usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldb -ldl -lm -lc
perllibs=-lsocket -lnsl -ldl -lm -lc
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options:
Built under solaris
Compiled at Mar 26 2004 17:20:59
@INC:
/usr/local/lib/perl5/5.8.2/sun4-solaris
/usr/local/lib/perl5/5.8.2
/usr/local/lib/perl5/site_perl/5.8.2/sun4-solaris
/usr/local/lib/perl5/site_perl/5.8.2
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl
Characteristics of this binary (from libperl):
Compile-time options:
Built under solaris
Compiled at Mar 26 2004 15:30:31
@INC:
/usr/local/lib/perl5/5.8.2/sun4-solaris
/usr/local/lib/perl5/5.8.2
/usr/local/lib/perl5/site_perl/5.8.2/sun4-solaris
/usr/local/lib/perl5/site_perl/5.8.2
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl
On Wed, 31 Mar 2004 02:34:04 +0000, Jeffrey M. Vinocur wrote:
> In article <pan.2004.03.31.00.04.19.234631@siu.edu>,
> N.A. <leftfoot@siu.edu> wrote:
>>After upgrading to perl-5.8.2 from -5.6.1, the CKPASSWD manual page Perl
>>script for creating a local password database, appears to have a problem.
>>Rather, the perl-5.8.2 NDBM_File module appears to have a problem as it
>>inserts gobs of what looks like Perl code into the password DB file (as
>>viewable via STRINGS).
>
> Hmm. I can't reproduce this with 5.8.0 -- can you post the
> output of `strings` (on a test database, of course).
Technical Details
Message-ID:
<pan.2004.03.31.07.58.14.172520@globaleyes.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!news.glorb.com!wn51feed!worldnet.att.net!216.168.1.162!sn-xit-02!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mailReferences:
<pan.2004.03.31.00.04.19.234631@siu.edu> <c4dams$gq1$2@puck.litech.org>Show Full Headers
Complete Article Headers
Message-ID: <pan.2004.03.31.07.58.14.172520@globaleyes.net> Subject: Re: Perl5.8.2 NDBM_File + ckpasswd script appears to corrupt passwd DB Date: Wed, 31 Mar 2004 01:58:16 -0600 From: none <supraexpress@globaleyes.net> References: <pan.2004.03.31.00.04.19.234631@siu.edu> <c4dams$gq1$2@puck.litech.org> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!news1.google.com!news.glorb.com!wn51feed!worldnet.att.net!216.168.1.162!sn-xit-02!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Newsgroups: news.software.nntp Organization: Posted via Supernews, http://www.supernews.com User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@supernews.com Lines: 291