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