~thomas-voss/biometryd/verify-incoming-requests

« back to all changes in this revision

Viewing changes to src/biometry/dbus/skeleton/daemon_credentials_resolver.cpp

  • Committer: Thomas Voß
  • Date: 2016-06-17 10:35:35 UTC
  • Revision ID: thomas.voss@canonical.com-20160617103535-9mbkpkzwhh1a3ld7
Make sure that test cases pass if run in virtualized environments without securityfs being mounted.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <core/dbus/macros.h>
26
26
#include <core/dbus/object.h>
27
27
 
 
28
#include <core/posix/this_process.h>
 
29
 
28
30
namespace
29
31
{
 
32
bool is_running_in_a_testing_environment()
 
33
{
 
34
    return core::posix::this_process::env::get("BIOMETRYD_DBUS_SKELETON_IS_RUNNING_UNDER_TESTING", "0") == "1";
 
35
}
 
36
 
30
37
struct DBus
31
38
{
32
39
    static const std::string& name()
70
77
        {
71
78
            object->invoke_method_asynchronously_with_callback<GetConnectionAppArmorSecurityContext, std::string>([handler](const core::dbus::Result<std::string>& result)
72
79
            {
73
 
                biometry::Optional<std::string> label; handler((not result.is_error() ? label = result.value() : label));
 
80
                biometry::Optional<std::string> label; handler((not result.is_error() ?
 
81
                                                                        label = result.value() :
 
82
                                                                        is_running_in_a_testing_environment() ? label = "unconfined" : label));
74
83
            }, name);
75
84
        }
76
85