Skip to content

Commit 47c244e

Browse files
authored
fix(chromeos): Fix compatibility with new deps and new ChromeOS (#89)
- Update CrOS private key URL (branch name "master" => "main") - Fix private key permissions (0600) - Fix node-ssh usage ("privateKey" => "privateKeyPath", exit code "null" => "0") - Move shell scripts into "scripts" folder (cleanup) - Fix Chrome launch arguments for compatibility with Lacros
1 parent 85b4ccf commit 47c244e

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

backends/chromeos/chromeos-utils.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const path = require('path');
2222

2323
// A URL where the default SSH private key for dev-mode ChromeOS can be found.
2424
// The key is encoded in base64.
25-
const DEFAULT_PRIVATE_KEY_URL = 'https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/master/chromeos-base/chromeos-ssh-testkeys/files/testing_rsa?format=TEXT';
25+
const DEFAULT_PRIVATE_KEY_URL = 'https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/chromeos-base/chromeos-ssh-testkeys/files/testing_rsa?format=TEXT';
2626

2727
// The default path where the ChromeOS private key will be read/stored.
2828
const DEFAULT_PRIVATE_KEY_PATH =
@@ -64,6 +64,7 @@ async function fetchPrivateKey(flags, log) {
6464
// decode it for us.
6565
const privateKeyBase64 = await response.text();
6666
fs.writeFileSync(flags.privateKey, privateKeyBase64, 'base64');
67+
fs.chmodSync(flags.privateKey, 0o600);
6768
} else {
6869
log.error(`Private key not found at ${flags.privateKey} and ` +
6970
`fetching disabled. See --fetch-private-key and ` +
@@ -98,7 +99,7 @@ async function connectAndPrepDevice(flags, log) {
9899
host,
99100
port,
100101
username: flags.username,
101-
privateKey: flags.privateKey,
102+
privateKeyPath: flags.privateKey,
102103
});
103104

104105
log.debug(`Creating scripts folder ${DESTINATION_FOLDER}`);
@@ -109,7 +110,7 @@ async function connectAndPrepDevice(flags, log) {
109110
const transfers = [];
110111

111112
for (const scriptName of SCRIPTS) {
112-
const src = path.resolve(__dirname, scriptName);
113+
const src = path.resolve(__dirname, 'scripts', scriptName);
113114
const dest = `${DESTINATION_FOLDER}/${scriptName}`;
114115

115116
destinations.push(dest);
@@ -158,7 +159,9 @@ async function loadOnChromeOS(log, ssh, url, chromeArgs) {
158159
log.info(`Directing to ${url}`);
159160
// --kiosk is needed to avoid showing any existing tabs from a previous
160161
// session.
161-
launchCommand.push('--kiosk', url);
162+
launchCommand.push('--kiosk');
163+
// Recent ChromeOS versions must specify the kiosk-mode URL with --app=...
164+
launchCommand.push('--app=' + url);
162165
} else {
163166
log.info(`Opening previous session.`);
164167
}
@@ -200,8 +203,8 @@ async function executeRemoteCommand(log, ssh, argv) {
200203

201204
const output = await ssh.exec(executable, args, options);
202205

203-
// output.code == null occurs with success, not code == 0.
204-
if (output.code != null) {
206+
// output.code == 0 means success.
207+
if (output.code != 0) {
205208
log.error(`Remote command ${argv.join(' ')} ` +
206209
`failed with exit code ${output.code} ` +
207210
`and full output: ${output.stdout} ${output.stderr}`);
File renamed without changes.

0 commit comments

Comments
 (0)