Bug 1540937 - DBus method Unregister works even a wrong proxy is set in /etc/rhsm/rhsm.conf
Summary: DBus method Unregister works even a wrong proxy is set in /etc/rhsm/rhsm.conf
Keywords:
Status: CLOSED DUPLICATE of bug 1504588
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager
Version: 7.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: candlepin-bugs
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-01 11:08 UTC by Jan Stavel
Modified: 2018-02-08 15:25 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-08 15:25:10 UTC


Attachments (Terms of Use)
an auxilliary systemd service to let rhsm service log appear in systemd ecosystem (52 bytes, application/x-shellscript)
2018-02-06 10:14 UTC, Jan Stavel
no flags Details
an auxilliary systemd service to let rhsm service log appear in systemd ecosystem (146 bytes, text/plain)
2018-02-06 10:15 UTC, Jan Stavel
no flags Details

Description Jan Stavel 2018-02-01 11:08:27 UTC
Description of problem:

  Before a system is registered 
     and no proxy is used
  When I set a wrong proxy_hostname
    and I call dbus method Unregister
  Then the dbus should give me an error kind of 'Resolution of host failed'


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

  [root@jstavel-rhel7-server ~]# rpm -qa | egrep "subscription|rhsm|cockpit"
  cockpit-ws-154-3.el7.x86_64
  subscription-manager-plugin-container-1.21.1-1.git.45.a7566d6.el7.x86_64
  subscription-manager-migration-data-2.0.37-1.el7.noarch
  subscription-manager-rhsm-1.21.1-1.git.45.a7566d6.el7.x86_64
  cockpit-bridge-154-3.el7.x86_64
  
  subscription-manager-initial-setup-addon-1.21.1-1.git.45.a7566d6.el7.x86_64
  
  cockpit-154-3.el7.x86_64
  
  subscription-manager-gui-1.21.1-1.git.45.a7566d6.el7.x86_64
  subscription-manager-migration-1.21.1-1.git.45.a7566d6.el7.x86_64
  subscription-manager-1.21.1-1.git.45.a7566d6.el7.x86_64
  
  cockpit-system-154-3.el7.noarch
  
  subscription-manager-plugin-ostree-1.21.1-1.git.45.a7566d6.el7.x86_64
  subscription-manager-rhsm-certificates-1.21.1-1.git.45.a7566d6.el7.x86_64
  subscription-manager-cockpit-1.20.10-1.el7.noarch


How to reproduce:

[root@jstavel-rhel7-server ~]# subscription-manager register --username stage_jstavel_demo01 --password redhat
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
The system has been registered with ID: a30016a9-3934-468f-8db9-c0676c92128b
The registered system name is: jstavel-rhel7-server


[root@jstavel-rhel7-server ~]# perl -pi -e 's/(proxy_hostname[\ ]*=).*$/proxy_hostname = wrong.auto-services.usersys.redhat.com/' /etc/rhsm/rhsm.conf


[root@jstavel-rhel7-server ~]# dbus-send --system --print-reply --dest='com.redhat.RHSM1' /com/redhat/RHSM1/Unregister com.redhat.RHSM1.Unregister.Unregister dict:string:string:'','' string:'en'
method return time=1517482844.058483 sender=:1.16629 -> destination=:1.16644 serial=3 reply_serial=2

Actual results:

The method Unregister unregisters the system even the proxy connection is set as wrong.

Expected results:

some kind of 'Unresolved hostname error' should appear after dbus method Unregister is called.



Additional info:

Comment 2 Kevin Howell 2018-02-01 15:35:36 UTC
Jan, if the config change is made via D-BUS, does the D-BUS call work as expected?

Comment 3 Jan Stavel 2018-02-01 15:54:29 UTC
Hello Kevin,
no it does not reflect a config change either in this case.

[root@jstavel-rhel7-server ~]# subscription-manager register --username stage_jstavel_demo01 --password redhat

  Registering to: subscription.rhsm.stage.redhat.com:443/subscription
  The system has been registered with ID: 679802df-c3ee-4722-8671-cbb385a76b4d
  The registered system name is: jstavel-rhel7-server

[root@jstavel-rhel7-server ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Config com.redhat.RHSM1.Config Set svs server.proxy_hostname s wrong.auto-services.usersys.redhat.com "en"

[root@jstavel-rhel7-server ~]# less /etc/rhsm/rhsm.conf

[root@jstavel-rhel7-server ~]# dbus-send --system --print-reply --dest='com.redhat.RHSM1' /com/redhat/RHSM1/Unregister com.redhat.RHSM1.Unregister.Unregister dict:string:string:'','' string:'en'

  method return time=1517500345.259415 sender=:1.16814 -> destination=:1.16818 serial=4 reply_serial=2

Comment 4 Kevin Howell 2018-02-05 16:12:24 UTC
Jan, if the user is in an environment where they must use a proxy, can the user successfully unregister?

Comment 5 Jan Stavel 2018-02-05 17:38:04 UTC
Hi Kevin


```shell


[root@jstavel-rhel7-server ~]# perl -pi -e 's/(proxy_port[\ ]*=).*$/proxy_port = 3129/' /etc/rhsm/rhsm.conf
[root@jstavel-rhel7-server ~]# perl -pi -e 's/(proxy_hostname[\ ]*=).*$/proxy_hostname = auto-services.usersys.redhat.com/' /etc/rhsm/rhsm.conf
[root@jstavel-rhel7-server ~]# systemctl restart rhsm.service
[root@jstavel-rhel7-server ~]# subscription-manager register --username stage_jstavel_demo01 --password redhat
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
The system has been registered with ID: 1db598c4-28db-4bdd-bb0a-468bfc20bc5c
The registered system name is: jstavel-rhel7-server
[root@jstavel-rhel7-server ~]# subscription-manager unregister
Unregistering from: subscription.rhsm.stage.redhat.com:443/subscription
System has been unregistered.
[root@jstavel-rhel7-server ~]# 

```

Is this you wanted to try?

Comment 6 Jan Stavel 2018-02-06 10:14:09 UTC
Created attachment 1391938 [details]
an auxilliary systemd service to let rhsm service log appear in systemd ecosystem

It helps me to apply a time window to log outputs of rhsm service.
Using journalctl --since $DATE

Comment 7 Jan Stavel 2018-02-06 10:15:01 UTC
Created attachment 1391939 [details]
an auxilliary systemd service to let rhsm service log appear in systemd ecosystem

systemd configuration

Comment 8 Jan Stavel 2018-02-06 10:29:38 UTC
In the following scenarions a systemd service 'tail-f-rhsm-log' comes to play.
It helps me to put a time window onto /var/log/rhsm/rhsm.log file.

Before:
- copy tail-f-rhsm.log.sh into /root/bin/
- copy tail-f-rhsm-log.service into /etc/systemd/system
- reload a systemd: systemctl daemon-reload
- start the service: systemctl start tail-f-rhsm-log.service

Once I add 'iptables -A OUTPUt -d subscription.rhsm.stage.redhat.com -j REJECT' into the origin scenarion a dbus call fails with an error 'Connection refused'


The scenarion follows:

[root@jstavel-rhel7-server ~]# subscription-manager register --username stage_jstavel_demo01 --password redhat                                                                                
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
The system has been registered with ID: 87619021-75ff-4ded-a220-c735754b5ea6
The registered system name is: jstavel-rhel7-server
[root@jstavel-rhel7-server ~]# perl -pi -e 's/(proxy_hostname[\ ]*=).*$/proxy_hostname = auto-services.usersys.redhat.com/' /etc/rhsm/rhsm.conf                                               
[root@jstavel-rhel7-server ~]# perl -pi -e 's/(proxy_port[\ ]*=).*$/proxy_port = 3129/' /etc/rhsm/rhsm.conf                                                                                   
[root@jstavel-rhel7-server ~]# iptables -A OUTPUT -d subscription.rhsm.stage.redhat.com -j REJECT                                                                                             
[root@jstavel-rhel7-server ~]# now=$(date +'%F %T')                                                                                                                                           


[root@jstavel-rhel7-server ~]# dbus-send --system --print-reply --dest='com.redhat.RHSM1' /com/redhat/RHSM1/Unregister com.redhat.RHSM1.Unregister.Unregister dict:string:string:'','' string:
'en'


Error org.freedesktop.DBus.Python.dbus.exceptions.DBusException: [Errno 111] Connection refused
[root@jstavel-rhel7-server ~]# journalctl -u tail-f-rhsm-log --since "$now" --no-pager | less
[root@jstavel-rhel7-server ~]# journalctl -u tail-f-rhsm-log --since "$now" --no-pager
-- No entries --


[root@jstavel-rhel7-server ~]# dbus-send --system --print-reply --dest='com.redhat.RHSM1' /com/redhat/RHSM1/Unregister com.redhat.RHSM1.Unregister.Unregister dict:string:string:'','' string:'en'

Error org.freedesktop.DBus.Python.dbus.exceptions.DBusException: [Errno 111] Connection refused


[root@jstavel-rhel7-server ~]# journalctl -u tail-f-rhsm-log --since "$now" --no-pager
-- No entries --
[root@jstavel-rhel7-server ~]# systemctl status rhsm.service
● rhsm.service - RHSM dbus service
   Loaded: loaded (/usr/lib/systemd/system/rhsm.service; disabled; vendor preset: disabled)
   Active: active (running) since Út 2018-02-06 05:17:42 EST; 8min ago
 Main PID: 23638 (rhsm-service)
    Tasks: 3
   CGroup: /system.slice/rhsm.service
           └─23638 /usr/bin/python /usr/libexec/rhsm-service

úno 06 05:25:23 jstavel-rhel7-server rhsm-service[23638]: INFO [subscription_manager.i18n:146] Could not import locale for en: [Errno 2] No translation file found for domain: 'rhsm'


úno 06 05:25:23 jstavel-rhel7-server rhsm-service[23638]: INFO [subscription_manager.i18n:118] Could not import locale either for en_EN: [Errno 2] No translation file found fo...ain: 'rhsm'


úno 06 05:25:23 jstavel-rhel7-server rhsm-service[23638]: INFO [rhsm.connection:871] Connection built: host=subscription.rhsm.stage.redhat.com port=443 handler=/subscription a...ecure=False


úno 06 05:25:24 jstavel-rhel7-server rhsm-service[23638]: ERROR [rhsmlib.dbus.util:39] [Errno 111] Connection refused


úno 06 05:25:24 jstavel-rhel7-server rhsm-service[23638]: Traceback (most recent call last):


úno 06 05:25:24 jstavel-rhel7-server rhsm-service[23638]: File "/usr/lib64/python2.7/site-packages/rhsmlib/dbus/util.py", line 36, in dbus_handle_exceptions


úno 06 05:25:24 jstavel-rhel7-server rhsm-service[23638]: ret = func(*args, **kwargs)


úno 06 05:25:24 jstavel-rhel7-server rhsm-service[23638]: File "/usr/lib64/python2.7/site-packages/rhsmlib/dbus/objects/unregister.py", line 73, in Unregister


úno 06 05:25:24 jstavel-rhel7-server rhsm-service[23638]: raise dbus.DBusException(str(err))


úno 06 05:25:24 jstavel-rhel7-server rhsm-service[23638]: DBusException: [Errno 111] Connection refused


Hint: Some lines were ellipsized, use -l to show in full.

Comment 9 Jan Stavel 2018-02-06 10:41:01 UTC
The previous scenarions has just confirmed that dbus service 'rhsm' does not reflects changes made in /etc/rhsm/rhsm.conf. It tried to connect a candlepin server directly.

Comment 10 Kevin Howell 2018-02-08 15:25:10 UTC
Seems like a dupe of bug 1504588. Please reopen if you disagree.

*** This bug has been marked as a duplicate of bug 1504588 ***


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