/* 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
#include "config.h"
#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef _WIN32
+#include <io.h>
+#endif
+
+#include <glib/gstdio.h>
#include "gdbusauthmechanismsha1.h"
#include "gcredentials.h"
#include "gdbuserror.h"
#include "gioenumtypes.h"
#include "gioerror.h"
-
-#ifdef G_OS_UNIX
-#include <unistd.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#endif
-
-#include <errno.h>
-
-#include <glib/gstdio.h>
+#include "gdbusprivate.h"
#include "glibintl.h"
goto out;
}
#else
-#error Please implement permission checking on non-UNIX platforms
+#ifdef __GNUC__
+#warning Please implement permission checking on this non-UNIX platform
+#endif
#endif
}
goto out;
guint n;
gchar **lines;
- g_return_val_if_fail (cookie_context != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ g_return_val_if_fail (cookie_context != NULL, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, NULL);
ret = NULL;
path = NULL;
num_tries++;
if (num_tries == 50)
{
- /* ok, we slept 50*10ms = 0.5 seconds.. Conclude that the lock-file must be
+ /* ok, we slept 50*10ms = 0.5 seconds. Conclude that the lock file must be
* stale (nuke the it from orbit)
*/
if (g_unlink (lock) != 0)
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error deleting stale lock-file `%s': %s"),
+ _("Error deleting stale lock file `%s': %s"),
lock,
strerror (errno));
goto out;
}
- _log ("Deleted stale lock-file `%s'", lock);
+ _log ("Deleted stale lock file `%s'", lock);
break;
}
}
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error creating lock-file `%s': %s"),
+ _("Error creating lock file `%s': %s"),
lock,
strerror (errno));
goto out;
ret = FALSE;
lock = g_strdup_printf ("%s.lock", path);
- if (g_unlink (lock) != 0)
+ if (close (lock_fd) != 0)
{
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error unlinking lock-file `%s': %s"),
+ _("Error closing (unlinked) lock file `%s': %s"),
lock,
strerror (errno));
goto out;
}
- if (close (lock_fd) != 0)
+ if (g_unlink (lock) != 0)
{
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error closing (unlinked) lock-file `%s': %s"),
+ _("Error unlinking lock file `%s': %s"),
lock,
strerror (errno));
goto out;
}
}
#elif defined(G_OS_WIN32)
- GCredentials *credentials;
- credentials = g_credentials_new_for_process ();
- if (g_strcmp0 (g_credentials_get_windows_user (credentials), initial_response) == 0)
+ gchar *sid;
+ sid = _g_dbus_win32_get_user_sid ();
+ if (g_strcmp0 (initial_response, sid) == 0)
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_HAVE_DATA_TO_SEND;
- g_object_unref (credentials);
+ g_free (sid);
#else
#error Please implement for your OS
#endif
#ifdef G_OS_UNIX
initial_response = g_strdup_printf ("%" G_GINT64_FORMAT, (gint64) getuid ());
#elif defined (G_OS_WIN32)
- {
- GCredentials *credentials;
- credentials = g_credentials_new_for_process ();
- initial_response = g_strdup (g_credentials_get_windows_user (credentials));
- g_object_unref (credentials);
- }
+initial_response = _g_dbus_win32_get_user_sid ();
#else
+#error Please implement for your OS
#endif
g_assert (initial_response != NULL);