diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-07-24 14:10:55 +0200 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-07-25 09:20:31 +0200 |
commit | 93f7fa96d6a2b4e5da03a3d1f19b2d3ca538b7f6 (patch) | |
tree | 595e886ee55eab7a764cec3d7fb51c2a42876d38 | |
parent | 1c7e3d85fc372bc29209a013fa78a883da4c0769 (diff) | |
download | NetworkManager-93f7fa96d6a2b4e5da03a3d1f19b2d3ca538b7f6.tar.gz |
ifcfg-rh: fix a crash on setting hostname with SELinux disabled (rh #1122826)
When SELinux is disabled, getfscreatecon() fails leaving se_ctx_prev undefined
and then later freecon (se_ctx_prev) fails with a crash. Initializing
se_ctx_prev to NULL fixes the crash. (It is fine to pass NULL context to
setfscreatecon()).
Testcase:
1) Enable ifcfg-rh plugin in /etc/NetworkManger/NetworkManger.conf
plugins=ifcfg-rh
2) Edit /etc/sysconfig/selinux to contain
SELINUX=disabled
3) Reboot
4) Set hostname via nmcli, nmtui or D-Bus SaveHostname() call
5) NM crashes
https://bugzilla.redhat.com/show_bug.cgi?id=1122826
-rw-r--r-- | src/settings/plugins/ifcfg-rh/plugin.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index b067c5861d..0567ba2406 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -670,7 +670,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname) char *hostname_eol; gboolean ret; #if HAVE_SELINUX - security_context_t se_ctx_prev, se_ctx = NULL; + security_context_t se_ctx_prev = NULL, se_ctx = NULL; struct stat file_stat = { .st_mode = 0 }; /* Get default context for HOSTNAME_FILE and set it for fscreate */ |