1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
5    Copyright (C) 2011-2012 Planets Communications B.V.
6    Copyright (C) 2013-2016 Bareos GmbH & Co. KG
7 
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12 
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    Affero General Public License for more details.
17 
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22 */
23 /*
24  * Kern Sibbald, Sep MM
25  */
26 /**
27  * @file
28  * Bareos User Agent specific configuration and defines
29  */
30 
31 #ifndef BAREOS_CONSOLE_CONSOLE_CONF_H_
32 #define BAREOS_CONSOLE_CONSOLE_CONF_H_ 1
33 
34 #include <string>
35 #include "lib/parse_conf.h"
36 
37 class ConfigurationParser;
38 
39 namespace console {
40 
41 static const std::string default_config_filename("bconsole.conf");
42 
43 /**
44  * Resource codes -- they must be sequential for indexing
45  */
46 
47 enum
48 {
49   R_CONSOLE = 1001,
50   R_DIRECTOR,
51   R_FIRST = R_CONSOLE,
52   R_LAST = R_DIRECTOR /* Keep this updated */
53 };
54 
55 enum
56 {
57   R_NAME = 1020,
58   R_ADDRESS,
59   R_PASSWORD,
60   R_TYPE,
61   R_BACKUP
62 };
63 
64 class ConsoleResource
65     : public BareosResource
66     , public TlsResource {
67  public:
68   ConsoleResource() = default;
69   virtual ~ConsoleResource() = default;
70 
71   char* rc_file = nullptr;       /**< startup file */
72   char* history_file = nullptr;  /**< command history file */
73   s_password password;           /**< UA server password */
74   uint32_t history_length = 0;   /**< readline history length */
75   char* director = nullptr;      /**< bind to director */
76   utime_t heartbeat_interval{0}; /**< Interval to send heartbeats to Dir */
77 };
78 
79 class DirectorResource
80     : public BareosResource
81     , public TlsResource {
82  public:
83   DirectorResource() = default;
84   virtual ~DirectorResource() = default;
85 
86   uint32_t DIRport = 0;          /**< UA server port */
87   char* address = nullptr;       /**< UA server address */
88   utime_t heartbeat_interval{0}; /**< Interval to send heartbeats to Dir */
89 };
90 
91 ConfigurationParser* InitConsConfig(const char* configfile, int exit_code);
92 bool PrintConfigSchemaJson(PoolMem& buffer);
93 
94 } /* namespace console */
95 #endif /* BAREOS_CONSOLE_CONSOLE_CONF_H_ */
96