Bug 1308974 - NetworkManager does not correctly set hostname obtained from DNS
NetworkManager does not correctly set hostname obtained from DNS
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: NetworkManager (Show other bugs)
24
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Beniamino Galvani
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-16 10:45 EST by Petr Spacek
Modified: 2016-03-26 14:01 EDT (History)
6 users (show)

See Also:
Fixed In Version: NetworkManager-1.2.0-0.7.beta2.fc24
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-03-26 14:01:52 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Full output from "journalctl -b" (100.19 KB, text/plain)
2016-02-16 10:45 EST, Petr Spacek
no flags Details
[PATCH] core: use hostnamed to set the transient hostname (8.28 KB, patch)
2016-02-19 05:16 EST, Beniamino Galvani
no flags Details | Diff

  None (edit)
Description Petr Spacek 2016-02-16 10:45:02 EST
Created attachment 1127619 [details]
Full output from "journalctl -b"

Description of problem:
After a upgrade to Fedora 24, machine is no longer getting its hostname set from PTR record in DNS.

Version-Release number of selected component (if applicable):
NetworkManager-1.2.0-0.6.beta1.fc24.x86_64

How reproducible:
100 %

Steps to Reproduce:
1. do not configure any hostname in the machine
2. boot the machine in a network where DNS contains a hostname in the reverse record for IPv4 address

Actual results:
NetworkManager[892]: <warn>  couldn't set the system hostname to 'vm-058-011.abc.idm.lab.eng.brq.redhat.com': (1) Operation not permitted
NetworkManager[892]: <warn>  You should use hostnamed when systemd hardening is in effect!


Expected results:
The hostname is set.


Additional info:
Audit log does not show any SELinux AVC. Switching SELinux to permissive mode does not help.

Full output from "journalctl -b" is attached.
Comment 1 Beniamino Galvani 2016-02-19 05:16 EST
Created attachment 1128501 [details]
[PATCH] core: use hostnamed to set the transient hostname
Comment 2 Dan Williams 2016-02-20 11:08:29 EST
In nm_settings_set_transient_hostname() the variable 'var' is unused.

Might as well use gs_free_error for 'error' in set_transient_hostname_done() too, and you could use gs_free for 'info', and gs_unref_variant for 'result' too.

Also, since set_system_hostname() only gets called from one place now, and your patch reduces its size, maybe we should just move that code into _set_hostname()?
Comment 3 Beniamino Galvani 2016-02-22 04:52:58 EST
(In reply to Dan Williams from comment #2)
> In nm_settings_set_transient_hostname() the variable 'var' is unused.
> 
> Might as well use gs_free_error for 'error' in set_transient_hostname_done()
> too, and you could use gs_free for 'info', and gs_unref_variant for 'result'
> too.
> 
> Also, since set_system_hostname() only gets called from one place now, and
> your patch reduces its size, maybe we should just move that code into
> _set_hostname()?

Fixed and pushed 2 additional commits to bg/sethostname-hostnamed-rh1308974.
Comment 4 Dan Williams 2016-02-22 17:40:41 EST
> core: use hostnamed to set the transient hostname

set_system_hostname() doesn't need a return; at the end of the function anymore since it's not returning anything.

Also, instead of strdup-ing the hostname in set_system_hostname(), I'd do that in nm_settings_set_transient_hostname() when creating the info structure, and then free it in set_transient_hostname_done().  That way the callback itself doesn't have to care, and the thing that might do the asynchronous operation is responsible for alloc/free.

rest looks good to me!
Comment 5 Beniamino Galvani 2016-02-23 17:17:17 EST
(In reply to Dan Williams from comment #4)
> Also, instead of strdup-ing the hostname in set_system_hostname(), I'd do
> that in nm_settings_set_transient_hostname() when creating the info
> structure, and then free it in set_transient_hostname_done().  That way the
> callback itself doesn't have to care, and the thing that might do the
> asynchronous operation is responsible for alloc/free.

Makes sense, thanks. Branch updated.
Comment 6 Jan Kurik 2016-02-24 10:22:33 EST
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase
Comment 7 Thomas Haller 2016-03-01 10:55:35 EST
+typedef void (*NMSettingsSetHostnameCb) (const char *name, gboolean result);

when having a callback, it requires a user-data argument.
Comment 8 Beniamino Galvani 2016-03-02 04:50:38 EST
(In reply to Thomas Haller from comment #7)
> +typedef void (*NMSettingsSetHostnameCb) (const char *name, gboolean result);
> 
> when having a callback, it requires a user-data argument.

Fixed and repushed.
Comment 9 Dan Williams 2016-03-03 16:05:35 EST
LGTM now.
Comment 10 Thomas Haller 2016-03-04 02:26:18 EST
Maybe use g_slice allocator for SetHostnameInfo and replace "!strlen (new_hostname)" by "!new_hostname[0]" 


Otherwise, lgtm.
Comment 11 Beniamino Galvani 2016-03-04 08:41:02 EST
(In reply to Thomas Haller from comment #10)
> Maybe use g_slice allocator for SetHostnameInfo

Probably it doesn't make much difference since the function is called rarely.

> and replace "!strlen (new_hostname)" by "!new_hostname[0]" 

Changed and merged to master as:

https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=0fe8a557f80ddcebbf637c585d02cebd0bd735a2
Comment 12 Fedora Update System 2016-03-22 06:32:40 EDT
NetworkManager-1.2.0-0.7.beta2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-e4d2697a0b
Comment 13 Fedora Update System 2016-03-22 06:32:54 EDT
NetworkManager-1.2.0-0.7.beta2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-e4d2697a0b
Comment 14 Fedora Update System 2016-03-22 12:56:06 EDT
NetworkManager-1.2.0-0.7.beta2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-e4d2697a0b
Comment 15 Fedora Update System 2016-03-26 14:01:45 EDT
NetworkManager-1.2.0-0.7.beta2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

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