mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-04 22:00:19 -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
|
|
@ -213,7 +213,7 @@ int main(int argc, char* argv[])
|
|||
int i;
|
||||
int pos;
|
||||
int mode;
|
||||
int gui;
|
||||
int lock_options;
|
||||
int ret;
|
||||
|
||||
(void)argc;
|
||||
|
|
@ -247,12 +247,16 @@ int main(int argc, char* argv[])
|
|||
utf8_argc = 1;
|
||||
|
||||
mode = MODE_DEFAULT;
|
||||
gui = 0;
|
||||
lock_options = 0;
|
||||
for (i = 1; i < wide_argc; i++) {
|
||||
if (wcscmp(wide_argv[i], L"--gui") == 0 || wcscmp(wide_argv[i], L"--gui-verbose") == 0)
|
||||
gui = 1;
|
||||
if (wcscmp(wide_argv[i], L"--lock-options") == 0)
|
||||
lock_options = 1;
|
||||
|
||||
if (wcscmp(wide_argv[i], L"-s") == 0 || wcscmp(wide_argv[i], L"--spin-down-on-error") == 0) {
|
||||
if (lock_options) {
|
||||
fprintf(stderr, "The --spin-down-on-error option cannot be used after --lock-options.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
mode = MODE_SPINDOWN;
|
||||
} else {
|
||||
pos = argcat(cmd_buffer, COMMAND_LINE_MAX, pos, wide_argv[i]);
|
||||
|
|
@ -269,11 +273,6 @@ int main(int argc, char* argv[])
|
|||
utf8_argv[utf8_argc] = 0;
|
||||
cmd_buffer[pos] = 0;
|
||||
|
||||
if (mode == MODE_SPINDOWN && gui) {
|
||||
fprintf(stderr, "The --spin-down-on-error option cannot be used with --gui.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
LocalFree(wide_argv);
|
||||
|
||||
if (mode == MODE_DEFAULT) {
|
||||
|
|
@ -380,18 +379,22 @@ static void forward_signal(int sig)
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
int mode;
|
||||
int gui;
|
||||
int lock_options;
|
||||
int i, j;
|
||||
int ret;
|
||||
|
||||
mode = MODE_DEFAULT;
|
||||
gui = 0;
|
||||
lock_options = 0;
|
||||
j = 1;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "--gui") == 0 || strcmp(argv[i], "--gui-verbose") == 0)
|
||||
gui = 1;
|
||||
if (strcmp(argv[i], "--lock-options") == 0)
|
||||
lock_options = 1;
|
||||
|
||||
if (strcmp(argv[i], "-s") == 0 || strcmp(argv[i], "--spin-down-on-error") == 0) {
|
||||
if (lock_options) {
|
||||
fprintf(stderr, "The --spin-down-on-error option cannot be used after --lock-options.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
mode = MODE_SPINDOWN;
|
||||
} else {
|
||||
argv[j] = argv[i];
|
||||
|
|
@ -401,11 +404,6 @@ int main(int argc, char* argv[])
|
|||
argc = j;
|
||||
argv[argc] = 0;
|
||||
|
||||
if (mode == MODE_SPINDOWN && gui) {
|
||||
fprintf(stderr, "The --spin-down-on-error option cannot be used with --gui.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (mode == MODE_DEFAULT) {
|
||||
ret = snapraid_main(argc, argv);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue