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:
21pages
2025-11-03 09:43:27 +08:00
committed by GitHub
parent d03a9e2baf
commit f7f947beb9

View File

@@ -373,6 +373,10 @@ pub fn core_main() -> Option<Vec<String>> {
}
return None;
} else if args[0] == "--password" {
if config::is_disable_settings() {
println!("Settings are disabled!");
return None;
}
if args.len() == 2 {
if crate::platform::is_installed() && is_root() {
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());
return None;
} else if args[0] == "--set-id" {
if config::is_disable_settings() {
println!("Settings are disabled!");
return None;
}
if args.len() == 2 {
if crate::platform::is_installed() && is_root() {
let old_id = crate::ipc::get_id();
@@ -442,6 +450,10 @@ pub fn core_main() -> Option<Vec<String>> {
}
return None;
} else if args[0] == "--option" {
if config::is_disable_settings() {
println!("Settings are disabled!");
return None;
}
if crate::platform::is_installed() && is_root() {
if args.len() == 2 {
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![];
while let Some(arg) = args.next() {
match arg.as_str() {
"--connect" | "--play" | "--file-transfer" | "--view-camera" | "--port-forward" | "--terminal"
| "--rdp" => {
"--connect" | "--play" | "--file-transfer" | "--view-camera" | "--port-forward"
| "--terminal" | "--rdp" => {
authority = Some((&arg.to_string()[2..]).to_owned());
id = args.next();
}