- Main Page
- Classes
- Files

- File List

# include/pion/admin_rights.hpp

    00001 // ---------------------------------------------------------------------
    00002 // pion:  a Boost C++ framework for building lightweight HTTP interfaces
    00003 // ---------------------------------------------------------------------
    00004 // Copyright (C) 2007-2012 Cloudmeter, Inc.  (http://www.cloudmeter.com)
    00005 //
    00006 // Distributed under the Boost Software License, Version 1.0.
    00007 // See http://www.boost.org/LICENSE_1_0.txt
    00008 //
    00009
    00010 #ifndef __PION_ADMIN_RIGHTS_HEADER__
    00011 #define __PION_ADMIN_RIGHTS_HEADER__
    00012
    00013 #include <pion/config.hpp>
    00014 #include <pion/logger.hpp>
    00015 #include <boost/cstdint.hpp>
    00016 #include <boost/thread/mutex.hpp>
    00017
    00018
    00019 namespace pion {    // begin namespace pion
    00020
    00021
    00025 class PION_API admin_rights {
    00026 public:
    00027
    00034     admin_rights(bool use_log = true);
    00035
    00037     virtual ~admin_rights() { release(); }
    00038
    00040     void release(void);
    00041
    00043     static long run_as_user(const std::string& user_name);
    00044
    00046     static long run_as_group(const std::string& group_name);
    00047
    00048
    00049 private:
    00050
    00059     static long find_system_id(const std::string& name, const std::string& file);
    00060
    00061
    00063     static const boost::int16_t         ADMIN_USER_ID;
    00064
    00066     static boost::mutex                 m_mutex;
    00067
    00069     logger                              m_logger;
    00070
    00072     boost::unique_lock<boost::mutex>    m_lock;
    00073
    00075     boost::int16_t                      m_user_id;
    00076
    00078     bool                                m_has_rights;
    00079
    00081     bool                                m_use_log;
    00082 };
    00083
    00084
    00085 }   // end namespace pion
    00086
    00087 #endif
    00088