forked from osmocom/wireshark
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.
This commit is contained in:
parent
abe8798b78
commit
1eeb0c9934
23
tfshark.c
23
tfshark.c
|
@ -392,6 +392,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);
|
||||
return 1;
|
||||
|
|
23
tshark.c
23
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;
|
||||
|
|
|
@ -265,6 +265,27 @@ void commandline_early_options(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(INVALID_FILE);
|
||||
}
|
||||
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(INVALID_FILE);
|
||||
}
|
||||
set_profile_name (ws_optarg);
|
||||
} else {
|
||||
cmdarg_err("Configuration Profile \"%s\" does not exist", ws_optarg);
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue