Bug 484699 - /usr/bin/rhn-populate-database.pl not needed in /etc/sudoers
/usr/bin/rhn-populate-database.pl not needed in /etc/sudoers
Status: CLOSED CURRENTRELEASE
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server (Show other bugs)
530
All Linux
low Severity medium
: ---
: ---
Assigned To: Jan Pazdziora
wes hayutin
:
Depends On:
Blocks: 457079
  Show dependency treegraph
 
Reported: 2009-02-09 11:07 EST by Jan Pazdziora
Modified: 2009-09-10 15:11 EDT (History)
1 user (show)

See Also:
Fixed In Version: sat530
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-10 15:11:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jan Pazdziora 2009-02-09 11:07:25 EST
Description of problem:

The default installation of Satellite 5.3.0 adds /usr/bin/rhn-populate-database.pl to alias INSTALL_RHN in /etc/sudoers.

I've grepped Spacewalk source and rhn-populate-database.pl appears to be called in two places -- in spacewalk/setup/lib/Spacewalk/Setup.pm, and in web/modules/rhn/RHN/SatInstall.pm. That Spacewalk::Setup is being used by root, so no sudo is needed (and called) there. That RHN::SatInstall calls

sub populate_database {
  my $class = shift;
  my %params = validate(@_, { user => 1,
                              password => 1,
                              sid => 1,
                              clear_db => 0,
                              nofork => 0,
                              log_file => 0,
                            });

  $params{log_file} ||= DEFAULT_DB_POP_LOG_FILE;

  my $tablespace_name = $class->get_default_tablespace_name($params{user});
  $class->populate_tablespace_name($tablespace_name);

  my $sat_schema_deploy =
    File::Spec->catfile(DEFAULT_RHN_ETC_DIR, 'universe.deploy.sql');

  my @extra_opts;
  if ($params{clear_db}) {
    push @extra_opts, '--clear-db';
  }

  if ($params{nofork}) {
    push @extra_opts, '--nofork';
  }

  if ($params{log_file}) {
    push @extra_opts, '--log=' . $params{log_file};
  }

  my $dsn = sprintf '%s/%s@%s', @{\%params}{qw/user password sid/};

  my @opts = ('/usr/bin/rhn-populate-database.pl',
                   "--dsn=$dsn", "--schema-deploy-file=$sat_schema_deploy",
                   @extra_opts);

  my $ret = system('/usr/bin/sudo', @opts);

  if ($ret) {
    my $exit_value = $? >> 8;
    if ($exit_value == 100) {
      throw "(satinstall:db_population_in_progress) Database population is already in progress";
    }

    throw "(satinstall:db_population_error) Error populating db: $exit_value";
  }

  return;
}

But the function populate_database not used in the whole Spacewalk codebase. Therefore I assume it is dead code which can be removed, and so can /usr/bin/rhn-populate-database.pl from /etc/sudoers.

Note: I did this scan through our code to figure out if there are some commands that need additional SELinux treatment.

Version-Release number of selected component (if applicable):

Satellite-5.3.0-RHEL5-re20090206.1

How reproducible:

Deterministic.

Steps to Reproduce:
1. Install Satellite 5.3.0.
2. Look into /etc/sudoers.
  
Actual results:

/usr/bin/rhn-populate-database.pl is there.

Expected results:

/usr/bin/rhn-populate-database.pl is not there and Satellite continues to work OK.

Additional info:

This bug was modeled based on bug 484681.
Comment 1 Jan Pazdziora 2009-02-10 07:25:22 EST
The proposed change is to remove the INSTALL_RHN section and merge whatever needs to be there to CONFIG_RHN. The proposed sudoers.rhn is below. I've tested that with this, the Satellite/Spacewalk works and runs external commands fine.

## RHN specifics ##
Cmnd_Alias CONFIG_RHN = /usr/sbin/rhn-sat-restart-silent,\
                        /usr/bin/rhn-config-satellite.pl,\
                        /usr/bin/rhn-satellite-activate,\
                        /usr/bin/rhn-bootstrap,\
                        /usr/bin/rhn-ssl-tool,\
                        /usr/bin/rhn-ssl-dbstore,\
                        /usr/bin/rhn-load-ssl-cert.pl,\
                        /etc/rc.d/np.d/step Monitoring install,\
                        /etc/rc.d/np.d/step MonitoringScout install,\
                        /etc/rc.d/np.d/step Monitoring uninstall,\
                        /etc/rc.d/np.d/step MonitoringScout uninstall,\
                        /sbin/service Monitoring restart,\
                        /sbin/service MonitoringScout restart,\
                        /sbin/service taskomatic restart

# The CONFIG_RHN commands are required for reconfiguration of a
# running RHN Satellite.  They should be enabled for proper operation
# of the RHN Satellite.
apache  ALL=(root)      NOPASSWD: CONFIG_RHN
tomcat  ALL=(root)      NOPASSWD: CONFIG_RHN

# These two directives allow tomcat and apache to invoke CONFIG_RHN
# commands via sudo even without a real tty
Defaults:tomcat !requiretty
Defaults:apache !requiretty
Comment 2 Clifford Perry 2009-02-10 12:01:49 EST
This is a throw back from the old Installer - where we had command line install laid down packages. The WebUI then went through configuration/installation of Satellite to get it running, with many many steps, unlike the new WebUI portion that just asks for Username/password to be created for Sat Admin account. 

Cliff.
Comment 3 Jan Pazdziora 2009-02-11 02:25:59 EST
Reassigning to myself as the bugzillas are not tracked against the SELinux feature.
Comment 4 Jan Pazdziora 2009-02-11 02:28:05 EST
The previous comment should have been "are *now*".
Comment 5 Jan Pazdziora 2009-02-17 05:20:16 EST
Committed to Spacewalk repo, e938f82170180712fdda06348af74705f5698411 and b1845f85ab592f4bfeb3fb42a64b9ca9eab3da85.
Comment 6 Jan Pazdziora 2009-02-24 07:30:52 EST
With compose Satellite-5.3.0-RHEL5-re20090220.1 available, moving ON_QA.
Comment 7 wes hayutin 2009-02-25 14:06:43 EST
[root@grandprix ~]# cat /etc/sudoers | grep  rhn-populate-database.pl
[root@grandprix ~]# 

 Satellite-5.3.0-RHEL5-re20090220.1-i386-embedded-oracle.iso
verified
Comment 8 Miroslav Suchý 2009-08-26 05:26:27 EDT
[root@xen5 ~]# grep rhn-populate-database.pl /etc/sudoers
[root@xen5 ~]#
satellite works fine

verified in stage on xen5
Comment 9 Brandon Perkins 2009-09-10 15:11:38 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1434.html

Note You need to log in before you can comment on or make changes to this bug.