diff --git a/.gitmodules b/.gitmodules index d80e69aa8..5fc4a9392 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "libs/hbb_common"] path = libs/hbb_common - url = https://github.com/rustdesk/hbb_common + url = https://github.com/21pages/hbb_common + branch = disable-change-permanent-password diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 8de0f2b12..b4c9c6e82 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -3805,6 +3805,16 @@ setResizable(bool resizable) { isOptionFixed(String key) => bind.mainIsOptionFixed(key: key); +bool isChangePermanentPasswordDisabled() => + bind.mainGetBuildinOption(key: kOptionDisableChangePermanentPassword) == + 'Y'; + +bool isChangeIdDisabled() => + bind.mainGetBuildinOption(key: kOptionDisableChangeId) == 'Y'; + +bool isUnlockPinDisabled() => + bind.mainGetBuildinOption(key: kOptionDisableUnlockPin) == 'Y'; + bool? _isCustomClient; bool get isCustomClient { _isCustomClient ??= bind.isCustomClient(); diff --git a/flutter/lib/consts.dart b/flutter/lib/consts.dart index 7bcadd658..aea744a78 100644 --- a/flutter/lib/consts.dart +++ b/flutter/lib/consts.dart @@ -180,6 +180,10 @@ const String kOptionHideSecuritySetting = "hide-security-settings"; const String kOptionHideNetworkSetting = "hide-network-settings"; const String kOptionRemovePresetPasswordWarning = "remove-preset-password-warning"; +const String kOptionDisableChangePermanentPassword = + "disable-change-permanent-password"; +const String kOptionDisableChangeId = "disable-change-id"; +const String kOptionDisableUnlockPin = "disable-unlock-pin"; const kHideUsernameOnCard = "hide-username-on-card"; const String kOptionHideHelpCards = "hide-help-cards"; diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index ab6dfe47e..a431efee4 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -825,7 +825,8 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { permissions(context), password(context), _Card(title: '2FA', children: [tfa()]), - _Card(title: 'ID', children: [changeId()]), + if (!isChangeIdDisabled()) + _Card(title: 'ID', children: [changeId()]), more(context), ]), ), @@ -1091,6 +1092,10 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { .indexOf(kUsePermanentPassword)] && (await bind.mainGetPermanentPassword()) .isEmpty) { + if (isChangePermanentPasswordDisabled()) { + await callback(); + return; + } setPasswordDialog(notEmptyCallback: callback); } else { await callback(); @@ -1195,7 +1200,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { enabled: tmpEnabled && !locked), if (usePassword) numericOneTimePassword, if (usePassword) radios[1], - if (usePassword) + if (usePassword && !isChangePermanentPasswordDisabled()) _SubButton('Set permanent password', setPasswordDialog, permEnabled && !locked), // if (usePassword) @@ -1218,7 +1223,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin { _OptionCheckBox(context, 'allow-only-conn-window-open-tip', 'allow-only-conn-window-open', reverse: false, enabled: enabled), - if (bind.mainIsInstalled()) unlockPin() + if (bind.mainIsInstalled() && !isUnlockPinDisabled()) unlockPin() ]); } @@ -2654,7 +2659,7 @@ Widget _lock( ]).marginSymmetric(vertical: 2)), onPressed: () async { final unlockPin = bind.mainGetUnlockPin(); - if (unlockPin.isEmpty) { + if (unlockPin.isEmpty || isUnlockPinDisabled()) { bool checked = await callMainCheckSuperUserPermission(); if (checked) { onUnlock(); diff --git a/flutter/lib/mobile/pages/server_page.dart b/flutter/lib/mobile/pages/server_page.dart index ed4fe4d98..d2a6ed8a8 100644 --- a/flutter/lib/mobile/pages/server_page.dart +++ b/flutter/lib/mobile/pages/server_page.dart @@ -61,12 +61,13 @@ class _DropDownAction extends StatelessWidget { final isAllowNumericOneTimePassword = gFFI.serverModel.allowNumericOneTimePassword; return [ - PopupMenuItem( - enabled: gFFI.serverModel.connectStatus > 0, - value: "changeID", - child: Text(translate("Change ID")), - ), - const PopupMenuDivider(), + if (!isChangeIdDisabled()) + PopupMenuItem( + enabled: gFFI.serverModel.connectStatus > 0, + value: "changeID", + child: Text(translate("Change ID")), + ), + if (!isChangeIdDisabled()) const PopupMenuDivider(), PopupMenuItem( value: 'AcceptSessionsViaPassword', child: listTile( @@ -87,7 +88,8 @@ class _DropDownAction extends StatelessWidget { ), if (showPasswordOption) const PopupMenuDivider(), if (showPasswordOption && - verificationMethod != kUseTemporaryPassword) + verificationMethod != kUseTemporaryPassword && + !isChangePermanentPasswordDisabled()) PopupMenuItem( value: "setPermanentPassword", child: Text(translate("Set permanent password")), @@ -149,6 +151,10 @@ class _DropDownAction extends StatelessWidget { if (value == kUsePermanentPassword && (await bind.mainGetPermanentPassword()).isEmpty) { + if (isChangePermanentPasswordDisabled()) { + callback(); + return; + } setPasswordDialog(notEmptyCallback: callback); } else { callback(); @@ -648,9 +654,8 @@ class ConnectionManager extends StatelessWidget { return Column( children: serverModel.clients .map((client) => PaddingCard( - title: translate(client.isFileTransfer - ? "Transfer file" - : "Share screen"), + title: translate( + client.isFileTransfer ? "Transfer file" : "Share screen"), titleIcon: client.isFileTransfer ? Icon(Icons.folder_outlined) : Icon(Icons.mobile_screen_share), diff --git a/libs/hbb_common b/libs/hbb_common index 12f2a4777..73ab9575f 160000 --- a/libs/hbb_common +++ b/libs/hbb_common @@ -1 +1 @@ -Subproject commit 12f2a47770af7521588ccaa67731806f15d0132d +Subproject commit 73ab9575fdfc1dbf2aad477bb9a8875405661cfc diff --git a/src/core_main.rs b/src/core_main.rs index 9abfcb444..59adf3aff 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -406,6 +406,10 @@ pub fn core_main() -> Option> { println!("Settings are disabled!"); return None; } + if config::Config::is_disable_change_permanent_password() { + println!("Changing permanent password is 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()) { @@ -419,6 +423,10 @@ pub fn core_main() -> Option> { } return None; } else if args[0] == "--set-unlock-pin" { + if config::Config::is_disable_unlock_pin() { + println!("Unlock PIN is disabled!"); + return None; + } #[cfg(feature = "flutter")] if args.len() == 2 { if crate::platform::is_installed() && is_root() { @@ -440,6 +448,10 @@ pub fn core_main() -> Option> { println!("Settings are disabled!"); return None; } + if config::Config::is_disable_change_id() { + println!("Changing ID is disabled!"); + return None; + } if args.len() == 2 { if crate::platform::is_installed() && is_root() { let old_id = crate::ipc::get_id(); diff --git a/src/ui/index.tis b/src/ui/index.tis index 966b39734..20cbb7ba2 100644 --- a/src/ui/index.tis +++ b/src/ui/index.tis @@ -16,6 +16,8 @@ const disable_ab = handler.is_disable_ab(); const hide_server_settings = handler.get_builtin_option("hide-server-settings") == "Y"; const hide_proxy_settings = handler.get_builtin_option("hide-proxy-settings") == "Y"; const hide_websocket_settings = handler.get_builtin_option("hide-websocket-settings") == "Y"; +const disable_change_permanent_password = handler.get_builtin_option("disable-change-permanent-password") == "Y"; +const disable_change_id = handler.get_builtin_option("disable-change-id") == "Y"; // html min-width, min-height not working on mac, below works for all if (incoming_only) { @@ -508,11 +510,11 @@ class MyIdMenu: Reactor.Component { {!disable_settings && is_win && handler.is_installed() ? : ""} {!disable_settings && } {!disable_settings && false && handler.using_public_server() &&
  • {svg_checkmark}{translate('Always connect via relay')}
  • } - {handler.is_ok_change_id() ?
    : ""} - {!disable_account && (username ? + {!disable_change_id && handler.is_ok_change_id() ?
    : ""} + {!disable_account && (username ?
  • {translate('Logout')} ({username})
  • :
  • {translate('Login')}
  • )} - {!disable_settings && handler.is_ok_change_id() && key_confirmed && connect_status > 0 ?
  • {translate('Change ID')}
  • : ""} + {!disable_change_id && !disable_settings && handler.is_ok_change_id() && key_confirmed && connect_status > 0 ?
  • {translate('Change ID')}
  • : ""}
  • {svg_checkmark}{translate('Dark Theme')}
  • @@ -1050,7 +1052,7 @@ class PasswordArea: Reactor.Component { { !show_password ? '' :
  • {svg_checkmark}{translate('Use permanent password')}
  • } { !show_password ? '' :
  • {svg_checkmark}{translate('Use both passwords')}
  • } { !show_password ? '' :
    } - { !show_password ? '' :
  • {translate('Set permanent password')}
  • } + { !show_password || disable_change_permanent_password ? '' :
  • {translate('Set permanent password')}
  • } { !show_password ? '' : }
  • {svg_checkmark}{translate('enable-2fa-title')}