summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunammx <unammx>2001-05-22 00:22:19 +0000
committerunammx <unammx>2001-05-22 00:22:19 +0000
commit10cd0558ff5bbea953bfb80d004630e2096a071c (patch)
tree41f28ee88e5556973f6201953695557f8056b924
parent6592d959d75bee12b8baed0376e0c4011e4aed03 (diff)
2001-05-21 Arturo Espinosa Aldama <arturo@ximian.com>
* xml.pl.in (xst_xml_scan): Use new debug_print_log func. * users-conf.in (change_user): Just changed arg order to make it easier to compare it with man page when checking compatibility. * replace.pl.in (xst_replace_sh): Changed behaviour so that shell var will be expunged from file if $value eq "". (xst_replace_sh_join): Implemented. Required by network:suse70 * platform.pl.in (check_lsb): Check through lsb file, which may make our lives easier in the near future. check_*: use $xst_prefix to check platform too. * network.pl.in (xst_network_suse70_active_interfaces_get): Don't list "lo" as an active interface. (xst_network_suse70_ifaces_get_existing): Better code: finds all NETDEV vars in rc.config and takes values from there. (xst_network_suse70_parse_iface_num): Braking the 4 interface barrier here too. SuSE 7.0 scripts are broken, still. (xst_network_suse70_set_ifconfig_arg): Beautified output. (xst_network_suse70_get_file): Completly missed implemening this one. New interfaces weren't getting a NETDEV number. (xst_network_get_file): "suse-7.0" entry added. (xst_network_suse70_interface_delete): Was calling activate _by_dev with wrong value for $dev. (xst_network_suse70_interface_delete): Oops. Use "_" between var type and $dev. (xst_network_ensure_loopback_interface): Those distros that map to "" are not "ensured". (xst_network_get_interfaces_parse_table): Changed from XST_NAME to XST_IFACE_NAME, which is more verbose. (xst_network_get_interface_replace_table): same. * debug.pl.in (xst_debug_print_log_to_file): Seems like print can't handle strings larger than 4096 bytes. This routine is for printing large strings that may contain \n's inside (like in.xml).
-rw-r--r--ChangeLog41
-rw-r--r--debug.pl.in14
-rw-r--r--network.pl.in80
-rw-r--r--platform.pl.in33
-rw-r--r--replace.pl.in20
-rw-r--r--users-conf.in4
-rw-r--r--xml.pl.in2
7 files changed, 154 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 96d857a..1f2a457 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,43 @@
-2001-05-21 Chema Celorio <chema@celorio.com>
+2001-05-21 Arturo Espinosa Aldama <arturo@ximian.com>
- * test2
+ * xml.pl.in (xst_xml_scan): Use new debug_print_log func.
- * test
+ * users-conf.in (change_user): Just changed arg order to
+ make it easier to compare it with man page when checking
+ compatibility.
+
+ * replace.pl.in (xst_replace_sh): Changed behaviour so that
+ shell var will be expunged from file if $value eq "".
+ (xst_replace_sh_join): Implemented. Required by network:suse70
+
+ * platform.pl.in (check_lsb): Check through lsb file, which
+ may make our lives easier in the near future.
+ check_*: use $xst_prefix to check platform too.
+
+ * network.pl.in (xst_network_suse70_active_interfaces_get):
+ Don't list "lo" as an active interface.
+ (xst_network_suse70_ifaces_get_existing): Better code:
+ finds all NETDEV vars in rc.config and takes values from there.
+ (xst_network_suse70_parse_iface_num): Braking the 4
+ interface barrier here too. SuSE 7.0 scripts are broken, still.
+ (xst_network_suse70_set_ifconfig_arg): Beautified output.
+ (xst_network_suse70_get_file): Completly missed implemening
+ this one. New interfaces weren't getting a NETDEV number.
+ (xst_network_get_file): "suse-7.0" entry added.
+ (xst_network_suse70_interface_delete): Was calling activate
+ _by_dev with wrong value for $dev.
+ (xst_network_suse70_interface_delete): Oops. Use "_" between
+ var type and $dev.
+ (xst_network_ensure_loopback_interface): Those distros that
+ map to "" are not "ensured".
+ (xst_network_get_interfaces_parse_table): Changed from XST_NAME
+ to XST_IFACE_NAME, which is more verbose.
+ (xst_network_get_interface_replace_table): same.
+
+ * debug.pl.in (xst_debug_print_log_to_file): Seems like
+ print can't handle strings larger than 4096 bytes. This
+ routine is for printing large strings that may contain
+ \n's inside (like in.xml).
2001-05-18 Arturo Espinosa Aldama <arturo@ximian.com>
diff --git a/debug.pl.in b/debug.pl.in
index 4a74a7c..a278fe1 100644
--- a/debug.pl.in
+++ b/debug.pl.in
@@ -53,6 +53,20 @@ sub xst_debug_print_string_to_file
print $debug_file $_[1];
}
+sub xst_debug_print_log_to_file
+{
+ my ($file, $doc) = @_;
+ my (@buff, $line, $fd);
+
+ $fd = &xst_debug_open_output_file ($file);
+
+ @buff = split ("\n", $doc);
+ foreach $line (@buff)
+ {
+ print $fd "$line\n";
+ }
+}
+
sub xst_debug_print_string
{
diff --git a/network.pl.in b/network.pl.in
index 6e46ebd..a4f36cc 100644
--- a/network.pl.in
+++ b/network.pl.in
@@ -126,8 +126,11 @@ sub xst_network_suse70_active_interfaces_get
foreach $dev (@devs)
{
- $num = &xst_network_suse70_parse_iface_num ("$xst_prefix/etc/rc.config", $dev);
- push @ret, $num if $num != -1;
+ if ($dev ne "lo")
+ {
+ $num = &xst_network_suse70_parse_iface_num ("$xst_prefix/etc/rc.config", $dev);
+ push @ret, $num if $num != -1;
+ }
}
return @ret;
@@ -194,14 +197,20 @@ sub xst_network_debian_ifaces_get_existing
sub xst_network_suse70_ifaces_get_existing
{
my $file = "$xst_prefix/etc/rc.config";
- my ($i, @ret);
+ my ($i, $dev, @ret, $fd);
- # Ugh, sucks, but this is the SuSE 7.0 way...
- for ($i = 0; $i < 4; $i++)
+ $fd = &xst_file_open_read_from_names ($file);
+ return @ret if !$fd;
+
+ while ($i = <$fd>)
{
- push @ret, "$i" if (&xst_parse_sh ($file, "NETDEV_$i") ne "");
+ if ($i =~ /^[ \t]*NETDEV_([0-9]+)=/)
+ {
+ push @ret, $1 if &xst_parse_sh ($file, "NETDEV_$1") ne "";
+ }
}
+ close $fd;
return @ret;
}
@@ -210,13 +219,13 @@ sub xst_network_suse70_parse_iface_num
my ($file, $dev) = @_;
my ($i, $ret);
- for ($i = 0; $i < 4; $i++)
+ foreach $i (&xst_network_suse70_ifaces_get_existing ())
{
$ret = &xst_parse_sh ($file, "NETDEV_$i");
return $i if $ret eq $dev;
}
- &xst_debug_print_string ("\n\nWarning! xst_network_suse70_parse_iface_num: num for $dev not found.\n\n");
+ &xst_debug_print_string ("\n\nWarning: xst_network_suse70_parse_iface_num: num for $dev not found.\n\n");
return -1;
}
@@ -292,7 +301,8 @@ sub xst_network_suse70_set_ifconfig_arg
if (! ($val =~ s/([ \t]+$key[ \t]+)[^ \t]+/\1$value/))
{
$val =~ s/[ \t]+up$//;
- $val .= "$value up";
+ $val .= " " if $val =~ /[^ \t]$/;
+ $val .= "$key $value up";
}
return &xst_network_suse70_replace_iface_sh ($file, $iface, "IFCONFIG", $val);
@@ -309,6 +319,7 @@ sub xst_network_suse70_set_ifconfig_ip
if (! ($val =~ s/^[0-9\.]+([ \t])/$value\1/))
{
$val = "$value $val";
+ $val =~ s/[ \t]+/ /;
}
return &xst_network_suse70_replace_iface_sh ($file, $iface, "IFCONFIG", $val);
@@ -356,13 +367,6 @@ sub xst_network_conf_get
return $hash;
}
-sub xst_network_deb22_get_file
-{
- my $dev = $_[0];
-
- return $dev;
-}
-
sub xst_network_rh62_get_file
{
my $dev = $_[0];
@@ -381,6 +385,24 @@ sub xst_network_rh62_get_file
return "$dev$i";
}
+sub xst_network_deb22_get_file
+{
+ my $dev = $_[0];
+
+ return $dev;
+}
+
+sub xst_network_suse70_get_file
+{
+ my $file = "$xst_prefix/etc/rc.config";
+ my ($i);
+
+ $i = 0;
+ $i ++ while (&xst_parse_sh ($file, "NETDEV_$i") ne "");
+
+ return $i;
+}
+
sub xst_network_get_file
{
my $dev = $_[0];
@@ -394,7 +416,8 @@ sub xst_network_get_file
"redhat-7.0" => \&xst_network_rh62_get_file,
"mandrake-7.2" => \&xst_network_rh62_get_file,
"debian-2.2" => \&xst_network_deb22_get_file,
- "debian-woody" => \&xst_network_deb22_get_file
+ "debian-woody" => \&xst_network_deb22_get_file,
+ "suse-7.0" => \&xst_network_suse70_get_file
);
$proc = $dist_map{$xst_dist};
@@ -402,6 +425,7 @@ sub xst_network_get_file
return &$proc ($dev) if $proc;
# FIXME: should make us bail.
+ &xst_debug_print_string ("\n\nWarning: No network_get_file proc for dist $xst_dist.\n\n");
return undef;
}
@@ -464,6 +488,7 @@ sub xst_network_dialing_set
return $ret;
}
+# This works for all systems that have ifup/ifdown scripts.
sub xst_network_rh62_interface_activate_by_dev
{
my ($dev, $enabled) = @_;
@@ -604,6 +629,7 @@ sub xst_network_deb22_interface_delete
my ($old_hash) = @_;
my $dev = $$old_hash{"dev"};
+ &xst_network_rh62_interface_activate_by_dev ($dev, 0);
&xst_replace_interfaces_iface_stanza_delete ("$xst_prefix/etc/network/interfaces", $dev);
$login = $old_hash{"login"};
@@ -621,7 +647,7 @@ sub xst_network_suse70_interface_delete
my $file = "$xst_prefix/etc/rc.config";
my $login;
- &xst_network_suse70_interface_activate_by_dev ($dev, 0);
+ &xst_network_suse70_interface_activate_by_dev ($$old_hash{"dev"}, 0);
# Commented until I know what to do with ppp connections.
# $login = $old_hash{"login"};
@@ -631,9 +657,9 @@ sub xst_network_suse70_interface_delete
# &xst_network_remove_pap_entry ("/etc/ppp/chap-secrets", $login);
# }
- &xst_replace_sh ($file, "IPADDR$dev", "");
- &xst_replace_sh ($file, "NETDEV$dev", "");
- &xst_replace_sh ($file, "IFCONFIG$dev", "");
+ &xst_replace_sh ($file, "IPADDR_$dev", "");
+ &xst_replace_sh ($file, "NETDEV_$dev", "");
+ &xst_replace_sh ($file, "IFCONFIG_$dev", "");
}
sub xst_network_interfaces_down_changed
@@ -1098,23 +1124,29 @@ sub xst_network_debian_woody_set_auto
return &xst_file_buffer_save ($buff, $file);
}
+# Set dist_map for your distro to "" if you don't want
+# loopback ensuring. See suse-7.0 entry for example.
sub xst_network_ensure_loopback_interface
{
my ($interface) = @_;
my $dev;
my %dist_map =
(
+ "redhat-5.2" => "lo",
"redhat-6.0" => "lo",
"redhat-6.1" => "lo",
"redhat-6.2" => "lo",
"redhat-7.0" => "lo",
"mandrake-7.2" => "lo",
"debian-2.2" => "lo",
- "debian-woody" => "lo"
+ "debian-woody" => "lo",
+ "suse-7.0" => ""
);
$dev = $dist_map {$xst_dist};
+ return if $dev eq "";
+
if (!exists $$interface{$dev})
{
my %iface = (
@@ -1524,7 +1556,7 @@ sub xst_network_get_interfaces_parse_table
[ "bootproto", \&xst_network_suse70_parse_bootproto, [IFCFG, IFACE] ],
[ "auto", \&xst_network_suse70_parse_iface_auto, [IFCFG, IFACE], NETCONFIG ],
[ "user", \&xst_parse_trivial, 0 ], # not supported.
- [ "name", \&xst_network_suse70_parse_iface_sh, [IFCFG, IFACE], XST_NAME ],
+ [ "name", \&xst_network_suse70_parse_iface_sh, [IFCFG, IFACE], XST_IFACE_NAME ],
[ "dev", \&xst_network_suse70_parse_iface_sh, [IFCFG, IFACE], NETDEV ],
[ "address", \&xst_network_suse70_parse_iface_sh, [IFCFG, IFACE], IPADDR ],
[ "netmask", \&xst_network_suse70_get_ifconfig_arg, [IFCFG, IFACE], netmask ],
@@ -1878,7 +1910,7 @@ sub xst_network_get_interface_replace_table
[ "auto", \&xst_network_suse70_replace_iface_auto, [IFCFG, IFACE], NETCONFIG ],
[ "dev", \&xst_network_suse70_replace_iface_sh, [IFCFG, IFACE], NETDEV ],
# not sup [ "user", \&xst_parse_trivial, 0 ], # not supported.
- [ "name", \&xst_network_suse70_replace_iface_sh, [IFCFG, IFACE], XST_NAME ],
+ [ "name", \&xst_network_suse70_replace_iface_sh, [IFCFG, IFACE], XST_IFACE_NAME ],
[ "address", \&xst_network_suse70_replace_iface_sh, [IFCFG, IFACE], IPADDR ],
[ "address", \&xst_network_suse70_set_ifconfig_ip, [IFCFG, IFACE] ],
[ "netmask", \&xst_network_suse70_set_ifconfig_arg, [IFCFG, IFACE], netmask ],
diff --git a/platform.pl.in b/platform.pl.in
index a9955f5..09ccb7d 100644
--- a/platform.pl.in
+++ b/platform.pl.in
@@ -26,11 +26,26 @@
# --- System guessing --- #
+require "___scriptsdir___/parse.pl";
+
+
+sub check_lsb
+{
+ my ($ver, $dist);
+
+ # xst_prefix not required here: parse already does that for us.
+ $dist = lc (&xst_parse_sh ("/etc/lsb-release", "DISTRIB_ID"));
+ $ver = lc (&xst_parse_sh ("/etc/lsb-release", "DISTRIB_RELEASE"));
+
+ return -1 if ($dist eq "") || ($ver eq "");
+ return "$dist-$ver";
+}
+
sub check_debian
{
my $ver;
- open DEBIAN, "/etc/debian_version" or return -1;
+ open DEBIAN, "$xst_prefix/etc/debian_version" or return -1;
chomp ($ver = <DEBIAN>);
close DEBIAN;
return "debian-$ver";
@@ -39,7 +54,7 @@ sub check_debian
sub check_redhat
{
- open RELEASE, "/etc/redhat-release" or return -1;
+ open RELEASE, "$xst_prefix/etc/redhat-release" or return -1;
while (<RELEASE>)
{
chomp;
@@ -56,7 +71,7 @@ sub check_redhat
sub check_caldera
{
- open INSTALLED, "/etc/.installed" or return -1;
+ open INSTALLED, "$xst_prefix/etc/.installed" or return -1;
while (<INSTALLED>)
{
chomp;
@@ -73,7 +88,7 @@ sub check_caldera
sub check_suse
{
- open RELEASE, "/etc/SuSE-release" or return -1;
+ open RELEASE, "$xst_prefix/etc/SuSE-release" or return -1;
while (<RELEASE>)
{
chomp;
@@ -90,7 +105,7 @@ sub check_suse
sub check_mandrake
{
- open MANDRAKE, "/etc/mandrake-release" or return -1;
+ open MANDRAKE, "$xst_prefix/etc/mandrake-release" or return -1;
while (<MANDRAKE>)
{
chomp;
@@ -107,7 +122,7 @@ sub check_mandrake
sub check_turbolinux
{
- open RELEASE, "/etc/turbolinux-release" or return -1;
+ open RELEASE, "$xst_prefix/etc/turbolinux-release" or return -1;
while (<RELEASE>)
{
chomp;
@@ -124,7 +139,7 @@ sub check_turbolinux
sub check_linuxppc
{
- open RELEASE, "/etc/redhat-release" or return -1;
+ open RELEASE, "$xst_prefix/etc/redhat-release" or return -1;
while (<RELEASE>)
{
chomp;
@@ -173,8 +188,8 @@ sub xst_platform_guess
if ($xst_system =~ /linux/)
{
# Red Hat check must run after Mandrake
- my @checks = (\&check_debian, \&check_caldera, \&check_suse, \&check_mandrake,
- \&check_linuxppc, \&check_redhat, \&check_turbolinux);
+ my @checks = (\&check_lsb, \&check_debian, \&check_caldera, \&check_suse,
+ \&check_mandrake, \&check_linuxppc, \&check_redhat, \&check_turbolinux);
my ($check, $dist);
foreach $check (@checks)
diff --git a/replace.pl.in b/replace.pl.in
index 1e4d4aa..4eaf673 100644
--- a/replace.pl.in
+++ b/replace.pl.in
@@ -196,7 +196,17 @@ sub xst_replace_sh
&xst_report_enter ();
&xst_report ("replace_sh", $key, $file);
- $ret = &xst_replace_split ($file, $key, "[ \t]*=[ \t]*", $value);
+
+ # This will expunge the whole var if the value is empty.
+ if ($value eq "")
+ {
+ $ret = &xst_replace_split ($file, $key, "[ \t]*=[ \t]*");
+ }
+ else
+ {
+ $ret = &xst_replace_split ($file, $key, "[ \t]*=[ \t]*", $value);
+ }
+
&xst_report_leave ();
return $ret;
}
@@ -233,6 +243,14 @@ sub xst_replace_sh_set_domain
return &xst_replace_sh ($file, $key, "$hostname.$value");
}
+sub xst_replace_sh_join
+{
+ my ($file, $key, $re, $value) = @_;
+
+ return &xst_replace_sh ($file, $key,
+ join (&xst_replace_regexp_to_separator ($re), @$value));
+}
+
# Quick trick to set a keyword $key in $file.
sub xst_replace_kw
{
diff --git a/users-conf.in b/users-conf.in
index bb3a036..b0f1faa 100644
--- a/users-conf.in
+++ b/users-conf.in
@@ -538,10 +538,10 @@ sub change_user
$command = "$cmd_usermod -c \'" . $$new_data[$users_prop_map{"comment"}] .
"\' -d \'" . $$new_data[$users_prop_map{"home"}] .
"\' -g \'" . $$new_data[$users_prop_map{"gid"}] .
- "\' -s \'" . $$new_data[$users_prop_map{"shell"}] .
+ "\' -l \'" . $$new_data[$users_prop_map{"login"}] .
"\' -p \'" . $$new_data[$users_prop_map{"password"}] .
+ "\' -s \'" . $$new_data[$users_prop_map{"shell"}] .
"\' -u \'" . $$new_data[$users_prop_map{"uid"}] .
- "\' -l \'" . $$new_data[$users_prop_map{"login"}] .
"\' \'" . $$old_data[$users_prop_map{"login"}] . "\'";
&my_system ($command);
}
diff --git a/xml.pl.in b/xml.pl.in
index ff2cb61..83312a4 100644
--- a/xml.pl.in
+++ b/xml.pl.in
@@ -342,7 +342,7 @@ sub xst_xml_scan # (file) If no file specified, reads stdin.
close INPUT_FILE;
}
- &xst_debug_print_string_to_file ("in.xml", $doc);
+ &xst_debug_print_log_to_file ("in.xml", $doc);
&xst_archive_data ($doc);
@xst_xml_scan_list = ($doc =~ /([^\<]*)(\<[^\>]*\>)[ \t\n\r]*/mg); # pcdata, tag, pcdata, tag, ...