Fix "generated by" comments in configuration files.

Add get_configuration_namespace() and use it in code that writes
"generated by" comments at the top of various configuration files.

Update our Logwolf colorfilters.
This commit is contained in:
Gerald Combs 2022-04-28 13:41:27 -07:00
parent b244db8f3c
commit 70bd130379
7 changed files with 34 additions and 15 deletions

View File

@ -807,7 +807,7 @@ write_filters_file(GSList *cfl, FILE *f, gboolean only_selected)
data.f = f; data.f = f;
data.only_selected = only_selected; data.only_selected = only_selected;
fprintf(f,"# DO NOT EDIT THIS FILE! It was created by Wireshark\n"); fprintf(f,"# This file was created by %s. Edit with care.\n", get_configuration_namespace());
g_slist_foreach(cfl, write_filter, &data); g_slist_foreach(cfl, write_filter, &data);
return TRUE; return TRUE;
} }

View File

@ -412,11 +412,12 @@ save_decode_as_entries(gchar** err)
return -1; return -1;
} }
fputs("# \"Decode As\" entries file for Wireshark " VERSION ".\n" fprintf(da_file, "# \"Decode As\" entries file for %s " VERSION ".\n"
"#\n" "#\n"
"# This file is regenerated each time \"Decode As\" preferences\n" "# This file is regenerated each time \"Decode As\" preferences\n"
"# are saved within Wireshark. Making manual changes should be safe,\n" "# are saved within %s. Making manual changes should be safe,\n"
"# however.\n", da_file); "# however.\n",
get_configuration_namespace(), get_configuration_namespace());
dissector_all_tables_foreach_changed(decode_as_write_entry, &decode_as_rows_list); dissector_all_tables_foreach_changed(decode_as_write_entry, &decode_as_rows_list);

View File

@ -82,6 +82,7 @@ libwsutil.so.0 libwsutil0 #MINVER#
free_features@Base 3.7.0 free_features@Base 3.7.0
free_progdirs@Base 2.3.0 free_progdirs@Base 2.3.0
get_basename@Base 1.12.0~rc1 get_basename@Base 1.12.0~rc1
get_configuration_namespace@Base 3.7.0
get_copyright_info@Base 1.99.0 get_copyright_info@Base 1.99.0
get_cur_groupname@Base 1.10.0 get_cur_groupname@Base 1.10.0
get_cur_username@Base 1.10.0 get_cur_username@Base 1.10.0

View File

@ -1,4 +1,4 @@
# DO NOT EDIT THIS FILE! It was created by Wireshark # This file was created by Logwolf. Edit with care.
@Errors@ct.error@[42148,0,0][65535,64764,40092] @Errors@ct.error@[4626,10023,11822][63479,34695,34695]
@State Modifying Event@ct.readonly == "false"@[61423,50372,39578][0,0,0] @State Modifying Event@ct.readonly == "false"@[61423,50372,39578][0,0,0]
@Administrative Activity@cloudtrail and not (ct.name ~ "^Describe.*" or ct.name ~ "^List.*" or ct.name ~ "^(Batch|)Get.*")@[61423,50372,39578][0,0,0] @Administrative Activity@cloudtrail and not (ct.name ~ "^Describe.*" or ct.name ~ "^List.*" or ct.name ~ "^(Batch|)Get.*")@[61423,50372,39578][0,0,0]

View File

@ -674,14 +674,16 @@ write_recent(void)
} }
g_free(rf_path); g_free(rf_path);
fputs("# Common recent settings file for Wireshark " VERSION ".\n" fprintf(rf, "# Common recent settings file for %s " VERSION ".\n"
"#\n" "#\n"
"# This file is regenerated each time Wireshark is quit\n" "# This file is regenerated each time %s is quit\n"
"# and when changing configuration profile.\n" "# and when changing configuration profile.\n"
"# So be careful, if you want to make manual changes here.\n" "# So be careful, if you want to make manual changes here.\n"
"\n" "\n"
"######## Recent capture files (latest last), cannot be altered through command line ########\n" "######## Recent capture files (latest last), cannot be altered through command line ########\n"
"\n", rf); "\n",
get_configuration_namespace(), get_configuration_namespace());
menu_recent_file_write_all(rf); menu_recent_file_write_all(rf);
@ -816,12 +818,13 @@ write_profile_recent(void)
} }
g_free(rf_path); g_free(rf_path);
fputs("# Recent settings file for Wireshark " VERSION ".\n" fprintf(rf, "# Recent settings file for %s " VERSION ".\n"
"#\n" "#\n"
"# This file is regenerated each time Wireshark is quit\n" "# This file is regenerated each time %s is quit\n"
"# and when changing configuration profile.\n" "# and when changing configuration profile.\n"
"# So be careful, if you want to make manual changes here.\n" "# So be careful, if you want to make manual changes here.\n"
"\n", rf); "\n",
get_configuration_namespace(), get_configuration_namespace());
write_recent_boolean(rf, "Main Toolbar show (hide)", write_recent_boolean(rf, "Main Toolbar show (hide)",
RECENT_KEY_MAIN_TOOLBAR_SHOW, RECENT_KEY_MAIN_TOOLBAR_SHOW,

View File

@ -54,6 +54,8 @@
/* /*
* Application configuration namespace. Used to construct configuration * Application configuration namespace. Used to construct configuration
* paths and environment variables. * paths and environment variables.
* XXX We might want to use the term "application flavor" instead, with
* "packet" and "log" flavors.
*/ */
enum configuration_namespace_e { enum configuration_namespace_e {
CONFIGURATION_NAMESPACE_UNINITIALIZED, CONFIGURATION_NAMESPACE_UNINITIALIZED,
@ -62,6 +64,7 @@ enum configuration_namespace_e {
}; };
enum configuration_namespace_e configuration_namespace = CONFIGURATION_NAMESPACE_UNINITIALIZED; enum configuration_namespace_e configuration_namespace = CONFIGURATION_NAMESPACE_UNINITIALIZED;
#define CONFIGURATION_NAMESPACE_PROPER (configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "Wireshark" : "Logwolf")
#define CONFIGURATION_NAMESPACE_LOWER (configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "wireshark" : "logwolf") #define CONFIGURATION_NAMESPACE_LOWER (configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "wireshark" : "logwolf")
#define CONFIGURATION_ENVIRONMENT_VARIABLE(suffix) (configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "WIRESHARK_" suffix : "LOGWOLF_" suffix) #define CONFIGURATION_ENVIRONMENT_VARIABLE(suffix) (configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "WIRESHARK_" suffix : "LOGWOLF_" suffix)
@ -297,8 +300,13 @@ set_configuration_namespace(const char *namespace_name)
ws_error("Unknown configuration namespace %s", namespace_name); ws_error("Unknown configuration namespace %s", namespace_name);
} }
ws_debug("Using configuration namespace %s.", ws_debug("Using configuration namespace %s.", CONFIGURATION_NAMESPACE_PROPER);
configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "Wireshark" : "Logwolf"); }
const char *
get_configuration_namespace(void)
{
return CONFIGURATION_NAMESPACE_PROPER;
} }
#ifndef _WIN32 #ifndef _WIN32
@ -1330,7 +1338,7 @@ get_persconffile_dir_no_profile(void)
* is an inaccessible network drive. * is an inaccessible network drive.
*/ */
env = g_getenv("APPDATA"); env = g_getenv("APPDATA");
const char *persconf_namespace = configuration_namespace == CONFIGURATION_NAMESPACE_WIRESHARK ? "Wireshark" : "Logwolf"; const char *persconf_namespace = CONFIGURATION_NAMESPACE_PROPER;
if (env != NULL) { if (env != NULL) {
/* /*
* Concatenate %APPDATA% with "\Wireshark" or "\Logwolf". * Concatenate %APPDATA% with "\Wireshark" or "\Logwolf".

View File

@ -39,6 +39,12 @@ extern "C" {
*/ */
WS_DLL_PUBLIC char *configuration_init(const char *arg0, const char *namespace_name); WS_DLL_PUBLIC char *configuration_init(const char *arg0, const char *namespace_name);
/**
* Get the configuration namespace name.
* @return The namespace name. One of "Wireshark" or "Logwolf".
*/
WS_DLL_PUBLIC const char *get_configuration_namespace(void);
/* /*
* Get the directory in which the program resides. * Get the directory in which the program resides.
*/ */