mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-02 04:46:46 -05:00
Use --lock-options instead of --gui to restrict unsafe command-line options
This commit is contained in:
parent
c8baa605b7
commit
d2a4268d93
3 changed files with 29 additions and 28 deletions
|
|
@ -203,6 +203,7 @@ void log_close(const char* file)
|
|||
#define OPT_GUI_TOUCH_BEFORE 504
|
||||
#define OPT_GUI_THRESHOLD_REMOVES 505
|
||||
#define OPT_GUI_THRESHOLD_UPDATES 506
|
||||
#define OPT_LOCK_OPTIONS 507
|
||||
|
||||
/**
|
||||
* Test options
|
||||
|
|
@ -300,6 +301,7 @@ static struct option long_options[] = {
|
|||
{ "version", 0, 0, 'V' },
|
||||
|
||||
{ "no-warnings", 0, 0, OPT_NO_WARNINGS }, /* disable annoying warnings */
|
||||
{ "lock-options", 0, 0, OPT_LOCK_OPTIONS }, /* lock options to avoid unintended injection */
|
||||
{ "gui", 0, 0, OPT_GUI }, /* undocumented GUI interface option (it was also 'G' in the past) */
|
||||
{ "gui-verbose", 0, 0, OPT_GUI_VERBOSE }, /* undocumented GUI interface option */
|
||||
{ "gui-rescan-after", 0, 0, OPT_GUI_RESCAN_AFTER }, /* undocumented GUI, force a rescan after the command to log differences */
|
||||
|
|
@ -460,7 +462,7 @@ static struct option long_options[] = {
|
|||
*/
|
||||
#define OPTIONS "t:c:f:d:mebp:o:S:B:L:i:l:AZEUDNFRW:ahTC:vqHVw:"
|
||||
|
||||
static int option_gui_locked(int c)
|
||||
static int option_locked(int c)
|
||||
{
|
||||
if (c >= OPT_TEST_FIRST && c <= OPT_TEST_LAST)
|
||||
return 1;
|
||||
|
|
@ -564,7 +566,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
const char* import_content;
|
||||
const char* log_file;
|
||||
int lock;
|
||||
int gui_locked;
|
||||
int lock_options;
|
||||
const char* gen_conf;
|
||||
#if HAVE_CHECKER
|
||||
const char* run;
|
||||
|
|
@ -605,7 +607,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
import_content = 0;
|
||||
log_file = 0;
|
||||
lock = 0;
|
||||
gui_locked = 0;
|
||||
lock_options = 0;
|
||||
gen_conf = 0;
|
||||
speedtest = 0;
|
||||
#if HAVE_CHECKER
|
||||
|
|
@ -620,8 +622,8 @@ int snapraid_main(int argc, char* argv[])
|
|||
getopt(argc, argv, OPTIONS))
|
||||
#endif
|
||||
!= EOF) {
|
||||
if (gui_locked && option_gui_locked(c)) {
|
||||
log_fatal(EUSER, "Option not allowed after --gui.\n");
|
||||
if (lock_options && option_locked(c)) {
|
||||
log_fatal(EUSER, "Option not allowed after --lock-options.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -832,13 +834,14 @@ int snapraid_main(int argc, char* argv[])
|
|||
case OPT_NO_WARNINGS :
|
||||
opt.no_warnings = 1;
|
||||
break;
|
||||
case OPT_LOCK_OPTIONS :
|
||||
lock_options = 1;
|
||||
break;
|
||||
case OPT_GUI :
|
||||
opt.gui = 1;
|
||||
gui_locked = 1;
|
||||
break;
|
||||
case OPT_GUI_VERBOSE :
|
||||
opt.gui = 1;
|
||||
gui_locked = 1;
|
||||
opt.gui_verbose = 1;
|
||||
break;
|
||||
case OPT_GUI_RESCAN_AFTER :
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue