1 #ifndef _CONF_H
2 #define _CONF_H
3 
4 #define CONF_FLAG_CC_OVERRIDE		0x01
5 #define CONF_FLAG_INCEXC		0x02
6 #define CONF_FLAG_INCEXC_RESTORE	0x04
7 #define CONF_FLAG_STRLIST_SORTED	0x08
8 #define CONF_FLAG_STRLIST_REPLACE	0x10
9 
10 enum burp_mode
11 {
12 	BURP_MODE_UNSET=0,
13 	BURP_MODE_SERVER,
14 	BURP_MODE_CLIENT
15 };
16 
17 enum protocol
18 {
19 	PROTO_AUTO=0,
20 	PROTO_1,
21 	PROTO_2
22 };
23 
24 enum recovery_method
25 {
26 	RECOVERY_METHOD_UNSET=0,
27 	RECOVERY_METHOD_DELETE,
28 	RECOVERY_METHOD_RESUME
29 };
30 
31 enum rshash
32 {
33 	RSHASH_UNSET=0,
34 	RSHASH_MD4,
35 	RSHASH_BLAKE2
36 };
37 
38 enum vss_restore
39 {
40 	VSS_RESTORE_OFF=0,
41 	VSS_RESTORE_OFF_STRIP,
42 	VSS_RESTORE_ON
43 };
44 
45 enum conf_type
46 {
47 	CT_STRING=0,
48 	CT_UINT,
49 	CT_FLOAT,
50 	CT_MODE_T,
51 	CT_SSIZE_T,
52 	CT_E_BURP_MODE,
53 	CT_E_PROTOCOL,
54 	CT_E_RECOVERY_METHOD,
55 	CT_E_RSHASH,
56 	CT_STRLIST,
57 	CT_CNTR,
58 };
59 
60 struct conf
61 {
62 	enum conf_type conf_type;
63 	const char *field;
64 	union
65 	{
66 		char *s;
67 		float f;
68 		enum burp_mode burp_mode;
69 		enum recovery_method recovery_method;
70 		enum protocol protocol;
71 		enum rshash rshash;
72 		mode_t mode;
73 		uint64_t uint64;
74 		unsigned int i;
75 		struct strlist *sl;
76 		struct cntr *cntr;
77 	} data;
78 	int flags;
79 };
80 
81 enum conf_opt
82 {
83 	OPT_CONFFILE=0,
84 	OPT_BURP_MODE,
85 	OPT_LOCKFILE,
86 	OPT_PIDFILE,
87 	OPT_SYSLOG,
88 	OPT_STDOUT,
89 	OPT_PROGRESS_COUNTER,
90 	OPT_SSL_CERT_CA,
91 	OPT_SSL_CERT,
92 	OPT_SSL_KEY,
93 	OPT_SSL_KEY_PASSWORD,
94 	OPT_SSL_PEER_CN,
95 	OPT_SSL_CIPHERS,
96 	OPT_SSL_COMPRESSION,
97 	OPT_SSL_VERIFY_PEER_EARLY,
98 	OPT_USER,
99 	OPT_GROUP,
100 	OPT_RATELIMIT,
101 	OPT_NETWORK_TIMEOUT,
102 	OPT_CLIENT_IS_WINDOWS,
103 	OPT_PEER_VERSION,
104 	OPT_PROTOCOL,
105 	OPT_RSHASH,
106 	OPT_MESSAGE,
107 	OPT_CNAME_LOWERCASE, // force lowercase cname, client or server option
108 	OPT_CNAME_FQDN, // use fqdn cname, client or server option
109 	OPT_VSS_RESTORE,
110 
111 	// Server options.
112 	OPT_LISTEN,
113 	OPT_LISTEN_STATUS,
114 	OPT_NETWORK_ALLOW,
115 	OPT_NETWORK_ALLOW_STATUS,
116 	OPT_DIRECTORY,
117 	OPT_TIMESTAMP_FORMAT,
118 	OPT_CLIENTCONFDIR,
119 	OPT_SSL_DHFILE,
120 	OPT_MAX_CHILDREN,
121 	OPT_MAX_STATUS_CHILDREN,
122 	OPT_MAX_PARALLEL_BACKUPS,
123 	OPT_CLIENT_LOCKDIR,
124 	OPT_UMASK,
125 	OPT_MAX_HARDLINKS,
126 	OPT_MAX_STORAGE_SUBDIRS,
127 	OPT_FORK,
128 	OPT_DAEMON,
129 	OPT_DIRECTORY_TREE,
130 	OPT_CA_CONF,
131 	OPT_CA_NAME,
132 	OPT_CA_SERVER_NAME,
133 	OPT_CA_BURP_CA,
134 	OPT_CA_CRL_CHECK,
135 	OPT_CA_CRL,
136 	OPT_PASSWORD_CHECK,
137 	OPT_MANUAL_DELETE,
138 	OPT_RBLK_MEMORY_MAX,
139 	OPT_SPARSE_SIZE_MAX,
140 	OPT_MONITOR_LOGFILE, // An ncurses client option, from command line.
141 	OPT_MONITOR_BROWSE_CACHE,
142 	OPT_MONITOR_EXE,
143 	OPT_BACKUP_FAILOVERS_LEFT,
144 
145 	// Client options.
146 	OPT_CNAME, // set on the server when client connects
147 	OPT_PORT,
148 	OPT_STATUS_PORT,
149 	OPT_PORT_BACKUP,
150 	OPT_PORT_RESTORE,
151 	OPT_PORT_VERIFY,
152 	OPT_PORT_LIST,
153 	OPT_PORT_DELETE,
154 	OPT_PASSWORD, // also a clientconfdir option
155 	OPT_PASSWD, // also a clientconfdir option
156 	OPT_ENABLED, // also a clientconfdir option
157 	OPT_SERVER,
158 	OPT_SERVER_FAILOVER,
159 	OPT_FAILOVER_ON_BACKUP_ERROR,
160 	OPT_ENCRYPTION_PASSWORD,
161 	OPT_AUTOUPGRADE_OS,
162 	OPT_AUTOUPGRADE_DIR, // also a server option
163 	OPT_CA_CSR_DIR,
164 	OPT_RANDOMISE,
165 	OPT_SERVER_CAN_OVERRIDE_INCLUDES,
166 	OPT_RESTORE_LIST,
167 
168 	// This block of client stuff is all to do with what files to backup.
169 	OPT_STARTDIR,
170 	OPT_INCEXCDIR,
171 	OPT_INCLUDE,
172 	OPT_EXCLUDE,
173 	OPT_FSCHGDIR,
174 	OPT_NOBACKUP,
175 	OPT_INCEXT, // include extensions
176 	OPT_EXCEXT, // exclude extensions
177 	OPT_INCREG, // include (regular expression)
178 	OPT_EXCREG, // exclude (regular expression)
179 	OPT_INCLOGIC, // include logic expression
180 	OPT_EXCLOGIC, // exclude logic expression
181 	OPT_EXCFS, // exclude filesystems
182 	OPT_INCFS, // include filesystems
183 	OPT_EXCOM, // exclude from compression
184 	OPT_INCGLOB, // include (glob expression)
185 	OPT_SEED_SRC,
186 	OPT_SEED_DST,
187 	OPT_CROSS_ALL_FILESYSTEMS,
188 	OPT_READ_ALL_FIFOS,
189 	OPT_FIFOS,
190 	OPT_READ_ALL_BLOCKDEVS,
191 	OPT_BLOCKDEVS,
192 	OPT_MIN_FILE_SIZE,
193 	OPT_MAX_FILE_SIZE,
194 	OPT_SPLIT_VSS,
195 	OPT_STRIP_VSS,
196 	OPT_VSS_DRIVES,
197 	OPT_ACL,
198 	OPT_XATTR,
199 	OPT_ATIME,
200 	OPT_SCAN_PROBLEM_RAISES_ERROR,
201 	// These are to do with restore.
202 	OPT_OVERWRITE,
203 	OPT_STRIP,
204 	OPT_STRIP_FROM_PATH,
205 	OPT_BACKUP,
206 	OPT_BACKUP2, // For diffs.
207 	OPT_RESTOREPREFIX,
208 	OPT_REGEX,
209 	OPT_REGEX_CASE_INSENSITIVE,
210 	// To do with listing.
211 	OPT_BROWSEFILE,
212 	OPT_BROWSEDIR,
213 
214 	// Backup/restore client scripts.
215 	OPT_B_SCRIPT_PRE,
216 	OPT_B_SCRIPT_PRE_ARG,
217 	OPT_B_SCRIPT_POST,
218 	OPT_B_SCRIPT_POST_ARG,
219 	OPT_B_SCRIPT_POST_RUN_ON_FAIL,
220 	OPT_B_SCRIPT_RESERVED_ARGS,
221 	OPT_R_SCRIPT_PRE,
222 	OPT_R_SCRIPT_PRE_ARG,
223 	OPT_R_SCRIPT_POST,
224 	OPT_R_SCRIPT_POST_ARG,
225 	OPT_R_SCRIPT_POST_RUN_ON_FAIL,
226 	OPT_R_SCRIPT_RESERVED_ARGS,
227 
228 	// eval glob after script pre.
229 	OPT_GLOB_AFTER_SCRIPT_PRE,
230 
231 	// Server scripts.
232 	OPT_S_SCRIPT_PRE,
233 	OPT_S_SCRIPT_PRE_ARG,
234 	OPT_S_SCRIPT_PRE_NOTIFY,
235 	OPT_S_SCRIPT_POST,
236 	OPT_S_SCRIPT_POST_ARG,
237 	OPT_S_SCRIPT_POST_RUN_ON_FAIL,
238 	OPT_S_SCRIPT_POST_NOTIFY,
239 
240 	// Use these when you want to give the same args to both post and pre
241 	// scripts.
242 	// Backup/restore client scripts.
243 	OPT_B_SCRIPT,
244 	OPT_B_SCRIPT_ARG,
245 	OPT_R_SCRIPT,
246 	OPT_R_SCRIPT_ARG,
247 	// Server scripts.
248 	OPT_S_SCRIPT,
249 	OPT_S_SCRIPT_ARG,
250 	OPT_S_SCRIPT_NOTIFY,
251 
252 	// Client options on the server.
253 	// They can be set globally in the server config, or for each client.
254 	OPT_HARDLINKED_ARCHIVE,
255 
256 	OPT_KEEP,
257 
258 	OPT_WORKING_DIR_RECOVERY_METHOD,
259 	OPT_FAIL_ON_WARNING,
260 	OPT_MAX_RESUME_ATTEMPTS,
261 	OPT_LIBRSYNC,
262 	OPT_LIBRSYNC_MAX_SIZE,
263 
264 	OPT_COMPRESSION,
265 	OPT_VERSION_WARN,
266 	OPT_PATH_LENGTH_WARN,
267 	OPT_HARD_QUOTA,
268 	OPT_SOFT_QUOTA,
269 
270 	OPT_TIMER_SCRIPT,
271 	OPT_TIMER_ARG,
272 	OPT_TIMER_REPEAT_INTERVAL,
273 
274 	OPT_LABEL,
275 
276 	// Notify scripts
277 	OPT_N_SUCCESS_SCRIPT,
278 	OPT_N_SUCCESS_ARG,
279 	OPT_N_SUCCESS_WARNINGS_ONLY,
280 	OPT_N_SUCCESS_CHANGES_ONLY,
281 
282 	OPT_N_FAILURE_SCRIPT,
283 	OPT_N_FAILURE_ARG,
284 	OPT_N_FAILURE_BACKUP_FAILOVERS_LEFT,
285 	OPT_N_FAILURE_BACKUP_WORKING_DELETION,
286 
287 	OPT_RESTORE_CLIENTS,
288 	OPT_SUPER_CLIENTS,
289 
290 	OPT_DEDUP_GROUP,
291 
292 	OPT_CLIENT_CAN_DELETE,
293 	OPT_CLIENT_CAN_DIFF,
294 	OPT_CLIENT_CAN_FORCE_BACKUP,
295 	OPT_CLIENT_CAN_LIST,
296 	OPT_CLIENT_CAN_MONITOR,
297 	OPT_CLIENT_CAN_RESTORE,
298 	OPT_CLIENT_CAN_VERIFY,
299 	OPT_SERVER_CAN_RESTORE,
300 
301 	// Set to 1 on both client and server when the server is able to send
302 	// counters on resume/verify/restore.
303 	OPT_SEND_CLIENT_CNTR,
304 
305 	// Set on the server to the super client name (the one that you
306 	// connected with) when the client has switched to a different set of
307 	// client backups.
308 	OPT_SUPER_CLIENT,
309 	// Path to the server initiated restore file.
310 	OPT_RESTORE_PATH,
311 
312 	// Original client that backed up. Used when doing a server initiated
313 	// restore to an alternative client,
314 	OPT_ORIG_CLIENT,
315 	// The client that connected.
316 	OPT_CONNECT_CLIENT,
317 
318 	OPT_CNTR,
319 
320 	// For testing.
321 	OPT_BREAKPOINT,
322 
323 	// readall capability
324 	OPT_READALL,
325 
326 	OPT_MAX
327 };
328 
329 extern struct conf **confs_alloc(void);
330 extern void confs_free(struct conf ***confs);
331 extern void confs_free_content(struct conf **confs);
332 extern int confs_init(struct conf **confs);
333 extern void conf_free_content(struct conf *c);
334 extern void confs_free_content(struct conf **confs);
335 extern void confs_null(struct conf **confs);
336 extern void confs_memcpy(struct conf **dst, struct conf **src);
337 
338 extern void free_incexcs(struct conf **confs);
339 extern int conf_set(struct conf **confs, const char *field, const char *value);
340 extern int confs_dump(struct conf **confs, int flags);
341 
342 extern struct strlist *get_strlist(struct conf *conf);
343 extern char *get_string(struct conf *conf);
344 extern int get_int(struct conf *conf);
345 extern float get_float(struct conf *conf);
346 extern uint64_t get_uint64_t(struct conf *conf);
347 extern mode_t get_mode_t(struct conf *conf);
348 extern enum burp_mode get_e_burp_mode(struct conf *conf);
349 extern enum protocol get_e_protocol(struct conf *conf);
350 extern enum protocol get_protocol(struct conf **confs);
351 extern enum recovery_method get_e_recovery_method(struct conf *conf);
352 extern enum rshash get_e_rshash(struct conf *conf);
353 extern struct cntr *get_cntr(struct conf **confs);
354 
355 extern int set_cntr(struct conf *conf, struct cntr *cntr);
356 extern int set_string(struct conf *conf, const char *s);
357 extern int set_strlist(struct conf *conf, struct strlist *s);
358 extern int set_int(struct conf *conf, unsigned int i);
359 extern int set_e_burp_mode(struct conf *conf, enum burp_mode bm);
360 extern int set_e_protocol(struct conf *conf, enum protocol p);
361 extern int set_protocol(struct conf **confs, enum protocol p);
362 extern int set_e_rshash(struct conf *conf, enum rshash r);
363 extern int set_mode_t(struct conf *conf, mode_t m);
364 extern int set_float(struct conf *conf, float f);
365 extern int set_uint64_t(struct conf *conf, uint64_t s);
366 extern int add_to_strlist(struct conf *conf, const char *value, int include);
367 extern int add_to_strlist_include_uniq(struct conf *conf, const char *value);
368 
369 extern enum burp_mode str_to_burp_mode(const char *str);
370 extern enum protocol str_to_protocol(const char *str);
371 extern const char *recovery_method_to_str(enum recovery_method r);
372 extern enum recovery_method str_to_recovery_method(const char *str);
373 extern int set_e_recovery_method(struct conf *conf, enum recovery_method r);
374 extern const char *rshash_to_str(enum rshash r);
375 
376 #endif
377