Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 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 "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". 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 "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-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 2097679

Summary: When running subscription-manager from a script, it might hang if some arguments are not provided
Product: Red Hat Enterprise Linux 9 Reporter: Rehana <redakkan>
Component: subscription-managerAssignee: Jason Jerome <jajerome>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: low Docs Contact:
Priority: unspecified    
Version: 9.0CC: candlepin-bugs, dhill, jsefler, jstavel, redakkan, rhsm-qe
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: subscription-manager-1.29.32-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2096852 Environment:
Last Closed: 2023-05-09 08:18:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2096852    
Bug Blocks:    

Comment 2 Jan Stavel 2022-09-13 09:32:55 UTC
an ansible playbook to simulate a case that subscription-manager raises error when username,password are not provided - instead of waiting for user input.
The app does that when no tty is available.

Comment 3 Jan Stavel 2022-11-04 19:54:04 UTC
It works as supposed:

root@localhost ~]# ssh -T localhost "subscription-manager register"
root@localhost's password: 
Error: --username is a required parameter in non-interactive mode.
Registering to: subscription.rhsm.stage.redhat.com:443/subscription

[root@localhost ~]# rpm -qa | grep subscription-manager
subscription-manager-rhsm-certificates-20220623-1.el9.noarch
subscription-manager-cockpit-4^11.g9a71113-1.el9_1.noarch
python3-subscription-manager-rhsm-1.29.31+24.g0e624a373-1.git.0.1356af2.x86_64
libdnf-plugin-subscription-manager-1.29.31+24.g0e624a373-1.git.0.1356af2.x86_64
subscription-manager-1.29.31+24.g0e624a373-1.git.0.1356af2.x86_64

Comment 4 Jan Stavel 2022-11-08 20:59:34 UTC
PLAY [subscription-manager raises error when user input is required] ***********

TASK [Info about version of the entitlement stack] *****************************
ok: [192.168.122.47] => 
  msg: |2-
    server type: This system is currently not registered.
    subscription management server: 4.2.10-1
    subscription management rules: 5.43
    subscription-manager: 1.29.31+24.g0e624a373-1.git.0.1356af2

TASK [Register in a script without TTY - without username, password] ***********
  cmd: ssh -T localhost "subscription-manager register"
  rc: 64
  stdout: |-
    root@localhost's password:
    Registering to: subscription.rhsm.stage.redhat.com:443/subscription
    Error: --username is a required parameter in non-interactive mode.

TASK [ansible.builtin.assert] **************************************************
ok: [192.168.122.47] => changed=false 
  msg: The right error message was printed on stdout

TASK [Register in a script without TTY - without password] *********************
  cmd: ssh -T localhost "subscription-manager register --username stage_rhsmqe_testuser01"
  rc: 64
  stdout: |-
    root@localhost's password:
    Error: --password is a required parameter in non-interactive mode.
    Registering to: subscription.rhsm.stage.redhat.com:443/subscription

TASK [ansible.builtin.assert] **************************************************
ok: [192.168.122.47] => changed=false 
  msg: The right error message was printed on stdout

TASK [Register in a script without TTY - with username and password] ***********
changed: [192.168.122.47]

TASK [ansible.builtin.assert] **************************************************
ok: [192.168.122.47] => changed=false 
  msg: Info about registering of a system appeared.

TASK [Unregister in a script without TTY] **************************************
changed: [192.168.122.47]

TASK [ansible.builtin.assert] **************************************************
ok: [192.168.122.47] => changed=false 
  msg: Info about unregistering of a system appeared.

TASK [Register using activation key in a script without TTY - without org field] ***
  cmd: ssh -T localhost "subscription-manager register --activationkey stage_rhsmqe_testuser01_13267397-ActivationKey1645276042189"
  rc: 64
  stdout: |-
    root@localhost's password:
    Error: Must provide --org with activation keys.

TASK [ansible.builtin.assert] **************************************************
ok: [192.168.122.47] => changed=false 
  msg: Info about missing field org appeared.

TASK [Register using activation key in a script without TTY] *******************
  cmd: ssh -T localhost "subscription-manager register --org 13267397 --activationkey stage_rhsmqe_testuser01_13267397-ActivationKey1645276042189"
  rc: 1
  stdout: |-
    root@localhost's password:
    The system has been registered with ID: ef407fe6-5a06-45f2-a6f5-45767c34d9c9
    The registered system name is: localhost.localdomain
    Installed Product Current Status:
    Product Name: Red Hat Enterprise Linux for x86_64 Beta
    Status:       Not Subscribed
  
    Unable to find available subscriptions for all your installed products.

TASK [ansible.builtin.assert] **************************************************
ok: [192.168.122.47] => changed=false 
  msg: Info about registering of a system appeared.

Comment 8 Jan Stavel 2023-01-23 12:46:55 UTC
TASK: set the proper entitlement environment
   cmd: [subscription-manager, config, --server.hostname=subscription.rhsm.stage.redhat.com,
  --server.port=443, --server.insecure=1, '--rhsm.baseurl=https://cdn.stage.redhat.com']

   rc: 0
   stdout:     
   stderr:     

TASK: version of installed subscription-manager package
   cmd: [subscription-manager, version]

   rc: 0
   stdout:  
       [94mMaking insecure (no auth) request:[0m[91m subscription.rhsm.stage.redhat.com:443 GET /subscription/[0m
       
       
       [94mMaking insecure (no auth) request:[0m[91m subscription.rhsm.stage.redhat.com:443 GET /subscription/status[0m
       
       server type: This system is currently not registered.
       subscription management server: 4.2.10-1
       subscription management rules: 5.43
       subscription-manager: 1.29.32-1.el9   
   stderr:     

TASK: Assert that a command ssh -T does not enable tty
   cmd: ssh -T localhost "python3 -c 'import sys; print(sys.stdin and sys.stdin.isatty())'"

   rc: 0
   stdout:  
root@localhost's password: 
       False   
   stderr:     

ASSERT: A result should be False
   msg: All assertions passed
   status: ok
   

TASK: Register in a script without TTY - without username, password
   cmd: ssh -T localhost "subscription-manager register"

   rc: 64
   stdout:  
root@localhost's password: 
       Registering to: subscription.rhsm.stage.redhat.com:443/subscription
       Error: --username is a required parameter in non-interactive mode.   
   stderr:     

ASSERT: ansible.builtin.assert
   msg: The right error message was printed on stdout
   status: ok
   

TASK: Register in a script without TTY - without password
   cmd: ssh -T localhost "subscription-manager register --username stage_rhsmqe_testuser01"

   rc: 64
   stdout:  
root@localhost's password: 
       Registering to: subscription.rhsm.stage.redhat.com:443/subscription
       Error: --password is a required parameter in non-interactive mode.   
   stderr:     

ASSERT: ansible.builtin.assert
   msg: The right error message was printed on stdout
   status: ok
   

TASK: Register in a script without TTY - with username and password
   cmd: ssh -T localhost "subscription-manager register --username stage_rhsmqe_testuser01
  --password P@ssw0rd"

   rc: 0
   stdout:  
root@localhost's password: 
       Registering to: subscription.rhsm.stage.redhat.com:443/subscription
       The system has been registered with ID: 4209fc64-1d88-4ffb-8fa2-2f8ed44f06a0
       The registered system name is: auto-hv-02-guest01.idmqe.lab.eng.bos.redhat.com   
   stderr:     

ASSERT: ansible.builtin.assert
   msg: Info about registering of a system appeared.
   status: ok
   

TASK: Unregister in a script without TTY
   cmd: ssh -T localhost "subscription-manager unregister"

   rc: 0
   stdout:  
root@localhost's password: 
       Unregistering from: subscription.rhsm.stage.redhat.com:443/subscription
       System has been unregistered.   
   stderr:     

ASSERT: ansible.builtin.assert
   msg: Info about unregistering of a system appeared.
   status: ok
   

TASK: Register using activation key in a script without TTY - without org field
   cmd: ssh -T localhost "subscription-manager register --activationkey stage_rhsmqe_testuser01_13267397-ActivationKey1645276042189"

   rc: 64
   stdout:  
root@localhost's password: 
       Error: Must provide --org with activation keys.   
   stderr:     

ASSERT: ansible.builtin.assert
   msg: Info about missing field org appeared.
   status: ok
   

TASK: Register using activation key in a script without TTY
   cmd: ssh -T localhost "subscription-manager register --org 13267397 --activationkey stage_rhsmqe_testuser01_13267397-ActivationKey1645276042189"

   rc: 1
   stdout:  
root@localhost's password: 
       The system has been registered with ID: f4c5156f-1593-479e-afb4-0c1cfb6f4376
       The registered system name is: auto-hv-02-guest01.idmqe.lab.eng.bos.redhat.com
       Installed Product Current Status:
       Product Name: Red Hat Enterprise Linux for x86_64 Beta
       Status:       Not Subscribed
       
       Unable to find available subscriptions for all your installed products.   
   stderr:     

ASSERT: ansible.builtin.assert
   msg: Info about registering of a system appeared.
   status: ok

Comment 10 errata-xmlrpc 2023-05-09 08:18:42 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 (subscription-manager bug fix and enhancement 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/RHBA-2023:2493