Commit 285f1c9a authored by Ryan Jackson's avatar Ryan Jackson

Fixed some bugs with reading/writing config cache

parent dab1d636
......@@ -10,7 +10,7 @@
#
# Common routines and constants for the client bootime setup stuff.
#
package libnewsetup;
package libsetup;
use Exporter;
@ISA = "Exporter";
@EXPORT =
......@@ -40,7 +40,7 @@ use Exporter;
use English;
# The tmcc library.
use libnewtmcc;
use libtmcc;
#
# This is the VERSION. We send it through to tmcd so it knows what version
......@@ -49,13 +49,13 @@ use libnewtmcc;
# BE SURE TO BUMP THIS AS INCOMPATIBILE CHANGES TO TMCD ARE MADE!
#
sub TMCD_VERSION() { 29; };
libnewtmcc::configtmcc("version", TMCD_VERSION());
libtmcc::configtmcc("version", TMCD_VERSION());
# Control tmcc timeout.
sub libsetup_settimeout($) { libnewtmcc::configtmcc("timeout", $_[0]); };
sub libsetup_settimeout($) { libtmcc::configtmcc("timeout", $_[0]); };
# Refresh tmcc cache.
sub libsetup_refresh() { libnewtmcc::tmccgetconfig(); };
sub libsetup_refresh() { libtmcc::tmccgetconfig(); };
#
# For virtual (multiplexed nodes). If defined, tack onto tmcc command.
......@@ -75,7 +75,7 @@ sub libsetup_setvnodeid($)
}
$vnodeid = $vid;
libnewtmcc::configtmcc("subnode", $vnodeid);
libtmcc::configtmcc("subnode", $vnodeid);
}
sub libsetup_getvnodeid()
{
......@@ -289,7 +289,7 @@ sub CONTROL() { if (-e "$ETCDIR/isctrl") { return 1; } else { return 0; } }
#
# Same for a Windows (CygWinXP) node.
#
# XXX If you change this, look in libnewtmcc::tmccgetconfig() as well.
# XXX If you change this, look in libtmcc::tmccgetconfig() as well.
sub WINDOWS() { if (-e "$ETCDIR/iscygwin") { return 1; } else { return 0; } }
#
......@@ -1320,7 +1320,7 @@ sub bootsetup()
{
my $oldpid;
# Tell libnewtmcc to forget anything it knows.
# Tell libtmcc to forget anything it knows.
tmccclrconfig();
#
......@@ -1371,7 +1371,7 @@ sub bootsetup()
}
#
# Tell libnewtmcc to get the full config. Note that this must happen
# Tell libtmcc to get the full config. Note that this must happen
# AFTER initsfs() right above, since that changes what tmcd
# is going to tell us.
#
......@@ -1535,7 +1535,7 @@ sub vnodejailsetup($)
}
#
# Tell libnewtmcc to get the full config for the jail. At the moment
# Tell libtmcc to get the full config for the jail. At the moment
# we do not use SFS inside jails, so okay to do this now (usually
# have to call initsfs() first). The full config will be copied
# to the proper location inside the jail by mkjail.
......@@ -1556,7 +1556,7 @@ sub vnodejailsetup($)
#
sub plabsetup()
{
# Tell libnewtmcc to forget anything it knows.
# Tell libtmcc to forget anything it knows.
tmccclrconfig();
#
......@@ -1577,7 +1577,7 @@ sub plabsetup()
initsfs();
#
# Tell libnewtmcc to get the full config. Note that this must happen
# Tell libtmcc to get the full config. Note that this must happen
# AFTER initsfs() right above, since that changes what tmcd
# is going to tell us.
#
......
......@@ -11,7 +11,7 @@
#
# TODO: Proxy path in a jail.
#
package libnewtmcc;
package libtmcc;
use Exporter;
use Data::Dumper;
@ISA = "Exporter";
......@@ -407,11 +407,12 @@ sub runtmcc ($;$$%)
if (!defined($args)) {
$args = "";
}
my $string = "$TMCCBIN $options $cmd $args";
my $string = "$TMCCBIN -i $options $cmd $args";
if ($debug) {
print STDERR "$string\n";
}
#
# Special case. If the proxy option is given, exec and forget.
#
......@@ -439,22 +440,17 @@ sub runtmcc ($;$$%)
if ($cmd eq lc('bossinfo')) {
$xml =~ /^(\S+)\s+(\S+).*$/;
$config = { BOSSINFO => { BOSSNAME => $1, BOSSIP => $2 } };
}
else {
$config = parse_config($xml);
$xml = "<?xml version=\"1.0\"?>\n";
$xml .= "<tmcd>\n";
$xml .= "\t<bossinfo>\n";
$xml .= "\t\t<key name=\"bossname\">$1</key>\n";
$xml .= "\t\t<key name=\"bossip\">$2</key>\n";
$xml .= "\t</bossinfo>\n";
$xml .= "</tmcd>\n";
}
if (defined $results) {
if ($config && $cmd !~ /^fullconfig$/i) {
my $data = $$config{uc $cmd};
if ($data) {
%$results = %{$data};
}
}
elsif ($config) {
%$results = %$config;
}
$$results = $xml;
}
return 0;
}
......@@ -542,16 +538,15 @@ sub tmcc ($;$$%)
if ($xml) {
my $config = parse_config($xml);
if ($config && exists($$config{$tag})) {
if ($config && exists($$config{uc $tag})) {
#
# If we can get it, great! Otherwise go to tmcd.
#
%$results = %$config if (defined($results));
%$results = %{$$config{uc $tag}} if (defined($results));
return 0;
}
}
}
#
# If proxypath was not specified, check for a proxypath file,
# unless they explicilty specified not to use a proxy.
......@@ -571,7 +566,22 @@ sub tmcc ($;$$%)
die("Bad data in tmccproxy path: $ppath");
}
}
return(runtmcc($cmd, $args, $results, %opthash));
my $xml;
if (runtmcc($cmd, $args, \$xml, %opthash) < 0) {
return -1;
}
my $config_data = parse_config($xml);
if ($config_data && $cmd !~ /^fullconfig$/i) {
$config_data = $$config_data{uc $cmd};
}
if (defined $results && ref $config_data eq 'HASH') {
%$results = %$config_data;
}
return 0;
}
#
......@@ -678,7 +688,7 @@ sub tmccgetconfig()
my $ipodinfo;
# Hack to make sure ipodinfo is not world-readable
if ($xml =~ /^(.*)(<\s*ipodinfo[^>]*>.*<\s*\/ipodinfo\s*>)(.*)$/im) {
if ($xml =~ /^(.*)(<\s*ipodinfo[^>]*>.*<\s*\/ipodinfo\s*>)(.*)$/sim) {
$xml = $1 . $3;
$ipodinfo = $2;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment