[mutter/wip/lantw/gethostname: 2/4] xwayland: Use g_get_host_name instead of gethostname



commit c35e56196a0955b52e87a808126f09f79bebe731
Author: Ting-Wei Lan <lantw src gnome org>
Date:   Sun Jun 23 23:44:05 2019 +0800

    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.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/626
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/638

 src/wayland/meta-xwayland.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
---
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 9455326d0..88a4b4c11 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]