Changeset 130

Show
Ignore:
Timestamp:
03/01/06 15:14:08 (3 years ago)
Author:
ludo
Message:

v 2.6.3: fixed some problems when profile=all (from r3096)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/webmin/lbs/bootmenu.cgi

    r107 r130  
    5555 
    5656etherLoad( $etherfile, \%einfo ) or error( lbsGetError() ); 
     57 
     58# make sure to use the 'all' directory when any profile is requested 
     59my $oprofile = $in{'profile'}; 
     60if (exists($in{'profile'}) && ($in{'profile'} eq "")) { 
     61    $in{'profile'} = "all"; 
     62} 
    5763 
    5864# On effectue une modif si presence du param cgi 'apply' (on ignore sa valeur).  
     
    102108 
    103109        # Mode Selection 
     110        $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    104111        $mode = "MONO"  if (($in{'mac'})); 
    105         $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    106112         
    107113        # Get the computer (One Computer Mode) 
     
    179185                my $group   = $in{'group'}   or ""; 
    180186                 
     187                if ($profile eq "all") { $profile = ""; } # filter_machines_names does not like profile=all 
     188 
    181189                lbs_common::etherLoad("$home/etc/ether", \%ether); 
    182                 lbs_common::filter_machines_names($in{'profile'}, $in{'group'}, \%ether); 
     190                lbs_common::filter_machines_names($profile, $in{'group'}, \%ether); 
    183191                 
    184192                foreach my $name (etherGetNames(\%ether)) { 
     
    240248        } else { 
    241249                $mesg = text( "msg_bootmenu_groupwriteok", "$in{'profile'}:$in{'group'}"); 
    242                 print "<script>setTimeout(\"location='bootmenu.cgi?group=$in{'group'}&profile=$in{'profile'}&random='+Math.random();\",2000)</script>"; 
     250                print "<script>setTimeout(\"location='bootmenu.cgi?group=$in{'group'}&profile=$oprofile&random='+Math.random();\",2000)</script>"; 
    243251                print "<p>$mesg</p>\n"; 
    244                 print "<a href=\"bootmenu.cgi?group=$in{'group'}&profile=$in{'profile'}\">$but_return</a>"; 
     252                print "<a href=\"bootmenu.cgi?group=$in{'group'}&profile=$oprofile\">$but_return</a>"; 
    245253        } 
    246254        print "<p>&nbsp;</p>\n"; 
     
    256264         
    257265        # Mode Selection 
     266        $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    258267        $mode = "MONO"  if (($in{'mac'})); 
    259         $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    260268 
    261269        # grab the path of our menu 
     
    287295        } else { 
    288296                $mesg = text( "msg_bootmenu_groupwriteok", "$in{'profile'}:$in{'group'}"); 
    289                 print "<script>setTimeout(\"location='bootmenu.cgi?group=$in{'group'}&profile=$in{'profile'}&random='+Math.random();\",2000)</script>"; 
     297                print "<script>setTimeout(\"location='bootmenu.cgi?group=$in{'group'}&profile=$oprofile&random='+Math.random();\",2000)</script>"; 
    290298                print "<p>$mesg</p>\n"; 
    291                 print "<a href=\"bootmenu.cgi?group=$in{'group'}&profile=$in{'profile'}\">$but_return</a>"; 
     299                print "<a href=\"bootmenu.cgi?group=$in{'group'}&profile=$oprofile\">$but_return</a>"; 
    292300        } 
    293301        print "<p>&nbsp;</p>\n"; 
     
    321329        lbsClearError(); 
    322330 
     331        $mode = "MULTI" if (($in{'group'}) or exists($in{'profile'})); 
    323332        $mode = "MONO"  if (($in{'mac'}) or ( $in{'name'})); 
    324         $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    325333        $mode = "SKEL" if ($in{'skel'}); 
    326334         
  • trunk/webmin/lbs/bootoptions.cgi

    r93 r130  
    151151etherLoad( $etherfile, \%einfo ) or error( lbsGetError() ); 
    152152 
     153# make sure to use the 'all' directory when any profile is requested 
     154my $oprofile = $in{'profile'}; 
     155if (exists($in{'profile'}) && ($in{'profile'} eq "")) { 
     156    $in{'profile'} = "all"; 
     157} 
     158 
    153159# On effectue une modif si presence du param cgi 'apply' (on ignore sa valeur).  
    154160# Ou on redirige sur index.cgi si presence du param cgi 'cancel'. 
     
    170176 
    171177        if ( exists( $in{'form2'} ) ) { 
     178                $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    172179                $mode = "MONO"  if (($in{'mac'})); 
    173                 $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    174180 
    175181                # get the computer (One Computer Mode) 
     
    202208 
    203209                        lbs_common::etherLoad("$home/etc/ether", \%ether); 
    204                         lbs_common::filter_machines_names($in{'profile'}, $in{'group'}, \%ether); 
     210                        lbs_common::filter_machines_names($oprofile, $in{'group'}, \%ether); 
    205211 
    206212                        foreach my $name (etherGetNames(\%ether)) { 
     
    259265                        redirect("bootoptions.cgi?mac=$umac") ; 
    260266                } elsif ($mode eq "MULTI") { 
    261                         redirect("bootoptions.cgi?group=$in{'group'}&profile=$in{'profile'}") ; 
     267                        redirect("bootoptions.cgi?group=$in{'group'}&profile=$oprofile") ; 
    262268                } 
    263269                exit; 
     
    269275        # Must define a default menu: 
    270276        error( $text{'err_bootmenu_mustdef'} ) if ( not exists( $in{'default'} ) ); 
     277 
     278        $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    271279        $mode = "MONO"  if (($in{'mac'})); 
    272         $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    273280         
    274281        # get the computer (One Computer Mode) 
     
    346353        } elsif ($mode eq "MULTI") { 
    347354                print "<p>$mesg</p>\n"; 
    348                 print "<a href=\"bootoptions.cgi?group=$in{'group'}&profile=$in{'profile'}\">$but_return</a>"; 
     355                print "<a href=\"bootoptions.cgi?group=$in{'group'}&profile=$oprofile\">$but_return</a>"; 
    349356                print "<p>&nbsp;</p>\n"; 
    350357        } 
     
    378385        lbsClearError(); 
    379386 
     387        $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    380388        $mode = "MONO"  if (($in{'mac'}) or ( $in{'name'})); 
    381         $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    382389         
    383390        # get the computer (One Computer Mode) 
     
    581588        } elsif ($mode eq "MULTI") { 
    582589                print "<input type=hidden name=group value=\"$in{'group'}\">\n"; 
    583                 print "<input type=hidden name=profile value=\"$in{'profile'}\">\n"; 
     590                print "<input type=hidden name=profile value=\"$oprofile\">\n"; 
    584591        } 
    585592 
  • trunk/webmin/lbs/debian/changelog

    r109 r130  
    1 webmin-lbs (2.6.1) stable; urgency=low 
     1webmin-lbs (2.6.3) stable; urgency=low 
    22 
    33  * New release. 
  • trunk/webmin/lbs/lbs.pl

    r109 r130  
    536536 
    537537sub checkhostname { 
    538         return 0 if ( not grep(m/^[0-9a-z\.:\/-]+$/i, $_[0]) ) ; 
     538        return 0 if ( not grep(m/^[0-9a-z\.:\/-_]+$/i, $_[0]) ) ; 
    539539        1; 
    540540} 
     
    896896                $arrow = "doubleup1.gif" if ($$flags[$i]); 
    897897                 
    898                 if (($profile ne "") or ($group ne "")) { 
     898                if ((($profile ne "") or ($group ne "")) and ($mac eq "")) { 
    899899                        push @tohdr, "<center><a href=\"move.cgi?profile=$profile&group=$group&img=$uitem&op=b2h\">"  
    900900                                      . "<img src=\"images/$arrow\" border=no " 
  • trunk/webmin/lbs/module.info

    r109 r130  
    77 
    88depends=0.94 lbs_common proc at 
    9 version=2.6.1 
     9version=2.6.3 
  • trunk/webmin/lbs/move.cgi

    r44 r130  
    5555ReadParse() ; 
    5656 
     57# make sure to use the 'all' directory when any profile is requested 
     58my $oprofile = $in{'profile'}; 
     59if (exists($in{'profile'}) && ($in{'profile'} eq "")) { 
     60    $in{'profile'} = "all"; 
     61} 
     62 
     63$mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    5764$mode = "MONO"  if (($in{'mac'}) or ( $in{'name'})); 
    58 $mode = "MULTI" if (($in{'group'}) or ( $in{'profile'})); 
    59          
     65 
    6066if ($mode eq "MONO") { 
    6167        if (not exists($in{'mac'})) { 
     
    112118                        unlink("$lbs_home/images/$macfile/$img") if (-l "$lbs_home/images/$macfile/$img");  
    113119                } elsif ($mode eq "MULTI") { 
    114                         moveHdr2Local_Multi($lbs_home, $cfgpath, $img);                         
    115  
    116                         # to do this, we need the entire mac list to be loaded 
    117                         my $home=$lbs_common::lbsconf{'basedir'}; 
    118                         my %ether; 
    119          
    120                         # and normalized 
    121                         lbs_common::etherLoad("$home/etc/ether", \%ether); 
    122                         lbs_common::filter_machines_names($in{'profile'}, $in{'group'}, \%ether); 
    123  
    124                         my $profile = $in{'profile'} or ""; 
    125                         my $group = $in{'group'} or ""; 
    126                          
    127                         foreach my $name (etherGetNames(\%ether)) { 
    128                                 my $macaddr = etherGetMacByName (\%ether, $name); 
    129                                 my $macfile = toMacFileName($macaddr); 
    130                                 my $cfgpath = "$home/images/$macfile"; 
    131                                 if (opendir CFGPATH, $cfgpath) { 
    132                                         unlink map "$cfgpath/$_", grep { -l "$cfgpath/$_"} readdir(CFGPATH); 
    133                                         closedir CFGPATH; 
    134                                 } 
    135                                 my $origpath = "$lbs_home/imgprofiles/$in{'profile'}/$in{'group'}"; 
    136                                 if (opendir ORIGPATH, $origpath) { 
    137                                         my $cmd = "cp -a " . join " ", map "$origpath/$_", grep { -l "$origpath/$_" or $_ eq "header.lst" or $_ eq "header.lst.$WOL_EXTENSION" } readdir(ORIGPATH); 
    138                                         closedir CFGPATH; 
    139                                         $cmd .= " $cfgpath"; 
    140                                         system($cmd); 
    141                                 } 
    142                         } 
    143                          
    144 #                        foreach my $name (etherGetNames(\%ether)) { 
    145 #                                my $macaddr = etherGetMacByName (\%ether, $name); 
    146 #                                $macfile = toMacFileName($macaddr); 
    147 #                                moveHdr2Local($lbs_home, $macaddr, $img, undef, 1); 
    148 #                                unlink("$lbs_home/images/$macfile/$img") if (-l "$lbs_home/images/$macfile/$img");  
    149 #                        } 
    150                          
     120                        moveHdr2Local_Multi($lbs_home, $cfgpath, $img); 
    151121                } 
    152122        } elsif ($op eq "l2h") {                                # from local to host 
     
    159129                } elsif ($mode eq "MULTI") { 
    160130                        moveBase2Hdr_Multi($lbs_home, $cfgpath, $img); 
    161  
    162                         # then save the checked values for every machine of our group / profile 
    163                         my $profile=$in{'profile'}; 
    164                         my $group=$in{'group'}; 
    165          
    166                         # to do this, we need the entire mac list to be loaded 
    167                         my $home=$lbs_common::lbsconf{'basedir'}; 
    168                         my %ether; 
    169  
    170                         # and normalized 
    171                         lbs_common::etherLoad("$home/etc/ether", \%ether); 
    172                         lbs_common::filter_machines_names($in{'profile'}, $in{'group'}, \%ether); 
    173  
    174                         foreach my $name (etherGetNames(\%ether)) { 
    175                                 my $macaddr = etherGetMacByName (\%ether, $name); 
    176                                 my $macfile = toMacFileName($macaddr); 
    177                                 my $cfgpath = "$home/images/$macfile"; 
    178                                 if (opendir CFGPATH, $cfgpath) { 
    179                                         unlink map "$cfgpath/$_", grep { -l "$cfgpath/$_"} readdir(CFGPATH); 
    180                                         closedir CFGPATH; 
    181                                 } 
    182                                 my $origpath = "$lbs_home/imgprofiles/$in{'profile'}/$in{'group'}"; 
    183                                 if (opendir ORIGPATH, $origpath) { 
    184                                         my $cmd = "cp -a " . join " ", map "$origpath/$_", grep { -l "$origpath/$_" or $_ eq "header.lst" or $_ eq "header.lst.$WOL_EXTENSION" } readdir(ORIGPATH); 
    185                                         closedir CFGPATH; 
    186                                         $cmd .= " $cfgpath"; 
    187                                         system($cmd); 
    188                                 } 
    189                         } 
    190                          
    191 #                        foreach my $name (etherGetNames(\%ether)) { 
    192 #                                moveBase2Hdr($lbs_home, etherGetMacByName (\%ether, $name), $img, undef, 1); 
    193 #                        } 
    194131                } 
    195132        } elsif ($op eq "del") {                                # deletion 
     
    204141                redirect("move.cgi?mac=$umac") ; 
    205142        } elsif ($mode eq "MULTI") { 
    206                 redirect("move.cgi?group=$in{'group'}&profile=$in{'profile'}") ; 
     143                redirect("move.cgi?group=$in{'group'}&profile=$oprofile") ; 
    207144        } 
    208145         
     
    329266                                addBackupProgressInfo($f, \$d); 
    330267 
    331                                 push @basetitles, "<a href='title2.cgi?group=$in{'group'}&profile=$in{'profile'}&conf=$ff' $decor>$t</a>"; 
    332                                 push @basedescs, "<a href='desc2.cgi?group=$in{'group'}&profile=$in{'profile'}&conf=$ff' $decor>$d</a>" ; 
     268                                push @basetitles, "<a href='title2.cgi?group=$in{'group'}&profile=$oprofile&conf=$ff' $decor>$t</a>"; 
     269                                push @basedescs, "<a href='desc2.cgi?group=$in{'group'}&profile=$oprofile&conf=$ff' $decor>$d</a>" ; 
    333270                        } else { 
    334271                                push @basetitles, "(storage?)" ; 
  • trunk/webmin/lbs/wol.cgi

    r107 r130  
    6464        #redirect($redir) ; 
    6565} 
    66 elsif (exists $in{'group'}) { 
     66elsif ($in{'group'}) { 
    6767        my $macs = ""; 
    6868 
     
    8181        my $macs = ""; 
    8282 
    83         foreach my $k (etherGetMacsFilterName(\%einfo, $in{'profile'}.":")) { 
     83        my $filt = $in{'profile'}.":"; 
     84        if ($filt eq ":") { $filt = "" }; 
     85 
     86        foreach my $k (etherGetMacsFilterName(\%einfo, $filt)) { 
    8487            my $n = $einfo{$k}[1]; 
    8588            if ( $n =~ m|^([^:]+):| ) { 
    86                 # group found 
     89                # prof found 
    8790                if (index ($1,$in{'profile'}) != 0) { next; } 
    8891                $macs .=  $k." "; 
     92            } elsif ( $filt eq "" ) { 
     93                $macs .=  $k." ";            
    8994            } 
    9095        }