Coverage Report

Created: 2026-11-12 06:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/glib/gio/gunixsocketaddress.c
Line
Count
Source
1
/* GIO - GLib Input, Output and Streaming Library
2
 *
3
 * Copyright (C) 2008 Christian Kellner, Samuel Cormier-Iijima
4
 *
5
 * SPDX-License-Identifier: LGPL-2.1-or-later
6
 *
7
 * This library is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * This library is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General
18
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * Authors: Christian Kellner <gicmo@gnome.org>
21
 *          Samuel Cormier-Iijima <sciyoshi@gmail.com>
22
 */
23
24
#include <config.h>
25
#include <glib.h>
26
#include <string.h>
27
28
#include "gunixsocketaddress.h"
29
#include "gsocketconnectable.h"
30
#include "glibintl.h"
31
#include "gnetworking.h"
32
33
#ifdef G_OS_WIN32
34
#include "giowin32-afunix.h"
35
#endif
36
37
/**
38
 * GUnixSocketAddress:
39
 *
40
 * Support for UNIX-domain (also known as local) sockets, corresponding to
41
 * `struct sockaddr_un`.
42
 *
43
 * UNIX domain sockets are generally visible in the filesystem.
44
 * However, some systems support abstract socket names which are not
45
 * visible in the filesystem and not affected by the filesystem
46
 * permissions, visibility, etc. Currently this is only supported
47
 * under Linux. If you attempt to use abstract sockets on other
48
 * systems, function calls may return `G_IO_ERROR_NOT_SUPPORTED`
49
 * errors. You can use [func@Gio.UnixSocketAddress.abstract_names_supported]
50
 * to see if abstract names are supported.
51
 *
52
 * Since GLib 2.72, `GUnixSocketAddress` is available on all platforms. It
53
 * requires underlying system support (such as Windows 10 with `AF_UNIX`) at
54
 * run time.
55
 *
56
 * Before GLib 2.72, `<gio/gunixsocketaddress.h>` belonged to the UNIX-specific
57
 * GIO interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file
58
 * when using it. This is no longer necessary since GLib 2.72.
59
 */
60
61
enum
62
{
63
  PROP_0,
64
  PROP_PATH,
65
  PROP_PATH_AS_ARRAY,
66
  PROP_ABSTRACT,
67
  PROP_ADDRESS_TYPE
68
};
69
70
#ifndef UNIX_PATH_MAX
71
0
#define UNIX_PATH_MAX G_SIZEOF_MEMBER (struct sockaddr_un, sun_path)
72
#endif
73
74
struct _GUnixSocketAddressPrivate
75
{
76
  char path[UNIX_PATH_MAX + 1]; /* Not including the initial zero in abstract case, so
77
                                   we can guarantee zero termination of abstract
78
                                   pathnames in the get_path() API, but including
79
                                   an extra nul byte at the end so we can ensure our
80
                                   paths are always nul-terminated */
81
  gsize path_len; /* Not including any terminating zeros */
82
  GUnixSocketAddressType address_type;
83
};
84
85
static void   g_unix_socket_address_connectable_iface_init (GSocketConnectableIface *iface);
86
static gchar *g_unix_socket_address_connectable_to_string  (GSocketConnectable      *connectable);
87
88
0
G_DEFINE_TYPE_WITH_CODE (GUnixSocketAddress, g_unix_socket_address, G_TYPE_SOCKET_ADDRESS,
89
0
                         G_ADD_PRIVATE (GUnixSocketAddress)
90
0
                         G_IMPLEMENT_INTERFACE (G_TYPE_SOCKET_CONNECTABLE,
91
0
                                                g_unix_socket_address_connectable_iface_init))
92
0
93
0
static gsize
94
0
g_unix_socket_address_get_max_path_len (GUnixSocketAddressType address_type)
95
0
{
96
0
  switch (address_type)
97
0
    {
98
0
    case G_UNIX_SOCKET_ADDRESS_ANONYMOUS:
99
0
      return 0;
100
0
    case G_UNIX_SOCKET_ADDRESS_PATH:
101
0
      return UNIX_PATH_MAX;
102
0
    case G_UNIX_SOCKET_ADDRESS_ABSTRACT:
103
0
    case G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED:
104
0
      return UNIX_PATH_MAX - 1; /* initial zero */
105
0
    case G_UNIX_SOCKET_ADDRESS_INVALID:
106
0
    default:
107
0
      g_assert_not_reached ();
108
0
      return 0;
109
0
    }
110
0
}
111
112
static void
113
g_unix_socket_address_clamp_path_len (GUnixSocketAddress *address)
114
0
{
115
0
  gsize max_len;
116
117
  /* will be clamped once this has been set */
118
0
  if (address->priv->address_type == G_UNIX_SOCKET_ADDRESS_INVALID)
119
0
    return;
120
121
0
  max_len = g_unix_socket_address_get_max_path_len (address->priv->address_type);
122
0
  if (address->priv->path_len <= max_len)
123
0
    return;
124
125
0
  address->priv->path_len = max_len;
126
0
  address->priv->path[max_len] = 0;
127
0
}
128
129
static void
130
g_unix_socket_address_set_property (GObject      *object,
131
                                    guint         prop_id,
132
                                    const GValue *value,
133
                                    GParamSpec   *pspec)
134
0
{
135
0
  GUnixSocketAddress *address = G_UNIX_SOCKET_ADDRESS (object);
136
0
  const char *str;
137
0
  GByteArray *array;
138
0
  gsize len;
139
140
0
  switch (prop_id)
141
0
    {
142
0
    case PROP_PATH:
143
0
      str = g_value_get_string (value);
144
0
      if (str)
145
0
        {
146
0
          g_strlcpy (address->priv->path, str,
147
0
                     sizeof (address->priv->path));
148
0
          address->priv->path_len = strlen (address->priv->path);
149
0
          g_unix_socket_address_clamp_path_len (address);
150
0
        }
151
0
      break;
152
153
0
    case PROP_PATH_AS_ARRAY:
154
0
      array = g_value_get_boxed (value);
155
156
0
      if (array)
157
0
        {
158
          /* Clip to fit in UNIX_PATH_MAX with zero termination or first byte */
159
0
          len = MIN (array->len, UNIX_PATH_MAX);
160
161
0
          if (len != 0)
162
0
            memcpy (address->priv->path, array->data, len);
163
164
0
          address->priv->path[len] = 0; /* Ensure null-terminated */
165
0
          address->priv->path_len = len;
166
0
          g_unix_socket_address_clamp_path_len (address);
167
0
        }
168
0
      break;
169
170
0
    case PROP_ABSTRACT:
171
      /* Only set it if it's not the default... */
172
0
      if (g_value_get_boolean (value))
173
0
        {
174
0
          address->priv->address_type = G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED;
175
0
          g_unix_socket_address_clamp_path_len (address);
176
0
        }
177
0
      break;
178
179
0
    case PROP_ADDRESS_TYPE:
180
      /* Only set it if it's not the default... */
181
0
      if (g_value_get_enum (value) != G_UNIX_SOCKET_ADDRESS_PATH)
182
0
        {
183
0
          address->priv->address_type = g_value_get_enum (value);
184
0
          g_unix_socket_address_clamp_path_len (address);
185
0
        }
186
0
      break;
187
188
0
    default:
189
0
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
190
0
    }
191
0
}
192
193
static void
194
g_unix_socket_address_get_property (GObject    *object,
195
                                    guint       prop_id,
196
                                    GValue     *value,
197
                                    GParamSpec *pspec)
198
0
{
199
0
  GUnixSocketAddress *address = G_UNIX_SOCKET_ADDRESS (object);
200
0
  GByteArray *array;
201
202
0
  switch (prop_id)
203
0
    {
204
0
      case PROP_PATH:
205
0
        g_value_set_string (value, address->priv->path);
206
0
        break;
207
208
0
      case PROP_PATH_AS_ARRAY:
209
0
        array = g_byte_array_sized_new (address->priv->path_len);
210
0
        g_byte_array_append (array, (guint8 *)address->priv->path, address->priv->path_len);
211
0
        g_value_take_boxed (value, array);
212
0
        break;
213
214
0
      case PROP_ABSTRACT:
215
0
        g_value_set_boolean (value, (address->priv->address_type == G_UNIX_SOCKET_ADDRESS_ABSTRACT ||
216
0
                                     address->priv->address_type == G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED));
217
218
0
        break;
219
220
0
      case PROP_ADDRESS_TYPE:
221
0
        g_value_set_enum (value, address->priv->address_type);
222
0
        break;
223
224
0
      default:
225
0
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
226
0
    }
227
0
}
228
229
static GSocketFamily
230
g_unix_socket_address_get_family (GSocketAddress *address)
231
0
{
232
0
  g_assert (PF_UNIX == G_SOCKET_FAMILY_UNIX);
233
234
0
  return G_SOCKET_FAMILY_UNIX;
235
0
}
236
237
static gssize
238
g_unix_socket_address_get_native_size (GSocketAddress *address)
239
0
{
240
0
  GUnixSocketAddress *addr = G_UNIX_SOCKET_ADDRESS (address);
241
242
0
  switch (addr->priv->address_type)
243
0
    {
244
0
    case G_UNIX_SOCKET_ADDRESS_ANONYMOUS:
245
0
      return G_STRUCT_OFFSET(struct sockaddr_un, sun_path);
246
0
    case G_UNIX_SOCKET_ADDRESS_ABSTRACT:
247
0
      return G_STRUCT_OFFSET(struct sockaddr_un, sun_path) + addr->priv->path_len + 1;
248
0
    default:
249
0
      return sizeof (struct sockaddr_un);
250
0
    }
251
0
}
252
253
static gboolean
254
g_unix_socket_address_to_native (GSocketAddress *address,
255
                                 gpointer        dest,
256
                                 gsize           destlen,
257
                                 GError        **error)
258
0
{
259
0
  GUnixSocketAddress *addr = G_UNIX_SOCKET_ADDRESS (address);
260
0
  struct sockaddr_un *sock;
261
0
  gssize socklen;
262
263
0
  socklen = g_unix_socket_address_get_native_size (address);
264
0
  g_assert (socklen >= 0);
265
0
  if (destlen < (gsize) socklen)
266
0
    {
267
0
      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NO_SPACE,
268
0
                           _("Not enough space for socket address"));
269
0
      return FALSE;
270
0
    }
271
272
0
  sock = (struct sockaddr_un *) dest;
273
0
  memset (sock, 0, socklen);
274
0
  sock->sun_family = AF_UNIX;
275
276
0
  switch (addr->priv->address_type)
277
0
    {
278
0
    case G_UNIX_SOCKET_ADDRESS_INVALID:
279
0
    case G_UNIX_SOCKET_ADDRESS_ANONYMOUS:
280
0
      break;
281
282
0
    case G_UNIX_SOCKET_ADDRESS_PATH:
283
0
      memcpy (sock->sun_path, addr->priv->path, addr->priv->path_len);
284
0
      if (addr->priv->path_len < UNIX_PATH_MAX)
285
0
        sock->sun_path[addr->priv->path_len] = '\0';
286
0
      break;
287
288
0
    case G_UNIX_SOCKET_ADDRESS_ABSTRACT:
289
0
    case G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED:
290
0
      if (!g_unix_socket_address_abstract_names_supported ())
291
0
        {
292
0
          g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
293
0
                               _("Abstract UNIX domain socket addresses not supported on this system"));
294
0
          return FALSE;
295
0
        }
296
297
0
      sock->sun_path[0] = 0;
298
0
      memcpy (sock->sun_path+1, addr->priv->path, addr->priv->path_len);
299
0
      break;
300
0
    }
301
302
0
  return TRUE;
303
0
}
304
305
static void
306
g_unix_socket_address_class_init (GUnixSocketAddressClass *klass)
307
0
{
308
0
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
309
0
  GSocketAddressClass *gsocketaddress_class = G_SOCKET_ADDRESS_CLASS (klass);
310
311
0
  gobject_class->set_property = g_unix_socket_address_set_property;
312
0
  gobject_class->get_property = g_unix_socket_address_get_property;
313
314
0
  gsocketaddress_class->get_family = g_unix_socket_address_get_family;
315
0
  gsocketaddress_class->to_native = g_unix_socket_address_to_native;
316
0
  gsocketaddress_class->get_native_size = g_unix_socket_address_get_native_size;
317
318
  /**
319
   * GUnixSocketAddress:path:
320
   *
321
   * Unix socket path.
322
   *
323
   * Since: 2.22
324
   */
325
0
  g_object_class_install_property (gobject_class,
326
0
                                   PROP_PATH,
327
0
                                   g_param_spec_string ("path", NULL, NULL,
328
0
                                                        NULL,
329
0
                                                        G_PARAM_READWRITE |
330
0
                                                        G_PARAM_CONSTRUCT_ONLY |
331
0
                                                        G_PARAM_STATIC_STRINGS));
332
333
  /**
334
   * GUnixSocketAddress:path-as-array:
335
   *
336
   * Unix socket path, as a byte array.
337
   *
338
   * Since: 2.22
339
   */
340
0
  g_object_class_install_property (gobject_class, PROP_PATH_AS_ARRAY,
341
0
                                   g_param_spec_boxed ("path-as-array", NULL, NULL,
342
0
                                                       G_TYPE_BYTE_ARRAY,
343
0
                                                       G_PARAM_READWRITE |
344
0
                                                       G_PARAM_CONSTRUCT_ONLY |
345
0
                                                       G_PARAM_STATIC_STRINGS));
346
347
  /**
348
   * GUnixSocketAddress:abstract:
349
   *
350
   * Whether or not this is an abstract address
351
   *
352
   * Deprecated: Use #GUnixSocketAddress:address-type, which
353
   * distinguishes between zero-padded and non-zero-padded
354
   * abstract addresses.
355
   */
356
0
  g_object_class_install_property (gobject_class, PROP_ABSTRACT,
357
0
                                   g_param_spec_boolean ("abstract", NULL, NULL,
358
0
                                                         FALSE,
359
0
                                                         G_PARAM_READWRITE |
360
0
                                                         G_PARAM_CONSTRUCT_ONLY |
361
0
                                                         G_PARAM_STATIC_STRINGS));
362
363
  /**
364
   * GUnixSocketAddress:address-type:
365
   *
366
   * The type of Unix socket address.
367
   *
368
   * Since: 2.22
369
   */
370
0
  g_object_class_install_property (gobject_class, PROP_ADDRESS_TYPE,
371
0
                                   g_param_spec_enum ("address-type", NULL, NULL,
372
0
                                                      G_TYPE_UNIX_SOCKET_ADDRESS_TYPE,
373
0
                                                      G_UNIX_SOCKET_ADDRESS_PATH,
374
0
                                                      G_PARAM_READWRITE |
375
0
                                                      G_PARAM_CONSTRUCT_ONLY |
376
0
                                                      G_PARAM_STATIC_STRINGS));
377
0
}
378
379
static void
380
g_unix_socket_address_connectable_iface_init (GSocketConnectableIface *iface)
381
0
{
382
0
  GSocketConnectableIface *parent_iface = g_type_interface_peek_parent (iface);
383
384
0
  iface->enumerate = parent_iface->enumerate;
385
0
  iface->proxy_enumerate = parent_iface->proxy_enumerate;
386
0
  iface->to_string = g_unix_socket_address_connectable_to_string;
387
0
}
388
389
static gchar *
390
g_unix_socket_address_connectable_to_string (GSocketConnectable *connectable)
391
0
{
392
0
  GUnixSocketAddress *ua;
393
0
  GString *out;
394
0
  const gchar *path;
395
0
  gsize path_len, i;
396
397
0
  ua = G_UNIX_SOCKET_ADDRESS (connectable);
398
399
  /* Anonymous sockets have no path. */
400
0
  if (ua->priv->address_type == G_UNIX_SOCKET_ADDRESS_ANONYMOUS)
401
0
    return g_strdup ("anonymous");
402
403
0
  path = g_unix_socket_address_get_path (ua);
404
0
  path_len = g_unix_socket_address_get_path_len (ua);
405
0
  out = g_string_sized_new (path_len);
406
407
  /* Return the #GUnixSocketAddress:path, but with all non-printable characters
408
   * (including nul bytes) escaped to hex. */
409
0
  for (i = 0; i < path_len; i++)
410
0
    {
411
0
      guint8 c = path[i];
412
413
0
      if (g_ascii_isprint (path[i]))
414
0
        g_string_append_c (out, c);
415
0
      else
416
0
        g_string_append_printf (out, "\\x%02x", (guint) c);
417
0
    }
418
419
0
  return g_string_free (out, FALSE);
420
0
}
421
422
static void
423
g_unix_socket_address_init (GUnixSocketAddress *address)
424
0
{
425
0
  address->priv = g_unix_socket_address_get_instance_private (address);
426
427
0
  memset (address->priv->path, 0, sizeof (address->priv->path));
428
0
  address->priv->path_len = -1;
429
0
  address->priv->address_type = G_UNIX_SOCKET_ADDRESS_PATH;
430
0
}
431
432
/**
433
 * g_unix_socket_address_new:
434
 * @path: the socket path
435
 *
436
 * Creates a new #GUnixSocketAddress for @path.
437
 *
438
 * To create abstract socket addresses, on systems that support that,
439
 * use g_unix_socket_address_new_abstract().
440
 *
441
 * Returns: a new #GUnixSocketAddress
442
 *
443
 * Since: 2.22
444
 */
445
GSocketAddress *
446
g_unix_socket_address_new (const gchar *path)
447
0
{
448
0
  return g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
449
0
                       "path", path,
450
0
                       "abstract", FALSE,
451
0
                       NULL);
452
0
}
453
454
/**
455
 * g_unix_socket_address_new_abstract:
456
 * @path: (array length=path_len) (element-type gchar): the abstract name
457
 * @path_len: the length of @path, or -1
458
 *
459
 * Creates a new %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED
460
 * #GUnixSocketAddress for @path.
461
 *
462
 * Returns: a new #GUnixSocketAddress
463
 *
464
 * Deprecated: Use g_unix_socket_address_new_with_type().
465
 */
466
GSocketAddress *
467
g_unix_socket_address_new_abstract (const gchar *path,
468
                                    gint         path_len)
469
0
{
470
0
  return g_unix_socket_address_new_with_type (path, path_len,
471
0
                                              G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED);
472
0
}
473
474
/**
475
 * g_unix_socket_address_new_with_type:
476
 * @path: (array length=path_len) (element-type gchar): the name
477
 * @path_len: the length of @path, or -1
478
 * @type: a #GUnixSocketAddressType
479
 *
480
 * Creates a new #GUnixSocketAddress of type @type with name @path.
481
 *
482
 * If @type is %G_UNIX_SOCKET_ADDRESS_PATH, this is equivalent to
483
 * calling g_unix_socket_address_new().
484
 *
485
 * If @type is %G_UNIX_SOCKET_ADDRESS_ANONYMOUS, @path and @path_len will be
486
 * ignored.
487
 *
488
 * If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT, then @path_len
489
 * bytes of @path will be copied to the socket's path, and only those
490
 * bytes will be considered part of the name. (If @path_len is -1,
491
 * then @path is assumed to be NUL-terminated.) For example, if @path
492
 * was "test", then calling g_socket_address_get_native_size() on the
493
 * returned socket would return 7 (2 bytes of overhead, 1 byte for the
494
 * abstract-socket indicator byte, and 4 bytes for the name "test").
495
 *
496
 * If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, then
497
 * @path_len bytes of @path will be copied to the socket's path, the
498
 * rest of the path will be padded with 0 bytes, and the entire
499
 * zero-padded buffer will be considered the name. (As above, if
500
 * @path_len is -1, then @path is assumed to be NUL-terminated.) In
501
 * this case, g_socket_address_get_native_size() will always return
502
 * the full size of a `struct sockaddr_un`, although
503
 * g_unix_socket_address_get_path_len() will still return just the
504
 * length of @path.
505
 *
506
 * %G_UNIX_SOCKET_ADDRESS_ABSTRACT is preferred over
507
 * %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED for new programs. Of course,
508
 * when connecting to a server created by another process, you must
509
 * use the appropriate type corresponding to how that process created
510
 * its listening socket.
511
 *
512
 * Returns: a new #GUnixSocketAddress
513
 *
514
 * Since: 2.26
515
 */
516
GSocketAddress *
517
g_unix_socket_address_new_with_type (const gchar            *path,
518
                                     gint                    path_len,
519
                                     GUnixSocketAddressType  type)
520
0
{
521
0
  GSocketAddress *address;
522
0
  GByteArray *array;
523
0
  size_t path_len_unsigned;
524
525
0
  if (type == G_UNIX_SOCKET_ADDRESS_ANONYMOUS)
526
0
    path_len_unsigned = 0;
527
0
  else if (path_len < 0)
528
0
    path_len_unsigned = strlen (path);
529
0
  else
530
0
    path_len_unsigned = (size_t) path_len;
531
532
  /* The code below can’t handle anything longer. */
533
0
  g_return_val_if_fail (path_len_unsigned <= G_MAXUINT, NULL);
534
535
0
  array = g_byte_array_sized_new (path_len_unsigned);
536
537
0
  g_byte_array_append (array, (guint8 *)path, path_len_unsigned);
538
539
0
  address = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
540
0
                          "path-as-array", array,
541
0
                          "address-type", type,
542
0
                          NULL);
543
544
0
  g_byte_array_unref (array);
545
546
0
  return address;
547
0
}
548
549
/**
550
 * g_unix_socket_address_get_path:
551
 * @address: a #GInetSocketAddress
552
 *
553
 * Gets @address's path, or for abstract sockets the "name".
554
 *
555
 * Guaranteed to be zero-terminated, but an abstract socket
556
 * may contain embedded zeros, and thus you should use
557
 * g_unix_socket_address_get_path_len() to get the true length
558
 * of this string.
559
 *
560
 * Returns: the path for @address
561
 *
562
 * Since: 2.22
563
 */
564
const char *
565
g_unix_socket_address_get_path (GUnixSocketAddress *address)
566
0
{
567
0
  return address->priv->path;
568
0
}
569
570
/**
571
 * g_unix_socket_address_get_path_len:
572
 * @address: a #GInetSocketAddress
573
 *
574
 * Gets the length of @address's path.
575
 *
576
 * For details, see g_unix_socket_address_get_path().
577
 *
578
 * Returns: the length of the path
579
 *
580
 * Since: 2.22
581
 */
582
gsize
583
g_unix_socket_address_get_path_len (GUnixSocketAddress *address)
584
0
{
585
0
  return address->priv->path_len;
586
0
}
587
588
/**
589
 * g_unix_socket_address_get_address_type:
590
 * @address: a #GInetSocketAddress
591
 *
592
 * Gets @address's type.
593
 *
594
 * Returns: a #GUnixSocketAddressType
595
 *
596
 * Since: 2.26
597
 */
598
GUnixSocketAddressType
599
g_unix_socket_address_get_address_type (GUnixSocketAddress *address)
600
0
{
601
0
  return address->priv->address_type;
602
0
}
603
604
/**
605
 * g_unix_socket_address_get_is_abstract:
606
 * @address: a #GInetSocketAddress
607
 *
608
 * Tests if @address is abstract.
609
 *
610
 * Returns: %TRUE if the address is abstract, %FALSE otherwise
611
 *
612
 * Since: 2.22
613
 *
614
 * Deprecated: Use g_unix_socket_address_get_address_type()
615
 */
616
gboolean
617
g_unix_socket_address_get_is_abstract (GUnixSocketAddress *address)
618
0
{
619
0
  return (address->priv->address_type == G_UNIX_SOCKET_ADDRESS_ABSTRACT ||
620
0
          address->priv->address_type == G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED);
621
0
}
622
623
/**
624
 * g_unix_socket_address_abstract_names_supported:
625
 *
626
 * Checks if abstract UNIX domain socket names are supported.
627
 *
628
 * Returns: %TRUE if supported, %FALSE otherwise
629
 *
630
 * Since: 2.22
631
 */
632
gboolean
633
g_unix_socket_address_abstract_names_supported (void)
634
0
{
635
0
#ifdef __linux__
636
0
  return TRUE;
637
#else
638
  return FALSE;
639
#endif
640
0
}