]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dird_conf.h
- Integrated TLS network encryption
[bacula/bacula] / bacula / src / dird / dird_conf.h
1 /*
2  * Director specific configuration and defines
3  *
4  *     Kern Sibbald, Feb MM
5  *
6  *    Version $Id$
7  */
8 /*
9    Copyright (C) 2000-2005 Kern Sibbald
10
11    This program is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License as
13    published by the Free Software Foundation; either version 2 of
14    the License, or (at your option) any later version.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public
22    License along with this program; if not, write to the Free
23    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24    MA 02111-1307, USA.
25
26  */
27
28 /* NOTE:  #includes at the end of this file */
29
30 /*
31  * Resource codes -- they must be sequential for indexing
32  */
33 enum {
34    R_DIRECTOR = 1001,
35    R_CLIENT,
36    R_JOB,
37    R_STORAGE,
38    R_CATALOG,
39    R_SCHEDULE,
40    R_FILESET,
41    R_POOL,
42    R_MSGS,
43    R_COUNTER,
44    R_CONSOLE,
45    R_JOBDEFS,
46    R_DEVICE,
47    R_FIRST = R_DIRECTOR,
48    R_LAST  = R_DEVICE                 /* keep this updated */
49 };
50
51
52 /*
53  * Some resource attributes
54  */
55 enum {
56    R_NAME = 1020,
57    R_ADDRESS,
58    R_PASSWORD,
59    R_TYPE,
60    R_BACKUP
61 };
62
63
64 /* Used for certain KeyWord tables */
65 struct s_kw {
66    const char *name;
67    int token;
68 };
69
70 /* Job Level keyword structure */
71 struct s_jl {
72    const char *level_name;                  /* level keyword */
73    int  level;                        /* level */
74    int  job_type;                     /* JobType permitting this level */
75 };
76
77 /* Job Type keyword structure */
78 struct s_jt {
79    const char *type_name;
80    int job_type;
81 };
82
83 /* Definition of the contents of each Resource */
84 /* Needed for forward references */
85 struct SCHED;
86 struct CLIENT;
87 struct FILESET;
88 struct POOL;
89 struct RUN;
90 struct DEVICE;
91
92 /*
93  *   Director Resource
94  *
95  */
96 class DIRRES {
97 public:
98    RES   hdr;
99    dlist *DIRaddrs;
100    char *password;                    /* Password for UA access */
101    char *query_file;                  /* SQL query file */
102    char *working_directory;           /* WorkingDirectory */
103    const char *scripts_directory;     /* ScriptsDirectory */
104    char *pid_directory;               /* PidDirectory */
105    char *subsys_directory;            /* SubsysDirectory */
106    MSGS *messages;                    /* Daemon message handler */
107    uint32_t MaxConcurrentJobs;        /* Max concurrent jobs for whole director */
108    utime_t FDConnectTimeout;          /* timeout for connect in seconds */
109    utime_t SDConnectTimeout;          /* timeout in seconds */
110 #ifdef HAVE_TLS
111    int tls_enable;                    /* Enable TLS */
112    int tls_require;                   /* Require TLS */
113    int tls_verify_peer;              /* TLS Verify Client Certificate */
114    char *tls_ca_certfile;             /* TLS CA Certificate File */
115    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
116    char *tls_certfile;                /* TLS Server Certificate File */
117    char *tls_keyfile;                 /* TLS Server Key File */
118    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
119    alist *tls_allowed_cns;            /* TLS Allowed Clients */
120
121    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
122 #endif /* HAVE_TLS */
123 };
124
125 /*
126  * Device Resource
127  *  This resource is a bit different from the other resources
128  *  because it is not defined in the Director 
129  *  by DEVICE { ... }, but rather by a "reference" such as
130  *  DEVICE = xxx; Then when the Director connects to the
131  *  SD, it requests the information about the device.
132  */
133 class DEVICE {
134 public:
135    RES hdr;
136
137    bool found;                        /* found with SD */
138    int num_writers;                   /* number of writers */
139    int max_writers;                   /* = 1 for files */
140    int reserved;                      /* number of reserves */
141    int num_drives;                    /* for autochanger */
142    bool autochanger;                  /* set if device is autochanger */
143    bool open;                         /* drive open */
144    bool append;                       /* in append mode */
145    bool read;                         /* in read mode */
146    bool labeled;                      /* Volume name valid */
147    bool offline;                      /* not available */
148    bool autoselect;                   /* can be selected via autochanger */
149    uint32_t PoolId;
150    char ChangerName[MAX_NAME_LENGTH];
151    char VolumeName[MAX_NAME_LENGTH];
152    char MediaType[MAX_NAME_LENGTH];
153 };
154
155 /*
156  * Console ACL positions
157  */
158 enum {
159    Job_ACL = 0,
160    Client_ACL,
161    Storage_ACL,
162    Schedule_ACL,
163    Run_ACL,
164    Pool_ACL,
165    Command_ACL,
166    FileSet_ACL,
167    Catalog_ACL,
168    Num_ACL                            /* keep last */
169 };
170
171 /*
172  *    Console Resource
173  */
174 class CONRES {
175 public:
176    RES   hdr;
177    char *password;                    /* UA server password */
178    alist *ACL_lists[Num_ACL];         /* pointers to ACLs */
179 #ifdef HAVE_TLS
180    int tls_enable;                    /* Enable TLS */
181    int tls_require;                   /* Require TLS */
182    int tls_verify_peer;              /* TLS Verify Client Certificate */
183    char *tls_ca_certfile;             /* TLS CA Certificate File */
184    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
185    char *tls_certfile;                /* TLS Server Certificate File */
186    char *tls_keyfile;                 /* TLS Server Key File */
187    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
188    alist *tls_allowed_cns;            /* TLS Allowed Clients */
189
190    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
191 #endif /* HAVE_TLS */
192 };
193
194
195 /*
196  *   Catalog Resource
197  *
198  */
199 class CAT {
200 public:
201    RES   hdr;
202
203    int   db_port;                     /* Port -- not yet implemented */
204    char *db_address;                  /* host name for remote access */
205    char *db_socket;                   /* Socket for local access */
206    char *db_password;
207    char *db_user;
208    char *db_name;
209    int   mult_db_connections;         /* set if multiple connections wanted */
210 };
211
212
213 /*
214  *   Client Resource
215  *
216  */
217 class CLIENT {
218 public:
219    RES   hdr;
220
221    int   FDport;                      /* Where File daemon listens */
222    int   AutoPrune;                   /* Do automatic pruning? */
223    utime_t FileRetention;             /* file retention period in seconds */
224    utime_t JobRetention;              /* job retention period in seconds */
225    char *address;
226    char *password;
227    CAT *catalog;                      /* Catalog resource */
228    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
229    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
230 #ifdef HAVE_TLS
231    int tls_enable;                    /* Enable TLS */
232    int tls_require;                   /* Require TLS */
233    char *tls_ca_certfile;             /* TLS CA Certificate File */
234    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
235    char *tls_certfile;                /* TLS Client Certificate File */
236    char *tls_keyfile;                 /* TLS Client Key File */
237
238    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
239 #endif /* HAVE_TLS */
240 };
241
242 /*
243  *   Store Resource
244  *
245  */
246 class STORE {
247 public:
248    RES   hdr;
249
250    int   SDport;                      /* port where Directors connect */
251    int   SDDport;                     /* data port for File daemon */
252    char *address;
253    char *password;
254    char *media_type;
255    alist *device;                     /* Alternate devices for this Storage */
256    int  autochanger;                  /* set if autochanger */
257    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
258    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
259 #ifdef HAVE_TLS
260    int tls_enable;                    /* Enable TLS */
261    int tls_require;                   /* Require TLS */
262    char *tls_ca_certfile;             /* TLS CA Certificate File */
263    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
264    char *tls_certfile;                /* TLS Client Certificate File */
265    char *tls_keyfile;                 /* TLS Client Key File */
266
267    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
268 #endif /* HAVE_TLS */
269
270    int64_t StorageId;                 /* Set from Storage DB record */
271
272    /* Methods */
273    char *dev_name() const;
274    char *name() const;
275 };
276
277 inline char *STORE::dev_name() const
278
279    DEVICE *dev = (DEVICE *)device->first();
280    return dev->hdr.name;
281 }
282
283 inline char *STORE::name() const { return hdr.name; }
284
285
286 /*
287  *   Job Resource
288  */
289 class JOB {
290 public:
291    RES   hdr;
292
293    int   JobType;                     /* job type (backup, verify, restore */
294    int   JobLevel;                    /* default backup/verify level */
295    int   Priority;                    /* Job priority */
296    int   RestoreJobId;                /* What -- JobId to restore */
297    char *RestoreWhere;                /* Where on disk to restore -- directory */
298    char *RestoreBootstrap;            /* Bootstrap file */
299    char *RunBeforeJob;                /* Run program before Job */
300    char *RunAfterJob;                 /* Run program after Job */
301    char *RunAfterFailedJob;           /* Run program after Job that errs */
302    char *ClientRunBeforeJob;          /* Run client program before Job */
303    char *ClientRunAfterJob;           /* Run client program after Job */
304    char *WriteBootstrap;              /* Where to write bootstrap Job updates */
305    int   replace;                     /* How (overwrite, ..) */
306    utime_t MaxRunTime;                /* max run time in seconds */
307    utime_t MaxWaitTime;               /* max blocking time in seconds */
308    utime_t FullMaxWaitTime;           /* Max Full job wait time */
309    utime_t DiffMaxWaitTime;           /* Max Differential job wait time */
310    utime_t IncMaxWaitTime;            /* Max Incremental job wait time */
311    utime_t MaxStartDelay;             /* max start delay in seconds */
312    int PrefixLinks;                   /* prefix soft links with Where path */
313    int PruneJobs;                     /* Force pruning of Jobs */
314    int PruneFiles;                    /* Force pruning of Files */
315    int PruneVolumes;                  /* Force pruning of Volumes */
316    int SpoolAttributes;               /* Set to spool attributes in SD */
317    int spool_data;                    /* Set to spool data in SD */
318    int rerun_failed_levels;           /* Upgrade to rerun failed levels */
319    int NewVolEachJob;                 /* Mount new volume each Job */
320    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
321    int RescheduleOnError;             /* Set to reschedule on error */
322    int RescheduleTimes;               /* Number of times to reschedule job */
323    utime_t RescheduleInterval;        /* Reschedule interval */
324    utime_t JobRetention;              /* job retention period in seconds */
325    bool write_part_after_job;         /* Set to write part after job in SD */
326    
327    MSGS      *messages;               /* How and where to send messages */
328    SCHED     *schedule;               /* When -- Automatic schedule */
329    CLIENT    *client;                 /* Who to backup */
330    FILESET   *fileset;                /* What to backup -- Fileset */
331    alist     *storage;                /* Where is device -- list of Storage to be used */
332    POOL      *pool;                   /* Where is media -- Media Pool */
333    POOL      *full_pool;              /* Pool for Full backups */
334    POOL      *inc_pool;               /* Pool for Incremental backups */
335    POOL      *dif_pool;               /* Pool for Differental backups */
336    JOB       *verify_job;             /* Job name to verify */
337    JOB       *jobdefs;                /* Job defaults */
338    alist     *run_cmds;               /* Run commands */
339    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
340 };
341
342 #undef  MAX_FOPTS
343 #define MAX_FOPTS 34
344
345 /* File options structure */
346 struct FOPTS {
347    char opts[MAX_FOPTS];              /* options string */
348    alist regex;                       /* regex string(s) */
349    alist regexdir;                    /* regex string(s) for directories */
350    alist regexfile;                   /* regex string(s) for files */
351    alist wild;                        /* wild card strings */
352    alist wilddir;                     /* wild card strings for directories */
353    alist wildfile;                    /* wild card strings for files */
354    alist base;                        /* list of base names */
355    alist fstype;                      /* file system type limitation */
356    char *reader;                      /* reader program */
357    char *writer;                      /* writer program */
358 };
359
360
361 /* This is either an include item or an exclude item */
362 struct INCEXE {
363    FOPTS *current_opts;               /* points to current options structure */
364    FOPTS **opts_list;                 /* options list */
365    int num_opts;                      /* number of options items */
366    alist name_list;                   /* filename list -- holds char * */
367 };
368
369 /*
370  *   FileSet Resource
371  *
372  */
373 class FILESET {
374 public:
375    RES   hdr;
376
377    bool new_include;                  /* Set if new include used */
378    INCEXE **include_items;            /* array of incexe structures */
379    int num_includes;                  /* number in array */
380    INCEXE **exclude_items;
381    int num_excludes;
382    bool have_MD5;                     /* set if MD5 initialized */
383    struct MD5Context md5c;            /* MD5 of include/exclude */
384    char MD5[30];                      /* base 64 representation of MD5 */
385    int ignore_fs_changes;             /* Don't force Full if FS changed */
386 };
387
388
389 /*
390  *   Schedule Resource
391  *
392  */
393 class SCHED {
394 public:
395    RES   hdr;
396
397    RUN *run;
398 };
399
400 /*
401  *   Counter Resource
402  */
403 class COUNTER {
404 public:
405    RES   hdr;
406
407    int32_t  MinValue;                 /* Minimum value */
408    int32_t  MaxValue;                 /* Maximum value */
409    int32_t  CurrentValue;             /* Current value */
410    COUNTER *WrapCounter;              /* Wrap counter name */
411    CAT     *Catalog;                  /* Where to store */
412    bool     created;                  /* Created in DB */
413 };
414
415 /*
416  *   Pool Resource
417  *
418  */
419 class POOL {
420 public:
421    RES   hdr;
422
423    char *pool_type;                   /* Pool type */
424    char *label_format;                /* Label format string */
425    char *cleaning_prefix;             /* Cleaning label prefix */
426    int   LabelType;                   /* Bacula/ANSI/IBM label type */
427    int   use_catalog;                 /* maintain catalog for media */
428    int   catalog_files;               /* maintain file entries in catalog */
429    int   use_volume_once;             /* write on volume only once */
430    int   accept_any_volume;           /* accept any volume */
431    int   purge_oldest_volume;         /* purge oldest volume */
432    int   recycle_oldest_volume;       /* attempt to recycle oldest volume */
433    int   recycle_current_volume;      /* attempt recycle of current volume */
434    uint32_t max_volumes;              /* max number of volumes */
435    utime_t VolRetention;              /* volume retention period in seconds */
436    utime_t VolUseDuration;            /* duration volume can be used */
437    uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
438    uint32_t MaxVolFiles;              /* Maximum files on the Volume */
439    uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
440    int   AutoPrune;                   /* default for pool auto prune */
441    int   Recycle;                     /* default for media recycle yes/no */
442 };
443
444
445
446
447 /* Define the Union of all the above
448  * resource structure definitions.
449  */
450 union URES {
451    DIRRES     res_dir;
452    CONRES     res_con;
453    CLIENT     res_client;
454    STORE      res_store;
455    CAT        res_cat;
456    JOB        res_job;
457    FILESET    res_fs;
458    SCHED      res_sch;
459    POOL       res_pool;
460    MSGS       res_msgs;
461    COUNTER    res_counter;
462    DEVICE     res_dev;
463    RES        hdr;
464 };
465
466
467
468 /* Run structure contained in Schedule Resource */
469 class RUN {
470 public:
471    RUN *next;                         /* points to next run record */
472    int level;                         /* level override */
473    int Priority;                      /* priority override */
474    int job_type;
475    bool spool_data;                   /* Data spooling override */
476    bool spool_data_set;               /* Data spooling override given */
477    bool write_part_after_job;         /* Write part after job override */
478    bool write_part_after_job_set;     /* Write part after job override given */
479    
480    POOL *pool;                        /* Pool override */
481    POOL *full_pool;                   /* Pool override */
482    POOL *inc_pool;                    /* Pool override */
483    POOL *dif_pool;                    /* Pool override */
484    STORE *storage;                    /* Storage override */
485    MSGS *msgs;                        /* Messages override */
486    char *since;
487    int level_no;
488    int minute;                        /* minute to run job */
489    time_t last_run;                   /* last time run */
490    time_t next_run;                   /* next time to run */
491    char hour[nbytes_for_bits(24)];    /* bit set for each hour */
492    char mday[nbytes_for_bits(31)];    /* bit set for each day of month */
493    char month[nbytes_for_bits(12)];   /* bit set for each month */
494    char wday[nbytes_for_bits(7)];     /* bit set for each day of the week */
495    char wom[nbytes_for_bits(5)];      /* week of month */
496    char woy[nbytes_for_bits(54)];     /* week of year */
497 };