USBGuard
Software framework that protects your computer against rogue USB devices by implementing basic whitelisting and blacklisting capabilities.
ConfigFile.hpp
1 //
2 // Copyright (C) 2017 Red Hat, Inc.
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 2 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 //
17 // Authors: Daniel Kopecek <dkopecek@redhat.com>
18 //
19 #pragma once
20 
21 #include "Typedefs.hpp"
22 #include "usbguard/Logger.hpp"
23 
24 #include <string>
25 #include <vector>
26 #include <memory>
27 
28 namespace usbguard
29 {
30  class ConfigFilePrivate;
31 
36  class DLL_PUBLIC ConfigFile
37  {
38  public:
39 
47  ConfigFile(const std::vector<std::string>& known_names = std::vector<std::string>());
48 
56  ~ConfigFile();
57 
67  void open(const std::string& path, bool readonly = false);
68 
75  void write();
76 
84  void close();
85 
92  void setSettingValue(const std::string& name, std::string& value);
93 
101  bool hasSettingValue(const std::string& name) const;
102 
109  const std::string& getSettingValue(const std::string& name) const;
110 
111  private:
112  std::unique_ptr<ConfigFilePrivate> d_pointer;
113  };
114 } /* namespace usbguard */
115 
116 /* vim: set ts=2 sw=2 et */
Enables manipulation with the config file and its settings.
Definition: ConfigFile.hpp:36