+++ /dev/null
-Index: src/dird/dird.c
-===================================================================
---- src/dird/dird.c (révision 7482)
-+++ src/dird/dird.c (copie de travail)
-@@ -40,7 +40,7 @@
- /* Forward referenced subroutines */
- void terminate_dird(int sig);
- static bool check_resources();
--static bool check_catalog();
-+static bool check_catalog(bool printit=false);
- static void dir_sql_query(JCR *jcr, const char *cmd);
-
- /* Exported subroutines */
-@@ -99,6 +99,7 @@
- " -r <job> run <job> now\n"
- " -s no signals\n"
- " -t test - read configuration and exit\n"
-+" -B print catalog configuration and exit\n"
- " -u userid\n"
- " -v verbose user messages\n"
- " -? print this message.\n"
-@@ -124,6 +125,7 @@
- JCR *jcr;
- bool no_signals = false;
- bool test_config = false;
-+ bool print_catalog = false;
- char *uid = NULL;
- char *gid = NULL;
-
-@@ -140,7 +142,7 @@
-
- console_command = run_console_command;
-
-- while ((ch = getopt(argc, argv, "c:d:fg:r:stu:v?")) != -1) {
-+ while ((ch = getopt(argc, argv, "c:d:fg:r:stu:vB?")) != -1) {
- switch (ch) {
- case 'c': /* specify config file */
- if (configfile != NULL) {
-@@ -186,6 +188,11 @@
- test_config = true;
- break;
-
-+ case 'B': /* print catalog config */
-+ test_config = true;
-+ print_catalog = true;
-+ break;
-+
- case 'u': /* set uid */
- uid = optarg;
- break;
-@@ -249,7 +256,7 @@
-
- drop(uid, gid); /* reduce privileges if requested */
-
-- if (!check_catalog()) {
-+ if (!check_catalog(print_catalog)) {
- Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
- }
-
-@@ -876,7 +883,7 @@
- return OK;
- }
-
--static bool check_catalog()
-+static bool check_catalog(bool printit)
- {
- bool OK = true;
- bool need_tls;
-@@ -907,6 +914,18 @@
- continue;
- }
-
-+ if (printit) { /* print catalog information for scripting purpose */
-+ fprintf(stdout,
-+ "catalog=%s\ndb_type=%s\ndb_name=%s\ndb_driver=%s\ndb_user=%s\n"
-+ "db_password=%s\ndb_address=%s\ndb_port=%i\n"
-+ "db_socket=%s\n",
-+ catalog->name(), db_get_type(), NPRTB(catalog->db_name),
-+ NPRTB(catalog->db_driver),
-+ NPRTB(catalog->db_user), NPRTB(catalog->db_password),
-+ NPRTB(catalog->db_address), catalog->db_port,
-+ NPRTB(catalog->db_socket));
-+ }
-+
- /* Loop over all pools, defining/updating them in each database */
- POOL *pool;
- foreach_res(pool, R_POOL) {
-Index: src/cats/sqlite.c
-===================================================================
---- src/cats/sqlite.c (révision 7482)
-+++ src/cats/sqlite.c (copie de travail)
-@@ -59,14 +59,17 @@
-
- int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd);
-
--
- /*
- * Retrieve database type
- */
- const char *
- db_get_type(void)
- {
-+#ifdef HAVE_SQLITE3
-+ return "SQLite3";
-+#else
- return "SQLite";
-+#endif
- }
-
- /*
-Index: src/baconfig.h
-===================================================================
---- src/baconfig.h (révision 7482)
-+++ src/baconfig.h (copie de travail)
-@@ -79,7 +79,8 @@
-
- /* Allow printing of NULL pointers */
- #define NPRT(x) (x)?(x):_("*None*")
--
-+#define NPRTB(x) (x)?(x):""
-+
- #if defined(HAVE_WIN32)
-
- #define WIN32_REPARSE_POINT 1
--- /dev/null
+Index: src/dird/dird_conf.c
+===================================================================
+--- src/dird/dird_conf.c (révision 7525)
++++ src/dird/dird_conf.c (copie de travail)
+@@ -509,6 +509,16 @@
+ {NULL, 0}
+ };
+
++char *CAT::display(POOLMEM *dst) {
++ Mmsg(dst,"catalog=%s\ndb_name=%s\ndb_driver=%s\ndb_user=%s\n"
++ "db_password=%s\ndb_address=%s\ndb_port=%i\n"
++ "db_socket=%s\n",
++ name(), NPRTB(db_name),
++ NPRTB(db_driver), NPRTB(db_user), NPRTB(db_password),
++ NPRTB(db_address), db_port, NPRTB(db_socket));
++ return dst;
++}
++
+ const char *level_to_str(int level)
+ {
+ int i;
+Index: src/dird/dird_conf.h
+===================================================================
+--- src/dird/dird_conf.h (révision 7525)
++++ src/dird/dird_conf.h (copie de travail)
+@@ -236,6 +236,7 @@
+
+ /* Methods */
+ char *name() const;
++ char *display(POOLMEM *dst); /* Get catalog information */
+ };
+
+ inline char *CAT::name() const { return hdr.name; }
+Index: src/baconfig.h
+===================================================================
+--- src/baconfig.h (révision 7525)
++++ src/baconfig.h (copie de travail)
+@@ -79,7 +79,8 @@
+
+ /* Allow printing of NULL pointers */
+ #define NPRT(x) (x)?(x):_("*None*")
+-
++#define NPRTB(x) (x)?(x):""
++
+ #if defined(HAVE_WIN32)
+
+ #define WIN32_REPARSE_POINT 1
+Index: src/tools/dbcheck.c
+===================================================================
+--- src/tools/dbcheck.c (révision 7525)
++++ src/tools/dbcheck.c (copie de travail)
+@@ -100,14 +100,14 @@
+ static void do_interactive_mode();
+ static bool yes_no(const char *prompt);
+
+-
+ static void usage()
+ {
+ fprintf(stderr,
+-"Usage: dbcheck [-c config] [-C catalog name] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>] [<dbport>]\n"
++"Usage: dbcheck [-c config ] [-B] [-C catalog name] [-d debug_level] <working-directory> <bacula-database> <user> <password> [<dbhost>] [<dbport>]\n"
+ " -b batch mode\n"
+ " -C catalog name in the director conf file\n"
+ " -c Director conf filename\n"
++" -B print catalog configuration and exit\n"
+ " -d <nn> set debug level to <nn>\n"
+ " -dt print timestamp in debug output\n"
+ " -f fix inconsistencies\n"
+@@ -121,6 +121,7 @@
+ int ch;
+ const char *user, *password, *db_name, *dbhost;
+ int dbport = 0;
++ bool print_catalog=false;
+ char *configfile = NULL;
+ char *catalogname = NULL;
+ char *endptr;
+@@ -136,8 +137,12 @@
+ memset(&name_list, 0, sizeof(name_list));
+
+
+- while ((ch = getopt(argc, argv, "bc:C:d:fv?")) != -1) {
++ while ((ch = getopt(argc, argv, "bc:C:d:fvB?")) != -1) {
+ switch (ch) {
++ case 'B':
++ print_catalog = true; /* get catalog information from config */
++ break;
++
+ case 'b': /* batch */
+ batch = true;
+ break;
+@@ -215,6 +220,16 @@
+ exit(1);
+ }
+ set_working_directory(director->working_directory);
++
++ /* Print catalog information and exit (-B) */
++ if (print_catalog) {
++ POOLMEM *buf = get_pool_memory(PM_MESSAGE);
++ printf("%sdb_type=%s\nworking_dir=%s\n", catalog->display(buf),
++ db_get_type(), working_directory);
++ free_pool_memory(buf);
++ exit(0);
++ }
++
+ db_name = catalog->db_name;
+ user = catalog->db_user;
+ password = catalog->db_password;