From: Kern Sibbald Date: Tue, 30 Mar 2004 22:48:55 +0000 (+0000) Subject: Put back hard coded path for consolehelper X-Git-Tag: Release-7.0.0~9593 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=552054c7eae3e2a1e4897b74be7bb9ef9b13047f;p=bacula%2Fbacula Put back hard coded path for consolehelper git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1165 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/Makefile.in b/bacula/Makefile.in index d43c04318f..312c91c4e8 100755 --- a/bacula/Makefile.in +++ b/bacula/Makefile.in @@ -109,7 +109,7 @@ install-menu-consolehelper: installdirs gnomedirs ${INSTALL_DATA} scripts/bacula.desktop.gnome2.consolehelper $(DESTDIR)/usr/share/applications/bacula.desktop ${INSTALL_DATA} scripts/gnome-console.console_apps $(DESTDIR)/etc/security/console.apps/gnome-console ${INSTALL_DATA} scripts/gnome-console.pamd $(DESTDIR)/etc/pam.d/gnome-console - ln -s $(DESTDIR)$(sbindir)/consolehelper $(DESTDIR)$(sbindir)/gnome-console + ln -s $(DESTDIR)/usr/bin/consolehelper $(DESTDIR)/usr/bin/gnome-console install: installdirs @for I in $(all_subdirs); do (cd $$I; $(MAKE) DESTDIR=$(DESTDIR) $@ || exit 1); done diff --git a/bacula/kernstodo b/bacula/kernstodo index 7e9fb02a88..b3f1ed56b8 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -37,7 +37,6 @@ Testing to do: (painful) - Test cancel at EOM. For 1.33 Testing/Documentation: -- Document new Include/Exclude ... - Add counter variable test. - Document ln -sf /usr/lib/libncurses.so /usr/lib/libtermcap.so and install the esound-devĀ  package for compiling Console on SuSE. @@ -51,7 +50,6 @@ For 1.33 Testing/Documentation: Add Dan's work to manual See ssl.txt - Add db check test to regression. Test each function like delete, purge, ... -- Add subsections to the Disaster Recovery index section. - Document Pool keyword for restore. - If you use restore replace=never, the directory attributes for non-existent directories will not be restored properly. @@ -64,12 +62,6 @@ For 1.33 Testing/Documentation: "soft" and "intr"remount options may well help you. The only way of being sure would be totry it.See, for example, http://howtos.linux.com/guides/nag2/x-087-2-nfs.mountd.shtml -- Add the following devices as working: - Adic Scalar 100 DLT - Adic Fastor 22 DLT - (both HVD) - Overland LoaderXpress LTO (LVD) - Overland Neo2000 (LVD) For 1.33 - Null dlist head and tail pointers if all items are removed. diff --git a/bacula/src/tools/dbcheck.c b/bacula/src/tools/dbcheck.c index 34db8e6a1c..300b5e40da 100644 --- a/bacula/src/tools/dbcheck.c +++ b/bacula/src/tools/dbcheck.c @@ -50,8 +50,8 @@ typedef struct s_name_ctx { /* Global variables */ -static int fix = FALSE; -static int batch = FALSE; +static bool fix = false; +static bool batch = false; static B_DB *db; static ID_LIST id_list; static NAME_LIST name_list; @@ -73,6 +73,8 @@ static void eliminate_orphaned_file_records(); static void eliminate_orphaned_path_records(); static void eliminate_orphaned_filename_records(); static void eliminate_orphaned_fileset_records(); +static void repair_bad_paths(); +static void repair_bad_filenames(); static void do_interactive_mode(); static int yes_no(char *prompt); @@ -104,7 +106,7 @@ int main (int argc, char *argv[]) while ((ch = getopt(argc, argv, "bd:fv?")) != -1) { switch (ch) { case 'b': /* batch */ - batch = TRUE; + batch = true; break; case 'd': /* debug level */ @@ -114,7 +116,7 @@ int main (int argc, char *argv[]) break; case 'f': /* fix inconsistencies */ - fix = TRUE; + fix = true; break; case 'v': @@ -164,6 +166,8 @@ int main (int argc, char *argv[]) } if (batch) { + repair_bad_paths(); + repair_bad_filenames(); eliminate_duplicate_filenames(); eliminate_duplicate_paths(); eliminate_orphaned_jobmedia_records(); @@ -183,7 +187,7 @@ int main (int argc, char *argv[]) static void do_interactive_mode() { - int quit = FALSE; + bool quit = false; char *cmd; printf("Hello, this is the database check/correct program.\n\ @@ -196,28 +200,32 @@ Please select the fuction you want to perform.\n", printf(_("\n\ 1) Toggle modify database flag\n\ 2) Toggle verbose flag\n\ - 3) Eliminate duplicate Filename records\n\ - 4) Eliminate duplicate Path records\n\ - 5) Eliminate orphaned Jobmedia records\n\ - 6) Eliminate orphaned File records\n\ - 7) Eliminate orphaned Path records\n\ - 8) Eliminate orphaned Filename records\n\ - 9) Eliminate orphaned FileSet records\n\ - 10) All (3-9)\n\ - 11) Quit\n")); + 3) Repair bad Filename records\n\ + 4) Repair bad Path records\n\ + 5) Eliminate duplicate Filename records\n\ + 6) Eliminate duplicate Path records\n\ + 7) Eliminate orphaned Jobmedia records\n\ + 8) Eliminate orphaned File records\n\ + 9) Eliminate orphaned Path records\n\ + 10) Eliminate orphaned Filename records\n\ + 11) Eliminate orphaned FileSet records\n\ + 12) All (3-11)\n\ + 13) Quit\n")); } else { printf(_("\n\ 1) Toggle modify database flag\n\ 2) Toggle verbose flag\n\ - 3) Check for duplicate Filename records\n\ - 4) Check for duplicate Path records\n\ - 5) Check for orphaned Jobmedia records\n\ - 6) Check for orphaned File records\n\ - 7) Check for orphaned Path records\n\ - 8) Check for orphaned Filename records\n\ - 9) Check for orphaned FileSet records\n\ - 10) All (3-9)\n\ - 11) Quit\n")); + 3) Check for bad Filename records\n\ + 4) Check for bad Path records\n\ + 5) Check for duplicate Filename records\n\ + 6) Check for duplicate Path records\n\ + 7) Check for orphaned Jobmedia records\n\ + 8) Check for orphaned File records\n\ + 9) Check for orphaned Path records\n\ + 10) Check for orphaned Filename records\n\ + 11) Check for orphaned FileSet records\n\ + 12) All (3-11)\n\ + 13) Quit\n")); } cmd = get_cmd(_("Select function number: ")); @@ -233,27 +241,35 @@ Please select the fuction you want to perform.\n", printf(_("Verbose is %s\n"), verbose?_("On"):_("Off")); break; case 3: - eliminate_duplicate_filenames(); + repair_bad_filenames(); break; case 4: - eliminate_duplicate_paths(); + repair_bad_paths(); break; case 5: - eliminate_orphaned_jobmedia_records(); + eliminate_duplicate_filenames(); break; case 6: - eliminate_orphaned_file_records(); + eliminate_duplicate_paths(); break; case 7: - eliminate_orphaned_path_records(); + eliminate_orphaned_jobmedia_records(); break; case 8: - eliminate_orphaned_filename_records(); + eliminate_orphaned_file_records(); break; case 9: - eliminate_orphaned_fileset_records(); + eliminate_orphaned_path_records(); break; case 10: + eliminate_orphaned_filename_records(); + break; + case 11: + eliminate_orphaned_fileset_records(); + break; + case 12: + repair_bad_filenames(); + repair_bad_paths(); eliminate_duplicate_filenames(); eliminate_duplicate_paths(); eliminate_orphaned_jobmedia_records(); @@ -262,8 +278,8 @@ Please select the fuction you want to perform.\n", eliminate_orphaned_filename_records(); eliminate_orphaned_fileset_records(); break; - case 11: - quit = 1; + case 13: + quit = true; break; } } @@ -278,6 +294,16 @@ static int print_name_handler(void *ctx, int num_fields, char **row) return 0; } +static int get_name_handler(void *ctx, int num_fields, char **row) +{ + POOLMEM *buf = (POOLMEM *)ctx; + if (row[0]) { + pm_strcpy(&buf, row[0]); + } + return 0; +} + + static int print_jobmedia_handler(void *ctx, int num_fields, char **row) { printf(_("Orphaned JobMediaId=%s JobId=%s Volume=\"%s\"\n"), @@ -299,9 +325,6 @@ static int print_fileset_handler(void *ctx, int num_fields, char **row) return 0; } - - - /* * Called here with each id to be added to the list @@ -646,6 +669,94 @@ static void eliminate_orphaned_fileset_records() } } +static void repair_bad_filenames() +{ + char *query; + int i; + + printf("Checking for Filenames with a trailing slash\n"); + query = "SELECT FilenameId,Name from Filename " + "WHERE Name LIKE '%/'"; + if (!make_id_list(query, &id_list)) { + exit(1); + } + printf("Found %d bad Filename records.\n", id_list.num_ids); + if (name_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) { + for (i=0; i < id_list.num_ids; i++) { + sprintf(buf, + "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]); + if (!db_sql_query(db, buf, print_name_handler, NULL)) { + printf("%s\n", db_strerror(db)); + } + } + } + + if (fix && id_list.num_ids > 0) { + POOLMEM *name = get_pool_memory(PM_FNAME); + char esc_name[5000]; + printf("Reparing %d bad Filename records.\n", id_list.num_ids); + for (i=0; i < id_list.num_ids; i++) { + int len; + sprintf(buf, + "SELECT Name FROM Filename WHERE FilenameId=%u", id_list.Id[i]); + if (!db_sql_query(db, buf, get_name_handler, name)) { + printf("%s\n", db_strerror(db)); + } + /* Strip trailing slash(es) */ + for (len=strlen(name); len > 1 && name[len-1]; len--) + { } + db_escape_string(esc_name, name, len); + bsnprintf(buf, sizeof(buf), + "UPDATE Filename SET Name='%s' WHERE FilenameId=%u", id_list.Id[i]); + db_sql_query(db, buf, NULL, NULL); + } + } +} + +static void repair_bad_paths() +{ + char *query; + int i; + + printf("Checking for Paths without a trailing slash\n"); + query = "SELECT PathId,Path from Path " + "WHERE Path IS NOT LIKE '%/'"; + if (!make_id_list(query, &id_list)) { + exit(1); + } + printf("Found %d bad Path records.\n", id_list.num_ids); + if (name_list.num_ids && verbose && yes_no("Print them? (yes/no): ")) { + for (i=0; i < id_list.num_ids; i++) { + sprintf(buf, + "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]); + if (!db_sql_query(db, buf, print_name_handler, NULL)) { + printf("%s\n", db_strerror(db)); + } + } + } + + if (fix && id_list.num_ids > 0) { + POOLMEM *name = get_pool_memory(PM_FNAME); + char esc_name[5000]; + printf("Reparing %d bad Filename records.\n", id_list.num_ids); + for (i=0; i < id_list.num_ids; i++) { + sprintf(buf, + "SELECT Path FROM Path WHERE PathId=%u", id_list.Id[i]); + if (!db_sql_query(db, buf, get_name_handler, name)) { + printf("%s\n", db_strerror(db)); + } + /* Add trailing slash */ + int len = pm_strcat(&name, "/"); + db_escape_string(esc_name, name, len); + bsnprintf(buf, sizeof(buf), + "UPDATE Path SET Path='%s' WHERE PathId=%u", id_list.Id[i]); + db_sql_query(db, buf, NULL, NULL); + } + } +} + + + /* * Gen next input command from the terminal