123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- //////////////////////////////////////////////////////////////////////////////
- //
- // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
- // Software License, Version 1.0. (See accompanying file
- // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- //
- // See http://www.boost.org/libs/interprocess for documentation.
- //
- //////////////////////////////////////////////////////////////////////////////
- #ifndef BOOST_INTERPROCESS_PERMISSIONS_HPP
- #define BOOST_INTERPROCESS_PERMISSIONS_HPP
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- #ifndef BOOST_CONFIG_HPP
- # include <boost/config.hpp>
- #endif
- #
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- #include <boost/interprocess/detail/config_begin.hpp>
- #include <boost/interprocess/detail/workaround.hpp>
- #include <boost/interprocess/interprocess_fwd.hpp>
- #if defined(BOOST_INTERPROCESS_WINDOWS)
- #include <boost/interprocess/detail/win32_api.hpp>
- #else
- #include <sys/stat.h>
- #endif
- #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
- //!\file
- //!Describes permissions class
- namespace boost {
- namespace interprocess {
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- #if defined(BOOST_INTERPROCESS_WINDOWS)
- namespace ipcdetail {
- template <int Dummy>
- struct unrestricted_permissions_holder
- {
- static winapi::interprocess_all_access_security unrestricted;
- };
- template<int Dummy>
- winapi::interprocess_all_access_security unrestricted_permissions_holder<Dummy>::unrestricted;
- } //namespace ipcdetail {
- #endif //defined BOOST_INTERPROCESS_WINDOWS
- #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
- //!The permissions class represents permissions to be set to shared memory or
- //!files, that can be constructed form usual permission representations:
- //!a SECURITY_ATTRIBUTES pointer in windows or ORed rwx chmod integer in UNIX.
- class permissions
- {
- #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
- #if defined(BOOST_INTERPROCESS_WINDOWS)
- typedef void* os_permissions_type;
- #else
- typedef ::mode_t os_permissions_type;
- #endif
- os_permissions_type m_perm;
- #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
- public:
- //!Constructs a permissions object from a user provided os-dependent
- //!permissions.
- permissions(os_permissions_type type) BOOST_NOEXCEPT
- : m_perm(type)
- {}
- //!Constructs a default permissions object:
- //!A null security attributes pointer for windows or 0644
- //!for UNIX.
- permissions() BOOST_NOEXCEPT
- { set_default(); }
- //!Sets permissions to default values:
- //!A null security attributes pointer for windows or 0644
- //!for UNIX.
- void set_default() BOOST_NOEXCEPT
- {
- #if defined (BOOST_INTERPROCESS_WINDOWS)
- m_perm = 0;
- #else
- m_perm = 0644;
- #endif
- }
- //!Sets permissions to unrestricted access:
- //!A null DACL for windows or 0666 for UNIX.
- void set_unrestricted() BOOST_NOEXCEPT
- {
- #if defined (BOOST_INTERPROCESS_WINDOWS)
- m_perm = &ipcdetail::unrestricted_permissions_holder<0>::unrestricted;
- #else
- m_perm = 0666;
- #endif
- }
- //!Sets permissions from a user provided os-dependent
- //!permissions.
- void set_permissions(os_permissions_type perm) BOOST_NOEXCEPT
- { m_perm = perm; }
- //!Returns stored os-dependent
- //!permissions
- os_permissions_type get_permissions() const BOOST_NOEXCEPT
- { return m_perm; }
- };
- } //namespace interprocess {
- } //namespace boost {
- #include <boost/interprocess/detail/config_end.hpp>
- #endif //BOOST_INTERPROCESS_PERMISSIONS_HPP
|