aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-07-05 22:06:09 -0400
committerA Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2022-07-07 12:14:41 +0000
commit1eeb0c99345701dd5698a5a36ff8f87857422b02 (patch)
treee4570d119e62f5fc16423437d31e5111ea3db7d8 /tshark.c
parentabe8798b78eac21c39d45239ca6674bad7456346 (diff)
cli: Copy global configuration profile to personal as with the GUI
If a configuration profile is requested on the command line that does not exist as a personal profile but does exist as a global profile, copy it to the personal directory and use it, the same as when selecting a global profile in the GUI. Add the same feature to tshark and tfshark as well, where it is particularly useful.
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tshark.c b/tshark.c
index 9ac84a621d..498c5a95fb 100644
--- a/tshark.c
+++ b/tshark.c
@@ -936,6 +936,29 @@ main(int argc, char *argv[])
case 'C': /* Configuration Profile */
if (profile_exists (ws_optarg, FALSE)) {
set_profile_name (ws_optarg);
+ } else if (profile_exists (ws_optarg, TRUE)) {
+ char *pf_dir_path, *pf_dir_path2, *pf_filename;
+ /* Copy from global profile */
+ if (create_persconffile_profile(ws_optarg, &pf_dir_path) == -1) {
+ cmdarg_err("Can't create directory\n\"%s\":\n%s.",
+ pf_dir_path, g_strerror(errno));
+
+ g_free(pf_dir_path);
+ exit_status = INVALID_FILE;
+ goto clean_exit;
+ }
+ if (copy_persconffile_profile(ws_optarg, ws_optarg, TRUE, &pf_filename,
+ &pf_dir_path, &pf_dir_path2) == -1) {
+ cmdarg_err("Can't copy file \"%s\" in directory\n\"%s\" to\n\"%s\":\n%s.",
+ pf_filename, pf_dir_path2, pf_dir_path, g_strerror(errno));
+
+ g_free(pf_filename);
+ g_free(pf_dir_path);
+ g_free(pf_dir_path2);
+ exit_status = INVALID_FILE;
+ goto clean_exit;
+ }
+ set_profile_name (ws_optarg);
} else {
cmdarg_err("Configuration Profile \"%s\" does not exist", ws_optarg);
exit_status = INVALID_OPTION;