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-2018 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, Feb MM
25 */
26 /**
27 * @file
28 * Director specific configuration and defines
29 */
30 #ifndef BAREOS_DIRD_DIRD_CONF_H_
31 #define BAREOS_DIRD_DIRD_CONF_H_
32
33 #include "dird/client_connection_handshake_mode.h"
34 #include "dird/date_time_bitfield.h"
35 #include "lib/alist.h"
36 #include "lib/messages_resource.h"
37 #include "lib/resource_item.h"
38 #include "lib/output_formatter.h"
39 #include "lib/tls_conf.h"
40
41 class dlist;
42
43 namespace directordaemon {
44
45 static std::string default_config_filename("bareos-dir.conf");
46
47 /**
48 * Resource codes -- they must be sequential for indexing
49 */
50 enum
51 {
52 R_DIRECTOR = 1001,
53 R_CLIENT,
54 R_JOBDEFS,
55 R_JOB,
56 R_STORAGE,
57 R_CATALOG,
58 R_SCHEDULE,
59 R_FILESET,
60 R_POOL,
61 R_MSGS,
62 R_COUNTER,
63 R_PROFILE,
64 R_CONSOLE,
65 R_DEVICE,
66 R_USER,
67 R_FIRST = R_DIRECTOR,
68 R_LAST = R_USER /* keep this updated */
69 };
70
71 /**
72 * Some resource attributes
73 */
74 enum
75 {
76 R_NAME = 1020,
77 R_ADDRESS,
78 R_PASSWORD,
79 R_TYPE,
80 R_BACKUP
81 };
82
83 /**
84 * Job Level keyword structure
85 */
86 struct s_jl {
87 const char* level_name; /* level keyword */
88 uint32_t level; /* level */
89 int32_t job_type; /* JobType permitting this level */
90 };
91
92 /**
93 * Job Type keyword structure
94 */
95 struct s_jt {
96 const char* type_name;
97 uint32_t job_type;
98 };
99
100 /**
101 * Definition of the contents of each Resource
102 * Needed for forward references
103 */
104 class ScheduleResource;
105 class ClientResource;
106 class FilesetResource;
107 class PoolResource;
108 class RunResource;
109 class DeviceResource;
110
111 /*
112 * Print configuration file schema in json format
113 */
114 bool PrintConfigSchemaJson(PoolMem& buff);
115
116 /*
117 * Director Resource
118 */
119 class DirectorResource
120 : public BareosResource
121 , public TlsResource {
122 public:
123 DirectorResource() = default;
124 virtual ~DirectorResource() = default;
125
126 dlist* DIRaddrs = nullptr;
127 dlist* DIRsrc_addr = nullptr; /* Address to source connections from */
128 char* query_file = nullptr; /* SQL query file */
129 char* working_directory = nullptr; /* WorkingDirectory */
130 char* scripts_directory = nullptr; /* ScriptsDirectory */
131 char* plugin_directory = nullptr; /* Plugin Directory */
132 alist* plugin_names = nullptr; /* Plugin names to load */
133 char* pid_directory = nullptr; /* PidDirectory */
134 char* subsys_directory = nullptr; /* SubsysDirectory */
135 std::vector<std::string> backend_directories;
136 MessagesResource* messages = nullptr; /* Daemon message handler */
137 uint32_t MaxConcurrentJobs = 0; /* Max concurrent jobs for whole director */
138 uint32_t MaxConnections = 0; /* Max concurrent connections */
139 uint32_t MaxConsoleConnections = 0; /* Max concurrent console connections */
140 utime_t FDConnectTimeout = {0}; /* Timeout for connect in seconds */
141 utime_t SDConnectTimeout = {0}; /* Timeout for connect in seconds */
142 utime_t heartbeat_interval = {0}; /* Interval to send heartbeats */
143 utime_t stats_retention = {0}; /* Statistics retention period in seconds */
144 bool optimize_for_size = false; /* Optimize daemon for minimum memory size */
145 bool optimize_for_speed = false; /* Optimize daemon for speed which may need
146 more memory */
147 bool nokeepalive = false; /* Don't use SO_KEEPALIVE on sockets */
148 bool omit_defaults = false; /* Omit config variables with default values when
149 dumping the config */
150 bool ndmp_snooping = false; /* NDMP Protocol specific snooping enabled */
151 bool auditing = false; /* Auditing enabled */
152 alist* audit_events = nullptr; /* Specific audit events to enable */
153 uint32_t ndmp_loglevel = 0; /* NDMP Protocol specific loglevel to use */
154 uint32_t subscriptions = 0; /* Number of subscribtions available */
155 uint32_t subscriptions_used = 0; /* Number of subscribtions used */
156 uint32_t jcr_watchdog_time = 0; /* Absolute time after which a Job gets
157 terminated regardless of its progress */
158 uint32_t stats_collect_interval =
159 0; /* Statistics collect interval in seconds */
160 char* verid = nullptr; /* Custom Id to print in version command */
161 char* secure_erase_cmdline = nullptr; /* Cmdline to execute to perform secure
162 erase of file */
163 char* log_timestamp_format = nullptr; /* Timestamp format to use in generic
164 logging messages */
165 s_password keyencrkey; /* Key Encryption Key */
166 };
167
168 /*
169 * Device Resource
170 *
171 * This resource is a bit different from the other resources
172 * because it is not defined in the Director
173 * by Device { ... }, but rather by a "reference" such as
174 * Device = xxx; Then when the Director connects to the
175 * SD, it requests the information about the device.
176 */
177 class DeviceResource : public BareosResource {
178 public:
179 DeviceResource() = default;
180 virtual ~DeviceResource() = default;
181
182 bool found = false; /**< found with SD */
183 int32_t num_writers = 0; /**< number of writers */
184 int32_t max_writers = 0; /**< = 1 for files */
185 int32_t reserved = 0; /**< number of reserves */
186 int32_t num_drives = 0; /**< for autochanger */
187 bool autochanger = false; /**< set if device is autochanger */
188 bool open = false; /**< drive open */
189 bool append = false; /**< in append mode */
190 bool read = false; /**< in read mode */
191 bool labeled = false; /**< Volume name valid */
192 bool offline = false; /**< not available */
193 bool autoselect = false; /**< can be selected via autochanger */
194 uint32_t PoolId = 0;
195 char ChangerName[MAX_NAME_LENGTH] = {0};
196 char VolumeName[MAX_NAME_LENGTH] = {0};
197 char MediaType[MAX_NAME_LENGTH] = {0};
198 };
199
200 /**
201 * Console ACL positions
202 */
203 enum
204 {
205 Job_ACL = 0,
206 Client_ACL,
207 Storage_ACL,
208 Schedule_ACL,
209 Pool_ACL,
210 Command_ACL,
211 FileSet_ACL,
212 Catalog_ACL,
213 Where_ACL,
214 PluginOptions_ACL,
215 Num_ACL /**< keep last */
216 };
217
218 /**
219 * Profile Resource
220 */
221 class ProfileResource : public BareosResource {
222 public:
223 ProfileResource() = default;
224 virtual ~ProfileResource() = default;
225
226 alist* ACL_lists[Num_ACL] = {0}; /**< Pointers to ACLs */
227 };
228
229 struct UserAcl {
230 BareosResource* corresponding_resource = nullptr;
231 alist* ACL_lists[Num_ACL] = {0}; /**< Pointers to ACLs */
232 alist* profiles = nullptr; /**< Pointers to profile resources */
233 };
234
235 /**
236 * Console Resource
237 */
238 class ConsoleResource
239 : public BareosResource
240 , public TlsResource {
241 public:
242 ConsoleResource() = default;
243 virtual ~ConsoleResource() = default;
244 UserAcl user_acl;
245 bool use_pam_authentication_ = false; /**< PAM Console */
246 };
247
248 class UserResource : public BareosResource {
249 public:
250 UserResource() = default;
251 virtual ~UserResource() = default;
252 UserAcl user_acl;
253 };
254
255 /**
256 * Catalog Resource
257 */
258 class CatalogResource : public BareosResource {
259 public:
260 CatalogResource() = default;
261 virtual ~CatalogResource() = default;
262
263 uint32_t db_port = 0; /**< Port */
264 char* db_address = nullptr; /**< Hostname for remote access */
265 char* db_socket = nullptr; /**< Socket for local access */
266 s_password db_password;
267 char* db_user = nullptr;
268 char* db_name = nullptr;
269 char* db_driver = nullptr; /**< Select appropriate driver */
270 uint32_t mult_db_connections = 0; /**< Set if multiple connections wanted */
271 bool disable_batch_insert =
272 false; /**< Set if batch inserts should be disabled */
273 bool try_reconnect = false; /**< Try to reconnect a database connection when
274 its dropped */
275 bool exit_on_fatal = false; /**< Make any fatal error in the connection to the
276 database exit the program */
277 uint32_t pooling_min_connections =
278 0; /**< When using sql pooling start with this
279 number of connections to the database */
280 uint32_t pooling_max_connections = 0; /**< When using sql pooling maximum
281 number of connections to the database */
282 uint32_t pooling_increment_connections = 0; /**< When using sql pooling
283 increment the pool with this amount
284 when its to small */
285 uint32_t pooling_idle_timeout =
286 0; /**< When using sql pooling set this to the number
287 of seconds to keep an idle connection */
288 uint32_t pooling_validate_timeout = 0; /**< When using sql pooling set this to
289 the number of seconds after a idle
290 connection should be validated */
291
292 /**< Methods */
293 char* display(POOLMEM* dst); /**< Get catalog information */
294 };
295
296 /**
297 * Forward referenced structures
298 */
299 struct runtime_client_status_t;
300 struct RuntimeStorageStatus;
301 struct runtime_job_status_t;
302
303 /**
304 * Client Resource
305 */
306 class ClientResource
307 : public BareosResource
308 , public TlsResource {
309 public:
310 ClientResource() = default;
311 virtual ~ClientResource() = default;
312
313 uint32_t Protocol = 0; /* Protocol to use to connect */
314 uint32_t AuthType = 0; /* Authentication Type to use for protocol */
315 uint32_t ndmp_loglevel = 0; /* NDMP Protocol specific loglevel to use */
316 uint32_t ndmp_blocksize = 0; /* NDMP Protocol specific blocksize to use */
317 uint32_t FDport = 0; /* Where File daemon listens */
318 uint64_t SoftQuota = 0; /* Soft Quota permitted in bytes */
319 uint64_t HardQuota = 0; /* Maximum permitted quota in bytes */
320 uint64_t GraceTime = 0; /* Time remaining on gracetime */
321 uint64_t QuotaLimit = 0; /* The total softquota supplied if over grace */
322 utime_t SoftQuotaGracePeriod = {0}; /* Grace time for softquota */
323 utime_t FileRetention = {0}; /* File retention period in seconds */
324 utime_t JobRetention = {0}; /* Job retention period in seconds */
325 utime_t heartbeat_interval = {0}; /* Interval to send heartbeats */
326 char* address = nullptr; /* Hostname for remote access to Client */
327 char* lanaddress =
328 nullptr; /* Hostname for remote access to Client if behind NAT in LAN
329 */
330 char* username =
331 nullptr; /* Username to use for authentication if protocol supports it */
332 CatalogResource* catalog = nullptr; /* Catalog resource */
333 int32_t MaxConcurrentJobs = 0; /* Maximum concurrent jobs */
334 bool passive = false; /* Passive Client */
335 bool conn_from_dir_to_fd = false; /* Connect to Client */
336 bool conn_from_fd_to_dir = false; /* Allow incoming connections */
337 bool enabled = false; /* Set if client is enabled */
338 bool AutoPrune = false; /* Do automatic pruning? */
339 bool StrictQuotas = false; /* Enable strict quotas? */
340 bool QuotaIncludeFailedJobs =
341 false; /* Ignore failed jobs when calculating quota */
342 bool ndmp_use_lmdb =
343 false; /* NDMP Protocol specific use LMDB for the FHDB or not */
344 int64_t max_bandwidth = 0; /* Limit speed on this client */
345 runtime_client_status_t* rcs = nullptr; /* Runtime Client Status */
346 ClientConnectionHandshakeMode connection_successful_handshake_ =
347 ClientConnectionHandshakeMode::kUndefined;
348 };
349
350 /**
351 * Store Resource
352 */
353 class StorageResource
354 : public BareosResource
355 , public TlsResource {
356 public:
357 StorageResource() = default;
358 virtual ~StorageResource() = default;
359
360 uint32_t Protocol = 0; /* Protocol to use to connect */
361 uint32_t AuthType = 0; /* Authentication Type to use for protocol */
362 uint32_t SDport = 0; /* Port where Directors connect */
363 uint32_t SDDport = 0; /* Data port for File daemon */
364 char* address = nullptr; /* Hostname for remote access to Storage */
365 char* lanaddress = nullptr; /* Hostname for remote access to Storage if behind
366 NAT in LAN */
367 char* username =
368 nullptr; /* Username to use for authentication if protocol supports it */
369 char* media_type = nullptr; /**< Media Type provided by this Storage */
370 char* ndmp_changer_device = nullptr; /**< If DIR controls storage directly
371 (NDMP_NATIVE) changer device used */
372 alist* device = nullptr; /**< Alternate devices for this Storage */
373 int32_t MaxConcurrentJobs = 0; /**< Maximum concurrent jobs */
374 int32_t MaxConcurrentReadJobs = 0; /**< Maximum concurrent jobs reading */
375 bool enabled = false; /**< Set if device is enabled */
376 bool autochanger = false; /**< Set if autochanger */
377 bool collectstats =
378 false; /**< Set if statistics should be collected of this SD */
379 bool AllowCompress = false; /**< Set if this Storage should allow jobs to
380 enable compression */
381 int64_t StorageId = 0; /**< Set from Storage DB record */
382 int64_t max_bandwidth =
383 0; /**< Limit speed on this storage daemon for replication */
384 utime_t heartbeat_interval = {0}; /**< Interval to send heartbeats */
385 utime_t cache_status_interval = {
386 0}; /**< Interval to cache the vol_list in the runtime_storage_status */
387 RuntimeStorageStatus* runtime_storage_status = nullptr;
388 StorageResource* paired_storage = nullptr; /**< Paired storage configuration
389 item for protocols like NDMP */
390
391 /* Methods */
392 char* dev_name() const;
393 };
394
dev_name()395 inline char* StorageResource::dev_name() const
396 {
397 DeviceResource* dev = (DeviceResource*)device->first();
398 return dev->resource_name_;
399 }
400
401 /**
402 * This is a sort of "unified" store that has both the
403 * storage pointer and the text of where the pointer was
404 * found.
405 */
406 class UnifiedStorageResource : public BareosResource {
407 public:
408 StorageResource* store = nullptr;
409 POOLMEM* store_source = nullptr;
410
UnifiedStorageResource()411 UnifiedStorageResource()
412 {
413 store = nullptr;
414 store_source = GetPoolMemory(PM_MESSAGE);
415 *store_source = 0;
416 }
~UnifiedStorageResource()417 ~UnifiedStorageResource() { destroy(); }
418
419 void SetSource(const char* where);
420 void destroy();
421 };
422
destroy()423 inline void UnifiedStorageResource::destroy()
424 {
425 if (store_source) {
426 FreePoolMemory(store_source);
427 store_source = nullptr;
428 }
429 }
430
SetSource(const char * where)431 inline void UnifiedStorageResource::SetSource(const char* where)
432 {
433 if (!store_source) { store_source = GetPoolMemory(PM_MESSAGE); }
434 PmStrcpy(store_source, where);
435 }
436
437 /**
438 * Job Resource
439 */
440 /* clang-format off */
441 class JobResource : public BareosResource {
442 public:
443 JobResource() = default;
444 virtual ~JobResource() = default;
445
446 uint32_t Protocol = 0; /**< Protocol to use to connect */
447 uint32_t JobType = 0; /**< Job type (backup, verify, restore) */
448 uint32_t JobLevel = 0; /**< default backup/verify level */
449 int32_t Priority = 0; /**< Job priority */
450 uint32_t RestoreJobId = 0; /**< What -- JobId to restore */
451 int32_t RescheduleTimes = 0; /**< Number of times to reschedule job */
452 uint32_t replace = 0; /**< How (overwrite, ..) */
453 uint32_t selection_type = 0;
454
455 char* RestoreWhere = nullptr; /**< Where on disk to restore -- directory */
456 char* RegexWhere = nullptr; /**< RegexWhere option */
457 char* strip_prefix = nullptr; /**< Remove prefix from filename */
458 char* add_prefix = nullptr; /**< add prefix to filename */
459 char* add_suffix = nullptr; /**< add suffix to filename -- .old */
460 char* backup_format = nullptr; /**< Format of backup to use for protocols supporting multiple backup formats */
461 char* RestoreBootstrap = nullptr; /**< Bootstrap file */
462 char* WriteBootstrap = nullptr; /**< Where to write bootstrap Job updates */
463 char* WriteVerifyList = nullptr; /**< List of changed files */
464 utime_t MaxRunTime = {0}; /**< Max run time in seconds */
465 utime_t MaxWaitTime = {0}; /**< Max blocking time in seconds */
466 utime_t FullMaxRunTime = {0}; /**< Max Full job run time */
467 utime_t DiffMaxRunTime = {0}; /**< Max Differential job run time */
468 utime_t IncMaxRunTime = {0}; /**< Max Incremental job run time */
469 utime_t MaxStartDelay = {0}; /**< Max start delay in seconds */
470 utime_t MaxRunSchedTime = {0}; /**< Max run time in seconds from Scheduled time*/
471 utime_t RescheduleInterval = {0}; /**< Reschedule interval */
472 utime_t MaxFullInterval = {0}; /**< Maximum time interval between Fulls */
473 utime_t MaxVFullInterval = {0}; /**< Maximum time interval between Virtual Fulls */
474 utime_t MaxDiffInterval = {0}; /**< Maximum time interval between Diffs */
475 utime_t DuplicateJobProximity = {0}; /**< Permitted time between duplicicates */
476 utime_t AlwaysIncrementalJobRetention = {0}; /**< Timeinterval where incrementals are not consolidated */
477 utime_t AlwaysIncrementalMaxFullAge = {0}; /**< If Full Backup is older than this age
478 * the consolidation job will include also the full */
479 utime_t RunOnIncomingConnectInterval = {0};
480 int64_t spool_size = 0; /**< Size of spool file for this job */
481 int64_t max_bandwidth = 0; /**< Speed limit on this job */
482 int64_t FileHistSize = 0; /**< Hint about the size of the expected File history */
483 int32_t MaxConcurrentJobs = 0; /**< Maximum concurrent jobs */
484 int32_t MaxConcurrentCopies = 0; /**< Limit number of concurrent jobs one Copy Job spawns */
485 int32_t AlwaysIncrementalKeepNumber = 0; /**< Number of incrementals that are always left and not consolidated */
486 int32_t MaxFullConsolidations = 0; /**< Number of consolidate jobs to be started that will include a full */
487
488 MessagesResource* messages = nullptr; /**< How and where to send messages */
489 ScheduleResource* schedule = nullptr; /**< When -- Automatic schedule */
490 ClientResource* client = nullptr; /**< Who to backup */
491 FilesetResource* fileset = nullptr; /**< What to backup -- Fileset */
492 CatalogResource* catalog = nullptr; /**< Which Catalog to use */
493 alist* storage = nullptr; /**< Where is device -- list of Storage to be used */
494 PoolResource* pool = nullptr; /**< Where is media -- Media Pool */
495 PoolResource* full_pool = nullptr; /**< Pool for Full backups */
496 PoolResource* vfull_pool = nullptr; /**< Pool for Virtual Full backups */
497 PoolResource* inc_pool = nullptr; /**< Pool for Incremental backups */
498 PoolResource* diff_pool = nullptr; /**< Pool for Differental backups */
499 PoolResource* next_pool = nullptr; /**< Next Pool for Copy/Migration Jobs and Virtual backups */
500 char* selection_pattern = nullptr;
501 JobResource* verify_job = nullptr; /**< Job name to verify */
502 JobResource* jobdefs = nullptr; /**< Job defaults */
503 alist* run_cmds = nullptr; /**< Run commands */
504 alist* RunScripts = nullptr; /**< Run {client} program {after|before} Job */
505 alist* FdPluginOptions = nullptr; /**< Generic FD plugin options used by this Job */
506 alist* SdPluginOptions = nullptr; /**< Generic SD plugin options used by this Job */
507 alist* DirPluginOptions = nullptr; /**< Generic DIR plugin options used by this Job */
508 alist* base = nullptr; /**< Base jobs */
509
510 bool allow_mixed_priority = false; /**< Allow jobs with higher priority concurrently with this */
511 bool where_use_regexp = false; /**< true if RestoreWhere is a BareosRegex */
512 bool RescheduleOnError = false; /**< Set to reschedule on error */
513 bool RescheduleIncompleteJobs = false; /**< Set to reschedule incomplete Jobs */
514 bool PrefixLinks = false; /**< Prefix soft links with Where path */
515 bool PruneJobs = false; /**< Force pruning of Jobs */
516 bool PruneFiles = false; /**< Force pruning of Files */
517 bool PruneVolumes = false; /**< Force pruning of Volumes */
518 bool SpoolAttributes = false; /**< Set to spool attributes in SD */
519 bool spool_data = false; /**< Set to spool data in SD */
520 bool rerun_failed_levels = false; /**< Upgrade to rerun failed levels */
521 bool PreferMountedVolumes = false; /**< Prefer vols mounted rather than new one */
522 bool write_part_after_job = false; /**< Set to write part after job in SD */
523 bool enabled = false; /**< Set if job enabled */
524 bool accurate = false; /**< Set if it is an accurate backup job */
525 bool AllowDuplicateJobs = false; /**< Allow duplicate jobs */
526 bool AllowHigherDuplicates = false; /**< Permit Higher Level */
527 bool CancelLowerLevelDuplicates = false; /**< Cancel lower level backup jobs */
528 bool CancelQueuedDuplicates = false; /**< Cancel queued jobs */
529 bool CancelRunningDuplicates = false; /**< Cancel Running jobs */
530 bool PurgeMigrateJob = false; /**< Purges source job on completion */
531 bool IgnoreDuplicateJobChecking = false; /**< Ignore Duplicate Job Checking */
532 bool SaveFileHist = false; /**< Ability to disable File history saving for certain protocols */
533 bool AlwaysIncremental = false; /**< Always incremental with regular consolidation */
534
535 runtime_job_status_t* rjs = nullptr; /**< Runtime Job Status */
536
537 /* Methods */
538 bool Validate();
539 };
540 /* clang-format on */
541
542 #undef MAX_FOPTS
543 #define MAX_FOPTS 40
544
545 /**
546 * File options structure
547 */
548 struct FileOptions {
549 FileOptions() = default;
550 virtual ~FileOptions() = default;
551
552 char opts[MAX_FOPTS] = {0}; /**< Options string */
553 alist regex; /**< Regex string(s) */
554 alist regexdir; /**< Regex string(s) for directories */
555 alist regexfile; /**< Regex string(s) for files */
556 alist wild; /**< Wild card strings */
557 alist wilddir; /**< Wild card strings for directories */
558 alist wildfile; /**< Wild card strings for files */
559 alist wildbase; /**< Wild card strings for files without '/' */
560 alist base; /**< List of base names */
561 alist fstype; /**< File system type limitation */
562 alist Drivetype; /**< Drive type limitation */
563 alist meta; /**< Backup meta information */
564 char* reader = nullptr; /**< Reader program */
565 char* writer = nullptr; /**< Writer program */
566 char* plugin = nullptr; /**< Plugin program */
567 };
568
569 /**
570 * This is either an include item or an exclude item
571 */
572 class IncludeExcludeItem {
573 public:
574 IncludeExcludeItem() = default;
575 virtual ~IncludeExcludeItem() = default;
576
577 FileOptions* current_opts = nullptr;
578 std::vector<FileOptions*> file_options_list;
579 alist name_list; /**< Filename list -- holds char * */
580 alist plugin_list; /**< Filename list for plugins */
581 alist ignoredir; /**< Ignoredir string */
582 };
583
584 /**
585 * FileSet Resource
586 */
587 class FilesetResource : public BareosResource {
588 public:
589 FilesetResource() = default;
590 virtual ~FilesetResource() = default;
591
592 bool new_include = false; /**< Set if new include used */
593 std::vector<IncludeExcludeItem*> include_items;
594 std::vector<IncludeExcludeItem*> exclude_items;
595 bool have_MD5 = false; /**< Set if MD5 initialized */
596 MD5_CTX md5c = {0}; /**< MD5 of include/exclude */
597 char MD5[30]{0}; /**< Base 64 representation of MD5 */
598 bool ignore_fs_changes = false; /**< Don't force Full if FS changed */
599 bool enable_vss = false; /**< Enable Volume Shadow Copy */
600
601 /* Methods */
602 bool PrintConfig(PoolMem& buf,
603 const ConfigurationParser& /* unused */,
604 bool hide_sensitive_data = false,
605 bool verbose = false) override;
606 };
607
608 /**
609 * Schedule Resource
610 */
611 class ScheduleResource : public BareosResource {
612 public:
613 ScheduleResource() = default;
614 virtual ~ScheduleResource() = default;
615
616 RunResource* run = nullptr;
617 bool enabled = false; /* Set if schedule is enabled */
618 };
619
620 /**
621 * Counter Resource
622 */
623 class CounterResource : public BareosResource {
624 public:
625 CounterResource() = default;
626 virtual ~CounterResource() = default;
627
628 int32_t MinValue = 0; /* Minimum value */
629 int32_t MaxValue = 0; /* Maximum value */
630 int32_t CurrentValue = 0; /* Current value */
631 CounterResource* WrapCounter = nullptr; /* Wrap counter name */
632 CatalogResource* Catalog = nullptr; /* Where to store */
633 bool created; /* Created in DB */
634 };
635
636 /**
637 * Pool Resource
638 */
639 class PoolResource : public BareosResource {
640 public:
641 PoolResource() = default;
642 virtual ~PoolResource() = default;
643
644 char* pool_type = nullptr; /* Pool type */
645 char* label_format = nullptr; /* Label format string */
646 char* cleaning_prefix = nullptr; /* Cleaning label prefix */
647 int32_t LabelType = 0; /* Bareos/ANSI/IBM label type */
648 uint32_t max_volumes = 0; /* Max number of volumes */
649 utime_t VolRetention = {0}; /* Volume retention period in seconds */
650 utime_t VolUseDuration = {0}; /* Duration volume can be used */
651 uint32_t MaxVolJobs = 0; /* Maximum jobs on the Volume */
652 uint32_t MaxVolFiles = 0; /* Maximum files on the Volume */
653 uint64_t MaxVolBytes = 0; /* Maximum bytes on the Volume */
654 utime_t MigrationTime = {0}; /* Time to migrate to next pool */
655 uint64_t MigrationHighBytes = 0; /* When migration starts */
656 uint64_t MigrationLowBytes = 0; /* When migration stops */
657 PoolResource* NextPool = nullptr; /* Next pool for migration */
658 alist* storage = nullptr; /* Where is device -- list of Storage to be used */
659 bool use_catalog = false; /* Maintain catalog for media */
660 bool catalog_files = false; /* Maintain file entries in catalog */
661 bool use_volume_once = false; /* Write on volume only once */
662 bool purge_oldest_volume = false; /* Purge oldest volume */
663 bool recycle_oldest_volume = false; /* Attempt to recycle oldest volume */
664 bool recycle_current_volume = false; /* Attempt recycle of current volume */
665 bool AutoPrune = false; /* Default for pool auto prune */
666 bool Recycle = false; /* Default for media recycle yes/no */
667 uint32_t action_on_purge =
668 0; /* Action on purge, e.g. truncate the disk volume */
669 PoolResource* RecyclePool =
670 nullptr; /* RecyclePool destination when media is purged */
671 PoolResource* ScratchPool =
672 nullptr; /* ScratchPool source when requesting media */
673 CatalogResource* catalog = nullptr; /* Catalog to be used */
674 utime_t FileRetention = {0}; /* File retention period in seconds */
675 utime_t JobRetention = {0}; /* Job retention period in seconds */
676 uint32_t MinBlocksize = 0; /* Minimum Blocksize */
677 uint32_t MaxBlocksize = 0; /* Maximum Blocksize */
678 };
679
680 /**
681 * Run structure contained in Schedule Resource
682 */
683 class RunResource : public BareosResource {
684 public:
685 RunResource() = default;
686 virtual ~RunResource() = default;
687
688 RunResource* next = nullptr; /**< points to next run record */
689 uint32_t level = 0; /**< level override */
690 int32_t Priority = 0; /**< priority override */
691 uint32_t job_type = 0;
692 utime_t MaxRunSchedTime = {0}; /**< max run time in sec from Sched time */
693 bool MaxRunSchedTime_set = false; /**< MaxRunSchedTime given */
694 bool spool_data = false; /**< Data spooling override */
695 bool spool_data_set = false; /**< Data spooling override given */
696 bool accurate = false; /**< accurate */
697 bool accurate_set = false; /**< accurate given */
698
699 PoolResource* pool = nullptr; /**< Pool override */
700 PoolResource* full_pool = nullptr; /**< Full Pool override */
701 PoolResource* vfull_pool = nullptr; /**< Virtual Full Pool override */
702 PoolResource* inc_pool = nullptr; /**< Incr Pool override */
703 PoolResource* diff_pool = nullptr; /**< Diff Pool override */
704 PoolResource* next_pool = nullptr; /**< Next Pool override */
705 StorageResource* storage = nullptr; /**< Storage override */
706 MessagesResource* msgs = nullptr; /**< Messages override */
707 uint32_t minute = 0; /* minute to run job */
708 time_t scheduled_last = {0};
709 DateTimeBitfield date_time_bitfield;
710 };
711
712 ConfigurationParser* InitDirConfig(const char* configfile, int exit_code);
713 bool PropagateJobdefs(int res_type, JobResource* res);
714 bool ValidateResource(int type, ResourceItem* items, BareosResource* res);
715
716 bool print_datatype_schema_json(PoolMem& buffer,
717 int level,
718 const int type,
719 ResourceItem items[],
720 const bool last = false);
721 #ifdef HAVE_JANSSON
722 json_t* json_datatype(const int type, ResourceItem items[]);
723 #endif
724 const char* AuthenticationProtocolTypeToString(uint32_t auth_protocol);
725 const char* JobLevelToString(int level);
726 extern "C" char* job_code_callback_director(JobControlRecord* jcr, const char*);
727 const char* GetUsageStringForConsoleConfigureCommand();
728 void DestroyConfigureUsageString();
729 bool PopulateDefs();
730 std::vector<JobResource*> GetAllJobResourcesByClientName(std::string name);
731
732 } /* namespace directordaemon */
733 #endif // BAREOS_DIRD_DIRD_CONF_H_
734