1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2000-2011 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 /**
25  * @file bareos storage daemon configuration definitions
26  *
27  */
28 #ifndef BAREOS_STORED_STORED_CONF_H_
29 #define BAREOS_STORED_STORED_CONF_H_ 1
30 
31 #include "stored/dev.h"
32 
33 namespace storagedaemon {
34 
35 static const std::string default_config_filename("bareos-sd.conf");
36 
37 /*
38  * Resource codes -- they must be sequential for indexing
39  */
40 enum {
41    R_DIRECTOR = 3001,
42    R_NDMP,
43    R_STORAGE,
44    R_DEVICE,
45    R_MSGS,
46    R_AUTOCHANGER,
47    R_JOB, /* needed for Job name conversion */
48    R_FIRST = R_DIRECTOR,
49    R_LAST = R_JOB             /* keep this updated */
50 };
51 
52 enum {
53    R_NAME = 3020,
54    R_ADDRESS,
55    R_PASSWORD,
56    R_TYPE,
57    R_BACKUP
58 };
59 
60 /* Definition of the contents of each Resource */
61 class DirectorResource : public TlsResource {
62 public:
63    char *address;                     /**< Director IP address or zero */
64    bool monitor;                      /**< Have only access to status and .status functions */
65    uint64_t max_bandwidth_per_job;    /**< Bandwidth limitation (per director) */
66    s_password keyencrkey;             /**< Key Encryption Key */
DirectorResource()67    DirectorResource() : TlsResource() {}
68 };
69 
70 class NdmpResource {
71 public:
72    CommonResourceHeader hdr;
73 
74    uint32_t AuthType;                 /**< Authentication Type to use */
75    uint32_t LogLevel;                 /**< Log level to use for logging NDMP protocol msgs */
76    char *username;                    /**< NDMP username */
77    s_password password;               /**< NDMP password */
78 };
79 
80 /* Storage daemon "global" definitions */
81 class StorageResource : public TlsResource {
82 public:
83    dlist *SDaddrs;
84    dlist *SDsrc_addr;                 /**< Address to source connections from */
85    dlist *NDMPaddrs;
86    char *working_directory;           /**< Working directory for checkpoints */
87    char *pid_directory;
88    char *subsys_directory;
89    char *plugin_directory;            /**< Plugin directory */
90    alist *plugin_names;
91    char *scripts_directory;
92    alist *backend_directories;        /**< Backend Directories */
93    uint32_t MaxConcurrentJobs;        /**< Maximum concurrent jobs to run */
94    uint32_t MaxConnections;           /**< Maximum connections to allow */
95    uint32_t ndmploglevel;             /**< Initial NDMP log level */
96    uint32_t jcr_watchdog_time;        /**< Absolute time after which a Job gets terminated regardless of its progress */
97    uint32_t stats_collect_interval;   /**< Statistics collect interval in seconds */
98    MessagesResource *messages;                 /**< Daemon message handler */
99    utime_t SDConnectTimeout;          /**< Timeout in seconds */
100    utime_t FDConnectTimeout;          /**< Timeout in seconds */
101    utime_t heartbeat_interval;        /**< Interval to send hb to FD */
102    utime_t client_wait;               /**< Time to wait for FD to connect */
103    uint32_t max_network_buffer_size;  /**< Max network buf size */
104    bool autoxflateonreplication;      /**< Perform autoxflation when replicating data */
105    bool compatible;                   /**< Write compatible format */
106    bool allow_bw_bursting;            /**< Allow bursting with bandwidth limiting */
107    bool ndmp_enable;                  /**< Enable NDMP protocol listener */
108    bool ndmp_snooping;                /**< Enable NDMP protocol snooping */
109    bool nokeepalive;                  /**< Don't use SO_KEEPALIVE on sockets */
110    bool collect_dev_stats;            /**< Collect Device Statistics */
111    bool collect_job_stats;            /**< Collect Job Statistics */
112    bool device_reserve_by_mediatype;  /**< Allow device reservation based on a matching mediatype */
113    bool filedevice_concurrent_read;   /**< Allow filedevices to be read concurrently */
114    char *verid;                       /**< Custom Id to print in version command */
115    char *secure_erase_cmdline;        /**< Cmdline to execute to perform secure erase of file */
116    char *log_timestamp_format;        /**< Timestamp format to use in generic logging messages */
117    uint64_t max_bandwidth_per_job;    /**< Bandwidth limitation (global) */
118 
StorageResource()119    StorageResource() : TlsResource() {}
120 };
121 
122 class AutochangerResource : public BareosResource {
123 public:
124    alist *device;                     /**< List of DeviceResource device pointers */
125    char *changer_name;                /**< Changer device name */
126    char *changer_command;             /**< Changer command  -- external program */
127    brwlock_t changer_lock;            /**< One changer operation at a time */
128 
AutochangerResource()129    AutochangerResource() : BareosResource() {}
130 };
131 
132 /* Device specific definitions */
133 class DeviceResource : public BareosResource {
134 public:
135    char *media_type;                  /**< User assigned media type */
136    char *device_name;                 /**< Archive device name */
137    char *device_options;              /**< Device specific option string */
138    char *diag_device_name;            /**< Diagnostic device name */
139    char *changer_name;                /**< Changer device name */
140    char *changer_command;             /**< Changer command  -- external program */
141    char *alert_command;               /**< Alert command -- external program */
142    char *spool_directory;             /**< Spool file directory */
143    uint32_t dev_type;                 /**< device type */
144    uint32_t label_type;               /**< label type */
145    bool autoselect;                   /**< Automatically select from AutoChanger */
146    bool norewindonclose;              /**< Don't rewind tape drive on close */
147    bool drive_tapealert_enabled;      /**< Enable Tape Alert monitoring */
148    bool drive_crypto_enabled;         /**< Enable hardware crypto */
149    bool query_crypto_status;          /**< Query device for crypto status */
150    bool collectstats;                 /**< Set if statistics should be collected */
151    bool eof_on_error_is_eot;          /**< Interpret EOF during read error as EOT */
152    drive_number_t drive;              /**< Autochanger logical drive number */
153    drive_number_t drive_index;        /**< Autochanger physical drive index */
154    char cap_bits[CAP_BYTES];          /**< Capabilities of this device */
155    utime_t max_changer_wait;          /**< Changer timeout */
156    utime_t max_rewind_wait;           /**< Maximum secs to wait for rewind */
157    utime_t max_open_wait;             /**< Maximum secs to wait for open */
158    uint32_t max_open_vols;            /**< Maximum simultaneous open volumes */
159    uint32_t label_block_size;         /**< block size of the label block*/
160    uint32_t min_block_size;           /**< Current Minimum block size */
161    uint32_t max_block_size;           /**< Current Maximum block size */
162    uint32_t max_volume_jobs;          /**< Max jobs to put on one volume */
163    uint32_t max_network_buffer_size;  /**< Max network buf size */
164    uint32_t max_concurrent_jobs;      /**< Maximum concurrent jobs this drive */
165    uint32_t autodeflate_algorithm;    /**< Compression algorithm to use for compression */
166    uint16_t autodeflate_level;        /**< Compression level to use for compression algorithm which uses levels */
167    uint16_t autodeflate;              /**< Perform auto deflation in this IO direction */
168    uint16_t autoinflate;              /**< Perform auto inflation in this IO direction */
169    utime_t vol_poll_interval;         /**< Interval between polling volume during mount */
170    int64_t max_volume_files;          /**< Max files to put on one volume */
171    int64_t max_volume_size;           /**< Max bytes to put on one volume */
172    int64_t max_file_size;             /**< Max file size in bytes */
173    int64_t volume_capacity;           /**< Advisory capacity */
174    int64_t max_spool_size;            /**< Max spool size for all jobs */
175    int64_t max_job_spool_size;        /**< Max spool size for any single job */
176 
177    int64_t max_part_size;             /**< Max part size */
178    char *mount_point;                 /**< Mount point for require mount devices */
179    char *mount_command;               /**< Mount command */
180    char *unmount_command;             /**< Unmount command */
181    char *write_part_command;          /**< Write part command */
182    char *free_space_command;          /**< Free space command */
183 
184    /*
185     * The following are set at runtime
186     */
187    Device *dev;                       /* Pointer to physical dev -- set at runtime */
188    AutochangerResource *changer_res;       /* Pointer to changer res if any */
189 
DeviceResource()190    DeviceResource() : BareosResource() {}
191 };
192 
193 union UnionOfResources {
194    DirectorResource res_dir;
195    NdmpResource res_ndmp;
196    StorageResource res_store;
197    DeviceResource res_dev;
198    MessagesResource res_msgs;
199    AutochangerResource res_changer;
200    CommonResourceHeader hdr;
201 
UnionOfResources()202    UnionOfResources() {new(&hdr) CommonResourceHeader();}
~UnionOfResources()203    ~UnionOfResources() {}
204 };
205 
206 ConfigurationParser *InitSdConfig(const char *configfile, int exit_code);
207 bool PrintConfigSchemaJson(PoolMem &buffer);
208 
209 } /* namespace storagedaemon */
210 #endif /* BAREOS_STORED_STORED_CONF_H_ */
211