web/modules/rhn/RHN/DB.pm | 13 -
web/modules/rhn/RHN/SatInstall.pm | 336 -------------------------------------
web/modules/rhn/RHN/ServerGroup.pm | 8
3 files changed, 357 deletions(-)
New commits:
commit 665c076856959c6e7ee2024c3a9aa437e0bdd35e
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 21:10:27 2010 +0100
lookup_server_group is not used anywhere, removing.
diff --git a/web/modules/rhn/RHN/ServerGroup.pm b/web/modules/rhn/RHN/ServerGroup.pm
index efcf4b7..01baf09 100644
--- a/web/modules/rhn/RHN/ServerGroup.pm
+++ b/web/modules/rhn/RHN/ServerGroup.pm
@@ -43,12 +43,4 @@ sub lookup {
}
}
-sub lookup_server_group {
- my $class = shift;
-
- warn "deprecated use of $class->lookup_foo from (" . join(', ',
caller) . "). Using $class->lookup instead\n";
-
- return $class->lookup(@_);
-}
-
1;
commit 7b926862f9c75f5e64da5a76ab5c4a9ab5b11ac2
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 21:05:52 2010 +0100
Removal of restart_satellite made prepare_for_fork unused, removing.
diff --git a/web/modules/rhn/RHN/DB.pm b/web/modules/rhn/RHN/DB.pm
index cdddc90..af7c0e5 100644
--- a/web/modules/rhn/RHN/DB.pm
+++ b/web/modules/rhn/RHN/DB.pm
@@ -89,19 +89,6 @@ sub apache_child_init_handler {
}
}
-# DBD::Oracle handles don't survive forks well if you don't
-# immediately exec or somesuch. so this is what we call when we know
-# we're going to fork
-
-sub prepare_for_fork {
- my $class = shift;
-
- for my $handle (grep { defined $_ } values %handles) {
- $handle->force_disconnect;
- }
- %handles = ();
-}
-
# called after every request. necessary to cleanup uncommitted
# transactions and such
commit 4db7b05802434e8ab61876ebfa8907b69191ed52
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 21:04:51 2010 +0100
Removal of Sniglets::MonitoringConfig made restart_satellite unused, removing.
diff --git a/web/modules/rhn/RHN/SatInstall.pm b/web/modules/rhn/RHN/SatInstall.pm
index cffe405..2d14241 100644
--- a/web/modules/rhn/RHN/SatInstall.pm
+++ b/web/modules/rhn/RHN/SatInstall.pm
@@ -128,29 +128,6 @@ sub generate_server_cert {
return $ret;
}
-sub restart_satellite {
- my $class = shift;
- my %params = validate(@_, { delay => 1,
- service => { default => 'rhn-satellite' },
- });
-
- RHN::DB->prepare_for_fork();
- # we fork here. the original process returns and sends content to
- # the client so the page renders. the child will quickly terminate...
- return if fork;
-
- # sleep to let the parent process cleanup
- sleep $params{delay};
- # when apache restarts, it sends a kill to its entire process group.
- # for us, though, that would include the restart script. oops.
- POSIX::setsid();
-
- exec('/usr/bin/sudo', '/usr/sbin/rhn-satellite', 'restart')
- or throw "(exec_error) Could not exec '/usr/sbin/rhn-satellite restart':
$!";
-
- # exec does not return
-}
-
sub enable_notification_cron {
my $class = shift;
commit f2e7c180146506fc6048cbe5cdebaaef4a9033a0
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 21:03:19 2010 +0100
Removing some more functions from RHN::SatInstall, that are duplicated in
spacewalk-setup now:
is_embedded_db
local_sat_cert_checks
generate_ca_cert
is_rpm_installed
default_cert_expiration
diff --git a/web/modules/rhn/RHN/SatInstall.pm b/web/modules/rhn/RHN/SatInstall.pm
index beacb8e..cffe405 100644
--- a/web/modules/rhn/RHN/SatInstall.pm
+++ b/web/modules/rhn/RHN/SatInstall.pm
@@ -85,93 +85,10 @@ sub write_config {
return;
}
-sub is_embedded_db {
- my $class = shift;
-
- return $class->is_rpm_installed('oracle-server-admin');
-}
-
sub generate_secret {
return md5_hex(PXT::Utils->random_bits(4096));
}
-sub local_sat_cert_checks {
- my $filename = shift;
- my $check_monitoring = shift;
-
- open(CERT, $filename) or throw "(satellite_activation_failed) File upload error:
$OS_ERROR";
- my @data = <CERT>;
- close(CERT);
-
- my $cert_str = join('', @data);
- my ($signature, $cert);
-
- eval {
- ($signature, $cert) = RHN::SatelliteCert->parse_cert($cert_str);
- };
- if ($@) {
- throw "(parse_error) Error parsing satellite cert: $@";
- }
-
- my $sat_version = PXT::Config->get('version');
- my $cert_version = $cert->get_field('satellite-version');
-
- #The cert version should be less specific than the sat version.
- my $match_length = length($cert_version);
- $sat_version = substr($sat_version, 0, $match_length);
- unless ($sat_version eq $cert_version) {
- throw "(satellite_activation_failed) The version of the supplied cert
($cert_version)"
- . " did not match the version of this satellite ($sat_version)";
- }
-
- my $mon_slots = $cert->get_field('monitoring-slots');
-
- if ($check_monitoring and not $mon_slots) {
- throw "(no_monitoring_entitlements) You have provided a certificate that does
not contain monitoring entitlements.";
- }
-
- return;
-}
-
-my %ca_cert_opts = (
- dir => 1,
- password => 1,
- 'set-country' => 1,
- 'set-state' => 1,
- 'set-city' => 1,
- 'set-org' => 1,
- 'set-org-unit' => 1,
- 'set-common-name' => 0,
- 'cert-expiration' => 1, # In years
-);
-
-my @unquoted_cert_opts = qw/cert-expiration set-country dir set-hostname/;
-
-sub generate_ca_cert {
- my $class = shift;
- my %params = validate(@_, {
- %ca_cert_opts,
- 'server-rpm' => 1,
- });
-
- $params{'cert-expiration'} *= 365;
-
- my @opts = "--gen-ca";
-
- foreach my $name (keys %params) {
- next unless ($params{$name}
- and exists $ca_cert_opts{$name});
-
- push @opts, qq(--$name=$params{$name});
- }
-
- my @command = ('/usr/bin/rhn-sudo-ssl-tool', @opts);
-
- my $ret = system(@command);
-
- return $ret;
-}
-
my %server_cert_opts = (
dir => 1,
password => 1,
@@ -234,30 +151,6 @@ sub restart_satellite {
# exec does not return
}
-sub is_rpm_installed {
- my $class = shift;
- my $rpmname = shift;
-
- throw "(satinstall:missing_param) No rpm name param" unless $rpmname;
-
- # If the return code from rpm -q <rpmname> is nonzero, then the RPM was not
found.
- my $ret = system('rpm', '-q', $rpmname);
-
- if ($ret) {
- return 0;
- }
-
- return 1;
-}
-
-sub default_cert_expiration {
- my $dt = DateTime->now;
- my $dt2 = new DateTime (year => 2038, month => 1, day => 18);
- my $diff = $dt2 - $dt;
-
- return $diff->years - 1;
-}
-
sub enable_notification_cron {
my $class = shift;
commit 613967992050ccaa2064294fda023801d28388e3
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Tue Jan 5 20:57:38 2010 +0100
Removing bunch of unused functions from RHN::SatInstall:
config_up2date
db_population_in_progress
build_proxy_url
build_rhn_url
check_valid_ssl_cert_password
generate_bootstrap_scripts
write_satellite_cert
get_db_population_log_stats
setup_monitoring_sysv_step
get_db_population_errors
diff --git a/web/modules/rhn/RHN/SatInstall.pm b/web/modules/rhn/RHN/SatInstall.pm
index 67539cc..beacb8e 100644
--- a/web/modules/rhn/RHN/SatInstall.pm
+++ b/web/modules/rhn/RHN/SatInstall.pm
@@ -85,76 +85,12 @@ sub write_config {
return;
}
-sub config_up2date {
- my $class = shift;
- my %params = validate(@_, { http_proxy => 0,
- http_proxy_username => 0,
- http_proxy_password => 0,
- });
-
- my $up2date_opts = { enableProxy => ($params{http_proxy} ? '1' :
'0'),
- httpProxy => $params{http_proxy},
- enableProxyAuth => ($params{http_proxy_username} ? '1' :
'0'),
- proxyUser => $params{http_proxy_username},
- proxyPassword => $params{http_proxy_password},
- };
-
- $class->write_config($up2date_opts, '/etc/sysconfig/rhn/up2date');
-
- # swallow the exception - the only good reason for this to fail if
- # the previous command succeeded is that we are running an up2date
- # client that doesn't have seperate configs for rhn_regsiter.
- eval {
- $class->write_config($up2date_opts, '/etc/sysconfig/rhn/rhn_register');
- };
-
- return;
-}
-
sub is_embedded_db {
my $class = shift;
return $class->is_rpm_installed('oracle-server-admin');
}
-sub db_population_in_progress {
- my $class = shift;
-
- return (-e '/var/lock/subsys/rhn-satellite-db-population' ? 1 : 0);
-}
-
-sub build_proxy_url {
- my ($url, $user, $pass) = @_;
-
- return unless $url;
-
- $url =~ m|^((https?)://)?(.*)|;
- my $proto = $2 || 'http';
- my $rest = $3;
-
- throw "Could not parse url '$url'\n"
- unless $rest;
-
- my $ret;
-
- if ($user) {
- $ret = sprintf('%s://%s:%s@%s', $proto, $user, $pass, $rest);
- }
- else {
- $ret = sprintf('%s//%s', $proto, $rest);
- }
-
- return $ret;
-}
-
-sub build_rhn_url {
- my ($host, $ssl) = @_;
-
- my $proto = $ssl ? 'https' : 'http';
-
- return sprintf('%s://%s/XMLRPC', $proto, $host);
-}
-
sub generate_secret {
return md5_hex(PXT::Utils->random_bits(4096));
}
@@ -197,19 +133,6 @@ sub local_sat_cert_checks {
return;
}
-sub check_valid_ssl_cert_password {
- my $class = shift;
- my $password = shift;
-
- my $ret;
-
- if ($password =~ /([\t\r\n\f\013&+%\'\`\\\"=\#)])/) {
- $ret = $1;
- }
-
- return $ret;
-}
-
my %ca_cert_opts = (
dir => 1,
password => 1,
@@ -288,97 +211,6 @@ sub generate_server_cert {
return $ret;
}
-my $valid_bootstrap_params = {
- hostname => 1,
- "ssl-cert" => 1,
- "http-proxy" => 0,
- "http-proxy-username" => 0,
- "http-proxy-password" => 0,
- "no-ssl" => 0,
- "no-gpg" => 0,
- "allow-config-actions" => 0,
- "allow-remote-commands" => 0,
- overrides => 1,
- script => 1,
- };
-
-sub generate_bootstrap_scripts {
- my $class = shift;
- my %params = validate(@_, $valid_bootstrap_params);
-
- my @opts;
-
- foreach my $key (keys %{$valid_bootstrap_params}) {
- if (grep { $key eq $_ } qw/no-ssl no-gpg allow-config-actions allow-remote-commands/)
{
-
- push @opts, "--$key" if ($params{$key});
- next;
- }
-
- if (not $params{$key}) {
- next;
- }
-
- push @opts, sprintf('--%s=%s', $key, $params{$key});
- }
-
- my $ret = system('/usr/bin/sudo', '/usr/bin/rhn-bootstrap', @opts);
-
- my %retcodes = (
- 10 => 'A script with that name already exists',
- 11 => 'Invalid script name',
- 12 => 'Invalid arguments',
- 13 => 'Could not parse httpd proxy URL',
- 14 => 'Cannot find pub tree',
- 15 => 'The hostname was not valid',
- 16 => 'Could not find the CA certificate',
- 17 => 'Could not find GPG key',
- );
-
- if ($ret) {
- my $exit_value = $? >> 8;
- throw "(bootstrap_script_creation_failed) $retcodes{$exit_value}" if exists
$retcodes{$exit_value};
-
- throw "There was a problem generating the bootstrap scripts: $exit_value";
- }
-
- return;
-}
-
-sub write_satellite_cert {
- my $class = shift;
- my %params = validate(@_, {contents => 1});
-
- my $contents = $params{contents} || '';
- my $filename = "/tmp/satcert_${PID}";
-
- open(FH, ">$filename") or die "Could not open $filename for writing:
$OS_ERROR";
-
- print FH $contents;
-
- close(FH);
-
- return $filename;
-}
-
-sub get_db_population_log_stats {
- my $class = shift;
- my $file = shift || DEFAULT_DB_POP_LOG_FILE;
-
- my $ret = {};
- if (not (-r $file)) {
- $ret->{$_} = '' foreach (qw/file_size/);
- return $ret;
- }
-
- my @stats = stat $file;
-
- $ret->{file_size} = $stats[7];
- $ret->{percent_complete} = int(100 * $ret->{file_size} / DB_POP_LOG_SIZE);
-
- return $ret;
-}
-
sub restart_satellite {
my $class = shift;
my %params = validate(@_, { delay => 1,
@@ -402,44 +234,6 @@ sub restart_satellite {
# exec does not return
}
-my @valid_sysv_steps = qw/Monitoring MonitoringScout/;
-
-sub setup_monitoring_sysv_step {
- my $class = shift;
- my $step = shift;
- my $command = shift || 'install';
-
- throw "No step name given" unless $step;
- throw "Invalid step: '$step'"
- unless (grep { $step eq $_ } @valid_sysv_steps);
-
- my $ret = system('/usr/bin/sudo', '/etc/rc.d/np.d/step', $step,
$command);
-
- if ($ret) {
- throw "There was a problem starting the monitoring backend. "
- . 'See the webserver error log for details.';
- }
-
- return;
-}
-
-sub get_db_population_errors {
- my $class = shift;
- my %params = validate(@_, {log_file => 0});
-
- my $log_file = $params{log_file} || DEFAULT_DB_POP_LOG_FILE;
-
-
- open(ERRORS, qq(grep -P "^ORA|Errors for" $log_file |))
- or die "Could not grep $log_file: $OS_ERROR";
-
- my @errors = <ERRORS>;
-
- close(ERRORS);
-
- return @errors;
-}
-
sub is_rpm_installed {
my $class = shift;
my $rpmname = shift;