if (in_backslash)
{
unsigned char a;
-
+
if (b == 'r')
a = '\r';
else if (b == 'n')
if (!_dbus_string_append_byte (dest, a))
return FALSE;
-
+
in_backslash = FALSE;
}
else if (b == '\\')
return FALSE;
}
}
-
+
++i;
}
static DBusAuthState
auth_state_from_string (const DBusString *str)
-{
+{
if (_dbus_string_starts_with_c_str (str, "WAITING_FOR_INPUT"))
return DBUS_AUTH_STATE_WAITING_FOR_INPUT;
else if (_dbus_string_starts_with_c_str (str, "WAITING_FOR_MEMORY"))
DBusAuthState state;
DBusString context;
DBusString guid;
-
+
retval = FALSE;
auth = NULL;
_dbus_string_init_const (&guid, "5fa01f4202cd837709a3274ca0df9d00");
_dbus_string_init_const (&context, "org_freedesktop_test");
-
+
if (!_dbus_string_init (&file))
return FALSE;
next_iteration:
while (_dbus_string_pop_line (&file, &line))
- {
+ {
line_no += 1;
/* _dbus_warn ("%s", _dbus_string_get_const_data (&line)); */
-
+
_dbus_string_delete_leading_blanks (&line);
if (auth != NULL)
}
}
}
-
+
if (_dbus_string_get_length (&line) == 0)
{
/* empty line */
"CLIENT"))
{
DBusCredentials *creds;
-
+
if (auth != NULL)
{
_dbus_warn ("already created a DBusAuth (CLIENT or SERVER given twice)");
auth = NULL;
goto out;
}
-
+
if (!_dbus_auth_set_credentials (auth, creds))
{
_dbus_warn ("no memory for setting credentials");
_dbus_credentials_unref (creds);
goto out;
}
-
+
_dbus_credentials_unref (creds);
}
else if (_dbus_string_starts_with_c_str (&line,
"SERVER"))
{
DBusCredentials *creds;
-
+
if (auth != NULL)
{
_dbus_warn ("already created a DBusAuth (CLIENT or SERVER given twice)");
auth = NULL;
goto out;
}
-
+
if (!_dbus_auth_set_credentials (auth, creds))
{
_dbus_warn ("no memory for setting credentials");
_dbus_credentials_unref (creds);
goto out;
}
-
+
_dbus_credentials_unref (creds);
_dbus_auth_set_context (auth, &context);
"SEND"))
{
DBusString to_send;
-
+
_dbus_string_delete_first_word (&line);
if (!_dbus_string_init (&to_send))
}
_dbus_verbose ("Sending '%s'\n", _dbus_string_get_const_data (&to_send));
-
+
if (!_dbus_string_append (&to_send, "\r\n"))
{
_dbus_warn ("failed to append \\r\\n from line %d",
/* Replace USERID_HEX with our username in hex */
{
int where;
-
+
if (_dbus_string_find (&to_send, 0,
"USERID_HEX", &where))
{
}
_dbus_string_delete (&to_send, where, (int) strlen ("USERID_HEX"));
-
+
if (!_dbus_string_hex_encode (&username, 0,
&to_send, where))
{
}
_dbus_string_delete (&to_send, where, (int) strlen ("USERNAME_HEX"));
-
+
if (!_dbus_string_hex_encode (username, 0,
&to_send, where))
{
_dbus_auth_return_buffer (auth, buffer);
}
-
+
_dbus_string_free (&to_send);
}
else if (_dbus_string_starts_with_c_str (&line,
"EXPECT_STATE"))
{
DBusAuthState expected;
-
+
_dbus_string_delete_first_word (&line);
expected = auth_state_from_string (&line);
"EXPECT_COMMAND"))
{
DBusString received;
-
+
_dbus_string_delete_first_word (&line);
if (!_dbus_string_init (&received))
_dbus_string_free (&received);
goto out;
}
-
+
_dbus_string_free (&received);
}
else if (_dbus_string_starts_with_c_str (&line,
{
DBusString expected;
const DBusString *unused;
-
+
_dbus_string_delete_first_word (&line);
if (!_dbus_string_init (&expected))
}
_dbus_auth_get_unused_bytes (auth, &unused);
-
+
if (_dbus_string_equal (&expected, unused))
{
_dbus_auth_delete_unused_bytes (auth);
"EXPECT_HAVE_NO_CREDENTIALS"))
{
DBusCredentials *authorized_identity;
-
+
authorized_identity = _dbus_auth_get_identity (auth);
if (!_dbus_credentials_are_anonymous (authorized_identity))
{
"EXPECT_HAVE_SOME_CREDENTIALS"))
{
DBusCredentials *authorized_identity;
-
+
authorized_identity = _dbus_auth_get_identity (auth);
if (_dbus_credentials_are_anonymous (authorized_identity))
{
"EXPECT"))
{
DBusString expected;
-
+
_dbus_string_delete_first_word (&line);
if (!_dbus_string_init (&expected))
goto parse_failed;
goto next_iteration; /* skip parse_failed */
-
+
parse_failed:
{
_dbus_warn ("couldn't process line %d \"%s\"",
_dbus_warn ("Leftover data: %s", _dbus_string_get_const_data (&from_auth));
goto out;
}
-
+
retval = TRUE;
-
+
out:
if (auth)
_dbus_auth_unref (auth);
_dbus_string_free (&file);
_dbus_string_free (&line);
_dbus_string_free (&from_auth);
-
+
return retval;
}