From 7db099c14da7fde27be0cd6dbe0bf79183420a4f Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 28 May 2004 08:21:15 +0000 Subject: merge fixes from HEAD --- perl-install/any.pm | 14 ++-- perl-install/authentication.pm | 2 +- perl-install/c/stuff.xs.pl | 41 ++++++++- perl-install/detect_devices.pm | 9 +- perl-install/drakxtools.spec | 33 +++++++- perl-install/keyboard.pm | 37 +++++++-- perl-install/network/drakfirewall.pm | 6 ++ perl-install/network/ethernet.pm | 5 +- perl-install/standalone/drakTermServ | 157 +++++++++++++---------------------- perl-install/standalone/drakbackup | 19 ++--- perl-install/standalone/net_monitor | 10 ++- 11 files changed, 195 insertions(+), 138 deletions(-) diff --git a/perl-install/any.pm b/perl-install/any.pm index d3bd72065..a17442dae 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -847,22 +847,26 @@ Allowing this will permit users to simply click on \"Share\" in konqueror and na my $custom = $r eq $l[2]; if ($r ne $l[0]) { #- verify we can export in $type - my %type2file = (nfs => [ 'nfs-utils', '/etc/init.d/nfs' ], smb => [ 'samba-server', '/etc/init.d/smb' ]); + my %type2service = (nfs => [ 'nfs-utils', 'nfs' ], smb => [ 'samba-server', 'smb' ]); my %l; if ($type) { %l = ($type => 1); } else { - %l = map_each { $::a => -e $::b->[1] } %type2file; + %l = map_each { $::a => -e $::b->[1] } %type2service; $in->ask_from('', N("You can export using NFS or Samba. Please select which you'd like to use."), [ map { { text => $_, val => \$l{$_}, type => 'bool' } } keys %l ]) or return; } foreach (keys %l) { - my ($pkg, $file) = @{$type2file{$_}} or die "unknown type $_\n"; + my ($pkg, $service) = @{$type2service{$_}} or die "unknown type $_\n"; + my $file = "/etc/init.d/$service"; + require services; if ($l{$_}) { $in->do_pkgs->ensure_is_installed($pkg, $file) or return; + services::start($service); + services::start_service_on_boot($service); } elsif (-e $file) { - $in->ask_okcancel('', N("The package %s is going to be removed.", $pkg), 1) or return; - $in->do_pkgs->remove($pkg); + services::stop($service); + services::do_not_start_service_on_boot($service); } } } diff --git a/perl-install/authentication.pm b/perl-install/authentication.pm index 767ddd7cb..bde5ed6fd 100644 --- a/perl-install/authentication.pm +++ b/perl-install/authentication.pm @@ -78,7 +78,7 @@ sub set { set_pam_authentication('ldap'); set_ldap_conf($domain, $val, 1); } elsif ($kind eq 'NIS') { - $in->do_pkgs->install('ypbind'); + $in->do_pkgs->install(qw(ypbind autofs)); my $domain = $netc->{NISDOMAIN}; $domain || $val ne "broadcast" or die N("Can't use broadcast with no NIS domain"); my $t = $domain ? "domain $domain" . ($val ne "broadcast" && " server") : "ypserver"; diff --git a/perl-install/c/stuff.xs.pl b/perl-install/c/stuff.xs.pl index d30aff57f..07249d66b 100644 --- a/perl-install/c/stuff.xs.pl +++ b/perl-install/c/stuff.xs.pl @@ -400,7 +400,7 @@ hasNetDevice(device) int s = socket(AF_INET, SOCK_DGRAM, 0); if (s == -1) { RETVAL = 0; return; } - strcpy(req.ifr_name, device); + strncpy(req.ifr_name, device, IFNAMSIZ); RETVAL = ioctl(s, SIOCGIFFLAGS, &req) == 0; close(s); @@ -424,6 +424,43 @@ isNetDeviceWirelessAware(device) RETVAL +void +get_netdevices() + PPCODE: + struct ifconf ifc; + struct ifreq *ifr; + int i; + int numreqs = 10; + + int s = socket(AF_INET, SOCK_DGRAM, 0); + + ifc.ifc_buf = NULL; + for (;;) { + ifc.ifc_len = sizeof(struct ifreq) * numreqs; + ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len); + + if (ioctl(s, SIOCGIFCONF, &ifc) < 0) { + perror("SIOCGIFCONF"); + return; + } + if (ifc.ifc_len == sizeof(struct ifreq) * numreqs) { + /* assume it overflowed and try again */ + numreqs += 10; + continue; + } + break; + } + if (ifc.ifc_len) { + ifr = ifc.ifc_req; + EXTEND(sp, ifc.ifc_len); + for (i=0; i < ifc.ifc_len; i+= sizeof(struct ifreq)) { + PUSHs(sv_2mortal(newSVpv(ifr->ifr_name, 0))); + ifr++; + } + } + + close(s); + char* getNetDriver(char* device) @@ -435,7 +472,7 @@ getNetDriver(char* device) int s = socket(AF_INET, SOCK_DGRAM, 0); memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)-1); + strncpy(ifr.ifr_name, device, IFNAMSIZ); drvinfo.cmd = ETHTOOL_GDRVINFO; ifr.ifr_data = (caddr_t) &drvinfo; diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index 3e699ba24..0016e077b 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -493,14 +493,7 @@ sub getECI() { grep { member(sprintf("%04x%04x%04x%04x", $_->{vendor}, $_->{id}, $_->{subvendor}, $_->{subid}), @ids) } usb_probe(); } -sub getNet() { - grep { !($::isStandalone && /plip/) && c::hasNetDevice($_) } - grep { /^(ath|eth|fddi|plip|tr|usb|wifi|wlan)/ } - map_index { - # skip headers - if_(1 < $::i && /^\s*([a-z]*[0-9]*):/, $1) - } cat_("/proc/net/dev"); -} +sub getNet() { grep { $_ ne 'lo' } c::get_netdevices() } #sub getISDN() { # mapgrep(sub {member (($_[0] =~ /\s*(\w*):/), @netdevices), $1 }, split(/\n/, cat_("/proc/net/dev"))); diff --git a/perl-install/drakxtools.spec b/perl-install/drakxtools.spec index 17d5348c1..2d314ec33 100644 --- a/perl-install/drakxtools.spec +++ b/perl-install/drakxtools.spec @@ -1,7 +1,7 @@ Summary: The drakxtools (XFdrake, diskdrake, keyboarddrake, mousedrake...) Name: drakxtools Version: 10 -Release: 34.1mdk +Release: 34.2mdk Url: http://www.mandrakelinux.com/en/drakx.php3 Source0: %name-%version.tar.bz2 License: GPL @@ -314,8 +314,39 @@ file /etc/sysconfig/harddrake2/previous_hw | fgrep -q perl && %_datadir/harddrak %config(noreplace) %_sysconfdir/logrotate.d/drakxtools-http %changelog +* Fri May 28 2004 Thierry Vignaud 10-34.2mdk +- authentication: install autofs for nis authentication (florin & fcrozat) +- diskdrake: disable package instead of removing nfs-utils or + samba-server (when "diskdrake --fileshare" disables a export kind) + (pixel, #9804) +- drakbackup: fix dropped .txt files when running mkisofs (stew) + (Anthill #799) +- drakconnect: + o prevent identification mismatch on ethtool results (#9669) + o fix card name lookup when driver does not support GDRVINFO command + from ETHTOOL ioctl and there's only one card managed by this driver +- drakfirewall: handle BitTorrent (robert vojta) +- drakTermServ: add /etc/modprobe* mount points for client hardware + config (stew) +- keyboardrake (pablo): + o support more keyboards + o Nepali uses devanagari script +- localedrake: handle Latgalian language (pablo) +- net_monitor: ignore sit0 + * Tue May 11 2004 Pixel 10-34.1mdk - fix pam configuration when using winbind (also fixes LDAP and NIS (?)) +- drakclock: do saner check for ntp package (Robert Vojta) +- drakconnect: + o fix speedtouch ADSL model (using kernel mode) (poulpy) + o better LAN vs wireless filtering by using SIOCGIWNAME ioctl) + o handle ipw2100 wireless driver + o do not offer to set DOMAINNAME2 since it is never saved nor read + (#9580) + o kill "speedtouch and ISDN only work under 2.4 kernel" warnings + (poulpy) +- drakfirewall: open more ports for samba +- scannerdrake: fix firmware installation (till) * Tue May 4 2004 Thierry Vignaud 10-34mdk - drakconnect: diff --git a/perl-install/keyboard.pm b/perl-install/keyboard.pm index 7f3d90edd..a92f8ee13 100644 --- a/perl-install/keyboard.pm +++ b/perl-install/keyboard.pm @@ -23,6 +23,7 @@ my $KMAP_MAGIC = 0x8B39C07F; my %lang2keyboard = ( 'af' => 'us_intl', + 'am' => 'us:90', 'ar' => 'ar:90', 'as' => 'ben:90 dev:20 us_intl:5', 'az' => 'az:90 tr_q:10 us_intl:5', @@ -38,18 +39,22 @@ my %lang2keyboard = 'de' => 'de_nodeadkeys:70 de:50 be:50 ch_de:50', 'el' => 'gr:90', 'en' => 'us:89 us_intl:50 qc:50 uk:50', +'en_IE' => 'ie:80 uk:70', 'en_US' => 'us:90 us_intl:50', 'en_GB' => 'uk:89 us:60 us_intl:50', - 'eo' => 'us_intl:89 dvorak:20', + 'eo' => 'us_intl:89 dvorak_eo:30 dvorak:20', 'es' => 'es:85 la:80 us_intl:50', 'et' => 'ee:90', 'eu' => 'es:90 fr:15', 'fa' => 'ir:90', 'fi' => 'fi:90', + 'fo' => 'dk:90', 'fr' => 'fr:89 qc:85 be:85 ch_fr:70', + 'fur' => 'it:90', 'ga' => 'ie:80 uk:70', 'gd' => 'uk:80 ie:70', 'gl' => 'es:90', + 'gn' => 'la:85 es:80 us_intl:50', 'gu' => 'guj:90', 'gv' => 'uk:80 ie:70', 'he' => 'il:90 il_phonetic:10', @@ -57,10 +62,11 @@ my %lang2keyboard = 'hr' => 'hr:90 si:50', 'hu' => 'hu:90', 'hy' => 'am:90 am_old:10 am_phonetic:5', + 'ia' => 'us:90 us_intl:20', 'id' => 'us:90 us_intl:20', 'is' => 'is:90', - 'iu' => 'iu:90', 'it' => 'it:90 ch_fr:50 ch_de:50', + 'iu' => 'iu:90', 'ja' => 'jp:90 us:50 us_intl:20', 'ka' => 'ge_la:90 ge_ru:50', 'kl' => 'dk:80 us_intl:30', @@ -68,9 +74,11 @@ my %lang2keyboard = 'ko' => 'kr:90 us:60', 'ku' => 'tr_q:90 tr_f:30', 'kw' => 'uk:80 ie:70', + 'ky' => 'ky:90 ru_yawerty:40', 'li' => 'us_intl:80 be:70 nl:10 us:5', 'lo' => 'lao:90', 'lt' => 'lt:80 lt_new:70 lt_b:60 lt_p:50', + 'ltg' => 'lv:90 lt:40 lt_new:30 lt_b:20 lt_p:10 ee:5', 'lv' => 'lv:90 lt:40 lt_new:30 lt_b:20 lt_p:10 ee:5', 'mi' => 'us_intl:90 uk:20 us:10', 'mk' => 'mk:90', @@ -81,9 +89,11 @@ my %lang2keyboard = 'mt' => 'mt:90 mt_us:35 us_intl:10', 'my' => 'mm:90', 'nb' => 'no:90 dvorak_no:10', + 'nds' => 'de_nodeadkeys:70 de:50 us_intl:40 nl:10 us:5', + 'ne' => 'dev:90', 'nl' => 'us_intl:80 be:70 nl:10 us:5', 'nn' => 'no:90 dvorak_no:10', - 'no' => 'no:90 dvorak_no:10', + 'no' => 'no:90 dvorak_no:10', # for compatiblity only 'oc' => 'fr:90', 'or' => 'ori:90', 'pa' => 'gur:90', @@ -94,38 +104,51 @@ my %lang2keyboard = 'pt' => 'pt:90', 'ro' => 'ro2:80 ro:40 us_intl:10', 'ru' => 'ru:85 ru_yawerty:80 ua:50', + 'sc' => 'it:90', 'se' => 'sapmi:70 sapmi_sefi:50', 'sh' => 'yu:80', 'sk' => 'sk_qwerty:80 sk:70', 'sl' => 'si:90 hr:50', 'sq' => 'al:90', 'sr' => 'sr:80', + 'ss' => 'us_intl', + 'st' => 'us_intl', 'sv' => 'se:90 fi:30 dvorak_se:10', 'ta' => 'tscii:80 tml:20', 'te' => 'tel:90', 'tg' => 'tj:90 ru_yawerty:40', 'th' => 'th:90', + 'tk' => 'tr_q:50 tr_f:40', # proper Turkmen keyboard still to come + 'tl' => 'us:90 us_intl:20', 'tr' => 'tr_q:90 tr_f:30', 'tt' => 'ru:50 ru_yawerty:40', 'uk' => 'ua:90 ru:50 ru_yawerty:40', - 'uz' => 'us:80 uz:80', + 'ur' => 'ar:50 ir:40', # proper Urdu keyboard still to come + 'uz' => 'uz:80 ru_yawerty:40', 'uz\@Cyrl' => 'uz:80 ru_yawerty:40', + 'uz\@Latn' => 'us:80 uz:80', + 've' => 'us_intl', 'vi' => 'vn:80 us:60 us_intl:50', 'wa' => 'be:90 fr:5', + 'xh' => 'us_intl', 'yi' => 'il_phonetic:90 il:10 us_intl:10', 'zh_CN' => 'us:60', 'zh_TW' => 'us:60', + 'zu' => 'us_intl', ); # USB kbd table # The numeric values are the bCountryCode field (5th byte) of HID descriptor +# NOTE: we don't trust when the layout is declared as us layout (0x21) +# as most manufacturers just use that value when selling physical devices +# with different layouts printed on the keys. my @usb2keyboard = ( qw(SKIP ar_SKIP be ca_SKIP qc cz dk fi fr de gr il hu us_intl it jp), #- 0x10 qw(kr la nl no ir pl pt ru sk es se ch_de ch_de ch_de tw_SKIP tr_q), #- 0x20 - qw(uk us yu tr_f), + qw(uk us_SKIP yu tr_f), #- higher codes not attribued as of 2002-02 ); @@ -173,6 +196,7 @@ arch() =~ /^sparc/ ? ( "dev" => [ N_("Devanagari"), "us", "dev", 0 ], "dk" => [ N_("Danish"), "dk-latin1", "dk", 0 ], "dvorak" => [ N_("Dvorak (US)"), "pc-dvorak-latin1", "dvorak", 0 ], + "dvorak_eo" => [ N_("Dvorak (Esperanto)"), "us", "dvorak(eo)", 0 ], "dvorak_no" => [ N_("Dvorak (Norwegian)"), "no-dvorak", "dvorak(no)", 0 ], "dvorak_se" => [ N_("Dvorak (Swedish)"), "se-dvorak", "dvorak(se)", 0 ], "ee" => [ N_("Estonian"), "ee-latin9", "ee", 0 ], @@ -202,6 +226,7 @@ arch() =~ /^sparc/ ? ( #There is no XKB korean file yet; but using xmodmap one disables # some functioanlity; "us" used for XKB until this is fixed "kr" => [ N_("Korean keyboard"), "us", "us", 1 ], + "ky" => [ N_("Kyrgyz keyboard"), "ru", "ky", 1 ], "la" => [ N_("Latin American"), "la-latin1", "la", 0 ], "lao" => [ N_("Laotian"), "us", "lo", 1 ], "lt" => [ N_("Lithuanian AZERTY (old)"), "lt-latin7", "lt_a", 0 ], @@ -548,7 +573,7 @@ sub check() { } } /SKIP/ || $keyboards{$_} or $err->("invalid keyboard $_ in \@usb2keyboard keyboard.pm") foreach @usb2keyboard; - $usb2keyboard[0x21] eq 'us' or $err->('@usb2keyboard is badly modified, 0x21 is not us keyboard'); + $usb2keyboard[0x21] eq 'us_SKIP' or $err->('@usb2keyboard is badly modified, 0x21 is not us keyboard'); my @xkb_groups = map { if_(/grp:(\S+)/, $1) } cat_('/usr/lib/X11/xkb/rules/xfree86.lst'); $err->("invalid xkb group toggle '$_' in \%grp_toggles") foreach difference2([ keys %grp_toggles ], \@xkb_groups); diff --git a/perl-install/network/drakfirewall.pm b/perl-install/network/drakfirewall.pm index 7c9450107..8b22c3001 100644 --- a/perl-install/network/drakfirewall.pm +++ b/perl-install/network/drakfirewall.pm @@ -61,6 +61,12 @@ my @all_servers = ports => '8/icmp', force_default_selection => 0, }, + { + name => "BitTorrent", + ports => '6881:6999/tcp', + hide => 1, + pkg => 'bittorrent bittorrent-shadowsclient', + }, ); sub port2server { diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm index 845d7b3d8..193bbf539 100644 --- a/perl-install/network/ethernet.pm +++ b/perl-install/network/ethernet.pm @@ -39,7 +39,8 @@ sub mapIntfToDevice { my ($interface) = @_; my $hw_addr = c::getHwIDs($interface); my ($bus, $slot, $func) = map { hex($_) } ($hw_addr =~ /([0-9a-f]+):([0-9a-f]+)\.([0-9a-f]+)/); - $hw_addr ? grep { $_->{pci_bus} == $bus && $_->{pci_device} == $slot && $_->{pci_function} == $func } detect_devices::probeall() : {}; + $hw_addr && (every { defined $_ } $bus, $slot, $func) ? + grep { $_->{pci_bus} == $bus && $_->{pci_device} == $slot && $_->{pci_function} == $func } detect_devices::probeall() : {}; } @@ -63,7 +64,7 @@ sub get_eth_cards() { } if (!$description) { my @cards = grep { $_->{driver} eq ($a || $saved_driver) } detect_devices::probeall(); - $description = $cards[0]{descripxtion} if @cards == 1; + $description = $cards[0]->{description} if $#cards == 0; } $a and $saved_driver = $a; # handle multiple cards managed by the same driver [ $interface, $saved_driver, if_($description, $description) ] diff --git a/perl-install/standalone/drakTermServ b/perl-install/standalone/drakTermServ index 9f3b5bfcc..1b3a62220 100755 --- a/perl-install/standalone/drakTermServ +++ b/perl-install/standalone/drakTermServ @@ -47,10 +47,11 @@ my $in_wizard = 0; my $config_written = 0; my $clients_set = 0; my @nothing = (0..10); +my %conf; +$conf{ALLOW_THIN} = 0; my $nfs_subnet; my $nfs_mask; -my $thin_clients = 0; my $cfg_dir = "/etc/drakxtools/draktermserv/"; my $cfg_file = $cfg_dir . "draktermserv.conf"; my $interface = get_net_interface(); @@ -150,24 +151,13 @@ interactive_mode() if $#ARGV < 1; sub read_conf_file() { if (-e $cfg_file) { - local *CONF_FILE; - open(CONF_FILE, "<" . $cfg_file) || print N("You must be root to read configuration file. \n"); - local $_; - while () { - if (/^\bALLOW_THIN\b/) { - $thin_clients = 1; - last; - } - } + substInFile { s/ALLOW_THIN$/ALLOW_THIN=1/ } $cfg_file; + %conf = getVarsFromSh($cfg_file); } } sub write_conf_file() { - my @cfg_list; - if ($thin_clients == 1) { - @cfg_list = "ALLOW_THIN\n"; - } - output_p($cfg_file, @cfg_list); + setVarsInSh($cfg_file, \%conf); chmod(0600, $cfg_file); } @@ -210,10 +200,7 @@ ca::ctrlaltdel:/sbin/reboot -f x:5:respawn:/usr/X11R6/bin/X -ac -query $server_ip\n"; my $inittab_file = "/etc/inittab$suffix"; - local *INITTAB; - open(INITTAB, "> $inittab_file") or warn("Can't open $inittab_file!"); - print INITTAB $inittab; - close INITTAB + output_p($inittab_file, $inittab); } sub cursor_wait() { @@ -443,7 +430,7 @@ sub clear_buttons() { sub client_type() { my $check_allow_thin = new Gtk2::CheckButton(N("Use thin clients.")); - $check_allow_thin->set_active($thin_clients); + $check_allow_thin->set_active($conf{ALLOW_THIN}); text_view(N("Please select default client type. 'Thin' clients run everything off the server's CPU/RAM, using the client display. 'Fat' clients use their own CPU/RAM but the server's filesystem."), "wizard"); @@ -451,7 +438,7 @@ sub client_type() { 0, gtkpack_(new Gtk2::HBox(1,0), 1, Gtk2::VBox->new, 0, gtksignal_connect($check_allow_thin, clicked => sub { - invbool \$thin_clients; + invbool \$conf{ALLOW_THIN}; client_set("all"); }), 0, Gtk2::VBox->new, @@ -477,17 +464,17 @@ sub sync_users { my $buff = N("Syncing server user list with client list, including root."); my @active_users = cat_("/etc/shadow"); - local *SHADOW; - open(SHADOW, '> /etc/shadow$$CLIENT$$'); - + my $shadow = '/etc/shadow$$CLIENT$$'; + my @userlist; + #- only users with home dirs, and root foreach my $user (@active_users) { my @fields = split(/:/, $user); if (-d "/home/" . $fields[0] || $fields[0] eq "root") { - print SHADOW $user; + push @userlist, $user; } } - close SHADOW; + output_p($shadow, @userlist); $buff .= "\n\n\t" . N("Done!"); text_view($buff, "wizard") if !$cmd_line; } @@ -1075,11 +1062,11 @@ sub maintain_clients() { ), ); - $check_allow_thin->set_active($thin_clients); - $check_thin->set_sensitive($thin_clients); + $check_allow_thin->set_active($conf{ALLOW_THIN}); + $check_thin->set_sensitive($conf{ALLOW_THIN}); gtksignal_connect($check_allow_thin, clicked => - sub { invbool \$thin_clients; - $check_thin->set_sensitive($thin_clients); + sub { invbool \$conf{ALLOW_THIN}; + $check_thin->set_sensitive($conf{ALLOW_THIN}); client_set("single"); $in->ask_warn(N("Warning"), N("Need to restart the Display Manager for full changes to take effect. \n(service dm restart - at the console)")); } @@ -1119,7 +1106,7 @@ sub client_set { # we need to change some system files to allow the thin clients # to access the server - enabling xdmcp and modify hosts.deny/hosts.allow for some security # we also need to set runlevel to 5 and restart the display manager - if ($thin_clients == 1) { + if ($conf{ALLOW_THIN} == 1) { if (-f "/etc/sysconfig/autologin") { my $answer = $in->ask_yesorno('', N("Thin clients won't work with autologin. Disable autologin?")); if ($answer == 1) { @@ -1385,15 +1372,14 @@ sub get_ip_from_sys() { sub write_dhcpd_config { my ($mode, $subnet, $netmask, $routers, $subnet_mask, $broadcast, $domain, $ns1, $ns2, $ns3, $pool_start, $pool_end) = @_; + my @dhcpd_config; if ($mode eq "append") { append_to_file("/etc/dhcpd.conf", qq(include "/etc/dhcpd.conf.terminal-server";\n)); - local *FHANDLE; - open(FHANDLE, "> /etc/dhcpd.conf.terminal-server"); - print FHANDLE qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n); - print FHANDLE qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n); - print FHANDLE qq(# Include client machine configurations\ninclude "$client_cfg";\n); - close FHANDLE; + push @dhcpd_config, qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n); + push @dhcpd_config, qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n); + push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n); + output_p("/etc/dhcpd.conf.terminal-server", @dhcpd_config); $config_written = 1; return; } @@ -1401,34 +1387,32 @@ sub write_dhcpd_config { $nfs_subnet = $subnet; $nfs_mask = $subnet_mask; - local *FHANDLE; - open(FHANDLE, "> /etc/dhcpd.conf"); - print FHANDLE "#dhcpd.conf - generated by drakTermServ\n\n"; - print FHANDLE "ddns-update-style none;\n\n"; - print FHANDLE "# Long leases (48 hours)\ndefault-lease-time 172800;\nmax-lease-time 172800;\n\n"; - print FHANDLE qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n); - print FHANDLE qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n\n); - print FHANDLE "# Network-specific section\n\n"; + push @dhcpd_config, "#dhcpd.conf - generated by drakTermServ\n\n"; + push @dhcpd_config, "ddns-update-style none;\n\n"; + push @dhcpd_config, "# Long leases (48 hours)\ndefault-lease-time 172800;\nmax-lease-time 172800;\n\n"; + push @dhcpd_config, qq(# Include Etherboot definitions and defaults\ninclude "/etc/dhcpd.conf.etherboot.include";\n); + push @dhcpd_config, qq(# Include Etherboot default kernel version\ninclude "/etc/dhcpd.conf.etherboot.kernel";\n\n); + push @dhcpd_config, "# Network-specific section\n\n"; - print FHANDLE "subnet $subnet netmask $netmask {\n"; - print FHANDLE "\toption routers $routers;\n" if $routers; - print FHANDLE "\toption subnet-mask $subnet_mask;\n" if $subnet_mask; - print FHANDLE "\toption broadcast-address $broadcast;\n" if $broadcast; - print FHANDLE qq(\toption domain-name "$domain";\n) if $domain; + push @dhcpd_config, "subnet $subnet netmask $netmask {\n"; + push @dhcpd_config, "\toption routers $routers;\n" if $routers; + push @dhcpd_config, "\toption subnet-mask $subnet_mask;\n" if $subnet_mask; + push @dhcpd_config, "\toption broadcast-address $broadcast;\n" if $broadcast; + push @dhcpd_config, qq(\toption domain-name "$domain";\n) if $domain; my $pool_string = "\trange dynamic-bootp " . $pool_start . " " . $pool_end . ";\n" if $pool_start && $pool_end; - print FHANDLE $pool_string if $pool_string; + push @dhcpd_config, $pool_string if $pool_string; my $ns_string = "\toption domain-name-servers " . $ns1 if $ns1; $ns_string = $ns_string . ", " . $ns2 if $ns2; $ns_string = $ns_string . ", " . $ns3 if $ns3; $ns_string = $ns_string . ";\n" if $ns_string; - print FHANDLE $ns_string if $ns_string; + push @dhcpd_config, $ns_string if $ns_string; - print FHANDLE "}\n\n"; + push @dhcpd_config, "}\n\n"; - print FHANDLE qq(# Include client machine configurations\ninclude "$client_cfg";\n); - close FHANDLE; + push @dhcpd_config, qq(# Include client machine configurations\ninclude "$client_cfg";\n); + output_p("/etc/dhcpd.conf", @dhcpd_config); $config_written = 1; } @@ -1564,14 +1548,11 @@ sub toggle_chkconfig { sub service_change { my ($service, $command, $buff_index) = @_; system("BOOTUP=serial /sbin/service $service $command > /tmp/drakTSservice.status 2>&1"); - local *STATUS; - open(STATUS, "/tmp/drakTSservice.status"); - local $_; - while () { + my @result = cat_("/tmp/drakTSservice.status"); + foreach (@result) { $buff[$buff_index] = "\t$_"; - $buff_index++; + $buff_index++; } - close STATUS; unlink "/tmp/drakTSservice.status"; $buff_index; } @@ -1655,13 +1636,8 @@ sub adduser { } } else { # new ts user - local *FHANDLE; - open(FHANDLE, '>> /etc/shadow$$CLIENT$$'); - print FHANDLE $shadow_entry[0] or $add_fail = 1; - close FHANDLE; - open(FHANDLE, '>> /etc/passwd$$CLIENT$$'); - print FHANDLE $passwd_entry[0] or $add_fail = 1; - close FHANDLE; + append_to_file('/etc/shadow$$CLIENT$$', $shadow_entry[0]) or $add_fail = 1; + append_to_file('/etc/passwd$$CLIENT$$', $passwd_entry[0]) or $add_fail = 1; $in_already = 0; } } @@ -1700,10 +1676,7 @@ sub deluser { } $i++; } - local *FHANDLE; - open(FHANDLE, '> /etc/shadow$$CLIENT$$'); - print FHANDLE $_ foreach @ts_users; - close FHANDLE; + output_p('/etc/shadow$$CLIENT$$', @ts_users); } if ($is_passwd_user) { @@ -1716,10 +1689,7 @@ sub deluser { } $i++; } - local *FHANDLE; - open(FHANDLE, '> /etc/passwd$$CLIENT$$'); - print FHANDLE $_ foreach @passwd_users; - close FHANDLE; + output_p('/etc/passwd$$CLIENT$$', @passwd_users); } if ($cmd_line == 1) { @@ -1772,12 +1742,8 @@ sub addclient { $ts_clients{$hostname}{hdw_config} = "false"; client_hdw_config($ip, 0); } - my $clients = $client_cfg; - local *CLIENT; - open(CLIENT, ">> $clients") or warn(N("Can't open %s!", $clients)); my $client_entry = format_client_entry($hostname, %ts_clients); - print CLIENT $client_entry; - close CLIENT; + append_to_file($client_cfg, $client_entry); $changes_made = 1; create_client_sysnetwork($hostname, $ip); 0; @@ -1898,15 +1864,12 @@ qq(\tfilename\t\t"$ts_clients{$client}{filename}";), sub write_dhcpd_conf { my %ts_clients = @_; - my $clients = $client_cfg; - - local *CLIENT; - open(CLIENT, "> $clients") or warn("Can't open $clients!"); + my @client_data; foreach my $key (keys(%ts_clients)) { my $client_entry = format_client_entry($key, %ts_clients); - print CLIENT $client_entry; + push @client_data, $client_entry; } - close CLIENT + output_p($client_cfg, @client_data); } sub read_dhcpd_conf() { @@ -1915,9 +1878,8 @@ sub read_dhcpd_conf() { my $hostname; #- read and parse current client entries - local *CLIENTS; - open(CLIENTS, $clients) or warn("Can't open $clients\n"); - while () { + my @client_data = cat_($clients); + foreach (@client_data) { my ($name, $val, $val2) = split ' '; $val = $val2 if $name =~ /hardware/; $val =~ s/[;"]//g; @@ -1932,7 +1894,6 @@ sub read_dhcpd_conf() { } } } - close CLIENTS; %ts_clients; } @@ -1960,11 +1921,15 @@ sub client_hdw_config { cp_af('/etc/X11/XF86Config-4$$CLIENT$$', "/etc/X11/XF86Config-4$suffix") if -f '/etc/X11/XF86Config-4$$CLIENT$$'; cp_af("/dev/null", "/etc/modules.conf$suffix"); cp_af("/dev/null", "/etc/modules$suffix"); + cp_af("/dev/null", "/etc/modprobe.conf$suffix"); + cp_af("/dev/null", "/etc/modprobe.preload$suffix"); # create mount points so they can be edited by the client my $mnt_access = "$client_ip(rw,no_root_squash)"; append_to_file("/etc/exports", "/etc/sysconfig/mouse$suffix\t$mnt_access\n"); append_to_file("/etc/exports", "/etc/modules.conf$suffix\t$mnt_access\n"); append_to_file("/etc/exports", "/etc/modules$suffix\t$mnt_access\n"); + append_to_file("/etc/exports", "/etc/modprobe.conf$suffix\t$mnt_access\n"); + append_to_file("/etc/exports", "/etc/modprobe.preload$suffix\t$mnt_access\n"); append_to_file("/etc/exports", "/etc/X11/XF86Config$suffix\t$mnt_access\n"); append_to_file("/etc/exports", "/etc/X11/XF86Config-4$suffix\t$mnt_access\n"); } else { @@ -1979,12 +1944,8 @@ sub create_client_sysnetwork { my ($hostname, $ip) = @_; log::explanations("Adding /etc/sysconfig/network for $ip"); my $network_file = "/etc/sysconfig/network\$\$IP=$ip\$\$"; - local *NETWORK; - open(NETWORK, "> $network_file") or warn("Can't open $network_file!"); - print NETWORK "HOSTNAME=$hostname\n"; - print NETWORK "NETWORKING=yes\n"; - print NETWORK "FORWARD_IPV4=false\n"; - close NETWORK; + my %net_data = ("HOSTNAME=$hostname\n", "NETWORKING=yes\n", "FORWARD_IPV4=false\n"); + output_p($network_file, %net_data); } sub restart_server() { @@ -2005,6 +1966,8 @@ sub clean_client_config { eval { rm_rf("/etc/sysconfig/mouse$suffix") }; eval { rm_rf("/etc/modules.conf$suffix") }; eval { rm_rf("/etc/modules$suffix") }; + eval { rm_rf("/etc/modprobe.conf$suffix") }; + eval { rm_rf("/etc/modprobe.preload$suffix") }; eval { rm_rf("/etc/X11/XF86Config$suffix") }; eval { rm_rf("/etc/X11/XF86Config-4$suffix") }; eval { rm_rf("/etc/sysconfig/network$suffix") }; diff --git a/perl-install/standalone/drakbackup b/perl-install/standalone/drakbackup index 351f363f3..00f3a3a15 100755 --- a/perl-install/standalone/drakbackup +++ b/perl-install/standalone/drakbackup @@ -225,14 +225,11 @@ sub get_tape_info() { @tape_devices = (); system("dmesg | grep 'st[0-9] at' > $info"); - local *INFO; - open INFO, $info or warn("Can't open $info\n"); - local $_; - while () { + my @info = cat_($info); + foreach (@info) { @line_data = split(/[ \t,]+/, $_); push @tape_devices, "/dev/" . $line_data[3]; } - close INFO; unlink($info); } @@ -1044,7 +1041,7 @@ sub build_backup_files() { do_find(undef, $find_args_user, $list_file, $path_name); do_tar($tar_cmd_user, "backup_$incr$user", undef, $path_name); } - push_list("$incr$user") if $incr =~ /_user/; + push_list("list_$incr$user") if $incr =~ /_user/; files_to_results("$incr$user"); } } @@ -1254,7 +1251,7 @@ sub push_list { my $filename = $conf{PATH_TO_SAVE} . "/" . $prefix . $the_time . "."; $filename .= $conf{OPTION_COMP} if $prefix =~ /^backup/; $filename .= "txt" if $prefix =~ /^list/; - push @file_list_to_send_by_ftp, $filename; + push @file_list_to_send_by_ftp, $filename if -e $filename; } sub files_to_results { @@ -2776,22 +2773,18 @@ sub restore_aff_result() { button_box_ok_only(); $central_widget = \$do_restore; $up_box->show_all; - } sub return_path { my ($username) = @_; my $usr; my $home_dir; - my $passwdfile = "/etc/passwd"; - local *PASSWD; - open(PASSWD, $passwdfile) or exit 1; - while (defined(my $line = )) { + my @passwords = cat_("/etc/passwd"); + foreach my $line (@passwords) { chomp($line); ($usr, $home_dir) = (split(/:/, $line))[0,5]; last if $usr eq $username; } - close(PASSWD); return $home_dir; } diff --git a/perl-install/standalone/net_monitor b/perl-install/standalone/net_monitor index 7e323fb19..3863e0197 100755 --- a/perl-install/standalone/net_monitor +++ b/perl-install/standalone/net_monitor @@ -25,6 +25,7 @@ use lib qw(/usr/lib/libDrakX); use strict; use standalone; #- warning, standalone must be loaded very first, for 'explanations' +use c; use interactive; use ugtk2 qw(:helpers :wrappers :create); use common; @@ -281,12 +282,15 @@ sub get_val() { $a =~ s/^.*?\n.*?\n//; $a =~ s/^\s*lo:.*?\n//; my @line = split(/\n/, $a); + my @interfaces = c::get_netdevices(); map { s/\s*(\w*)://; my $intf = $1; - $monitor->{$intf}{val} = [split()]; - $monitor->{$intf}{intf} = $intf; - $intf; + if (member($intf, @interfaces)) { + $monitor->{$intf}{val} = [ split() ]; + $monitor->{$intf}{intf} = $intf; + $intf; + } else { () } } @line; } -- cgit v1.2.1