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 1737283

Summary: backport ExecCondition
Product: Red Hat Enterprise Linux 8 Reporter: Aniket Bhavsar <abhavsar>
Component: systemdAssignee: David Tardon <dtardon>
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.4CC: dtardon, fkrska, msekleta, sbalasub, systemd-maint-list
Target Milestone: rcKeywords: Patch
Target Release: 8.0Flags: msekleta: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:02:06 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:

Description Aniket Bhavsar 2019-08-05 01:39:14 UTC
[RFE] Request.

1. Proposed title of this feature request
=>systemd unit condition DomainName

3. What are the nature and description of the request?
=> A sysadmin wants to setup a job on all hosts in the 'dhcp' subdomain (dhcp.example.com) or run a service on all hosts not in the 'dhcp' subdomain.  The systems are cloud VMs and get their hostname dynamically.

4. Why does the customer need this? (List the business requirements here)
=>Systemd has unit file conditions for node name (gethostname/uname -n).  However, the DNS Domain Name may not be set within the host's node name.  It would be helpful if there was a way to query against the DNS Domain Name.

5. How would the customer like to achieve this? (List the functional requirements here)
=>Add a systemd.unit condition "ConditionDNSDomainName" (just a name suggestion) that performs the same set of calls as `dnsdomainname` from the 'hostname` rpm to return the value.  Use of this condition should force a dependency on 'nss-lookup.target' to ensure the name service is rationally setup.

6. For each functional requirement listed, specify how Red Hat and the customer can test to confirm the requirement is successfully implemented.
=> Customer dont have test machine.

7. Is there already an existing RFE upstream or in Red Hat Bugzilla?
=> Not found any.

8. Does the customer have any specific timeline dependencies and which release would they like to target (i.e. RHEL5, RHEL6)?
=> RHEL 8.2

9. Would the customer be able to assist in testing this functionality if implemented?
=> Customer dont have test server.

Comment 1 Lukáš Nykrýn 2019-08-05 08:21:45 UTC
To be honest, I don't like this idea since it can easily get racy. If I am not mistaken, the dnsdomainname depends on the network, and it might not be available until very late into the boot.

Comment 4 David Tardon 2019-11-25 08:55:16 UTC
Is there any reason the customer cannot use ExecCondition? E.g., something like

ExecCondition=/usr/bin/sh -c 'test `dnsdomainname` = dhcp.example.com'

Comment 5 David Tardon 2019-11-25 13:07:58 UTC
Uh, I didn't notice ExecCondition= has only been added in v. 243. I'll backport it.

Comment 6 David Tardon 2019-12-03 16:11:15 UTC
Let's generalize this bug into a backport request for ExecCondition. With ExecCondition available, the customer can easily run a check on DNS domain name as suggested in comment 4.

Comment 7 David Tardon 2019-12-03 16:12:36 UTC
PR: https://github.com/systemd-rhel/rhel-8/pull/48

Comment 15 Lukáš Nykrýn 2020-05-26 09:12:42 UTC
fix merged to github master branch -> https://github.com/systemd-rhel/rhel-8/pull/48

Comment 20 Lukáš Nykrýn 2020-06-16 10:45:52 UTC
fix merged to github master branch -> https://github.com/systemd-rhel/rhel-8/pull/108

Comment 24 errata-xmlrpc 2020-11-04 02:02:06 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 (Low: systemd security, 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/RHSA-2020:4553