2015-02-11 18:09:14 +01:00
|
|
|
/*
|
2022-06-06 15:11:03 +01:00
|
|
|
* Copyright 2015 Ralf Habacker
|
|
|
|
|
* Copyright 2015-2020 Collabora Ltd.
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
2015-02-11 18:09:14 +01:00
|
|
|
* Simple manual paths check
|
|
|
|
|
*
|
|
|
|
|
* syntax: manual-paths
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "dbus/dbus-list.h"
|
|
|
|
|
#include "dbus/dbus-internals.h"
|
|
|
|
|
#include "dbus/dbus-sysdeps.h"
|
2020-04-16 14:21:36 +01:00
|
|
|
#include "test-utils.h"
|
2015-02-11 18:09:14 +01:00
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2016-08-19 11:23:54 +02:00
|
|
|
static dbus_bool_t
|
|
|
|
|
print_install_root (void)
|
2015-02-11 18:09:14 +01:00
|
|
|
{
|
2015-09-30 16:35:49 +01:00
|
|
|
DBusString runtime_prefix;
|
2015-02-11 18:09:14 +01:00
|
|
|
|
2015-09-30 16:35:49 +01:00
|
|
|
if (!_dbus_string_init (&runtime_prefix))
|
2015-02-11 18:09:14 +01:00
|
|
|
{
|
2020-04-16 14:21:36 +01:00
|
|
|
_dbus_test_fatal ("out of memory");
|
2015-02-11 18:09:14 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2015-09-30 16:35:49 +01:00
|
|
|
|
|
|
|
|
if (!_dbus_get_install_root (&runtime_prefix))
|
|
|
|
|
{
|
2020-04-16 14:21:36 +01:00
|
|
|
_dbus_test_fatal ("out of memory");
|
2015-09-30 16:35:49 +01:00
|
|
|
_dbus_string_free (&runtime_prefix);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_dbus_string_get_length (&runtime_prefix) == 0)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "_dbus_get_install_root() failed\n");
|
|
|
|
|
_dbus_string_free (&runtime_prefix);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf (stdout, "_dbus_get_install_root() returned '%s'\n",
|
|
|
|
|
_dbus_string_get_const_data (&runtime_prefix));
|
|
|
|
|
_dbus_string_free (&runtime_prefix);
|
2015-02-11 18:09:14 +01:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 11:23:54 +02:00
|
|
|
static dbus_bool_t
|
|
|
|
|
print_service_dirs (void)
|
2015-02-11 18:09:14 +01:00
|
|
|
{
|
|
|
|
|
DBusList *dirs;
|
|
|
|
|
DBusList *link;
|
|
|
|
|
dirs = NULL;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_get_standard_session_servicedirs (&dirs))
|
2020-04-16 14:21:36 +01:00
|
|
|
_dbus_test_fatal ("couldn't get standard dirs");
|
2015-02-11 18:09:14 +01:00
|
|
|
|
|
|
|
|
while ((link = _dbus_list_pop_first_link (&dirs)))
|
|
|
|
|
{
|
|
|
|
|
printf ("default service dir: %s\n", (char *)link->data);
|
|
|
|
|
dbus_free (link->data);
|
|
|
|
|
_dbus_list_free_link (link);
|
|
|
|
|
}
|
|
|
|
|
dbus_free (dirs);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-12 19:03:12 +00:00
|
|
|
static dbus_bool_t print_replace_install_prefix(const char *s)
|
2015-02-11 18:09:14 +01:00
|
|
|
{
|
2015-09-30 16:35:49 +01:00
|
|
|
DBusString str;
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_init (&str))
|
|
|
|
|
{
|
2020-04-16 14:21:36 +01:00
|
|
|
_dbus_test_fatal ("out of memory");
|
2015-09-30 16:35:49 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!_dbus_string_append (&str, s) ||
|
|
|
|
|
!_dbus_replace_install_prefix (&str))
|
|
|
|
|
{
|
2020-04-16 14:21:36 +01:00
|
|
|
_dbus_test_fatal ("out of memory");
|
2015-09-30 16:35:49 +01:00
|
|
|
_dbus_string_free (&str);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2015-02-11 18:09:14 +01:00
|
|
|
|
2015-09-30 16:35:49 +01:00
|
|
|
fprintf(stdout, "replaced '%s' by '%s'\n", s,
|
|
|
|
|
_dbus_string_get_const_data (&str));
|
|
|
|
|
_dbus_string_free (&str);
|
2015-02-11 18:09:14 +01:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main (int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
if (!print_install_root())
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (!print_service_dirs())
|
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
|
|
if (!print_replace_install_prefix(DBUS_BINDIR "/dbus-daemon"))
|
|
|
|
|
return -3;
|
|
|
|
|
|
|
|
|
|
if (!print_replace_install_prefix("c:\\Windows\\System32\\testfile"))
|
|
|
|
|
return -4;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|