Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2178734 - sudo should not be needed when migrating the pulp database script migrate.rb
Summary: sudo should not be needed when migrating the pulp database script migrate.rb
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Satellite Maintain
Version: 6.10.7
Hardware: x86_64
OS: Linux
high
high
Target Milestone: 6.14.0
Assignee: Sayan Das
QA Contact: Jameer Pathan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-03-15 17:23 UTC by Ganesh Payelkar
Modified: 2024-03-22 04:25 UTC (History)
7 users (show)

Fixed In Version: foreman-maintain-1.3.2
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-08 14:18:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 36365 0 Normal Closed Drop the usage of sudo during any pulpcore-manager command executions 2023-07-03 12:51:33 UTC
Github theforeman foreman_maintain pull 727 0 None open Fixes #36365 - Drop usage of sudo for any pulpcore-manager commands 2023-05-05 19:25:21 UTC
Red Hat Issue Tracker SAT-17608 0 None None None 2023-05-08 17:50:05 UTC
Red Hat Knowledge Base (Solution) 7002971 0 None None None 2023-05-05 15:53:45 UTC
Red Hat Product Errata RHSA-2023:6818 0 None None None 2023-11-08 14:19:10 UTC

Description Ganesh Payelkar 2023-03-15 17:23:18 UTC
Description of problem:

[RFE] Remove sudo from migrating the pulp database script migrate.rb

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

How reproducible:
Remove the sudo access of the "root"

Steps to Reproduce:
1. setup satellite 
2. remove the root from /etc/sudoers or restrict the "root" 
3.

# cat /etc/sudoers|grep -i root
#root	ALL=(ALL) 	ALL

or 

# cat /etc/sudoers|grep -i root
Defaults    !root_sudo


Actual results:

E, [2023-03-10 03:48:22+0000 #49723] ERROR -- : Failed executing sudo PULP_SETTINGS=/etc/pulp/settings.py DJANGO_SETTINGS_MODULE=pulpcore.app.settings python3-django-admin migrate --noinput, exit status 1:
 sudo: sudoers specifies that root is not allowed to sudo (ForemanMaintain::Error::ExecutionError)


# cat /usr/share/gems/gems/foreman_maintain-0.8.31/definitions/procedures/pulpcore/migrate.rb
module Procedures::Pulpcore
  class Migrate < ForemanMaintain::Procedure
    include ForemanMaintain::Concerns::SystemService
 
    metadata do
      description 'Migrate pulpcore db'
      for_feature :pulpcore
    end
 
    def run
      with_spinner('Migrating pulpcore') do |spinner|
        necessary_services = feature(:pulpcore_database).services
        pulp_services = feature(:pulpcore).services
 
        feature(:service).handle_services(spinner, 'start', :only => necessary_services)
        feature(:service).handle_services(spinner, 'stop', :only => pulp_services)
 
        spinner.update('Migrating pulpcore database')
        execute!('sudo PULP_SETTINGS=/etc/pulp/settings.py '\   <-- sudo requires
          'DJANGO_SETTINGS_MODULE=pulpcore.app.settings '\
          'python3-django-admin migrate --noinput')
      end
    end
  end
end


6.10: 

]# sudo PULP_SETTINGS=/etc/pulp/settings.py DJANGO_SETTINGS_MODULE=pulpcore.app.settings python3-django-admin migrate --noinput
root is not in the sudoers file.  This incident will be reported.

6.11 : 

# sudo PULP_SETTINGS=/etc/pulp/settings.py DJANGO_SETTINGS_MODULE=pulpcore.app.settings pulpcore-manager migrate --noinput
root is not in the sudoers file.  This incident will be reported.

6.12 : 

# sudo PULP_SETTINGS=/etc/pulp/settings.py DJANGO_SETTINGS_MODULE=pulpcore.app.settings pulpcore-manager migrate --noinput
sudo: sudoers specifies that root is not allowed to sudo


Expected results:

If satellite-maintain is being executed as the root user, it ought to function without needing sudo privileges.

Additional info: 



Running Procedures after migrating to Satellite 6.12.z
================================================================================
Refresh detected features:                                            [OK]
--------------------------------------------------------------------------------
Start applicable services: 

Starting the following service(s):
redis, postgresql, pulpcore-api, pulpcore-content, qdrouterd, qpidd, pulpcore-worker, pulpcore-worker, tomcat, dynflow-sidekiq@orchestrator, foreman, httpd, puppetserver, dynflow-sidekiq@worker-1, dynflow-sidekiq@worker-hosts-queue-1, foreman-proxy, foreman-cockpit
| All services started                                                [OK]      
--------------------------------------------------------------------------------
Trim RPM changelogs in the pulpcore db: 
| Trimming RPM changelogs                                             [FAIL]    
Failed executing sudo PULP_SETTINGS=/etc/pulp/settings.py DJANGO_SETTINGS_MODULE=pulpcore.app.settings pulpcore-manager rpm-trim-changelogs, exit status 1:
 sudo: sudoers specifies that root is not allowed to sudo
--------------------------------------------------------------------------------
Scenario [Procedures after migrating to Satellite 6.12.z] failed.

The following steps ended up in failing state:

  [pulpcore-trim-rpm-changelogs]

Resolve the failed steps and rerun the command.

If the situation persists and, you are unclear what to do next,
contact Red Hat Technical Support.

In case the failures are false positives, use
--whitelist="pulpcore-trim-rpm-changelogs"

Comment 2 Sayan Das 2023-04-09 01:11:29 UTC
The request remains the same for the trim-changelogs action in the post-upgrade 


Failed executing sudo PULP_SETTINGS=/etc/pulp/settings.py DJANGO_SETTINGS_MODULE=pulpcore.app.settings pulpcore-manager rpm-trim-changelogs, exit status 1:
Sorry, user root is not allowed to execute '/usr/bin/pulpcore-manager rpm-trim-changelogs' as root on satellite.example.com


The only way to get past it would be:

* Complete the upgrade using  --whitelist="pulpcore-trim-rpm-changelogs" 

* Run the command in one of the following ways:

# sudo -u pulp PULP_SETTINGS='/etc/pulp/settings.py' /usr/bin/pulpcore-manager rpm-trim-changelogs

or

# PULP_SETTINGS='/etc/pulp/settings.py' /usr/bin/pulpcore-manager rpm-trim-changelogs


I don't know why we call the commands with sudo here but without specifying any users, But it should be fixed

Comment 5 Sayan Das 2023-05-05 19:25:21 UTC
Created 

Bug #36365: Drop the usage of sudo during any pulpcore-manager command executions - Foreman Maintain - Foreman
https://projects.theforeman.org/issues/36365

Fixes #36365 - Drop usage of sudo for any pulpcore-manager commands by sayan3296 · Pull Request #727 · theforeman/foreman_maintain
https://github.com/theforeman/foreman_maintain/pull/727

Comment 6 Bryan Kearney 2023-05-08 16:04:29 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/36365 has been resolved.

Comment 7 Patrick Creech 2023-05-30 18:18:14 UTC
need this fix released in an upstream version of foreman_maintain

Comment 8 Jameer Pathan 2023-08-10 08:53:38 UTC
Verified

Verified with:
- Satellite 6.14.0 snap 10
- rubygem-foreman_maintain-1.3.3-1.el8sat.noarch

Test steps:
- Remove the root from /etc/sudoers
- Perform Satellite upgrade


observations:
- No error, upgrade completed successfully.

Comment 11 errata-xmlrpc 2023-11-08 14:18:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.14 security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6818

Comment 12 Red Hat Bugzilla 2024-03-22 04:25:03 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days


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