diff --git a/core/src/filed/CMakeLists.txt b/core/src/filed/CMakeLists.txt index 5dd28137d79..4bbe549418e 100644 --- a/core/src/filed/CMakeLists.txt +++ b/core/src/filed/CMakeLists.txt @@ -28,8 +28,8 @@ ELSE() ENDIF() set(FDSRCS accurate.cc authenticate.cc crypto.cc fd_plugins.cc fileset.cc sd_cmds.cc verify.cc - accurate_htable.cc backup.cc dir_cmd.cc filed.cc heartbeat.cc socket_server.cc verify_vol.cc - accurate_lmdb.cc compression.cc estimate.cc filed_conf.cc restore.cc status.cc) + accurate_htable.cc backup.cc dir_cmd.cc filed.cc filed_globals.cc heartbeat.cc socket_server.cc + verify_vol.cc accurate_lmdb.cc compression.cc estimate.cc filed_conf.cc restore.cc status.cc) IF(HAVE_WIN32) LIST(APPEND FDSRCS diff --git a/core/src/filed/accurate.cc b/core/src/filed/accurate.cc index 32f1d5b111a..76d26c4be96 100644 --- a/core/src/filed/accurate.cc +++ b/core/src/filed/accurate.cc @@ -24,10 +24,13 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/accurate.h" +#include "filed/filed_globals.h" #include "filed/verify.h" #include "lib/attribs.h" #include "lib/edit.h" +namespace filedaemon { + static int debuglevel = 100; bool AccurateMarkFileAsSeen(JobControlRecord *jcr, char *fname) @@ -414,3 +417,5 @@ bool AccurateCmd(JobControlRecord *jcr) return true; } + +} /* namespace filedaemon */ diff --git a/core/src/filed/accurate.h b/core/src/filed/accurate.h index 35660cb56ff..db769e39846 100644 --- a/core/src/filed/accurate.h +++ b/core/src/filed/accurate.h @@ -47,6 +47,8 @@ #pragma pack(push,4) #endif +namespace filedaemon { + struct accurate_payload { int64_t filenr; int32_t delta_seq; @@ -202,4 +204,5 @@ bool accurate_unMarkAllFilesAsSeen(JobControlRecord *jcr); void AccurateFree(JobControlRecord *jcr); +} /* namespace filedaemon */ #endif /* BAREOS_FILED_ACCURATE_H_ */ diff --git a/core/src/filed/accurate_htable.cc b/core/src/filed/accurate_htable.cc index 7aa4746fd50..eb8e06d644d 100644 --- a/core/src/filed/accurate_htable.cc +++ b/core/src/filed/accurate_htable.cc @@ -33,6 +33,8 @@ #include "accurate.h" #include "lib/attribs.h" +namespace filedaemon { + static int debuglevel = 100; BareosAccurateFilelistHtable::BareosAccurateFilelistHtable(JobControlRecord *jcr, uint32_t number_of_files) @@ -194,3 +196,5 @@ void BareosAccurateFilelistHtable::destroy() filenr_ = 0; } + +} /* namespace filedaemon */ diff --git a/core/src/filed/accurate_lmdb.cc b/core/src/filed/accurate_lmdb.cc index 05209bb17db..3f6c8c80576 100644 --- a/core/src/filed/accurate_lmdb.cc +++ b/core/src/filed/accurate_lmdb.cc @@ -28,11 +28,15 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #ifdef HAVE_LMDB - #include "accurate.h" +#endif +namespace filedaemon { + +#ifdef HAVE_LMDB static int debuglevel = 100; #define AVG_NR_BYTES_PER_ENTRY 256 @@ -572,3 +576,4 @@ void BareosAccurateFilelistLmdb::destroy() filenr_ = 0; } #endif /* HAVE_LMDB */ +} /* namespace filedaemon */ diff --git a/core/src/filed/authenticate.cc b/core/src/filed/authenticate.cc index e3597fafce4..c2025175446 100644 --- a/core/src/filed/authenticate.cc +++ b/core/src/filed/authenticate.cc @@ -30,7 +30,11 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "lib/bnet.h" +#include "restore.h" + +namespace filedaemon { const int debuglevel = 50; @@ -195,3 +199,4 @@ bool AuthenticateWithStoragedaemon(JobControlRecord *jcr) return result; } +} /* namespace filedaemon */ diff --git a/core/src/filed/authenticate.h b/core/src/filed/authenticate.h index dc3b8bcb8c6..11a6acb1d6f 100644 --- a/core/src/filed/authenticate.h +++ b/core/src/filed/authenticate.h @@ -1,5 +1,36 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2010 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2018 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_FILED_AUTHENTICATE_H_ +#define BAREOS_FILED_AUTHENTICATE_H_ 1 + +namespace filedaemon { bool AuthenticateDirector(JobControlRecord *jcr); bool AuthenticateWithDirector(JobControlRecord *jcr, DirectorResource *director); bool AuthenticateStoragedaemon(JobControlRecord *jcr); bool AuthenticateWithStoragedaemon(JobControlRecord *jcr); + +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_AUTHENTICATE_H_ */ diff --git a/core/src/filed/backup.cc b/core/src/filed/backup.cc index f02d075fa18..dc389a1c42d 100644 --- a/core/src/filed/backup.cc +++ b/core/src/filed/backup.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "filed/accurate.h" #include "filed/compression.h" #include "filed/crypto.h" @@ -41,6 +42,8 @@ #include "findlib/find_one.h" #include "lib/btimers.h" +namespace filedaemon { + #ifdef HAVE_DARWIN_OS const bool have_darwin_os = true; #else @@ -1623,3 +1626,4 @@ static void CloseVssBackupSession(JobControlRecord *jcr) } #endif } +} /* namespace filedaemon */ diff --git a/core/src/filed/backup.h b/core/src/filed/backup.h index 8b7db712604..12f1ea13cb6 100644 --- a/core/src/filed/backup.h +++ b/core/src/filed/backup.h @@ -24,6 +24,8 @@ #ifndef BAREOS_FILED_BACKUP_H_ #define BAREOS_FILED_BACKUP_H_ +namespace filedaemon { + struct b_save_ctx { JobControlRecord *jcr; /* Current Job Control Record */ FindFilesPacket *ff_pkt; /* File being processed */ @@ -66,4 +68,5 @@ bool EncodeAndSendAttributes(JobControlRecord *jcr, FindFilesPacket *ff_pkt, int void StripPath(FindFilesPacket *ff_pkt); void UnstripPath(FindFilesPacket *ff_pkt); +} /* namespace filedaemon */ #endif diff --git a/core/src/filed/compression.cc b/core/src/filed/compression.cc index 535a7c3059a..08e4b48f867 100644 --- a/core/src/filed/compression.cc +++ b/core/src/filed/compression.cc @@ -31,9 +31,9 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #if defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ) - #if defined(HAVE_LIBZ) #include #endif @@ -41,6 +41,11 @@ #if defined(HAVE_FASTLZ) #include #endif +#endif /* defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ) */ + + +namespace filedaemon { +#if defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ) /** * For compression we enable all used compressors in the fileset. @@ -226,4 +231,6 @@ bool SetupCompressionContext(b_ctx &bctx) { return true; } + #endif /* defined(HAVE_LZO) || defined(HAVE_LIBZ) || defined(HAVE_FASTLZ) */ +} /* namespace filedaemon */ diff --git a/core/src/filed/compression.h b/core/src/filed/compression.h index d944557ca69..bbb925d7142 100644 --- a/core/src/filed/compression.h +++ b/core/src/filed/compression.h @@ -19,7 +19,15 @@ 02110-1301, USA. */ +#ifndef BAREOS_FILED_COMPRESSION_H +#define BAREOS_FILED_COMPRESSION_H 1 + +namespace filedaemon { + bool AdjustCompressionBuffers(JobControlRecord *jcr); bool AdjustDecompressionBuffers(JobControlRecord *jcr); bool SetupCompressionContext(b_ctx &bctx); +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_COMPRESSION_H */ diff --git a/core/src/filed/crypto.cc b/core/src/filed/crypto.cc index e982919af53..ef359201d8c 100644 --- a/core/src/filed/crypto.cc +++ b/core/src/filed/crypto.cc @@ -31,9 +31,12 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/restore.h" #include "findlib/find_one.h" #include "lib/edit.h" +namespace filedaemon { + #ifdef HAVE_SHA2 const bool have_sha2 = true; #else @@ -606,3 +609,4 @@ bool DecryptData(JobControlRecord *jcr, char **data, uint32_t *length, RestoreCi bail_out: return false; } +} /* namespace filedaemon */ diff --git a/core/src/filed/crypto.h b/core/src/filed/crypto.h index 1fd7029861b..644133f4dc9 100644 --- a/core/src/filed/crypto.h +++ b/core/src/filed/crypto.h @@ -19,6 +19,14 @@ 02110-1301, USA. */ +#ifndef BAREOS_FILED_CRYPTO_H_ +#define BAREOS_FILED_CRYPTO_H_ + +namespace filedaemon { + +struct r_ctx; +class RestoreCipherContext; + bool CryptoSessionStart(JobControlRecord *jcr, crypto_cipher_t cipher); void CryptoSessionEnd(JobControlRecord *jcr); bool CryptoSessionSend(JobControlRecord *jcr, BareosSocket *sd); @@ -32,3 +40,6 @@ bool SetupDecryptionContext(r_ctx &rctx, RestoreCipherContext &rcctx); bool EncryptData(b_ctx *bctx, bool *need_more_data); bool DecryptData(JobControlRecord *jcr, char **data, uint32_t *length, RestoreCipherContext *cipher_ctx); +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_CRYPTO_H_ */ diff --git a/core/src/filed/dir_cmd.cc b/core/src/filed/dir_cmd.cc index 3cd11227a2e..d614da8a392 100644 --- a/core/src/filed/dir_cmd.cc +++ b/core/src/filed/dir_cmd.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "ch.h" #include "filed/authenticate.h" #include "filed/dir_cmd.h" @@ -37,6 +38,7 @@ #include "filed/heartbeat.h" #include "filed/fileset.h" #include "filed/socket_server.h" +#include "filed/restore.h" #include "filed/verify.h" #include "findlib/enable_priv.h" #include "findlib/shadowing.h" @@ -50,6 +52,8 @@ #include "vss.h" #endif +namespace filedaemon { + extern bool backup_only_mode; extern bool restore_only_mode; @@ -2658,3 +2662,4 @@ bool response(JobControlRecord *jcr, BareosSocket *sd, char *resp, const char *c } return false; } +} /* namespace filedaemon */ diff --git a/core/src/filed/dir_cmd.h b/core/src/filed/dir_cmd.h index baa93fcd3f0..d9ffc4c5313 100644 --- a/core/src/filed/dir_cmd.h +++ b/core/src/filed/dir_cmd.h @@ -19,9 +19,17 @@ 02110-1301, USA. */ +#ifndef BAREOS_FILED_DIR_CMD_H_ +#define BAREOS_FILED_DIR_CMD_H_ 1 + +namespace filedaemon { + JobControlRecord *create_new_director_session(BareosSocket *dir); void *process_director_commands(JobControlRecord *jcr, BareosSocket *dir); void *handle_director_connection(BareosSocket *dir); bool StartConnectToDirectorThreads(); bool StopConnectToDirectorThreads(bool wait=false); +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_DIR_CMD_H_ */ diff --git a/core/src/filed/estimate.cc b/core/src/filed/estimate.cc index 5571a89966e..deaf4582762 100644 --- a/core/src/filed/estimate.cc +++ b/core/src/filed/estimate.cc @@ -32,6 +32,8 @@ #include "filed/filed.h" #include "filed/accurate.h" +namespace filedaemon { + static int TallyFile(JobControlRecord *jcr, FindFilesPacket *ff_pkt, bool); /** @@ -117,3 +119,4 @@ static int TallyFile(JobControlRecord *jcr, FindFilesPacket *ff_pkt, bool top_le } return 1; } +} /* namespace filedaemon */ diff --git a/core/src/filed/estimate.h b/core/src/filed/estimate.h index 7d3e317a7df..94626e9a003 100644 --- a/core/src/filed/estimate.h +++ b/core/src/filed/estimate.h @@ -19,5 +19,13 @@ 02110-1301, USA. */ +#ifndef BAREOS_FILED_ESTIMATE_H_ +#define BAREOS_FILED_ESTIMATE_H_ 1 + +namespace filedaemon { + int MakeEstimate(JobControlRecord *jcr); +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_ESTIMATE_H_ */ diff --git a/core/src/filed/fd_plugins.cc b/core/src/filed/fd_plugins.cc index 50d3bec4753..0ff60370a49 100644 --- a/core/src/filed/fd_plugins.cc +++ b/core/src/filed/fd_plugins.cc @@ -29,6 +29,7 @@ */ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "filed/accurate.h" #include "filed/heartbeat.h" #include "filed/fileset.h" @@ -38,11 +39,21 @@ #include "findlib/find_one.h" #include "findlib/hardlink.h" -extern ClientResource *me; +/** + * Function pointers to be set here (findlib) + */ +extern DLL_IMP_EXP int (*plugin_bopen)(BareosWinFilePacket *bfd, const char *fname, int flags, mode_t mode); +extern DLL_IMP_EXP int (*plugin_bclose)(BareosWinFilePacket *bfd); +extern DLL_IMP_EXP ssize_t (*plugin_bread)(BareosWinFilePacket *bfd, void *buf, size_t count); +extern DLL_IMP_EXP ssize_t (*plugin_bwrite)(BareosWinFilePacket *bfd, void *buf, size_t count); +extern DLL_IMP_EXP boffset_t (*plugin_blseek)(BareosWinFilePacket *bfd, boffset_t offset, int whence); + extern DLL_IMP_EXP char *exepath; extern DLL_IMP_EXP char *version; extern DLL_IMP_EXP char *dist_name; +namespace filedaemon { + const int debuglevel = 150; #ifdef HAVE_WIN32 const char *plugin_type = "-fd.dll"; @@ -54,15 +65,6 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; extern int SaveFile(JobControlRecord *jcr, FindFilesPacket *ff_pkt, bool top_level); -/** - * Function pointers to be set here - */ -extern DLL_IMP_EXP int (*plugin_bopen)(BareosWinFilePacket *bfd, const char *fname, int flags, mode_t mode); -extern DLL_IMP_EXP int (*plugin_bclose)(BareosWinFilePacket *bfd); -extern DLL_IMP_EXP ssize_t (*plugin_bread)(BareosWinFilePacket *bfd, void *buf, size_t count); -extern DLL_IMP_EXP ssize_t (*plugin_bwrite)(BareosWinFilePacket *bfd, void *buf, size_t count); -extern DLL_IMP_EXP boffset_t (*plugin_blseek)(BareosWinFilePacket *bfd, boffset_t offset, int whence); - /** * Forward referenced functions */ @@ -2712,3 +2714,4 @@ int main(int argc, char *argv[]) } #endif /* TEST_PROGRAM */ +} /* namespace filedaemon */ diff --git a/core/src/filed/fd_plugins.h b/core/src/filed/fd_plugins.h index cbdc5edbb45..ab8aaf392ee 100644 --- a/core/src/filed/fd_plugins.h +++ b/core/src/filed/fd_plugins.h @@ -56,6 +56,13 @@ #include "vss.h" #endif +#ifdef FILE_DAEMON +struct BareosWinFilePacket; +struct FindFilesPacket; +#endif /* FILE_DAEMON */ + +namespace filedaemon { + /* * This packet is used for the restore objects * It is passed to the plugin when restoring @@ -248,8 +255,6 @@ typedef struct s_bareosInfo { * Bareos Core Routines -- not used within a plugin */ #ifdef FILE_DAEMON -struct BareosWinFilePacket; /* forward referenced */ -struct FindFilesPacket; void LoadFdPlugins(const char *plugin_dir, alist *plugin_names); void UnloadFdPlugins(void); int ListFdPlugins(PoolMem &msg); @@ -357,4 +362,5 @@ typedef struct s_pluginFuncs { } #endif +} /* namespace filedaemon */ #endif /* BAREOS_FILED_FD_PLUGINS_H_ */ diff --git a/core/src/filed/filed.cc b/core/src/filed/filed.cc index f4518d99711..9b16d067847 100644 --- a/core/src/filed/filed.cc +++ b/core/src/filed/filed.cc @@ -30,12 +30,15 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "filed/dir_cmd.h" #include "filed/socket_server.h" #include "lib/mntent_cache.h" #include "lib/daemon.h" #include "lib/bsignal.h" +using namespace filedaemon; + /* Imported Functions */ extern void *handle_connection_request(void *dir_sock); extern void PrintMessage(void *sock, const char *fmt, ...); @@ -43,16 +46,6 @@ extern void PrintMessage(void *sock, const char *fmt, ...); /* Forward referenced functions */ static bool CheckResources(); -/* Exported variables */ -ClientResource *me = NULL; /* Our Global resource */ -ConfigurationParser *my_config = nullptr; /* Our Global config */ - -bool no_signals = false; -bool backup_only_mode = false; -bool restore_only_mode = false; -void *start_heap; - -char *configfile = NULL; static bool foreground = false; static void usage() @@ -302,6 +295,8 @@ int main (int argc, char *argv[]) exit(0); } +namespace filedaemon { + void TerminateFiled(int sig) { static bool already_here = false; @@ -340,6 +335,7 @@ void TerminateFiled(int sig) sm_dump(false, false); /* dump orphaned buffers */ exit(sig); } +} /* namespace filedaemon */ /** * Make a quick check to see that we have all the diff --git a/core/src/filed/filed.h b/core/src/filed/filed.h index fa9e6aafd17..7af137514e5 100644 --- a/core/src/filed/filed.h +++ b/core/src/filed/filed.h @@ -42,10 +42,8 @@ #include "fd_plugins.h" #include "ch.h" #include "backup.h" -#include "restore.h" -extern ClientResource *me; /* "Global" Client resource */ -extern ConfigurationParser *my_config; /* Our Global config */ +namespace filedaemon { void TerminateFiled(int sig); @@ -54,4 +52,5 @@ void TerminateFiled(int sig); */ const int FD_PROTOCOL_VERSION = 54; +} /* namespace filedaemon */ #endif /* BAREOS_FILED_FILED_H_ */ diff --git a/core/src/filed/filed_conf.cc b/core/src/filed/filed_conf.cc index 60dcb5e550e..aec2b6a81d3 100644 --- a/core/src/filed/filed_conf.cc +++ b/core/src/filed/filed_conf.cc @@ -46,6 +46,9 @@ #define NEED_JANSSON_NAMESPACE 1 #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" + +namespace filedaemon { /** * Define the first and last resource ID record @@ -171,6 +174,155 @@ static ResourceTable resources[] = { { NULL, NULL, 0} }; +static struct s_kw CryptoCiphers[] = { + { "blowfish", CRYPTO_CIPHER_BLOWFISH_CBC }, + { "3des", CRYPTO_CIPHER_3DES_CBC }, + { "aes128", CRYPTO_CIPHER_AES_128_CBC }, + { "aes192", CRYPTO_CIPHER_AES_192_CBC }, + { "aes256", CRYPTO_CIPHER_AES_256_CBC }, + { "camellia128", CRYPTO_CIPHER_CAMELLIA_128_CBC }, + { "camellia192", CRYPTO_CIPHER_CAMELLIA_192_CBC }, + { "camellia256", CRYPTO_CIPHER_CAMELLIA_256_CBC }, + { "aes128hmacsha1", CRYPTO_CIPHER_AES_128_CBC_HMAC_SHA1 }, + { "aes256hmacsha1", CRYPTO_CIPHER_AES_256_CBC_HMAC_SHA1 }, + { NULL, 0 } +}; + +static void StoreCipher(LEX *lc, ResourceItem *item, int index, int pass) +{ + int i; + LexGetToken(lc, BCT_NAME); + + /* + * Scan Crypto Ciphers name. + */ + for (i = 0; CryptoCiphers[i].name; i++) { + if (Bstrcasecmp(lc->str, CryptoCiphers[i].name)) { + *(uint32_t *)(item->value) = CryptoCiphers[i].token; + i = 0; + break; + } + } + if (i != 0) { + scan_err1(lc, _("Expected a Crypto Cipher option, got: %s"), lc->str); + } + ScanToEol(lc); + SetBit(index, res_all.hdr.item_present); + ClearBit(index, res_all.hdr.inherit_content); +} + +/** + * callback function for init_resource + * See ../lib/parse_conf.c, function InitResource, for more generic handling. + */ +static void InitResourceCb(ResourceItem *item, int pass) +{ + switch (pass) { + case 1: + switch (item->type) { + case CFG_TYPE_CIPHER: + for (int i = 0; CryptoCiphers[i].name; i++) { + if (Bstrcasecmp(item->default_value, CryptoCiphers[i].name)) { + *(uint32_t *)(item->value) = CryptoCiphers[i].token; + } + } + break; + default: + break; + } + break; + default: + break; + } +} + +/** + * callback function for parse_config + * See ../lib/parse_conf.c, function ParseConfig, for more generic handling. + */ +static void ParseConfigCb(LEX *lc, ResourceItem *item, int index, int pass) +{ + switch (item->type) { + case CFG_TYPE_CIPHER: + StoreCipher(lc, item, index, pass); + break; + default: + break; + } +} + +ConfigurationParser *InitFdConfig(const char *configfile, int exit_code) +{ + return new ConfigurationParser ( + configfile, + nullptr, + nullptr, + InitResourceCb, + ParseConfigCb, + nullptr, + exit_code, + (void *)&res_all, + res_all_size, + R_FIRST, + R_LAST, + resources, + res_head, + CONFIG_FILE, + "bareos-fd.d"); +} + +/** + * Print configuration file schema in json format + */ +#ifdef HAVE_JANSSON +bool PrintConfigSchemaJson(PoolMem &buffer) +{ + ResourceTable *resources = my_config->resources_; + + InitializeJson(); + + json_t *json = json_object(); + json_object_set_new(json, "format-version", json_integer(2)); + json_object_set_new(json, "component", json_string("bareos-fd")); + json_object_set_new(json, "version", json_string(VERSION)); + + /* + * Resources + */ + json_t *resource = json_object(); + json_object_set(json, "resource", resource); + json_t *bareos_fd = json_object(); + json_object_set(resource, "bareos-fd", bareos_fd); + + for (int r = 0; resources[r].name; r++) { + ResourceTable resource = my_config->resources_[r]; + json_object_set(bareos_fd, resource.name, json_items(resource.items)); + } + + PmStrcat(buffer, json_dumps(json, JSON_INDENT(2))); + json_decref(json); + + return true; +} +#else +bool PrintConfigSchemaJson(PoolMem &buffer) +{ + PmStrcat(buffer, "{ \"success\": false, \"message\": \"not available\" }"); + return false; +} +#endif + +/* **************************************************************************** */ +} /* namespace filedaemon */ +/* **************************************************************************** */ + +/** + * starting from here "override" methods to use in parse_conf.cc + * that must not be in the namespace of file daemon + **/ + +using namespace filedaemon; + /** * Dump contents of resource */ @@ -525,141 +677,3 @@ bool SaveResource(int type, ResourceItem *items, int pass) } return (error == 0); } - -static struct s_kw CryptoCiphers[] = { - { "blowfish", CRYPTO_CIPHER_BLOWFISH_CBC }, - { "3des", CRYPTO_CIPHER_3DES_CBC }, - { "aes128", CRYPTO_CIPHER_AES_128_CBC }, - { "aes192", CRYPTO_CIPHER_AES_192_CBC }, - { "aes256", CRYPTO_CIPHER_AES_256_CBC }, - { "camellia128", CRYPTO_CIPHER_CAMELLIA_128_CBC }, - { "camellia192", CRYPTO_CIPHER_CAMELLIA_192_CBC }, - { "camellia256", CRYPTO_CIPHER_CAMELLIA_256_CBC }, - { "aes128hmacsha1", CRYPTO_CIPHER_AES_128_CBC_HMAC_SHA1 }, - { "aes256hmacsha1", CRYPTO_CIPHER_AES_256_CBC_HMAC_SHA1 }, - { NULL, 0 } -}; - -static void StoreCipher(LEX *lc, ResourceItem *item, int index, int pass) -{ - int i; - LexGetToken(lc, BCT_NAME); - - /* - * Scan Crypto Ciphers name. - */ - for (i = 0; CryptoCiphers[i].name; i++) { - if (Bstrcasecmp(lc->str, CryptoCiphers[i].name)) { - *(uint32_t *)(item->value) = CryptoCiphers[i].token; - i = 0; - break; - } - } - if (i != 0) { - scan_err1(lc, _("Expected a Crypto Cipher option, got: %s"), lc->str); - } - ScanToEol(lc); - SetBit(index, res_all.hdr.item_present); - ClearBit(index, res_all.hdr.inherit_content); -} - -/** - * callback function for init_resource - * See ../lib/parse_conf.c, function InitResource, for more generic handling. - */ -static void InitResourceCb(ResourceItem *item, int pass) -{ - switch (pass) { - case 1: - switch (item->type) { - case CFG_TYPE_CIPHER: - for (int i = 0; CryptoCiphers[i].name; i++) { - if (Bstrcasecmp(item->default_value, CryptoCiphers[i].name)) { - *(uint32_t *)(item->value) = CryptoCiphers[i].token; - } - } - break; - default: - break; - } - break; - default: - break; - } -} - -/** - * callback function for parse_config - * See ../lib/parse_conf.c, function ParseConfig, for more generic handling. - */ -static void ParseConfigCb(LEX *lc, ResourceItem *item, int index, int pass) -{ - switch (item->type) { - case CFG_TYPE_CIPHER: - StoreCipher(lc, item, index, pass); - break; - default: - break; - } -} - -ConfigurationParser *InitFdConfig(const char *configfile, int exit_code) -{ - return new ConfigurationParser ( - configfile, - nullptr, - nullptr, - InitResourceCb, - ParseConfigCb, - nullptr, - exit_code, - (void *)&res_all, - res_all_size, - R_FIRST, - R_LAST, - resources, - res_head, - CONFIG_FILE, - "bareos-fd.d"); -} - -/** - * Print configuration file schema in json format - */ -#ifdef HAVE_JANSSON -bool PrintConfigSchemaJson(PoolMem &buffer) -{ - ResourceTable *resources = my_config->resources_; - - InitializeJson(); - - json_t *json = json_object(); - json_object_set_new(json, "format-version", json_integer(2)); - json_object_set_new(json, "component", json_string("bareos-fd")); - json_object_set_new(json, "version", json_string(VERSION)); - - /* - * Resources - */ - json_t *resource = json_object(); - json_object_set(json, "resource", resource); - json_t *bareos_fd = json_object(); - json_object_set(resource, "bareos-fd", bareos_fd); - - for (int r = 0; resources[r].name; r++) { - ResourceTable resource = my_config->resources_[r]; - json_object_set(bareos_fd, resource.name, json_items(resource.items)); - } - - PmStrcat(buffer, json_dumps(json, JSON_INDENT(2))); - json_decref(json); - - return true; -} -#else -bool PrintConfigSchemaJson(PoolMem &buffer) -{ - PmStrcat(buffer, "{ \"success\": false, \"message\": \"not available\" }"); - return false; -} -#endif diff --git a/core/src/filed/filed_conf.h b/core/src/filed/filed_conf.h index 1d056fae239..7a2caf46b53 100644 --- a/core/src/filed/filed_conf.h +++ b/core/src/filed/filed_conf.h @@ -26,6 +26,11 @@ * Kern Sibbald, Sep MM */ +#ifndef BAREOS_FILED_FILED_CONF_H_ +#define BAREOS_FILED_FILED_CONF_H_ 1 + +namespace filedaemon { + #define CONFIG_FILE "bareos-fd.conf" /* default config file */ /* @@ -120,3 +125,6 @@ union UnionOfResources { ConfigurationParser *InitFdConfig(const char *configfile, int exit_code); bool PrintConfigSchemaJson(PoolMem &buffer); + +} /* namespace filedaemon */ +#endif /* BAREOS_FILED_FILED_CONF_H_ */ diff --git a/core/src/filed/filed_globals.cc b/core/src/filed/filed_globals.cc new file mode 100644 index 00000000000..674cdc7b643 --- /dev/null +++ b/core/src/filed/filed_globals.cc @@ -0,0 +1,39 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2007-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2018 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +class ConfigurationParser; +ConfigurationParser *my_config = nullptr; + +namespace filedaemon { + +bool no_signals = false; +bool backup_only_mode = false; +bool restore_only_mode = false; + +struct ClientResource; +ClientResource *me = nullptr; + +void *start_heap = nullptr; +char *configfile = nullptr; + +} /* namespace filedaemon */ diff --git a/core/src/filed/filed_globals.h b/core/src/filed/filed_globals.h new file mode 100644 index 00000000000..6553d5aad6e --- /dev/null +++ b/core/src/filed/filed_globals.h @@ -0,0 +1,42 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2007-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2018 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation, which is + listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_FILED_FILED_GLOBALS_H_ +#define BAREOS_FILED_FILED_GLOBALS_H_ 1 + +class ConfigurationParser; +extern ConfigurationParser *my_config; + +namespace filedaemon { + +extern bool no_signals; +extern bool backup_only_mode; +extern bool restore_only_mode; + +extern ClientResource *me; +extern void *start_heap; +extern char *configfile; + +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_FILED_GLOBALS_H_ */ diff --git a/core/src/filed/fileset.cc b/core/src/filed/fileset.cc index b3386354366..3acbc5ac633 100644 --- a/core/src/filed/fileset.cc +++ b/core/src/filed/fileset.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "findlib/match.h" #include "lib/edit.h" #include "ch.h" @@ -39,6 +40,8 @@ #include "win32/findlib/win32.h" #endif +namespace filedaemon { + /* Forward referenced functions */ static int SetOptions(findFOPTS *fo, const char *opts); @@ -800,3 +803,4 @@ static int SetOptions(findFOPTS *fo, const char *opts) return state_options; } +} /* namespace filedaemon */ diff --git a/core/src/filed/fileset.h b/core/src/filed/fileset.h index b046f3924e7..c69c7eaaa7f 100644 --- a/core/src/filed/fileset.h +++ b/core/src/filed/fileset.h @@ -19,6 +19,11 @@ 02110-1301, USA. */ +#ifndef BAREOS_FILED_FILESET_H_ +#define BAREOS_FILED_FILESET_H_ 1 + +namespace filedaemon { + bool InitFileset(JobControlRecord *jcr); void AddFileToFileset(JobControlRecord *jcr, const char *fname, bool IsFile); findIncludeExcludeItem *get_incexe(JobControlRecord *jcr); @@ -29,3 +34,6 @@ int AddOptionsToFileset(JobControlRecord *jcr, const char *item); void AddFileset(JobControlRecord *jcr, const char *item); bool TermFileset(JobControlRecord *jcr); +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_FILESET_H_ */ diff --git a/core/src/filed/heartbeat.cc b/core/src/filed/heartbeat.cc index 71897707d54..05088f075fa 100644 --- a/core/src/filed/heartbeat.cc +++ b/core/src/filed/heartbeat.cc @@ -32,8 +32,11 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "lib/bnet.h" +namespace filedaemon { + #define WAIT_INTERVAL 5 extern "C" void *sd_heartbeat_thread(void *arg); @@ -233,3 +236,4 @@ void StopDirHeartbeat(JobControlRecord *jcr) StopHeartbeatMonitor(jcr); } } +} /* namespace filedaemon */ diff --git a/core/src/filed/heartbeat.h b/core/src/filed/heartbeat.h index 8b277607756..95b6861ef4f 100644 --- a/core/src/filed/heartbeat.h +++ b/core/src/filed/heartbeat.h @@ -1,5 +1,35 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2003-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2016 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_FILED_HEARBEAT_H_ +#define BAREOS_FILED_HEARBEAT_H_ 1 + +namespace filedaemon { void StartHeartbeatMonitor(JobControlRecord *jcr); void StopHeartbeatMonitor(JobControlRecord *jcr); void StartDirHeartbeat(JobControlRecord *jcr); void StopDirHeartbeat(JobControlRecord *jcr); + +} /* namespace filedaemon */ +#endif /* BAREOS_FILED_HEARBEAT_H_ */ diff --git a/core/src/filed/restore.cc b/core/src/filed/restore.cc index 59bba47f32a..7c894092d79 100644 --- a/core/src/filed/restore.cc +++ b/core/src/filed/restore.cc @@ -32,6 +32,7 @@ #include "filed/filed.h" #include "filed/compression.h" #include "filed/crypto.h" +#include "filed/restore.h" #include "filed/verify.h" #include "ch.h" #include "findlib/create_file.h" @@ -47,6 +48,11 @@ #if defined(HAVE_DARWIN_OS) #include +#endif + +namespace filedaemon { + +#if defined(HAVE_DARWIN_OS) const bool have_darwin_os = true; #else const bool have_darwin_os = false; @@ -1407,3 +1413,5 @@ void FreeSession(r_ctx &rctx) rctx.cs = NULL; } } + +} /* namespace filedaemon */ diff --git a/core/src/filed/restore.h b/core/src/filed/restore.h index 810e85197dd..868d97d8604 100644 --- a/core/src/filed/restore.h +++ b/core/src/filed/restore.h @@ -23,6 +23,10 @@ #ifndef BAREOS_FILED_RESTORE_H_ #define BAREOS_FILED_RESTORE_H_ +#include "findlib/bfile.h" + +namespace filedaemon { + struct DelayedDataStream { int32_t stream; /* stream less new bits */ char *content; /* stream data */ @@ -44,16 +48,16 @@ struct r_ctx { int32_t prev_stream; /* previous stream */ int32_t full_stream; /* full stream including new bits */ int32_t comp_stream; /* last compressed stream found. needed only to restore encrypted compressed backup */ - BareosWinFilePacket bfd; /* File content */ + BareosWinFilePacket bfd; /* File content */ uint64_t fileAddr; /* file write address */ uint32_t size; /* Size of file */ char flags[FOPTS_BYTES]; /* Options for ExtractData() */ - BareosWinFilePacket forkbfd; /* Alternative data stream */ + BareosWinFilePacket forkbfd; /* Alternative data stream */ uint64_t fork_addr; /* Write address for alternative stream */ int64_t fork_size; /* Size of alternate stream */ char fork_flags[FOPTS_BYTES]; /* Options for ExtractData() */ int32_t type; /* file type FT_ */ - Attributes *attr; /* Pointer to attributes */ + Attributes *attr; /* Pointer to attributes */ bool extract; /* set when extracting */ alist *delayed_streams; /* streams that should be restored as last */ @@ -69,4 +73,5 @@ int DoFileDigest(JobControlRecord *jcr, FindFilesPacket *ff_pkt, bool top_level) bool SparseData(JobControlRecord *jcr, BareosWinFilePacket *bfd, uint64_t *addr, char **data, uint32_t *length); bool StoreData(JobControlRecord *jcr, BareosWinFilePacket *bfd, char *data, const int32_t length, bool win32_decomp); +} /* namespace filedaemon */ #endif diff --git a/core/src/filed/sd_cmds.cc b/core/src/filed/sd_cmds.cc index 6949cc7871d..bb3a5f2dcfc 100644 --- a/core/src/filed/sd_cmds.cc +++ b/core/src/filed/sd_cmds.cc @@ -28,9 +28,12 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "filed/authenticate.h" #include "lib/bnet.h" +namespace filedaemon { + static int debuglevel = 100; void *handle_stored_connection(BareosSocket *sd) @@ -103,3 +106,4 @@ void *handle_stored_connection(BareosSocket *sd) return NULL; } +} /* namespace filedaemon */ diff --git a/core/src/filed/sd_cmds.h b/core/src/filed/sd_cmds.h index 9a6f8e20884..1924d7c826d 100644 --- a/core/src/filed/sd_cmds.h +++ b/core/src/filed/sd_cmds.h @@ -1,2 +1,32 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2013-2016 Bareos GmbH & Co. KG + Copyright (C) 2018-2018 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_FILED_SD_CMDS_H_ +#define BAREOS_FILED_SD_CMDS_H_ 1 + +namespace filedaemon { void *handle_stored_connection(BareosSocket *sd); + +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_SD_CMDS_H_ */ diff --git a/core/src/filed/socket_server.cc b/core/src/filed/socket_server.cc index 182aaab4e0d..57dd71d453a 100644 --- a/core/src/filed/socket_server.cc +++ b/core/src/filed/socket_server.cc @@ -30,10 +30,13 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "filed/dir_cmd.h" #include "filed/sd_cmds.h" #include "lib/bnet_sever_tcp.h" +namespace filedaemon { + /* Global variables */ static workq_t socket_workq; static pthread_t tcp_server_tid; @@ -128,3 +131,4 @@ void StopSocketServer(bool wait) } } } +} /* namespace filedaemon */ diff --git a/core/src/filed/socket_server.h b/core/src/filed/socket_server.h index 535ff4881c9..f35872447cf 100644 --- a/core/src/filed/socket_server.h +++ b/core/src/filed/socket_server.h @@ -1,3 +1,33 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2011 Free Software Foundation Europe e.V. + Copyright (C) 2014-2018 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_FILED_SOCKET_SERVER_H_ +#define BAREOS_FILED_SOCKET_SERVER_H_ 1 + +namespace filedaemon { void StartSocketServer(dlist *addrs); void StopSocketServer(bool wait=false); + +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_SOCKET_SERVER_H_ */ diff --git a/core/src/filed/status.cc b/core/src/filed/status.cc index 6aabc2aeea9..96eaee46e47 100644 --- a/core/src/filed/status.cc +++ b/core/src/filed/status.cc @@ -30,11 +30,13 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/filed_globals.h" #include "lib/status.h" #include "lib/edit.h" #include "findlib/enable_priv.h" -extern void *start_heap; +namespace filedaemon { + extern bool GetWindowsVersionString(char *buf, int maxsiz); /* Forward referenced functions */ @@ -635,3 +637,4 @@ char *bareos_status(char *buf, int buf_len) } #endif /* HAVE_WIN32 */ +} /* namespace filedaemon */ diff --git a/core/src/filed/verify.cc b/core/src/filed/verify.cc index 054d0496e78..c9f0e045acf 100644 --- a/core/src/filed/verify.cc +++ b/core/src/filed/verify.cc @@ -34,6 +34,8 @@ #include "lib/attribs.h" #include "lib/bnet.h" +namespace filedaemon { + #ifdef HAVE_DARWIN_OS const bool have_darwin_os = true; #else @@ -453,3 +455,4 @@ bool CalculateAndCompareFileChksum(JobControlRecord *jcr, FindFilesPacket *ff_pk return retval; } +} /* namespace filedaemon */ diff --git a/core/src/filed/verify.h b/core/src/filed/verify.h index 4c507ef2a13..690b692ee9b 100644 --- a/core/src/filed/verify.h +++ b/core/src/filed/verify.h @@ -19,9 +19,17 @@ 02110-1301, USA. */ +#ifndef BAREOS_FILED_VERIFY_H_ +#define BAREOS_FILED_VERIFY_H_ 1 + +namespace filedaemon { + int DigestFile(JobControlRecord *jcr, FindFilesPacket *ff_pkt, DIGEST *digest); void DoVerify(JobControlRecord *jcr); void DoVerifyVolume(JobControlRecord *jcr); bool CalculateAndCompareFileChksum(JobControlRecord *jcr, FindFilesPacket *ff_pkt, const char *fname, const char *chksum); +} /* namespace filedaemon */ + +#endif /* BAREOS_FILED_VERIFY_H_ */ diff --git a/core/src/filed/verify_vol.cc b/core/src/filed/verify_vol.cc index e5194e5ca51..26063a04881 100644 --- a/core/src/filed/verify_vol.cc +++ b/core/src/filed/verify_vol.cc @@ -33,6 +33,8 @@ #include "lib/bget_msg.h" #include "lib/bnet.h" +namespace filedaemon { + /* Data received from Storage Daemon */ static char rec_header[] = "rechdr %ld %ld %ld %ld %ld"; @@ -268,3 +270,4 @@ void DoVerifyVolume(JobControlRecord *jcr) FreePoolMemory(lname); Dmsg2(050, "End Verify-Vol. Files=%d Bytes=%" lld "\n", jcr->JobFiles, jcr->JobBytes); } +} /* namespace filedaemon */ diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 0da29af8807..333d21f325d 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -47,6 +47,13 @@ namespace storagedaemon { } #endif +#ifdef FILE_DAEMON +namespace filedaemon { +class BareosAccurateFilelist; +struct save_pkt; +} +#endif /* FILE_DAEMON */ + /** * Backup/Verify level code. These are stored in the DB */ @@ -198,7 +205,6 @@ class BareosSocket; struct FindFilesPacket; class BareosDb; struct AttributesDbRecord; -struct save_pkt; struct bpContext; #ifdef HAVE_WIN32 struct CopyThreadContext; @@ -206,7 +212,6 @@ struct CopyThreadContext; #ifdef FILE_DAEMON class htable; -class BareosAccurateFilelist; struct acl_data_t; struct xattr_data_t; @@ -433,7 +438,6 @@ class DLL_IMP_EXP JobControlRecord { alist *plugin_ctx_list; /**< List of contexts for plugins */ bpContext *plugin_ctx; /**< Current plugin context */ - save_pkt *plugin_sp; /**< Plugin save packet */ POOLMEM *comment; /**< Comment for this Job */ int64_t max_bandwidth; /**< Bandwidth limit for this Job */ htable *path_list; /**< Directory list (used by findlib) */ @@ -546,12 +550,13 @@ class DLL_IMP_EXP JobControlRecord { std::shared_ptr hb_dir_bsock; /**< Duped DIR socket */ alist *RunScripts; /**< Commands to run before and after job */ CryptoContext crypto; /**< Crypto ctx */ - DirectorResource *director; /**< Director resource */ + filedaemon::DirectorResource *director;/**< Director resource */ bool enable_vss; /**< VSS used by FD */ bool got_metadata; /**< Set when found job_metadata */ bool multi_restore; /**< Dir can do multiple storage restore */ - BareosAccurateFilelist *file_list; /**< Previous file list (accurate mode) */ + filedaemon::BareosAccurateFilelist *file_list; /**< Previous file list (accurate mode) */ uint64_t base_size; /**< Compute space saved with base job */ + filedaemon::save_pkt *plugin_sp; /**< Plugin save packet */ #ifdef HAVE_WIN32 VSSClient *pVSSClient; /**< VSS Client Instance */ #endif diff --git a/core/src/plugins/filed/bpipe-fd.cc b/core/src/plugins/filed/bpipe-fd.cc index 54533fd29d3..de4941d6945 100644 --- a/core/src/plugins/filed/bpipe-fd.cc +++ b/core/src/plugins/filed/bpipe-fd.cc @@ -30,6 +30,8 @@ #include "fd_plugins.h" #include "fd_common.h" +namespace filedaemon { + static const int debuglevel = 150; #define PLUGIN_LICENSE "Bareos AGPLv3" @@ -919,3 +921,4 @@ static bRC plugin_has_all_arguments(bpContext *ctx) return retval; } +} /* namespace filedaemon */ diff --git a/core/src/plugins/filed/cephfs-fd.cc b/core/src/plugins/filed/cephfs-fd.cc index a44aa9704a7..802e02cbdf5 100644 --- a/core/src/plugins/filed/cephfs-fd.cc +++ b/core/src/plugins/filed/cephfs-fd.cc @@ -32,6 +32,8 @@ #include #include +namespace filedaemon { + static const int debuglevel = 150; #define PLUGIN_LICENSE "Bareos AGPLv3" @@ -1930,3 +1932,5 @@ static bRC setXattr(bpContext *ctx, xattr_pkt *xp) return bRC_OK; } + +} /* namespace filedaemon */ diff --git a/core/src/plugins/filed/example-plugin-fd.cc b/core/src/plugins/filed/example-plugin-fd.cc index 3fc7fca5d05..3daf6379608 100644 --- a/core/src/plugins/filed/example-plugin-fd.cc +++ b/core/src/plugins/filed/example-plugin-fd.cc @@ -22,6 +22,8 @@ #define PLUGIN_VERSION "1" #define PLUGIN_DESCRIPTION "Test File Daemon Plugin" +namespace filedaemon { + /* Forward referenced functions */ static bRC newPlugin(bpContext *ctx); static bRC freePlugin(bpContext *ctx); @@ -332,3 +334,5 @@ static bRC checkFile(bpContext *ctx, char *fname) { return bRC_OK; } + +} /* namespace filedaemon */ diff --git a/core/src/plugins/filed/gfapi-fd.cc b/core/src/plugins/filed/gfapi-fd.cc index 90e0b38b932..a551ee2ffdf 100644 --- a/core/src/plugins/filed/gfapi-fd.cc +++ b/core/src/plugins/filed/gfapi-fd.cc @@ -33,6 +33,8 @@ #include #include +namespace filedaemon { + static const int debuglevel = 150; #define PLUGIN_LICENSE "Bareos AGPLv3" @@ -2466,3 +2468,4 @@ static bRC setXattr(bpContext *ctx, xattr_pkt *xp) return bRC_OK; } +} /* namespace filedaemon */ diff --git a/core/src/plugins/filed/python-fd.cc b/core/src/plugins/filed/python-fd.cc index 0339129ff2f..72181d222f5 100644 --- a/core/src/plugins/filed/python-fd.cc +++ b/core/src/plugins/filed/python-fd.cc @@ -32,7 +32,9 @@ #include #include "filed/fd_plugins.h" #include "plugins/filed/fd_common.h" +#include "python-fd.h" +namespace filedaemon { #if (PY_VERSION_HEX < 0x02060000) #error "Need at least Python version 2.6 or newer" @@ -154,8 +156,6 @@ struct plugin_ctx { PyObject *bpContext; /* Python representation of plugin context */ }; -#include "python-fd.h" - /** * We don't actually use this but we need it to tear down the * final python interpreter on unload of the plugin. Each instance of @@ -3855,3 +3855,4 @@ static void PyXattrPacket_dealloc(PyXattrPacket *self) } PyObject_Del(self); } +} /* namespace filedaemon */ diff --git a/core/src/plugins/filed/python-fd.h b/core/src/plugins/filed/python-fd.h index e383bc25f03..5c04a3d4905 100644 --- a/core/src/plugins/filed/python-fd.h +++ b/core/src/plugins/filed/python-fd.h @@ -28,6 +28,8 @@ #include "structmember.h" +namespace filedaemon { + /** * This defines the arguments that the plugin parser understands. */ @@ -677,4 +679,6 @@ static PyMethodDef BareosFDMethods[] = { { "ClearSeenBitmap", PyBareosClearSeenBitmap, METH_VARARGS, "Clear bit in the Accurate Seen bitmap" }, { NULL, NULL, 0, NULL } }; + +} /* namespace filedaemon */ #endif /* BAREOS_PLUGINS_FILED_PYTHON_FD_H_ */ diff --git a/core/src/plugins/filed/rados-fd.cc b/core/src/plugins/filed/rados-fd.cc index daa2ce9ae87..4b61f5ccf33 100644 --- a/core/src/plugins/filed/rados-fd.cc +++ b/core/src/plugins/filed/rados-fd.cc @@ -29,6 +29,8 @@ #include +namespace filedaemon { + static const int debuglevel = 150; #define PLUGIN_LICENSE "Bareos AGPLv3" @@ -1224,3 +1226,4 @@ static bRC setXattr(bpContext *ctx, xattr_pkt *xp) bail_out: return bRC_Error; } +} /* namespace filedaemon */ diff --git a/core/src/plugins/filed/test-deltaseq-fd.cc b/core/src/plugins/filed/test-deltaseq-fd.cc index 16618a8d142..4429361240b 100644 --- a/core/src/plugins/filed/test-deltaseq-fd.cc +++ b/core/src/plugins/filed/test-deltaseq-fd.cc @@ -29,6 +29,8 @@ #include "fd_plugins.h" #include "fd_common.h" +namespace filedaemon { + static const int debuglevel = 0; #define PLUGIN_LICENSE "Bareos AGPLv3" @@ -463,3 +465,4 @@ static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp) // Dmsg(ctx, debuglevel, "delta-test-fd: setFileAttributes\n"); return bRC_OK; } +} /* namespace filedaemon */ diff --git a/core/src/plugins/filed/test-plugin-fd.cc b/core/src/plugins/filed/test-plugin-fd.cc index 32c4aa4cc53..ee26eb32af8 100644 --- a/core/src/plugins/filed/test-plugin-fd.cc +++ b/core/src/plugins/filed/test-plugin-fd.cc @@ -33,6 +33,8 @@ #include "lib/ini.h" #include +namespace filedaemon { + static const int debuglevel = 000; #define PLUGIN_LICENSE "Bareos AGPLv3" @@ -710,3 +712,4 @@ static bRC checkFile(bpContext *ctx, char *fname) { return bRC_OK; } +} /* namespace filedaemon */ diff --git a/core/src/tests/testls.cc b/core/src/tests/testls.cc index 5db1da1c231..2880c8cee4d 100644 --- a/core/src/tests/testls.cc +++ b/core/src/tests/testls.cc @@ -35,7 +35,7 @@ /* Dummy functions */ int GenerateJobEvent(JobControlRecord *jcr, const char *event) { return 1; } -void GeneratePluginEvent(JobControlRecord *jcr, bEventType eventType, void *value) { } +void GeneratePluginEvent(JobControlRecord *jcr, filedaemon::bEventType eventType, void *value) { } /* Global variables */ int attrs = 0; diff --git a/core/src/tools/bpluginfo.cc b/core/src/tools/bpluginfo.cc index 9c4b1d80de9..1fced2f418e 100644 --- a/core/src/tools/bpluginfo.cc +++ b/core/src/tools/bpluginfo.cc @@ -69,7 +69,7 @@ enum plugintype { typedef union _plugfuncs plugfuncs; union _plugfuncs { directordaemon::pDirFuncs pdirfuncs; - pFuncs pfdfuncs; + filedaemon::pFuncs pfdfuncs; storagedaemon::psdFuncs psdfuncs; }; @@ -101,7 +101,7 @@ struct _bareosfuncs { typedef union _bareosinfos bareosinfos; union _bareosinfos { directordaemon::bDirInfo bdirinfo; - bInfo bfdinfo; + filedaemon::bInfo bfdinfo; storagedaemon::bsdInfo bsdinfo; };