mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Bug 619142 – Build fixes
- Fix various #include issues - Change #error to #warning for the EXTERNAL authentication mechanism. It is not clear if this should work on Win32 at all. - Call close() before unlink() for the SHA1 keyring - Change #error to #warning so we don't forget to do permission checking of the .dbus-keyrings directory - Use Win32 SID for the SHA1 auth mech - Apparently we can't use word 'interface' as an identifier - Implement a _g_dbus_win32_get_user_sid() function. For now it's private. Don't know if it should be public somewhere. Maybe in a future GCredentials support for Win32? I don't know. - GFileDescriptorBased is not available on Win32. So avoid using it in GLocalFile stuff. Now, Win32 still uses GLocalFile + friends (which works with file descriptors) so expose a private function to get the fd for an OutputStream so things still work. - Fixup gio.symbols - Fixup tests/gdbus-peer.c so it builds With this, at least things compile and the gdbus-peer.exe test case passes. Which is a great start. I've tested this by cross-compiling on a x86_64 Fedora 13 host using mingw32 and running the code on a 32-bit Windows 7 box. https://bugzilla.gnome.org/show_bug.cgi?id=619142 Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
parent
152448cb29
commit
366b3ffcde
@ -25,10 +25,16 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "gioerror.h"
|
||||||
#include "gdbusutils.h"
|
#include "gdbusutils.h"
|
||||||
#include "gdbusaddress.h"
|
#include "gdbusaddress.h"
|
||||||
#include "gdbuserror.h"
|
#include "gdbuserror.h"
|
||||||
#include "gioenumtypes.h"
|
#include "gioenumtypes.h"
|
||||||
|
#include "gnetworkaddress.h"
|
||||||
|
#include "gsocketclient.h"
|
||||||
|
#include "giostream.h"
|
||||||
|
#include "gasyncresult.h"
|
||||||
|
#include "gsimpleasyncresult.h"
|
||||||
#include "gdbusprivate.h"
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
|
@ -22,9 +22,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include "gdbusauth.h"
|
#include "gdbusauth.h"
|
||||||
|
|
||||||
#include "gdbusauthmechanismanon.h"
|
#include "gdbusauthmechanismanon.h"
|
||||||
@ -37,8 +34,13 @@
|
|||||||
#include "gioenumtypes.h"
|
#include "gioenumtypes.h"
|
||||||
#include "gcredentials.h"
|
#include "gcredentials.h"
|
||||||
#include "gdbusprivate.h"
|
#include "gdbusprivate.h"
|
||||||
|
#include "giostream.h"
|
||||||
|
#include "gdatainputstream.h"
|
||||||
|
#include "gdataoutputstream.h"
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include "gunixconnection.h"
|
#include "gunixconnection.h"
|
||||||
#include "gunixcredentialsmessage.h"
|
#include "gunixcredentialsmessage.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -352,9 +352,7 @@ mechanism_client_initiate (GDBusAuthMechanism *mechanism,
|
|||||||
#if defined(G_OS_UNIX)
|
#if defined(G_OS_UNIX)
|
||||||
initial_response = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64) g_credentials_get_unix_user (credentials, NULL));
|
initial_response = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64) g_credentials_get_unix_user (credentials, NULL));
|
||||||
#elif defined(G_OS_WIN32)
|
#elif defined(G_OS_WIN32)
|
||||||
initial_response = g_strdup_printf ("%s", g_credentials_get_windows_user ());
|
#warning Dont know how to send credentials on this OS. The EXTERNAL D-Bus authentication mechanism will not work.
|
||||||
#else
|
|
||||||
#warning Dont know how to send credentials on this OS. Please implement.
|
|
||||||
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
|
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
|
||||||
#endif
|
#endif
|
||||||
return initial_response;
|
return initial_response;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "gdbuserror.h"
|
#include "gdbuserror.h"
|
||||||
#include "gioenumtypes.h"
|
#include "gioenumtypes.h"
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
|
#include "gdbusprivate.h"
|
||||||
|
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
@ -280,7 +281,7 @@ ensure_keyring_directory (GError **error)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#error Please implement permission checking on non-UNIX platforms
|
#warning Please implement permission checking on this non-UNIX platform
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
@ -583,16 +584,6 @@ keyring_release_lock (const gchar *path,
|
|||||||
|
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
lock = g_strdup_printf ("%s.lock", path);
|
lock = g_strdup_printf ("%s.lock", path);
|
||||||
if (g_unlink (lock) != 0)
|
|
||||||
{
|
|
||||||
g_set_error (error,
|
|
||||||
G_IO_ERROR,
|
|
||||||
g_io_error_from_errno (errno),
|
|
||||||
_("Error unlinking lock-file `%s': %s"),
|
|
||||||
lock,
|
|
||||||
strerror (errno));
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (close (lock_fd) != 0)
|
if (close (lock_fd) != 0)
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -603,6 +594,16 @@ keyring_release_lock (const gchar *path,
|
|||||||
strerror (errno));
|
strerror (errno));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if (g_unlink (lock) != 0)
|
||||||
|
{
|
||||||
|
g_set_error (error,
|
||||||
|
G_IO_ERROR,
|
||||||
|
g_io_error_from_errno (errno),
|
||||||
|
_("Error unlinking lock-file `%s': %s"),
|
||||||
|
lock,
|
||||||
|
strerror (errno));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
@ -953,11 +954,11 @@ mechanism_server_initiate (GDBusAuthMechanism *mechanism,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(G_OS_WIN32)
|
#elif defined(G_OS_WIN32)
|
||||||
GCredentials *credentials;
|
gchar *sid;
|
||||||
credentials = g_credentials_new_for_process ();
|
sid = _g_dbus_win32_get_user_sid ();
|
||||||
if (g_strcmp0 (g_credentials_get_windows_user (credentials), initial_response) == 0)
|
if (g_strcmp0 (initial_response, sid) == 0)
|
||||||
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_HAVE_DATA_TO_SEND;
|
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_HAVE_DATA_TO_SEND;
|
||||||
g_object_unref (credentials);
|
g_free (sid);
|
||||||
#else
|
#else
|
||||||
#error Please implement for your OS
|
#error Please implement for your OS
|
||||||
#endif
|
#endif
|
||||||
@ -1109,13 +1110,9 @@ mechanism_client_initiate (GDBusAuthMechanism *mechanism,
|
|||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
initial_response = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64) getuid ());
|
initial_response = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64) getuid ());
|
||||||
#elif defined (G_OS_WIN32)
|
#elif defined (G_OS_WIN32)
|
||||||
{
|
initial_response = _g_dbus_win32_get_user_sid ();
|
||||||
GCredentials *credentials;
|
|
||||||
credentials = g_credentials_new_for_process ();
|
|
||||||
initial_response = g_strdup (g_credentials_get_windows_user (credentials));
|
|
||||||
g_object_unref (credentials);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
|
#error Please implement for your OS
|
||||||
#endif
|
#endif
|
||||||
g_assert (initial_response != NULL);
|
g_assert (initial_response != NULL);
|
||||||
|
|
||||||
|
@ -1815,6 +1815,7 @@ initable_init (GInitable *initable,
|
|||||||
|
|
||||||
//g_debug ("haz unix fd passing powers: %d", connection->priv->capabilities & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
|
//g_debug ("haz unix fd passing powers: %d", connection->priv->capabilities & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
/* Hack used until
|
/* Hack used until
|
||||||
*
|
*
|
||||||
* https://bugzilla.gnome.org/show_bug.cgi?id=616458
|
* https://bugzilla.gnome.org/show_bug.cgi?id=616458
|
||||||
@ -1825,6 +1826,7 @@ initable_init (GInitable *initable,
|
|||||||
{
|
{
|
||||||
g_socket_set_blocking (g_socket_connection_get_socket (G_SOCKET_CONNECTION (connection->priv->stream)), FALSE);
|
g_socket_set_blocking (g_socket_connection_get_socket (G_SOCKET_CONNECTION (connection->priv->stream)), FALSE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
connection->priv->worker = _g_dbus_worker_new (connection->priv->stream,
|
connection->priv->worker = _g_dbus_worker_new (connection->priv->stream,
|
||||||
connection->priv->capabilities,
|
connection->priv->capabilities,
|
||||||
|
@ -134,7 +134,7 @@ g_dbus_message_new (void)
|
|||||||
* g_dbus_message_new_method_call:
|
* g_dbus_message_new_method_call:
|
||||||
* @name: A valid D-Bus name or %NULL.
|
* @name: A valid D-Bus name or %NULL.
|
||||||
* @path: A valid object path.
|
* @path: A valid object path.
|
||||||
* @interface: A valid D-Bus interface name or %NULL.
|
* @interface_: A valid D-Bus interface name or %NULL.
|
||||||
* @method: A valid method name.
|
* @method: A valid method name.
|
||||||
*
|
*
|
||||||
* Creates a new #GDBusMessage for a method call.
|
* Creates a new #GDBusMessage for a method call.
|
||||||
@ -146,7 +146,7 @@ g_dbus_message_new (void)
|
|||||||
GDBusMessage *
|
GDBusMessage *
|
||||||
g_dbus_message_new_method_call (const gchar *name,
|
g_dbus_message_new_method_call (const gchar *name,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *interface,
|
const gchar *interface_,
|
||||||
const gchar *method)
|
const gchar *method)
|
||||||
{
|
{
|
||||||
GDBusMessage *message;
|
GDBusMessage *message;
|
||||||
@ -154,7 +154,7 @@ g_dbus_message_new_method_call (const gchar *name,
|
|||||||
g_return_val_if_fail (name == NULL || g_dbus_is_name (name), NULL);
|
g_return_val_if_fail (name == NULL || g_dbus_is_name (name), NULL);
|
||||||
g_return_val_if_fail (g_variant_is_object_path (path), NULL);
|
g_return_val_if_fail (g_variant_is_object_path (path), NULL);
|
||||||
g_return_val_if_fail (g_dbus_is_member_name (method), NULL);
|
g_return_val_if_fail (g_dbus_is_member_name (method), NULL);
|
||||||
g_return_val_if_fail (interface == NULL || g_dbus_is_interface_name (interface), NULL);
|
g_return_val_if_fail (interface_ == NULL || g_dbus_is_interface_name (interface_), NULL);
|
||||||
|
|
||||||
message = g_dbus_message_new ();
|
message = g_dbus_message_new ();
|
||||||
message->priv->type = G_DBUS_MESSAGE_TYPE_METHOD_CALL;
|
message->priv->type = G_DBUS_MESSAGE_TYPE_METHOD_CALL;
|
||||||
@ -163,8 +163,8 @@ g_dbus_message_new_method_call (const gchar *name,
|
|||||||
g_dbus_message_set_destination (message, name);
|
g_dbus_message_set_destination (message, name);
|
||||||
g_dbus_message_set_path (message, path);
|
g_dbus_message_set_path (message, path);
|
||||||
g_dbus_message_set_member (message, method);
|
g_dbus_message_set_member (message, method);
|
||||||
if (interface != NULL)
|
if (interface_ != NULL)
|
||||||
g_dbus_message_set_interface (message, interface);
|
g_dbus_message_set_interface (message, interface_);
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ g_dbus_message_new_method_call (const gchar *name,
|
|||||||
/**
|
/**
|
||||||
* g_dbus_message_new_signal:
|
* g_dbus_message_new_signal:
|
||||||
* @path: A valid object path.
|
* @path: A valid object path.
|
||||||
* @interface: A valid D-Bus interface name or %NULL.
|
* @interface_: A valid D-Bus interface name or %NULL.
|
||||||
* @signal: A valid signal name.
|
* @signal: A valid signal name.
|
||||||
*
|
*
|
||||||
* Creates a new #GDBusMessage for a signal emission.
|
* Creates a new #GDBusMessage for a signal emission.
|
||||||
@ -183,14 +183,14 @@ g_dbus_message_new_method_call (const gchar *name,
|
|||||||
*/
|
*/
|
||||||
GDBusMessage *
|
GDBusMessage *
|
||||||
g_dbus_message_new_signal (const gchar *path,
|
g_dbus_message_new_signal (const gchar *path,
|
||||||
const gchar *interface,
|
const gchar *interface_,
|
||||||
const gchar *signal)
|
const gchar *signal)
|
||||||
{
|
{
|
||||||
GDBusMessage *message;
|
GDBusMessage *message;
|
||||||
|
|
||||||
g_return_val_if_fail (g_variant_is_object_path (path), NULL);
|
g_return_val_if_fail (g_variant_is_object_path (path), NULL);
|
||||||
g_return_val_if_fail (g_dbus_is_member_name (signal), NULL);
|
g_return_val_if_fail (g_dbus_is_member_name (signal), NULL);
|
||||||
g_return_val_if_fail (interface == NULL || g_dbus_is_interface_name (interface), NULL);
|
g_return_val_if_fail (interface_ == NULL || g_dbus_is_interface_name (interface_), NULL);
|
||||||
|
|
||||||
message = g_dbus_message_new ();
|
message = g_dbus_message_new ();
|
||||||
message->priv->type = G_DBUS_MESSAGE_TYPE_SIGNAL;
|
message->priv->type = G_DBUS_MESSAGE_TYPE_SIGNAL;
|
||||||
@ -199,8 +199,8 @@ g_dbus_message_new_signal (const gchar *path,
|
|||||||
g_dbus_message_set_path (message, path);
|
g_dbus_message_set_path (message, path);
|
||||||
g_dbus_message_set_member (message, signal);
|
g_dbus_message_set_member (message, signal);
|
||||||
|
|
||||||
if (interface != NULL)
|
if (interface_ != NULL)
|
||||||
g_dbus_message_set_interface (message, interface);
|
g_dbus_message_set_interface (message, interface_);
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,11 @@ struct _GDBusMessage
|
|||||||
GType g_dbus_message_get_type (void) G_GNUC_CONST;
|
GType g_dbus_message_get_type (void) G_GNUC_CONST;
|
||||||
GDBusMessage *g_dbus_message_new (void);
|
GDBusMessage *g_dbus_message_new (void);
|
||||||
GDBusMessage *g_dbus_message_new_signal (const gchar *path,
|
GDBusMessage *g_dbus_message_new_signal (const gchar *path,
|
||||||
const gchar *interface,
|
const gchar *interface_,
|
||||||
const gchar *signal);
|
const gchar *signal);
|
||||||
GDBusMessage *g_dbus_message_new_method_call (const gchar *name,
|
GDBusMessage *g_dbus_message_new_method_call (const gchar *name,
|
||||||
const gchar *path,
|
const gchar *path,
|
||||||
const gchar *interface,
|
const gchar *interface_,
|
||||||
const gchar *method);
|
const gchar *method);
|
||||||
GDBusMessage *g_dbus_message_new_method_reply (GDBusMessage *method_call_message);
|
GDBusMessage *g_dbus_message_new_method_reply (GDBusMessage *method_call_message);
|
||||||
GDBusMessage *g_dbus_message_new_method_error (GDBusMessage *method_call_message,
|
GDBusMessage *g_dbus_message_new_method_error (GDBusMessage *method_call_message,
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "ginputstream.h"
|
#include "ginputstream.h"
|
||||||
#include "giostream.h"
|
#include "giostream.h"
|
||||||
#include "gsocketcontrolmessage.h"
|
#include "gsocketcontrolmessage.h"
|
||||||
|
#include "gsocketconnection.h"
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
#include "gunixfdmessage.h"
|
#include "gunixfdmessage.h"
|
||||||
@ -46,6 +47,10 @@
|
|||||||
#include "gunixcredentialsmessage.h"
|
#include "gunixcredentialsmessage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
|
|
||||||
@ -588,11 +593,13 @@ _g_dbus_worker_do_read_cb (GInputStream *input_stream,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
if (worker->read_fd_list != NULL)
|
if (worker->read_fd_list != NULL)
|
||||||
{
|
{
|
||||||
g_dbus_message_set_unix_fd_list (message, worker->read_fd_list);
|
g_dbus_message_set_unix_fd_list (message, worker->read_fd_list);
|
||||||
worker->read_fd_list = NULL;
|
worker->read_fd_list = NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (G_UNLIKELY (_g_dbus_debug_message ()))
|
if (G_UNLIKELY (_g_dbus_debug_message ()))
|
||||||
{
|
{
|
||||||
@ -1049,5 +1056,74 @@ _g_dbus_compute_complete_signature (GDBusArgInfo **args,
|
|||||||
return g_string_free (s, FALSE);
|
return g_string_free (s, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
|
||||||
|
extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid);
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
_g_dbus_win32_get_user_sid (void)
|
||||||
|
{
|
||||||
|
HANDLE h;
|
||||||
|
TOKEN_USER *user;
|
||||||
|
DWORD token_information_len;
|
||||||
|
PSID psid;
|
||||||
|
gchar *sid;
|
||||||
|
gchar *ret;
|
||||||
|
|
||||||
|
ret = NULL;
|
||||||
|
user = NULL;
|
||||||
|
h = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
|
if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &h))
|
||||||
|
{
|
||||||
|
g_warning ("OpenProcessToken failed with error code %d", (gint) GetLastError ());
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get length of buffer */
|
||||||
|
token_information_len = 0;
|
||||||
|
if (!GetTokenInformation (h, TokenUser, NULL, 0, &token_information_len))
|
||||||
|
{
|
||||||
|
if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
|
||||||
|
{
|
||||||
|
g_warning ("GetTokenInformation() failed with error code %d", (gint) GetLastError ());
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
user = g_malloc (token_information_len);
|
||||||
|
if (!GetTokenInformation (h, TokenUser, user, token_information_len, &token_information_len))
|
||||||
|
{
|
||||||
|
g_warning ("GetTokenInformation() failed with error code %d", (gint) GetLastError ());
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
psid = user->User.Sid;
|
||||||
|
if (!IsValidSid (psid))
|
||||||
|
{
|
||||||
|
g_warning ("Invalid SID");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConvertSidToStringSidA (psid, &sid))
|
||||||
|
{
|
||||||
|
g_warning ("Invalid SID");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = g_strdup (sid);
|
||||||
|
LocalFree (sid);
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_free (user);
|
||||||
|
if (h != INVALID_HANDLE_VALUE)
|
||||||
|
CloseHandle (h);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define __G_DBUS_PRIVATE_C__
|
#define __G_DBUS_PRIVATE_C__
|
||||||
#include "gioaliasdef.c"
|
#include "gioaliasdef.c"
|
||||||
|
@ -78,6 +78,10 @@ gchar * _g_dbus_compute_complete_signature (GDBusArgInfo **args,
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
gchar *_g_dbus_win32_get_user_sid (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __G_DBUS_PRIVATE_H__ */
|
#endif /* __G_DBUS_PRIVATE_H__ */
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "giotypes.h"
|
#include "giotypes.h"
|
||||||
|
#include "gioerror.h"
|
||||||
#include "gdbusaddress.h"
|
#include "gdbusaddress.h"
|
||||||
#include "gdbusutils.h"
|
#include "gdbusutils.h"
|
||||||
#include "gdbusconnection.h"
|
#include "gdbusconnection.h"
|
||||||
@ -40,6 +41,12 @@
|
|||||||
#include "gio-marshal.h"
|
#include "gio-marshal.h"
|
||||||
#include "ginitable.h"
|
#include "ginitable.h"
|
||||||
#include "gsocketservice.h"
|
#include "gsocketservice.h"
|
||||||
|
#include "gthreadedsocketservice.h"
|
||||||
|
#include "gresolver.h"
|
||||||
|
#include "ginetaddress.h"
|
||||||
|
#include "ginetsocketaddress.h"
|
||||||
|
#include "ginputstream.h"
|
||||||
|
#include "giostream.h"
|
||||||
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
#include "gunixsocketaddress.h"
|
#include "gunixsocketaddress.h"
|
||||||
|
@ -1390,10 +1390,12 @@ g_zlib_decompressor_new
|
|||||||
|
|
||||||
#if IN_HEADER(__G_FILE_DESCRIPTOR_BASED_H__)
|
#if IN_HEADER(__G_FILE_DESCRIPTOR_BASED_H__)
|
||||||
#if IN_FILE(__G_FILE_DESCRIPTOR_BASED_C__)
|
#if IN_FILE(__G_FILE_DESCRIPTOR_BASED_C__)
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
g_file_descriptor_based_get_type G_GNUC_CONST
|
g_file_descriptor_based_get_type G_GNUC_CONST
|
||||||
g_file_descriptor_based_get_fd
|
g_file_descriptor_based_get_fd
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if IN_HEADER(__G_SETTINGS_BACKEND_H__)
|
#if IN_HEADER(__G_SETTINGS_BACKEND_H__)
|
||||||
#if IN_FILE(__G_KEYFILE_SETTINGS_BACKEND_C__)
|
#if IN_FILE(__G_KEYFILE_SETTINGS_BACKEND_C__)
|
||||||
@ -1455,10 +1457,12 @@ g_credentials_to_string
|
|||||||
g_credentials_get_native
|
g_credentials_get_native
|
||||||
g_credentials_set_native
|
g_credentials_set_native
|
||||||
g_credentials_is_same_user
|
g_credentials_is_same_user
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
g_credentials_get_unix_user
|
g_credentials_get_unix_user
|
||||||
g_credentials_set_unix_user
|
g_credentials_set_unix_user
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if IN_HEADER(__G_DBUS_ADDRESS_H__)
|
#if IN_HEADER(__G_DBUS_ADDRESS_H__)
|
||||||
#if IN_FILE(__G_DBUS_ADDRESS_C__)
|
#if IN_FILE(__G_DBUS_ADDRESS_C__)
|
||||||
@ -1597,7 +1601,6 @@ g_dbus_message_get_sender
|
|||||||
g_dbus_message_get_serial
|
g_dbus_message_get_serial
|
||||||
g_dbus_message_get_signature
|
g_dbus_message_get_signature
|
||||||
g_dbus_message_get_message_type
|
g_dbus_message_get_message_type
|
||||||
g_dbus_message_get_unix_fd_list
|
|
||||||
g_dbus_message_print
|
g_dbus_message_print
|
||||||
g_dbus_message_set_body
|
g_dbus_message_set_body
|
||||||
g_dbus_message_set_destination
|
g_dbus_message_set_destination
|
||||||
@ -1613,9 +1616,12 @@ g_dbus_message_set_sender
|
|||||||
g_dbus_message_set_serial
|
g_dbus_message_set_serial
|
||||||
g_dbus_message_set_signature
|
g_dbus_message_set_signature
|
||||||
g_dbus_message_set_message_type
|
g_dbus_message_set_message_type
|
||||||
g_dbus_message_set_unix_fd_list
|
|
||||||
g_dbus_message_to_blob
|
g_dbus_message_to_blob
|
||||||
g_dbus_message_to_gerror
|
g_dbus_message_to_gerror
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
g_dbus_message_get_unix_fd_list
|
||||||
|
g_dbus_message_set_unix_fd_list
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1715,6 +1721,7 @@ g_dbus_is_unique_name
|
|||||||
|
|
||||||
#if IN_HEADER(__G_UNIX_CREDENTIALS_MESSAGE_H__)
|
#if IN_HEADER(__G_UNIX_CREDENTIALS_MESSAGE_H__)
|
||||||
#if IN_FILE(__G_UNIX_CREDENTIALS_MESSAGE_C__)
|
#if IN_FILE(__G_UNIX_CREDENTIALS_MESSAGE_C__)
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
g_unix_credentials_message_get_type G_GNUC_CONST
|
g_unix_credentials_message_get_type G_GNUC_CONST
|
||||||
g_unix_credentials_message_new
|
g_unix_credentials_message_new
|
||||||
g_unix_credentials_message_new_with_credentials
|
g_unix_credentials_message_new_with_credentials
|
||||||
@ -1722,3 +1729,4 @@ g_unix_credentials_message_get_credentials
|
|||||||
g_unix_credentials_message_is_supported
|
g_unix_credentials_message_is_supported
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -33,12 +33,15 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
#include "gfiledescriptorbased.h"
|
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
#include "glocalfileinputstream.h"
|
#include "glocalfileinputstream.h"
|
||||||
#include "glocalfileinfo.h"
|
#include "glocalfileinfo.h"
|
||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
#include "gfiledescriptorbased.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
@ -46,11 +49,17 @@
|
|||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static void g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
static void g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define g_local_file_input_stream_get_type _g_local_file_input_stream_get_type
|
#define g_local_file_input_stream_get_type _g_local_file_input_stream_get_type
|
||||||
G_DEFINE_TYPE_WITH_CODE (GLocalFileInputStream, g_local_file_input_stream, G_TYPE_FILE_INPUT_STREAM,
|
G_DEFINE_TYPE_WITH_CODE (GLocalFileInputStream, g_local_file_input_stream, G_TYPE_FILE_INPUT_STREAM,
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
||||||
g_file_descriptor_based_iface_init));
|
g_file_descriptor_based_iface_init)
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
struct _GLocalFileInputStreamPrivate {
|
struct _GLocalFileInputStreamPrivate {
|
||||||
int fd;
|
int fd;
|
||||||
@ -80,7 +89,9 @@ static GFileInfo *g_local_file_input_stream_query_info (GFileInputStream *strea
|
|||||||
const char *attributes,
|
const char *attributes,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static int g_local_file_input_stream_get_fd (GFileDescriptorBased *stream);
|
static int g_local_file_input_stream_get_fd (GFileDescriptorBased *stream);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_local_file_input_stream_finalize (GObject *object)
|
g_local_file_input_stream_finalize (GObject *object)
|
||||||
@ -115,11 +126,13 @@ g_local_file_input_stream_class_init (GLocalFileInputStreamClass *klass)
|
|||||||
file_stream_class->query_info = g_local_file_input_stream_query_info;
|
file_stream_class->query_info = g_local_file_input_stream_query_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static void
|
static void
|
||||||
g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||||
{
|
{
|
||||||
iface->get_fd = g_local_file_input_stream_get_fd;
|
iface->get_fd = g_local_file_input_stream_get_fd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_local_file_input_stream_init (GLocalFileInputStream *info)
|
g_local_file_input_stream_init (GLocalFileInputStream *info)
|
||||||
@ -349,10 +362,11 @@ g_local_file_input_stream_query_info (GFileInputStream *stream,
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static int
|
static int
|
||||||
g_local_file_input_stream_get_fd (GFileDescriptorBased *fd_based)
|
g_local_file_input_stream_get_fd (GFileDescriptorBased *fd_based)
|
||||||
{
|
{
|
||||||
GLocalFileInputStream *stream = G_LOCAL_FILE_INPUT_STREAM (fd_based);
|
GLocalFileInputStream *stream = G_LOCAL_FILE_INPUT_STREAM (fd_based);
|
||||||
return stream->priv->fd;
|
return stream->priv->fd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -27,11 +27,14 @@
|
|||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
#include "gfiledescriptorbased.h"
|
|
||||||
#include "glocalfileiostream.h"
|
#include "glocalfileiostream.h"
|
||||||
#include "glocalfileinputstream.h"
|
#include "glocalfileinputstream.h"
|
||||||
#include "glocalfileinfo.h"
|
#include "glocalfileinfo.h"
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
#include "gfiledescriptorbased.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
|
|
||||||
#define g_local_file_io_stream_get_type _g_local_file_io_stream_get_type
|
#define g_local_file_io_stream_get_type _g_local_file_io_stream_get_type
|
||||||
@ -59,8 +62,9 @@ _g_local_file_io_stream_new (GLocalFileOutputStream *output_stream)
|
|||||||
stream = g_object_new (G_TYPE_LOCAL_FILE_IO_STREAM, NULL);
|
stream = g_object_new (G_TYPE_LOCAL_FILE_IO_STREAM, NULL);
|
||||||
stream->output_stream = g_object_ref (output_stream);
|
stream->output_stream = g_object_ref (output_stream);
|
||||||
_g_local_file_output_stream_set_do_close (output_stream, FALSE);
|
_g_local_file_output_stream_set_do_close (output_stream, FALSE);
|
||||||
fd = g_file_descriptor_based_get_fd (G_FILE_DESCRIPTOR_BASED (output_stream));
|
fd = _g_local_file_output_stream_get_fd (output_stream);
|
||||||
stream->input_stream = (GInputStream *)_g_local_file_input_stream_new (fd);
|
stream->input_stream = (GInputStream *)_g_local_file_input_stream_new (fd);
|
||||||
|
|
||||||
_g_local_file_input_stream_set_do_close (G_LOCAL_FILE_INPUT_STREAM (stream->input_stream),
|
_g_local_file_input_stream_set_do_close (G_LOCAL_FILE_INPUT_STREAM (stream->input_stream),
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
|
@ -36,10 +36,13 @@
|
|||||||
#include "glibintl.h"
|
#include "glibintl.h"
|
||||||
#include "gioerror.h"
|
#include "gioerror.h"
|
||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
#include "gfiledescriptorbased.h"
|
|
||||||
#include "glocalfileoutputstream.h"
|
#include "glocalfileoutputstream.h"
|
||||||
#include "glocalfileinfo.h"
|
#include "glocalfileinfo.h"
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
|
#include "gfiledescriptorbased.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#ifndef S_ISDIR
|
#ifndef S_ISDIR
|
||||||
@ -56,11 +59,17 @@
|
|||||||
|
|
||||||
#include "gioalias.h"
|
#include "gioalias.h"
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static void g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
static void g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define g_local_file_output_stream_get_type _g_local_file_output_stream_get_type
|
#define g_local_file_output_stream_get_type _g_local_file_output_stream_get_type
|
||||||
G_DEFINE_TYPE_WITH_CODE (GLocalFileOutputStream, g_local_file_output_stream, G_TYPE_FILE_OUTPUT_STREAM,
|
G_DEFINE_TYPE_WITH_CODE (GLocalFileOutputStream, g_local_file_output_stream, G_TYPE_FILE_OUTPUT_STREAM,
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
G_IMPLEMENT_INTERFACE (G_TYPE_FILE_DESCRIPTOR_BASED,
|
||||||
g_file_descriptor_based_iface_init));
|
g_file_descriptor_based_iface_init)
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/* Some of the file replacement code was based on the code from gedit,
|
/* Some of the file replacement code was based on the code from gedit,
|
||||||
@ -104,7 +113,9 @@ static gboolean g_local_file_output_stream_truncate (GFileOutputStream *s
|
|||||||
goffset size,
|
goffset size,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static int g_local_file_output_stream_get_fd (GFileDescriptorBased *stream);
|
static int g_local_file_output_stream_get_fd (GFileDescriptorBased *stream);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_local_file_output_stream_finalize (GObject *object)
|
g_local_file_output_stream_finalize (GObject *object)
|
||||||
@ -144,11 +155,13 @@ g_local_file_output_stream_class_init (GLocalFileOutputStreamClass *klass)
|
|||||||
file_stream_class->truncate_fn = g_local_file_output_stream_truncate;
|
file_stream_class->truncate_fn = g_local_file_output_stream_truncate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static void
|
static void
|
||||||
g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
g_file_descriptor_based_iface_init (GFileDescriptorBasedIface *iface)
|
||||||
{
|
{
|
||||||
iface->get_fd = g_local_file_output_stream_get_fd;
|
iface->get_fd = g_local_file_output_stream_get_fd;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_local_file_output_stream_init (GLocalFileOutputStream *stream)
|
g_local_file_output_stream_init (GLocalFileOutputStream *stream)
|
||||||
@ -1159,11 +1172,18 @@ _g_local_file_output_stream_replace (const char *filename,
|
|||||||
return G_FILE_OUTPUT_STREAM (stream);
|
return G_FILE_OUTPUT_STREAM (stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
_g_local_file_output_stream_get_fd (GLocalFileOutputStream *stream)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (G_IS_LOCAL_FILE_OUTPUT_STREAM (stream), -1);
|
||||||
|
return stream->priv->fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
static int
|
static int
|
||||||
g_local_file_output_stream_get_fd (GFileDescriptorBased *fd_based)
|
g_local_file_output_stream_get_fd (GFileDescriptorBased *fd_based)
|
||||||
{
|
{
|
||||||
GLocalFileOutputStream *stream = G_LOCAL_FILE_OUTPUT_STREAM (fd_based);
|
GLocalFileOutputStream *stream = G_LOCAL_FILE_OUTPUT_STREAM (fd_based);
|
||||||
|
return _g_local_file_output_stream_get_fd (stream);
|
||||||
return stream->priv->fd;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@ -80,6 +80,12 @@ GFileOutputStream * _g_local_file_output_stream_replace (const char *file
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
/* Hack to get the fd since GFileDescriptorBased (which is how you
|
||||||
|
* _should_ get the fd) is only available on UNIX but things like
|
||||||
|
* win32 needs this as well
|
||||||
|
*/
|
||||||
|
gint _g_local_file_output_stream_get_fd (GLocalFileOutputStream *output_stream);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __G_LOCAL_FILE_OUTPUT_STREAM_H__ */
|
#endif /* __G_LOCAL_FILE_OUTPUT_STREAM_H__ */
|
||||||
|
@ -210,7 +210,7 @@ gdbus_export_LDADD = $(progs_ldadd)
|
|||||||
gdbus_error_SOURCES = gdbus-error.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
|
gdbus_error_SOURCES = gdbus-error.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
|
||||||
gdbus_error_LDADD = $(progs_ldadd)
|
gdbus_error_LDADD = $(progs_ldadd)
|
||||||
|
|
||||||
gdbus_peer_SOURCES = gdbus-peer.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
|
gdbus_peer_SOURCES = gdbus-peer.c gdbus-tests.h gdbus-tests.c
|
||||||
gdbus_peer_LDADD = $(progs_ldadd)
|
gdbus_peer_LDADD = $(progs_ldadd)
|
||||||
|
|
||||||
gdbus_exit_on_close_SOURCES = gdbus-exit-on-close.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
|
gdbus_exit_on_close_SOURCES = gdbus-exit-on-close.c gdbus-sessionbus.c gdbus-sessionbus.h gdbus-tests.h gdbus-tests.c
|
||||||
|
@ -126,6 +126,7 @@ test_interface_method_call (GDBusConnection *connection,
|
|||||||
}
|
}
|
||||||
else if (g_strcmp0 (method_name, "OpenFile") == 0)
|
else if (g_strcmp0 (method_name, "OpenFile") == 0)
|
||||||
{
|
{
|
||||||
|
#ifdef G_OS_UNIX
|
||||||
const gchar *path;
|
const gchar *path;
|
||||||
GDBusMessage *reply;
|
GDBusMessage *reply;
|
||||||
GError *error;
|
GError *error;
|
||||||
@ -154,6 +155,11 @@ test_interface_method_call (GDBusConnection *connection,
|
|||||||
&error);
|
&error);
|
||||||
g_assert_no_error (error);
|
g_assert_no_error (error);
|
||||||
g_object_unref (reply);
|
g_object_unref (reply);
|
||||||
|
#else
|
||||||
|
g_dbus_method_invocation_return_dbus_error (invocation,
|
||||||
|
"org.gtk.GDBus.NotOnUnix",
|
||||||
|
"Your OS does not support file descriptor passing");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -617,6 +623,18 @@ test_peer (void)
|
|||||||
g_assert_cmpstr (buf, ==, buf2);
|
g_assert_cmpstr (buf, ==, buf2);
|
||||||
g_free (buf2);
|
g_free (buf2);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
error = NULL;
|
||||||
|
result = g_dbus_proxy_call_sync (proxy,
|
||||||
|
"OpenFile",
|
||||||
|
g_variant_new ("(s)", "boo"),
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
-1,
|
||||||
|
NULL, /* GCancellable */
|
||||||
|
&error);
|
||||||
|
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR);
|
||||||
|
g_assert (result == NULL);
|
||||||
|
g_error_free (error);
|
||||||
#endif /* G_OS_UNIX */
|
#endif /* G_OS_UNIX */
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user