/* GDBus - GLib D-Bus Library
*
- * Copyright (C) 2008-2009 Red Hat, Inc.
+ * Copyright (C) 2008-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#include "config.h"
-#include <glib/gi18n.h>
+#include <string.h>
#include "gdbusauthmechanismexternal.h"
#include "gcredentials.h"
#include "gdbuserror.h"
#include "gioenumtypes.h"
-#ifdef G_OS_UNIX
-#include <sys/types.h>
-#include <unistd.h>
-#endif
+#include "glibintl.h"
struct _GDBusAuthMechanismExternalPrivate
{
/* ---------------------------------------------------------------------------------------------------- */
-G_DEFINE_TYPE (GDBusAuthMechanismExternal, _g_dbus_auth_mechanism_external, G_TYPE_DBUS_AUTH_MECHANISM);
+G_DEFINE_TYPE_WITH_PRIVATE (GDBusAuthMechanismExternal, _g_dbus_auth_mechanism_external, G_TYPE_DBUS_AUTH_MECHANISM)
/* ---------------------------------------------------------------------------------------------------- */
GObjectClass *gobject_class;
GDBusAuthMechanismClass *mechanism_class;
- g_type_class_add_private (klass, sizeof (GDBusAuthMechanismExternalPrivate));
-
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = _g_dbus_auth_mechanism_external_finalize;
static void
_g_dbus_auth_mechanism_external_init (GDBusAuthMechanismExternal *mechanism)
{
- mechanism->priv = G_TYPE_INSTANCE_GET_PRIVATE (mechanism,
- G_TYPE_DBUS_AUTH_MECHANISM_EXTERNAL,
- GDBusAuthMechanismExternalPrivate);
+ mechanism->priv = _g_dbus_auth_mechanism_external_get_instance_private (mechanism);
}
/* ---------------------------------------------------------------------------------------------------- */
alleged_uid = g_ascii_strtoll (data, &endp, 10);
if (*endp == '\0')
{
- if (g_credentials_has_unix_user (credentials) &&
- g_credentials_get_unix_user (credentials) == alleged_uid)
+ if (g_credentials_get_unix_user (credentials, NULL) == alleged_uid)
{
match = TRUE;
}
}
}
-#elif defined(G_OS_WIN32)
- {
- const gchar *alleged_sid;
-
- /* on Win32, this is the User SID */
- alleged_sid = data;
- if (g_credentials_has_windows_user (credentials) &&
- g_strcmp0 (g_credentials_get_windows_user (credentials), alleged_sid) == 0)
- {
- match = TRUE;
- }
- }
#else
-#error Dont know how to read credentials on this OS. Please implement.
+ /* TODO: Dont know how to compare credentials on this OS. Please implement. */
#endif
out:
gsize *out_initial_response_len)
{
GDBusAuthMechanismExternal *m = G_DBUS_AUTH_MECHANISM_EXTERNAL (mechanism);
- gchar *initial_response;
+ gchar *initial_response = NULL;
GCredentials *credentials;
g_return_val_if_fail (G_IS_DBUS_AUTH_MECHANISM_EXTERNAL (mechanism), NULL);
/* return the uid */
#if defined(G_OS_UNIX)
- initial_response = g_strdup_printf ("%" G_GINT64_FORMAT, g_credentials_get_unix_user (credentials));
+ initial_response = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64) g_credentials_get_unix_user (credentials, NULL));
#elif defined(G_OS_WIN32)
- initial_response = g_strdup_printf ("%s", g_credentials_get_windows_user ());
-#else
-#warning Dont know how to send credentials on this OS. Please implement.
+#ifdef __GNUC__
+#warning Dont know how to send credentials on this OS. The EXTERNAL D-Bus authentication mechanism will not work.
+#endif
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
#endif
return initial_response;