]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/interprocess/include/boost/interprocess/permissions.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / interprocess / include / boost / interprocess / permissions.hpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
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)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10
11 #ifndef BOOST_INTERPROCESS_PERMISSIONS_HPP
12 #define BOOST_INTERPROCESS_PERMISSIONS_HPP
13
14 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
15
16 #ifndef BOOST_CONFIG_HPP
17 # include <boost/config.hpp>
18 #endif
19 #
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
21 # pragma once
22 #endif
23
24 #include <boost/interprocess/detail/config_begin.hpp>
25 #include <boost/interprocess/detail/workaround.hpp>
26 #include <boost/interprocess/interprocess_fwd.hpp>
27
28 #if defined(BOOST_INTERPROCESS_WINDOWS)
29
30 #include <boost/interprocess/detail/win32_api.hpp>
31
32 #endif
33
34 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
35
36 //!\file
37 //!Describes permissions class
38
39 namespace boost {
40 namespace interprocess {
41
42 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
43
44 #if defined(BOOST_INTERPROCESS_WINDOWS)
45
46 namespace ipcdetail {
47
48 template <int Dummy>
49 struct unrestricted_permissions_holder
50 {
51 static winapi::interprocess_all_access_security unrestricted;
52 };
53
54 template<int Dummy>
55 winapi::interprocess_all_access_security unrestricted_permissions_holder<Dummy>::unrestricted;
56
57 } //namespace ipcdetail {
58
59 #endif //defined BOOST_INTERPROCESS_WINDOWS
60
61 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
62
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.
66 class permissions
67 {
68 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
69
70 #if defined(BOOST_INTERPROCESS_WINDOWS)
71 typedef void* os_permissions_type;
72 #else
73 typedef int os_permissions_type;
74 #endif
75 os_permissions_type m_perm;
76
77 #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
78
79 public:
80 //!Constructs a permissions object from a user provided os-dependent
81 //!permissions.
82 permissions(os_permissions_type type)
83 : m_perm(type)
84 {}
85
86 //!Constructs a default permissions object:
87 //!A null security attributes pointer for windows or 0644
88 //!for UNIX.
89 permissions()
90 { set_default(); }
91
92 //!Sets permissions to default values:
93 //!A null security attributes pointer for windows or 0644
94 //!for UNIX.
95 void set_default()
96 {
97 #if defined (BOOST_INTERPROCESS_WINDOWS)
98 m_perm = 0;
99 #else
100 m_perm = 0644;
101 #endif
102 }
103
104 //!Sets permissions to unrestricted access:
105 //!A null DACL for windows or 0666 for UNIX.
106 void set_unrestricted()
107 {
108 #if defined (BOOST_INTERPROCESS_WINDOWS)
109 m_perm = &ipcdetail::unrestricted_permissions_holder<0>::unrestricted;
110 #else
111 m_perm = 0666;
112 #endif
113 }
114
115 //!Sets permissions from a user provided os-dependent
116 //!permissions.
117 void set_permissions(os_permissions_type perm)
118 { m_perm = perm; }
119
120 //!Returns stored os-dependent
121 //!permissions
122 os_permissions_type get_permissions() const
123 { return m_perm; }
124 };
125
126 } //namespace interprocess {
127 } //namespace boost {
128
129 #include <boost/interprocess/detail/config_end.hpp>
130
131 #endif //BOOST_INTERPROCESS_PERMISSIONS_HPP
132