mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 18:08:05 +02:00
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
This commit is contained in:
parent
1c7e3d85fc
commit
93f7fa96d6
1 changed files with 1 additions and 1 deletions
|
|
@ -670,7 +670,7 @@ plugin_set_hostname (SCPluginIfcfg *plugin, const char *hostname)
|
||||||
char *hostname_eol;
|
char *hostname_eol;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
#if HAVE_SELINUX
|
#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 };
|
struct stat file_stat = { .st_mode = 0 };
|
||||||
|
|
||||||
/* Get default context for HOSTNAME_FILE and set it for fscreate */
|
/* Get default context for HOSTNAME_FILE and set it for fscreate */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue