mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-17 12:11:28 +03:00
restrict CLI options when settings disabled (#13400)
Prevent --password, --set-id, and --option command line arguments from modifying settings when is_disable_settings() returns true. Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -373,6 +373,10 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
} else if args[0] == "--password" {
|
} else if args[0] == "--password" {
|
||||||
|
if config::is_disable_settings() {
|
||||||
|
println!("Settings are disabled!");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
if args.len() == 2 {
|
if args.len() == 2 {
|
||||||
if crate::platform::is_installed() && is_root() {
|
if crate::platform::is_installed() && is_root() {
|
||||||
if let Err(err) = crate::ipc::set_permanent_password(args[1].to_owned()) {
|
if let Err(err) = crate::ipc::set_permanent_password(args[1].to_owned()) {
|
||||||
@@ -403,6 +407,10 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
println!("{}", crate::ipc::get_id());
|
println!("{}", crate::ipc::get_id());
|
||||||
return None;
|
return None;
|
||||||
} else if args[0] == "--set-id" {
|
} else if args[0] == "--set-id" {
|
||||||
|
if config::is_disable_settings() {
|
||||||
|
println!("Settings are disabled!");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
if args.len() == 2 {
|
if args.len() == 2 {
|
||||||
if crate::platform::is_installed() && is_root() {
|
if crate::platform::is_installed() && is_root() {
|
||||||
let old_id = crate::ipc::get_id();
|
let old_id = crate::ipc::get_id();
|
||||||
@@ -442,6 +450,10 @@ pub fn core_main() -> Option<Vec<String>> {
|
|||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
} else if args[0] == "--option" {
|
} else if args[0] == "--option" {
|
||||||
|
if config::is_disable_settings() {
|
||||||
|
println!("Settings are disabled!");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
if crate::platform::is_installed() && is_root() {
|
if crate::platform::is_installed() && is_root() {
|
||||||
if args.len() == 2 {
|
if args.len() == 2 {
|
||||||
let options = crate::ipc::get_options();
|
let options = crate::ipc::get_options();
|
||||||
@@ -668,8 +680,8 @@ fn core_main_invoke_new_connection(mut args: std::env::Args) -> Option<Vec<Strin
|
|||||||
let mut param_array = vec![];
|
let mut param_array = vec![];
|
||||||
while let Some(arg) = args.next() {
|
while let Some(arg) = args.next() {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--connect" | "--play" | "--file-transfer" | "--view-camera" | "--port-forward" | "--terminal"
|
"--connect" | "--play" | "--file-transfer" | "--view-camera" | "--port-forward"
|
||||||
| "--rdp" => {
|
| "--terminal" | "--rdp" => {
|
||||||
authority = Some((&arg.to_string()[2..]).to_owned());
|
authority = Some((&arg.to_string()[2..]).to_owned());
|
||||||
id = args.next();
|
id = args.next();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user