-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccd_pass.rs
39 lines (33 loc) · 1.13 KB
/
ccd_pass.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Provides the command "ccd_pass" for crosh
use std::path::Path;
use std::process;
use crate::dispatcher::{self, wait_for_result, Arguments, Command, Dispatcher};
const EXECUTABLE: &str = "/usr/sbin/gsctool";
pub fn register(dispatcher: &mut Dispatcher) {
// Only register the ccd_pass command if the executable is present.
if !Path::new(EXECUTABLE).exists() {
return;
}
dispatcher.register_command(
Command::new(
"ccd_pass".to_string(),
"".to_string(),
"When prompted, set or clear CCD password (use the word 'clear' to clear
the password)."
.to_string(),
)
.set_command_callback(Some(execute_ccd_pass)),
);
}
fn execute_ccd_pass(_cmd: &Command, _args: &Arguments) -> Result<(), dispatcher::Error> {
wait_for_result(
process::Command::new(EXECUTABLE)
.arg("-t")
.arg("-P")
.spawn()
.or(Err(dispatcher::Error::CommandReturnedError))?,
)
}