summaryrefslogtreecommitdiff
path: root/dbus/dbus-nonce.c
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus.brinkmann@ruhr-uni-bochum.de>2010-03-16 03:27:42 +0100
committerRalf Habacker <ralf.habacker@freenet.de>2010-04-13 15:46:35 +0200
commit6e214b5b3c283798b5743b4ebf7c9ec466fe3667 (patch)
treeb0659fce7a78777f22e644f25d86d1512b51e193 /dbus/dbus-nonce.c
parent4708efeebbac8a6345811e38da86961155e2b4ae (diff)
downloaddbus-6e214b5b3c283798b5743b4ebf7c9ec466fe3667.tar.gz
Prepare for WinCE port: Convert windows code to native API, avoid errno.
Diffstat (limited to 'dbus/dbus-nonce.c')
-rw-r--r--dbus/dbus-nonce.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c
index 3e5070f5..5143939a 100644
--- a/dbus/dbus-nonce.c
+++ b/dbus/dbus-nonce.c
@@ -30,10 +30,6 @@
#include <stdio.h>
-#ifdef HAVE_ERRNO_H
-# include <errno.h>
-#endif
-
static dbus_bool_t
do_check_nonce (int fd, const DBusString *nonce, DBusError *error)
{
@@ -191,7 +187,7 @@ generate_and_write_nonce (const DBusString *filename, DBusError *error)
* indicate whether the server accepted the nonce.
*/
dbus_bool_t
-_dbus_send_nonce(int fd, const DBusString *noncefile, DBusError *error)
+_dbus_send_nonce (int fd, const DBusString *noncefile, DBusError *error)
{
dbus_bool_t read_result;
int send_result;
@@ -203,36 +199,33 @@ _dbus_send_nonce(int fd, const DBusString *noncefile, DBusError *error)
if (_dbus_string_get_length (noncefile) == 0)
return FALSE;
- if ( !_dbus_string_init (&nonce) )
+ if (!_dbus_string_init (&nonce))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
return FALSE;
- }
-
- read_result = _dbus_read_nonce (noncefile, &nonce, NULL);
+ }
+ read_result = _dbus_read_nonce (noncefile, &nonce, error);
if (!read_result)
{
- dbus_set_error (error,
- _dbus_error_from_errno (errno),
- "Could not read nonce from file %s (%s)",
- _dbus_string_get_const_data (noncefile), _dbus_strerror(errno));
+ _DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_string_free (&nonce);
return FALSE;
}
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
send_result = _dbus_write_socket (fd, &nonce, 0, _dbus_string_get_length (&nonce));
_dbus_string_free (&nonce);
if (send_result == -1)
- {
- dbus_set_error (error,
- _dbus_error_from_errno (errno),
- "Failed to send nonce (fd=%d): %s",
- fd, _dbus_strerror(errno));
- return FALSE;
- }
+ {
+ dbus_set_error (error,
+ _dbus_error_from_system_errno (),
+ "Failed to send nonce (fd=%d): %s",
+ fd, _dbus_strerror_from_errno ());
+ return FALSE;
+ }
return TRUE;
}
@@ -284,8 +277,10 @@ do_noncefile_create (DBusNonceFile *noncefile,
}
if (!_dbus_create_directory (&noncefile->dir, error))
{
+ _DBUS_ASSERT_ERROR_IS_SET (error);
goto on_error;
}
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
}
else
@@ -303,10 +298,12 @@ do_noncefile_create (DBusNonceFile *noncefile,
if (!generate_and_write_nonce (&noncefile->path, error))
{
+ _DBUS_ASSERT_ERROR_IS_SET (error);
if (use_subdir)
_dbus_delete_directory (&noncefile->dir, NULL); //we ignore possible errors deleting the dir and return the write error instead
goto on_error;
}
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_string_free (&randomStr);