2007-07-14 02:44:01 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
2007-06-09 21:53:20 +00:00
|
|
|
/* dbus-credentials-util.c Would be in dbus-credentials.c, but only used for tests/bus
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2007 Red Hat Inc.
|
|
|
|
|
*
|
2023-01-02 15:31:43 +01:00
|
|
|
* SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
|
|
|
|
|
*
|
2007-06-09 21:53:20 +00:00
|
|
|
* Licensed under the Academic Free License version 2.1
|
2018-12-17 10:56:38 +00:00
|
|
|
*
|
2007-06-09 21:53:20 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
2018-12-17 10:56:38 +00:00
|
|
|
*
|
2007-06-09 21:53:20 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2009-07-10 19:32:38 -04:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-06-09 21:53:20 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2010-03-19 12:36:49 +01:00
|
|
|
|
|
|
|
|
#include <config.h>
|
2018-09-28 16:27:42 +01:00
|
|
|
|
|
|
|
|
#include "misc-internals.h"
|
|
|
|
|
|
|
|
|
|
#include "dbus/dbus-credentials.h"
|
|
|
|
|
#include "dbus/dbus-internals.h"
|
|
|
|
|
#include "dbus/dbus-test-tap.h"
|
|
|
|
|
#include "dbus/dbus-test.h"
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @addtogroup DBusCredentials
|
|
|
|
|
* @{
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
2013-06-28 16:25:54 +08:00
|
|
|
#ifdef DBUS_ENABLE_EMBEDDED_TESTS
|
2007-06-09 21:53:20 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
static DBusCredentials*
|
|
|
|
|
make_credentials(dbus_uid_t unix_uid,
|
2013-03-08 13:15:36 +01:00
|
|
|
dbus_pid_t pid,
|
2018-01-16 13:16:23 +00:00
|
|
|
int group_vector,
|
2007-06-09 21:53:20 +00:00
|
|
|
const char *windows_sid)
|
|
|
|
|
{
|
|
|
|
|
DBusCredentials *credentials;
|
2018-01-16 13:16:23 +00:00
|
|
|
static const struct
|
|
|
|
|
{
|
|
|
|
|
size_t n;
|
|
|
|
|
const dbus_gid_t gids[4];
|
|
|
|
|
}
|
|
|
|
|
group_vectors[] =
|
|
|
|
|
{
|
|
|
|
|
{ 4, { 1000, 42, 123, 5678 } },
|
|
|
|
|
{ 2, { 23, 1001 } },
|
|
|
|
|
{ 4, { 5678, 123, 42, 1000 } }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* group_vector is 0 to not add any groups, or n > 0 to add groups from
|
|
|
|
|
* group_vectors[n-1].
|
|
|
|
|
*/
|
|
|
|
|
_dbus_assert (group_vector >= 0);
|
|
|
|
|
_dbus_assert (group_vector <= _DBUS_N_ELEMENTS (group_vectors));
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
credentials = _dbus_credentials_new ();
|
|
|
|
|
|
|
|
|
|
if (unix_uid != DBUS_UID_UNSET)
|
|
|
|
|
{
|
|
|
|
|
if (!_dbus_credentials_add_unix_uid (credentials, unix_uid))
|
|
|
|
|
{
|
|
|
|
|
_dbus_credentials_unref (credentials);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-08 13:15:36 +01:00
|
|
|
if (pid != DBUS_PID_UNSET)
|
2007-06-09 21:53:20 +00:00
|
|
|
{
|
2013-03-08 13:15:36 +01:00
|
|
|
if (!_dbus_credentials_add_pid (credentials, pid))
|
2007-06-09 21:53:20 +00:00
|
|
|
{
|
|
|
|
|
_dbus_credentials_unref (credentials);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-16 13:16:23 +00:00
|
|
|
if (group_vector)
|
|
|
|
|
{
|
|
|
|
|
dbus_gid_t *copy;
|
|
|
|
|
|
|
|
|
|
copy = dbus_new0 (dbus_gid_t, group_vectors[group_vector - 1].n);
|
|
|
|
|
|
|
|
|
|
if (copy == NULL)
|
|
|
|
|
{
|
|
|
|
|
_dbus_credentials_unref (credentials);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy (copy, group_vectors[group_vector - 1].gids,
|
|
|
|
|
sizeof (dbus_gid_t) * group_vectors[group_vector - 1].n);
|
|
|
|
|
|
|
|
|
|
_dbus_credentials_take_unix_gids (credentials, copy,
|
|
|
|
|
group_vectors[group_vector - 1].n);
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
if (windows_sid != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (!_dbus_credentials_add_windows_sid (credentials, windows_sid))
|
|
|
|
|
{
|
|
|
|
|
_dbus_credentials_unref (credentials);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return credentials;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SAMPLE_SID "whatever a windows sid looks like"
|
|
|
|
|
#define OTHER_SAMPLE_SID "whatever else"
|
|
|
|
|
|
|
|
|
|
dbus_bool_t
|
|
|
|
|
_dbus_credentials_test (const char *test_data_dir)
|
|
|
|
|
{
|
|
|
|
|
DBusCredentials *creds;
|
|
|
|
|
DBusCredentials *creds2;
|
2018-01-16 13:16:23 +00:00
|
|
|
DBusString str;
|
2023-03-20 02:00:51 +00:00
|
|
|
DBusString str2;
|
2018-01-16 13:16:23 +00:00
|
|
|
const dbus_gid_t *gids;
|
|
|
|
|
size_t n;
|
2023-03-20 02:00:51 +00:00
|
|
|
dbus_pid_t pid = _dbus_getpid();
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
if (test_data_dir == NULL)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
2023-03-20 02:00:51 +00:00
|
|
|
creds = make_credentials (12, pid, 1, SAMPLE_SID);
|
2007-06-09 21:53:20 +00:00
|
|
|
if (creds == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
/* test refcounting */
|
|
|
|
|
_dbus_credentials_ref (creds);
|
|
|
|
|
_dbus_credentials_unref (creds);
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_assert (_dbus_credentials_include (creds, DBUS_CREDENTIAL_UNIX_USER_ID));
|
|
|
|
|
_dbus_assert (_dbus_credentials_include (creds, DBUS_CREDENTIAL_UNIX_PROCESS_ID));
|
2018-01-16 13:16:23 +00:00
|
|
|
_dbus_assert (_dbus_credentials_include (creds, DBUS_CREDENTIAL_UNIX_GROUP_IDS));
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_assert (_dbus_credentials_include (creds, DBUS_CREDENTIAL_WINDOWS_SID));
|
|
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_get_unix_uid (creds) == 12);
|
2023-03-20 02:00:51 +00:00
|
|
|
_dbus_assert (_dbus_credentials_get_pid (creds) == pid);
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_assert (strcmp (_dbus_credentials_get_windows_sid (creds), SAMPLE_SID) == 0);
|
2018-01-16 13:16:23 +00:00
|
|
|
_dbus_assert (_dbus_credentials_get_unix_gids (creds, &gids, &n));
|
|
|
|
|
_dbus_assert (n == 4);
|
|
|
|
|
_dbus_assert (gids[0] == 42);
|
|
|
|
|
_dbus_assert (gids[1] == 123);
|
|
|
|
|
_dbus_assert (gids[2] == 1000);
|
|
|
|
|
_dbus_assert (gids[3] == 5678);
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (!_dbus_credentials_are_empty (creds));
|
2007-06-12 18:36:19 +00:00
|
|
|
_dbus_assert (!_dbus_credentials_are_anonymous (creds));
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
/* Test copy */
|
|
|
|
|
creds2 = _dbus_credentials_copy (creds);
|
|
|
|
|
if (creds2 == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_UNIX_USER_ID));
|
|
|
|
|
_dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_UNIX_PROCESS_ID));
|
2018-01-16 13:16:23 +00:00
|
|
|
_dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_UNIX_GROUP_IDS));
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_WINDOWS_SID));
|
|
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_get_unix_uid (creds2) == 12);
|
2023-03-20 02:00:51 +00:00
|
|
|
_dbus_assert (_dbus_credentials_get_pid (creds2) == pid);
|
2018-12-17 11:30:23 +00:00
|
|
|
_dbus_assert (strcmp (_dbus_credentials_get_windows_sid (creds2), SAMPLE_SID) == 0);
|
2018-01-16 13:16:23 +00:00
|
|
|
_dbus_assert (_dbus_credentials_get_unix_gids (creds2, &gids, &n));
|
|
|
|
|
_dbus_assert (n == 4);
|
|
|
|
|
_dbus_assert (gids[0] == 42);
|
|
|
|
|
_dbus_assert (gids[1] == 123);
|
|
|
|
|
_dbus_assert (gids[2] == 1000);
|
|
|
|
|
_dbus_assert (gids[3] == 5678);
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_are_superset (creds, creds2));
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_credentials_unref (creds2);
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
/* Same user if both unix and windows are the same */
|
2018-01-16 13:16:23 +00:00
|
|
|
creds2 = make_credentials (12, DBUS_PID_UNSET, 0, SAMPLE_SID);
|
2007-06-09 21:53:20 +00:00
|
|
|
if (creds2 == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
|
|
|
|
/* Not the same user if Windows is missing */
|
2018-01-16 13:16:23 +00:00
|
|
|
creds2 = make_credentials (12, DBUS_PID_UNSET, 0, NULL);
|
2007-06-09 21:53:20 +00:00
|
|
|
if (creds2 == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (!_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
_dbus_assert (_dbus_credentials_are_superset (creds, creds2));
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
|
|
|
|
/* Not the same user if Windows is different */
|
2018-01-16 13:16:23 +00:00
|
|
|
creds2 = make_credentials (12, DBUS_PID_UNSET, 0, OTHER_SAMPLE_SID);
|
2007-06-09 21:53:20 +00:00
|
|
|
if (creds2 == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (!_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
_dbus_assert (!_dbus_credentials_are_superset (creds, creds2));
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
|
|
|
|
/* Not the same user if Unix is missing */
|
2018-01-16 13:16:23 +00:00
|
|
|
creds2 = make_credentials (DBUS_UID_UNSET, DBUS_PID_UNSET, 0, SAMPLE_SID);
|
2007-06-09 21:53:20 +00:00
|
|
|
if (creds2 == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (!_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
_dbus_assert (_dbus_credentials_are_superset (creds, creds2));
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
|
|
|
|
/* Not the same user if Unix is different */
|
2018-01-16 13:16:23 +00:00
|
|
|
creds2 = make_credentials (15, DBUS_PID_UNSET, 0, SAMPLE_SID);
|
2007-06-09 21:53:20 +00:00
|
|
|
if (creds2 == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (!_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
_dbus_assert (!_dbus_credentials_are_superset (creds, creds2));
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
|
|
|
|
/* Not the same user if both are missing */
|
2018-01-16 13:16:23 +00:00
|
|
|
creds2 = make_credentials (DBUS_UID_UNSET, DBUS_PID_UNSET, 0, NULL);
|
2007-06-09 21:53:20 +00:00
|
|
|
if (creds2 == NULL)
|
2017-11-14 14:17:53 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_assert (!_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
_dbus_assert (_dbus_credentials_are_superset (creds, creds2));
|
2018-12-17 11:30:23 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
2018-01-16 13:16:23 +00:00
|
|
|
/* Same user, but not a superset, if groups are different */
|
2023-03-20 02:00:51 +00:00
|
|
|
creds2 = make_credentials (12, pid, 2, SAMPLE_SID);
|
2018-01-16 13:16:23 +00:00
|
|
|
if (creds2 == NULL)
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
_dbus_assert (!_dbus_credentials_are_superset (creds, creds2));
|
|
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
|
|
|
|
/* Groups being in the same order make no difference */
|
2023-03-20 02:00:51 +00:00
|
|
|
creds2 = make_credentials (12, pid, 3, SAMPLE_SID);
|
2018-01-16 13:16:23 +00:00
|
|
|
if (creds2 == NULL)
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_same_user (creds, creds2));
|
|
|
|
|
_dbus_assert (_dbus_credentials_are_superset (creds, creds2));
|
|
|
|
|
_dbus_assert (_dbus_credentials_are_superset (creds2, creds));
|
|
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds2);
|
|
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
/* Clearing credentials works */
|
|
|
|
|
_dbus_credentials_clear (creds);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (!_dbus_credentials_include (creds, DBUS_CREDENTIAL_UNIX_USER_ID));
|
|
|
|
|
_dbus_assert (!_dbus_credentials_include (creds, DBUS_CREDENTIAL_UNIX_PROCESS_ID));
|
|
|
|
|
_dbus_assert (!_dbus_credentials_include (creds, DBUS_CREDENTIAL_WINDOWS_SID));
|
|
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_get_unix_uid (creds) == DBUS_UID_UNSET);
|
2013-03-08 13:15:36 +01:00
|
|
|
_dbus_assert (_dbus_credentials_get_pid (creds) == DBUS_PID_UNSET);
|
2007-06-09 21:53:20 +00:00
|
|
|
_dbus_assert (_dbus_credentials_get_windows_sid (creds) == NULL);
|
|
|
|
|
|
|
|
|
|
_dbus_assert (_dbus_credentials_are_empty (creds));
|
2007-06-12 18:36:19 +00:00
|
|
|
_dbus_assert (_dbus_credentials_are_anonymous (creds));
|
2007-06-09 21:53:20 +00:00
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds);
|
2018-01-16 13:16:38 +00:00
|
|
|
|
|
|
|
|
/* Make some more realistic credentials blobs to test stringification */
|
2023-03-20 02:00:51 +00:00
|
|
|
if (!_dbus_string_init (&str) || !_dbus_string_init (&str2))
|
2018-01-16 13:16:38 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
creds = make_credentials (12, DBUS_PID_UNSET, 0, NULL);
|
|
|
|
|
if (creds == NULL)
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
if (!_dbus_credentials_to_string_append (creds, &str))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
_dbus_test_diag ("Unix uid only: %s", _dbus_string_get_const_data (&str));
|
|
|
|
|
_dbus_assert (strcmp (_dbus_string_get_const_data (&str),
|
|
|
|
|
"uid=12") == 0);
|
|
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds);
|
|
|
|
|
|
2023-03-20 02:00:51 +00:00
|
|
|
creds = make_credentials (12, pid, 1, NULL);
|
2018-01-16 13:16:38 +00:00
|
|
|
if (creds == NULL)
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_set_length (&str, 0))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
if (!_dbus_credentials_to_string_append (creds, &str))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
2023-03-20 02:00:51 +00:00
|
|
|
if (!_dbus_string_append_printf(&str2, "uid=12 pid=" DBUS_PID_FORMAT " gid=42 gid=123 gid=1000 gid=5678", pid))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
2018-01-16 13:16:38 +00:00
|
|
|
_dbus_test_diag ("Unix complete set: %s", _dbus_string_get_const_data (&str));
|
2023-03-20 02:00:51 +00:00
|
|
|
_dbus_assert (strcmp (_dbus_string_get_const_data (&str), _dbus_string_get_const_data (&str2)) == 0);
|
2018-01-16 13:16:38 +00:00
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds);
|
|
|
|
|
|
|
|
|
|
creds = make_credentials (DBUS_UID_UNSET, DBUS_PID_UNSET, 0, SAMPLE_SID);
|
|
|
|
|
if (creds == NULL)
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_set_length (&str, 0))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
if (!_dbus_credentials_to_string_append (creds, &str))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
_dbus_test_diag ("Windows sid only: %s", _dbus_string_get_const_data (&str));
|
|
|
|
|
_dbus_assert (strcmp (_dbus_string_get_const_data (&str),
|
|
|
|
|
"sid=" SAMPLE_SID) == 0);
|
|
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds);
|
|
|
|
|
|
2023-03-20 02:00:51 +00:00
|
|
|
creds = make_credentials (DBUS_UID_UNSET, pid, 0, SAMPLE_SID);
|
2018-01-16 13:16:38 +00:00
|
|
|
if (creds == NULL)
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
2023-03-20 02:00:51 +00:00
|
|
|
if (!_dbus_string_set_length (&str, 0) || !_dbus_string_set_length (&str2, 0))
|
2018-01-16 13:16:38 +00:00
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
|
|
|
|
if (!_dbus_credentials_to_string_append (creds, &str))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
2023-03-20 02:00:51 +00:00
|
|
|
if (!_dbus_string_append_printf(&str2, "pid=" DBUS_PID_FORMAT " sid=" SAMPLE_SID, pid))
|
|
|
|
|
_dbus_test_fatal ("oom");
|
|
|
|
|
|
2018-01-16 13:16:38 +00:00
|
|
|
_dbus_test_diag ("Windows complete set: %s", _dbus_string_get_const_data (&str));
|
2023-03-20 02:00:51 +00:00
|
|
|
_dbus_assert (strcmp (_dbus_string_get_const_data (&str), _dbus_string_get_const_data (&str2)) == 0);
|
2018-01-16 13:16:38 +00:00
|
|
|
|
|
|
|
|
_dbus_credentials_unref (creds);
|
|
|
|
|
|
|
|
|
|
_dbus_string_free (&str);
|
2023-03-20 02:00:51 +00:00
|
|
|
_dbus_string_free (&str2);
|
2018-01-16 13:16:38 +00:00
|
|
|
|
2007-06-09 21:53:20 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-28 16:25:54 +08:00
|
|
|
#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
|