1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_PERMISSIONS_HPP
12 #define BOOST_INTERPROCESS_PERMISSIONS_HPP
14 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
16 #ifndef BOOST_CONFIG_HPP
17 # include <boost/config.hpp>
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
24 #include <boost/interprocess/detail/config_begin.hpp>
25 #include <boost/interprocess/detail/workaround.hpp>
26 #include <boost/interprocess/interprocess_fwd.hpp>
28 #if defined(BOOST_INTERPROCESS_WINDOWS)
30 #include <boost/interprocess/detail/win32_api.hpp>
34 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
37 //!Describes permissions class
40 namespace interprocess {
42 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
44 #if defined(BOOST_INTERPROCESS_WINDOWS)
49 struct unrestricted_permissions_holder
51 static winapi::interprocess_all_access_security unrestricted;
55 winapi::interprocess_all_access_security unrestricted_permissions_holder<Dummy>::unrestricted;
57 } //namespace ipcdetail {
59 #endif //defined BOOST_INTERPROCESS_WINDOWS
61 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
63 //!The permissions class represents permissions to be set to shared memory or
64 //!files, that can be constructed form usual permission representations:
65 //!a SECURITY_ATTRIBUTES pointer in windows or ORed rwx chmod integer in UNIX.
68 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
70 #if defined(BOOST_INTERPROCESS_WINDOWS)
71 typedef void* os_permissions_type;
73 typedef int os_permissions_type;
75 os_permissions_type m_perm;
77 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
80 //!Constructs a permissions object from a user provided os-dependent
82 permissions(os_permissions_type type)
86 //!Constructs a default permissions object:
87 //!A null security attributes pointer for windows or 0644
92 //!Sets permissions to default values:
93 //!A null security attributes pointer for windows or 0644
97 #if defined (BOOST_INTERPROCESS_WINDOWS)
104 //!Sets permissions to unrestricted access:
105 //!A null DACL for windows or 0666 for UNIX.
106 void set_unrestricted()
108 #if defined (BOOST_INTERPROCESS_WINDOWS)
109 m_perm = &ipcdetail::unrestricted_permissions_holder<0>::unrestricted;
115 //!Sets permissions from a user provided os-dependent
117 void set_permissions(os_permissions_type perm)
120 //!Returns stored os-dependent
122 os_permissions_type get_permissions() const
126 } //namespace interprocess {
127 } //namespace boost {
129 #include <boost/interprocess/detail/config_end.hpp>
131 #endif //BOOST_INTERPROCESS_PERMISSIONS_HPP