mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
gdbus: support unix:dir= addresses
unix:dir= addresses are exactly the same as unix:tmpdir= addresses, already supported by GDBus, except they forbid use of abstract sockets. This is convenient for situations where abstract sockets are impermissible, such as when a D-Bus client inside a network namespace needs to connect to a server running in a different network namespace. An abstract socket cannot be shared between two processes in different network namespaces. Applications could use unix:path= addresses instead, so this is only a convenience, but there's no good reason not to support unix:dir=. Currently it is not supported simply because unix:dir= is a relatively recent addition to the D-Bus spec.
This commit is contained in:
@@ -127,12 +127,14 @@ is_valid_unix (const gchar *address_entry,
|
||||
GList *keys;
|
||||
GList *l;
|
||||
const gchar *path;
|
||||
const gchar *dir;
|
||||
const gchar *tmpdir;
|
||||
const gchar *abstract;
|
||||
|
||||
ret = FALSE;
|
||||
keys = NULL;
|
||||
path = NULL;
|
||||
dir = NULL;
|
||||
tmpdir = NULL;
|
||||
abstract = NULL;
|
||||
|
||||
@@ -142,6 +144,8 @@ is_valid_unix (const gchar *address_entry,
|
||||
const gchar *key = l->data;
|
||||
if (g_strcmp0 (key, "path") == 0)
|
||||
path = g_hash_table_lookup (key_value_pairs, key);
|
||||
else if (g_strcmp0 (key, "dir") == 0)
|
||||
dir = g_hash_table_lookup (key_value_pairs, key);
|
||||
else if (g_strcmp0 (key, "tmpdir") == 0)
|
||||
tmpdir = g_hash_table_lookup (key_value_pairs, key);
|
||||
else if (g_strcmp0 (key, "abstract") == 0)
|
||||
@@ -158,9 +162,8 @@ is_valid_unix (const gchar *address_entry,
|
||||
}
|
||||
}
|
||||
|
||||
if ((path != NULL && tmpdir != NULL) ||
|
||||
(tmpdir != NULL && abstract != NULL) ||
|
||||
(abstract != NULL && path != NULL))
|
||||
/* Exactly one key must be set */
|
||||
if ((path != NULL) + (dir != NULL) + (tmpdir != NULL) + (abstract != NULL) > 1)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
@@ -169,12 +172,12 @@ is_valid_unix (const gchar *address_entry,
|
||||
address_entry);
|
||||
goto out;
|
||||
}
|
||||
else if (path == NULL && tmpdir == NULL && abstract == NULL)
|
||||
else if (path == NULL && dir == NULL && tmpdir == NULL && abstract == NULL)
|
||||
{
|
||||
g_set_error (error,
|
||||
G_IO_ERROR,
|
||||
G_IO_ERROR_INVALID_ARGUMENT,
|
||||
_("Address “%s” is invalid (need exactly one of path, tmpdir or abstract keys)"),
|
||||
_("Address “%s” is invalid (need exactly one of path, dir, tmpdir, or abstract keys)"),
|
||||
address_entry);
|
||||
goto out;
|
||||
}
|
||||
|
Reference in New Issue
Block a user