sbuild  1.6.10
sbuild-chroot-facet-userdata.h
1 /* Copyright © 2005-2009,2012 Roger Leigh <rleigh@debian.org>
2  *
3  * schroot is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * schroot is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  *********************************************************************/
18 
19 #ifndef SBUILD_CHROOT_FACET_USERDATA_H
20 #define SBUILD_CHROOT_FACET_USERDATA_H
21 
22 #include <sbuild/sbuild-chroot-facet.h>
23 #include <sbuild/sbuild-custom-error.h>
24 #include <sbuild/sbuild-types.h>
25 
26 namespace sbuild
27 {
28 
36  {
37  public:
40  {
45  };
46 
49 
51  typedef std::shared_ptr<chroot_facet_userdata> ptr;
52 
54  typedef std::shared_ptr<const chroot_facet_userdata> const_ptr;
55 
56  private:
59 
60  public:
62  virtual ~chroot_facet_userdata ();
63 
69  static ptr
70  create ();
71 
72  virtual chroot_facet::ptr
73  clone () const;
74 
75  virtual std::string const&
76  get_name () const;
77 
78  virtual void
79  setup_env (chroot const& chroot,
80  environment& env) const;
81 
82  virtual chroot::session_flags
83  get_session_flags (chroot const& chroot) const;
84 
85  virtual void
86  get_details (chroot const& chroot,
87  format_detail& detail) const;
88 
89  virtual void
90  get_keyfile (chroot const& chroot,
91  keyfile& keyfile) const;
92 
93  virtual void
95  keyfile const& keyfile,
96  string_list& used_keys);
97 
103  string_map const&
104  get_data () const;
105 
114  bool
115  get_data (std::string const& key,
116  std::string& value) const;
117 
124  void
125  set_data (string_map const& data);
126 
134  void
135  set_data (std::string const& key,
136  std::string const& value);
137 
145  void
146  set_system_data (std::string const& key,
147  std::string const& value);
148 
154  void
155  remove_data (std::string const& key);
156 
162  string_set const&
163  get_user_modifiable_keys () const;
164 
170  void
171  set_user_modifiable_keys (string_set const& keys);
172 
178  string_set const&
179  get_root_modifiable_keys () const;
180 
186  void
187  set_root_modifiable_keys (string_set const& keys);
188 
196  void
197  set_user_data(string_map const& data);
198 
206  void
207  set_root_data(string_map const& data);
208 
214  void
215  set_system_data(string_map const& data);
216 
217  private:
225  void
226  set_data(string_map const& data,
227  string_set const& allowed_keys,
228  bool root);
229 
238  };
239 
240 }
241 
242 #endif /* SBUILD_CHROOT_FACET_USERDATA_H */
243 
244 /*
245  * Local Variables:
246  * mode:C++
247  * End:
248  */
string_set const & get_root_modifiable_keys() const
Get the set of keys allowed to be modified by root.
Definition: sbuild-chroot-facet-userdata.cc:325
Chroot support for extensible user metadata.
Definition: sbuild-chroot-facet-userdata.h:35
error_code
Error codes.
Definition: sbuild-chroot-facet-userdata.h:39
Debian source builder components.
Definition: sbuild-auth-null.h:24
Configuration key name is ambiguous.
Definition: sbuild-chroot-facet-userdata.h:42
void remove_data(std::string const &key)
Remove a single key.
Definition: sbuild-chroot-facet-userdata.cc:235
void set_system_data(std::string const &key, std::string const &value)
Set a single key-value pair.
Definition: sbuild-chroot-facet-userdata.cc:210
string_set env
Environment checking.
Definition: sbuild-chroot-facet-userdata.h:233
void set_user_data(string_map const &data)
Set data for the current user.
Definition: sbuild-chroot-facet-userdata.cc:260
std::map< std::string, std::string > string_map
A string map.
Definition: sbuild-types.h:44
void set_root_modifiable_keys(string_set const &keys)
Set the set of keys allowed to be modified by root.
Definition: sbuild-chroot-facet-userdata.cc:331
custom_error< error_code > error
Exception type.
Definition: sbuild-chroot-facet-userdata.h:48
Container of environment variables.
Definition: sbuild-environment.h:38
std::set< std::string > string_set
A string set.
Definition: sbuild-types.h:41
string_map const & get_data() const
Get user data as a map of key-value pairs.
Definition: sbuild-chroot-facet-userdata.cc:193
string_set user_modifiable_keys
Keys modifiable by users.
Definition: sbuild-chroot-facet-userdata.h:235
Invalid name for configuration key.
Definition: sbuild-chroot-facet-userdata.h:44
std::shared_ptr< const chroot_facet_userdata > const_ptr
A shared_ptr to a const chroot facet object.
Definition: sbuild-chroot-facet-userdata.h:54
chroot_facet_userdata()
The constructor.
Definition: sbuild-chroot-facet-userdata.cc:93
string_set root_modifiable_keys
Keys modifiable by root.
Definition: sbuild-chroot-facet-userdata.h:237
Configuration file parser.
Definition: sbuild-basic-keyfile.h:138
virtual ~chroot_facet_userdata()
The destructor.
Definition: sbuild-chroot-facet-userdata.cc:102
virtual void get_details(chroot const &chroot, format_detail &detail) const
Get detailed information about the chroot for output.
Definition: sbuild-chroot-facet-userdata.cc:156
std::shared_ptr< chroot_facet_userdata > ptr
A shared_ptr to a chroot facet object.
Definition: sbuild-chroot-facet-userdata.h:51
virtual void get_keyfile(chroot const &chroot, keyfile &keyfile) const
Copy the chroot properties into a keyfile.
Definition: sbuild-chroot-facet-userdata.cc:337
Configuration key is not allowed to be modified.
Definition: sbuild-chroot-facet-userdata.h:43
virtual std::string const & get_name() const
Get the name of the chroot facet.
Definition: sbuild-chroot-facet-userdata.cc:119
virtual chroot_facet::ptr clone() const
Copy the chroot facet.
Definition: sbuild-chroot-facet-userdata.cc:113
std::vector< std::string > string_list
A string vector.
Definition: sbuild-types.h:38
string_map userdata
Mapping between user keys and values.
Definition: sbuild-chroot-facet-userdata.h:231
Custom error.
Definition: sbuild-custom-error.h:32
session_flags
Chroot session properties.
Definition: sbuild-chroot.h:57
std::shared_ptr< chroot_facet > ptr
A shared_ptr to a chroot facet object.
Definition: sbuild-chroot-facet.h:44
Format names and values for output.
Definition: sbuild-format-detail.h:38
Environment variable name is ambiguous.
Definition: sbuild-chroot-facet-userdata.h:41
virtual void set_keyfile(chroot &chroot, keyfile const &keyfile, string_list &used_keys)
Set the chroot properties from a keyfile.
Definition: sbuild-chroot-facet-userdata.cc:361
virtual chroot::session_flags get_session_flags(chroot const &chroot) const
Get the session flags of the chroot.
Definition: sbuild-chroot-facet-userdata.cc:150
void set_data(string_map const &data)
Set user data from a string map.
Definition: sbuild-chroot-facet-userdata.cc:251
Common chroot data.
Definition: sbuild-chroot.h:45
string_set const & get_user_modifiable_keys() const
Get the set of keys allowed to be modified by a user.
Definition: sbuild-chroot-facet-userdata.cc:313
virtual void setup_env(chroot const &chroot, environment &env) const
Set environment.
Definition: sbuild-chroot-facet-userdata.cc:127
static ptr create()
Create a chroot facet.
Definition: sbuild-chroot-facet-userdata.cc:107
Common chroot data.
Definition: sbuild-chroot-facet.h:40
void set_root_data(string_map const &data)
Set data for root.
Definition: sbuild-chroot-facet-userdata.cc:266
void set_user_modifiable_keys(string_set const &keys)
Set the set of keys allowed to be modified by a user.
Definition: sbuild-chroot-facet-userdata.cc:319