2 * Copyright Andrey Semashev 2015.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
8 * \file permissions.cpp
9 * \author Andrey Semashev
12 * \brief This header is the Boost.Log library implementation, see the library documentation
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html.
16 #include <boost/log/detail/config.hpp>
17 #include <boost/log/utility/permissions.hpp>
18 #include <boost/interprocess/permissions.hpp>
20 #if defined(BOOST_WINDOWS)
22 #include <boost/log/exceptions.hpp>
23 #include <boost/throw_exception.hpp>
24 #include <boost/log/utility/once_block.hpp>
26 #include <boost/log/detail/header.hpp>
30 BOOST_LOG_OPEN_NAMESPACE
32 BOOST_LOG_ANONYMOUS_NAMESPACE
{
34 static ::SECURITY_DESCRIPTOR g_unrestricted_security_descriptor
;
35 static ::SECURITY_ATTRIBUTES g_unrestricted_security_attributes
;
39 BOOST_LOG_API
permissions::native_type
permissions::get_unrestricted_security_attributes()
41 BOOST_LOG_ONCE_BLOCK()
43 if (!InitializeSecurityDescriptor(&g_unrestricted_security_descriptor
, SECURITY_DESCRIPTOR_REVISION
))
45 DWORD err
= GetLastError();
46 BOOST_LOG_THROW_DESCR_PARAMS(system_error
, "Failed to initialize security descriptor", (err
));
49 if (!SetSecurityDescriptorDacl(&g_unrestricted_security_descriptor
, TRUE
, NULL
, FALSE
))
51 DWORD err
= GetLastError();
52 BOOST_LOG_THROW_DESCR_PARAMS(system_error
, "Failed to set null DACL to a security descriptor", (err
));
55 g_unrestricted_security_attributes
.nLength
= sizeof(g_unrestricted_security_attributes
);
56 g_unrestricted_security_attributes
.lpSecurityDescriptor
= &g_unrestricted_security_descriptor
;
57 g_unrestricted_security_attributes
.bInheritHandle
= FALSE
;
60 return &g_unrestricted_security_attributes
;
63 //! Initializing constructor
64 BOOST_LOG_API
permissions::permissions(boost::interprocess::permissions
const& perms
) BOOST_NOEXCEPT
:
65 m_perms(reinterpret_cast< native_type
>(perms
.get_permissions()))
70 BOOST_LOG_CLOSE_NAMESPACE
// namespace log
74 #else // defined(BOOST_WINDOWS)
76 #include <boost/log/detail/header.hpp>
80 BOOST_LOG_OPEN_NAMESPACE
82 //! Initializing constructor
83 BOOST_LOG_API
permissions::permissions(boost::interprocess::permissions
const& perms
) BOOST_NOEXCEPT
:
84 m_perms(static_cast< native_type
>(perms
.get_permissions()))
88 BOOST_LOG_CLOSE_NAMESPACE
// namespace log
92 #endif // defined(BOOST_WINDOWS)
94 #include <boost/log/detail/footer.hpp>