projects
/
platform
/
upstream
/
glib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[kdbus] Fix problem with receiving async messages
[platform/upstream/glib.git]
/
gio
/
gdbusauthmechanismsha1.c
diff --git
a/gio/gdbusauthmechanismsha1.c
b/gio/gdbusauthmechanismsha1.c
index
badc108
..
0b9db7f
100644
(file)
--- a/
gio/gdbusauthmechanismsha1.c
+++ b/
gio/gdbusauthmechanismsha1.c
@@
-13,9
+13,7
@@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* 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>
*/
*
* Author: David Zeuthen <davidz@redhat.com>
*/
@@
-26,15
+24,16
@@
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
+
+#include <glib/gstdio.h>
+
+#ifdef G_OS_UNIX
#include <unistd.h>
#endif
#include <unistd.h>
#endif
-#ifdef _WIN32
+#ifdef
G_OS
_WIN32
#include <io.h>
#endif
#include <io.h>
#endif
-#include <glib/gstdio.h>
-
#include "gdbusauthmechanismsha1.h"
#include "gcredentials.h"
#include "gdbuserror.h"
#include "gdbusauthmechanismsha1.h"
#include "gcredentials.h"
#include "gdbuserror.h"
@@
-93,7
+92,7
@@
static void mechanism_client_shutdown (GDBusAuthMe
/* ---------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------- */
-G_DEFINE_TYPE
(GDBusAuthMechanismSha1, _g_dbus_auth_mechanism_sha1, G_TYPE_DBUS_AUTH_MECHANISM);
+G_DEFINE_TYPE
_WITH_PRIVATE (GDBusAuthMechanismSha1, _g_dbus_auth_mechanism_sha1, G_TYPE_DBUS_AUTH_MECHANISM)
/* ---------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------- */
@@
-117,8
+116,6
@@
_g_dbus_auth_mechanism_sha1_class_init (GDBusAuthMechanismSha1Class *klass)
GObjectClass *gobject_class;
GDBusAuthMechanismClass *mechanism_class;
GObjectClass *gobject_class;
GDBusAuthMechanismClass *mechanism_class;
- g_type_class_add_private (klass, sizeof (GDBusAuthMechanismSha1Private));
-
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = _g_dbus_auth_mechanism_sha1_finalize;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = _g_dbus_auth_mechanism_sha1_finalize;
@@
-144,9
+141,7
@@
_g_dbus_auth_mechanism_sha1_class_init (GDBusAuthMechanismSha1Class *klass)
static void
_g_dbus_auth_mechanism_sha1_init (GDBusAuthMechanismSha1 *mechanism)
{
static void
_g_dbus_auth_mechanism_sha1_init (GDBusAuthMechanismSha1 *mechanism)
{
- mechanism->priv = G_TYPE_INSTANCE_GET_PRIVATE (mechanism,
- G_TYPE_DBUS_AUTH_MECHANISM_SHA1,
- GDBusAuthMechanismSha1Private);
+ mechanism->priv = _g_dbus_auth_mechanism_sha1_get_instance_private (mechanism);
}
/* ---------------------------------------------------------------------------------------------------- */
}
/* ---------------------------------------------------------------------------------------------------- */
@@
-263,7
+258,7
@@
ensure_keyring_directory (GError **error)
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error
statting directory `
%s': %s"),
+ _("Error
when getting information for directory '
%s': %s"),
path,
strerror (errno));
g_free (path);
path,
strerror (errno));
g_free (path);
@@
-275,7
+270,7
@@
ensure_keyring_directory (GError **error)
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Permissions on directory
`
%s' are malformed. Expected mode 0700, got 0%o"),
+ _("Permissions on directory
'
%s' are malformed. Expected mode 0700, got 0%o"),
path,
statbuf.st_mode & 0777);
g_free (path);
path,
statbuf.st_mode & 0777);
g_free (path);
@@
-296,7
+291,7
@@
ensure_keyring_directory (GError **error)
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error creating directory
`
%s': %s"),
+ _("Error creating directory
'
%s': %s"),
path,
strerror (errno));
g_free (path);
path,
strerror (errno));
g_free (path);
@@
-359,8
+354,8
@@
keyring_lookup_entry (const gchar *cookie_context,
guint n;
gchar **lines;
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;
ret = NULL;
path = NULL;
@@
-379,7
+374,7
@@
keyring_lookup_entry (const gchar *cookie_context,
error))
{
g_prefix_error (error,
error))
{
g_prefix_error (error,
- _("Error opening keyring
`
%s' for reading: "),
+ _("Error opening keyring
'
%s' for reading: "),
path);
goto out;
}
path);
goto out;
}
@@
-403,7
+398,7
@@
keyring_lookup_entry (const gchar *cookie_context,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Line %d of the keyring at
`%s' with content `
%s' is malformed"),
+ _("Line %d of the keyring at
'%s' with content '
%s' is malformed"),
n + 1,
path,
line);
n + 1,
path,
line);
@@
-417,7
+412,7
@@
keyring_lookup_entry (const gchar *cookie_context,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("First token of line %d of the keyring at
`%s' with content `
%s' is malformed"),
+ _("First token of line %d of the keyring at
'%s' with content '
%s' is malformed"),
n + 1,
path,
line);
n + 1,
path,
line);
@@
-426,12
+421,13
@@
keyring_lookup_entry (const gchar *cookie_context,
}
line_when = g_ascii_strtoll (tokens[1], &endp, 10);
}
line_when = g_ascii_strtoll (tokens[1], &endp, 10);
+ line_when = line_when; /* To avoid -Wunused-but-set-variable */
if (*endp != '\0')
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
if (*endp != '\0')
{
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Second token of line %d of the keyring at
`%s' with content `
%s' is malformed"),
+ _("Second token of line %d of the keyring at
'%s' with content '
%s' is malformed"),
n + 1,
path,
line);
n + 1,
path,
line);
@@
-455,7
+451,7
@@
keyring_lookup_entry (const gchar *cookie_context,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Didn't find cookie with id %d in the keyring at
`
%s'"),
+ _("Didn't find cookie with id %d in the keyring at
'
%s'"),
cookie_id,
path);
cookie_id,
path);
@@
-468,6
+464,7
@@
keyring_lookup_entry (const gchar *cookie_context,
}
/* function for logging important events that the system administrator should take notice of */
}
/* function for logging important events that the system administrator should take notice of */
+G_GNUC_PRINTF(1, 2)
static void
_log (const gchar *message,
...)
static void
_log (const gchar *message,
...)
@@
-524,7
+521,7
@@
keyring_acquire_lock (const gchar *path,
num_tries++;
if (num_tries == 50)
{
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)
* stale (nuke the it from orbit)
*/
if (g_unlink (lock) != 0)
@@
-532,12
+529,12
@@
keyring_acquire_lock (const gchar *path,
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
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;
}
lock,
strerror (errno));
goto out;
}
- _log ("Deleted stale lock
-file `
%s'", lock);
+ _log ("Deleted stale lock
file '
%s'", lock);
break;
}
}
break;
}
}
@@
-560,10
+557,11
@@
keyring_acquire_lock (const gchar *path,
goto again;
}
#endif
goto again;
}
#endif
+ num_create_tries = num_create_tries; /* To avoid -Wunused-but-set-variable */
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
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;
lock,
strerror (errno));
goto out;
@@
-593,7
+591,7
@@
keyring_release_lock (const gchar *path,
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error closing (unlinked) lock
-file `
%s': %s"),
+ _("Error closing (unlinked) lock
file '
%s': %s"),
lock,
strerror (errno));
goto out;
lock,
strerror (errno));
goto out;
@@
-603,7
+601,7
@@
keyring_release_lock (const gchar *path,
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
g_set_error (error,
G_IO_ERROR,
g_io_error_from_errno (errno),
- _("Error unlinking lock
-file `
%s': %s"),
+ _("Error unlinking lock
file '
%s': %s"),
lock,
strerror (errno));
goto out;
lock,
strerror (errno));
goto out;
@@
-650,6
+648,7
@@
keyring_generate_entry (const gchar *cookie_context,
lines = NULL;
new_contents = NULL;
have_id = FALSE;
lines = NULL;
new_contents = NULL;
have_id = FALSE;
+ use_id = 0;
use_cookie = NULL;
lock_fd = -1;
use_cookie = NULL;
lock_fd = -1;
@@
-679,7
+678,7
@@
keyring_generate_entry (const gchar *cookie_context,
{
g_propagate_prefixed_error (error,
local_error,
{
g_propagate_prefixed_error (error,
local_error,
- _("Error opening keyring
`
%s' for writing: "),
+ _("Error opening keyring
'
%s' for writing: "),
path);
goto out;
}
path);
goto out;
}
@@
-712,7
+711,7
@@
keyring_generate_entry (const gchar *cookie_context,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Line %d of the keyring at
`%s' with content `
%s' is malformed"),
+ _("Line %d of the keyring at
'%s' with content '
%s' is malformed"),
n + 1,
path,
line);
n + 1,
path,
line);
@@
-726,7
+725,7
@@
keyring_generate_entry (const gchar *cookie_context,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("First token of line %d of the keyring at
`%s' with content `
%s' is malformed"),
+ _("First token of line %d of the keyring at
'%s' with content '
%s' is malformed"),
n + 1,
path,
line);
n + 1,
path,
line);
@@
-740,13
+739,15
@@
keyring_generate_entry (const gchar *cookie_context,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
- _("Second token of line %d of the keyring at
`%s' with content `
%s' is malformed"),
+ _("Second token of line %d of the keyring at
'%s' with content '
%s' is malformed"),
n + 1,
path,
line);
g_strfreev (tokens);
goto out;
}
n + 1,
path,
line);
g_strfreev (tokens);
goto out;
}
+ line_when = line_when; /* To avoid -Wunused-but-set-variable */
+
/* D-Bus spec says:
*
/* D-Bus spec says:
*
@@
-874,7
+875,7
@@
keyring_generate_entry (const gchar *cookie_context,
else
{
g_prefix_error (error,
else
{
g_prefix_error (error,
- _("(Additionally, releasing the lock for
`
%s' also failed: %s) "),
+ _("(Additionally, releasing the lock for
'
%s' also failed: %s) "),
path,
local_error->message);
}
path,
local_error->message);
}
@@
-990,7
+991,7
@@
mechanism_server_data_receive (GDBusAuthMechanism *mechanism,
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 2)
{
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 2)
{
- g_warning ("Malformed data
`
%s'", data);
+ g_warning ("Malformed data
'
%s'", data);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
@@
-1033,6
+1034,7
@@
mechanism_server_data_send (GDBusAuthMechanism *mechanism,
/* TODO: use GDBusAuthObserver here to get the cookie context to use? */
cookie_context = "org_gtk_gdbus_general";
/* TODO: use GDBusAuthObserver here to get the cookie context to use? */
cookie_context = "org_gtk_gdbus_general";
+ cookie_id = -1;
error = NULL;
if (!keyring_generate_entry (cookie_context,
&cookie_id,
error = NULL;
if (!keyring_generate_entry (cookie_context,
&cookie_id,
@@
-1150,7
+1152,7
@@
mechanism_client_data_receive (GDBusAuthMechanism *mechanism,
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 3)
{
tokens = g_strsplit (data, " ", 0);
if (g_strv_length (tokens) != 3)
{
- g_warning ("Malformed data
`
%s'", data);
+ g_warning ("Malformed data
'
%s'", data);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
@@
-1159,7
+1161,7
@@
mechanism_client_data_receive (GDBusAuthMechanism *mechanism,
cookie_id = g_ascii_strtoll (tokens[1], &endp, 10);
if (*endp != '\0')
{
cookie_id = g_ascii_strtoll (tokens[1], &endp, 10);
if (*endp != '\0')
{
- g_warning ("Malformed cookie_id
`
%s'", tokens[1]);
+ g_warning ("Malformed cookie_id
'
%s'", tokens[1]);
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}
m->priv->state = G_DBUS_AUTH_MECHANISM_STATE_REJECTED;
goto out;
}