From: Andres S. <di...@us...> - 2005-02-11 20:17:30
|
Update of /cvsroot/tuxaator/tuxaator/Plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8704/Plugins/Core Modified Files: Plugin.pm Log Message: use globs in hostfile Index: Plugin.pm =================================================================== RCS file: /cvsroot/tuxaator/tuxaator/Plugins/Core/Plugin.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Plugin.pm 11 Feb 2005 18:53:15 -0000 1.4 --- Plugin.pm 11 Feb 2005 20:17:05 -0000 1.5 *************** *** 173,189 **** my $basedir = shift; my %users; ! my $hostsfile = sprintf("%s/config/hosts",$basedir); my ($key,$value); ! open HOSTS,"<" . $hostsfile or die "cannot open hosts file\n"; ! while(<HOSTS>) { ! unless (/^#/) { ! my ($hostmask,$level) = $_ =~ /^\s*(.+?)\s*\|\s*(.+?)$/; ! if ($hostmask && $level) { ! $users{$hostmask} = $level; ! }; ! }; }; close HOSTS; --- 173,199 ---- my $basedir = shift; my %users; ! my $hostsfile = "$basedir/config/hosts"; my ($key,$value); ! print STDERR "DEBUG: loading $hostsfile\n"; ! open HOSTS, "<" . $hostsfile or die "$hostsfile: cannot open: $!\n"; ! ! while (<HOSTS>) { ! chomp; ! next if m/^#/ or m/^\s*$/; ! if (m/^\s*(.+?)\s*([|=])\s*(\d+?)\s*$/) { ! my ($hostmask, $delim, $level) = ($1, $2, $3); ! if ($delim eq '=') # glob ? { ! $hostmask =~ s/([^\w*])/\\$1/g; ! $hostmask =~ s/\*/.*/g; ! } ! $users{$hostmask} = $level; ! } ! else ! { ! warn "$hostsfile:$.: unable to parse host file line\n" ! } }; close HOSTS; |