(shell: String, cmd_option: Option<String>, escape_arguments: Option<bool>)
| 126 | |
| 127 | #[cfg(windows)] |
| 128 | fn set_default_shell(shell: String, cmd_option: Option<String>, escape_arguments: Option<bool>) -> Result<(), SshdConfigError> { |
| 129 | debug!("{}", t!("set.settingDefaultShell")); |
| 130 | if shell.is_empty() { |
| 131 | remove_registry(DEFAULT_SHELL)?; |
| 132 | } else { |
| 133 | // TODO: if shell contains quotes, we need to remove them |
| 134 | let shell_path = Path::new(&shell); |
| 135 | if shell_path.is_relative() && shell_path.components().any(|c| c == std::path::Component::ParentDir) { |
| 136 | return Err(SshdConfigError::InvalidInput(t!("set.shellPathMustNotBeRelative").to_string())); |
| 137 | } |
| 138 | if !shell_path.exists() { |
| 139 | return Err(SshdConfigError::InvalidInput(t!("set.shellPathDoesNotExist", shell = shell).to_string())); |
| 140 | } |
| 141 | set_registry(DEFAULT_SHELL, RegistryValueData::String(shell))?; |
| 142 | } |
| 143 | |
| 144 | if let Some(cmd_option) = cmd_option { |
| 145 | set_registry(DEFAULT_SHELL_CMD_OPTION, RegistryValueData::String(cmd_option.clone()))?; |
| 146 | } else { |
| 147 | remove_registry(DEFAULT_SHELL_CMD_OPTION)?; |
| 148 | } |
| 149 | |
| 150 | if let Some(escape_args) = escape_arguments { |
| 151 | let mut escape_data = 0; |
| 152 | if escape_args { |
| 153 | escape_data = 1; |
| 154 | } |
| 155 | set_registry(DEFAULT_SHELL_ESCAPE_ARGS, RegistryValueData::DWord(escape_data))?; |
| 156 | } else { |
| 157 | remove_registry(DEFAULT_SHELL_ESCAPE_ARGS)?; |
| 158 | } |
| 159 | |
| 160 | Ok(()) |
| 161 | } |
| 162 | |
| 163 | #[cfg(not(windows))] |
| 164 | fn set_default_shell(_shell: String, _cmd_option: Option<String>, _escape_arguments: Option<bool>) -> Result<(), SshdConfigError> { |
no test coverage detected