groot.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
20 
21 #ifndef G_ROOT_H
22 #define G_ROOT_H
23 
24 #include "gdef.h"
25 #include "gidentity.h"
26 #include "gnoncopyable.h"
27 
29 namespace G
30 {
31  class Root ;
32 }
33 
49 class G::Root : private G::noncopyable
50 {
51 public:
52  explicit Root( bool change_group = true ) ;
55 
56  ~Root() ;
59 
60  static void init( const std::string & nobody ) ;
66 
67  static Identity nobody() ;
70 
71  static Identity start( SignalSafe ) ;
73 
74  static void stop( SignalSafe , Identity ) ;
76 
77 private:
78  static Root * m_this ;
79  static bool m_initialised ;
80  static Identity m_special ;
81  static Identity m_nobody ;
82  bool m_change_group ;
83 } ;
84 
85 #endif
86 
Root(bool change_group=true)
Constructor.
Definition: groot.cpp:32
A noncopyable base class (a la boost).
Definition: gnoncopyable.h:35
An empty structure that is used to indicate a signal-safe, reentrant implementation.
Definition: gsignalsafe.h:35
static Identity nobody()
Returns the 'nobody' identity.
Definition: groot.cpp:82
A very low-level interface to getpwnam() and the get/set/e/uid/gid functions.
Definition: gidentity.h:41
A class which acquires the process's special privileges on construction and releases them on destruct...
Definition: groot.h:49
static Identity start(SignalSafe)
A signal-safe alternative to construction.
Definition: groot.cpp:62
static void stop(SignalSafe, Identity)
A signal-safe alternative to destruction.
Definition: groot.cpp:68
Low-level classes.
~Root()
Desctructor.
Definition: groot.cpp:42
static void init(const std::string &nobody)
Initialises this class on process start-up by releasing root or suid privileges.
Definition: groot.cpp:74