Commit c35e5619 authored by Ting-Wei Lan's avatar Ting-Wei Lan Committed by Jonas Ådahl

xwayland: Use g_get_host_name instead of gethostname

Since the xauth file is never going to be changed after it is generated,
it is safe to use g_get_host_name here.

GNOME/mutter!626
GNOME/mutter!638
parent 181c7cab
......@@ -452,7 +452,6 @@ prepare_auth_file (MetaXWaylandManager *manager)
{
Xauth auth_entry = { 0 };
g_autoptr (FILE) fp = NULL;
char hostname[HOST_NAME_MAX + 1];
char auth_data[16];
int fd;
......@@ -460,9 +459,6 @@ prepare_auth_file (MetaXWaylandManager *manager)
".mutter-Xwaylandauth.XXXXXX",
NULL);
if (gethostname (hostname, HOST_NAME_MAX) < 0)
g_strlcpy (hostname, "localhost", HOST_NAME_MAX);
if (getrandom (auth_data, sizeof (auth_data), 0) != sizeof (auth_data))
{
g_warning ("Failed to get random data: %s", g_strerror (errno));
......@@ -470,7 +466,7 @@ prepare_auth_file (MetaXWaylandManager *manager)
}
auth_entry.family = FamilyLocal;
auth_entry.address = hostname;
auth_entry.address = (char *) g_get_host_name ();
auth_entry.address_length = strlen (auth_entry.address);
auth_entry.name = (char *) "MIT-MAGIC-COOKIE-1";
auth_entry.name_length = strlen (auth_entry.name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment