From 0ee73f5164473e47960eb4571a0434a4694abc7c Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Tue, 28 May 2019 10:39:30 +0100 Subject: [PATCH] Don't require a login for commands operating on local devices Change-type: patch Closes: #1195 Signed-off-by: Cameron Diver --- doc/cli.markdown | 5 +++-- lib/actions/logs.ts | 6 ++++-- lib/actions/ssh.ts | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/cli.markdown b/doc/cli.markdown index 2254e86f..949476ce 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -1305,8 +1305,9 @@ id of the application to preload #### --commit, -c <hash> -the commit hash for a specific application release to preload, use "latest" to specify the latest release -(ignored if no appId is given) +The commit hash for a specific application release to preload, use "current" to specify the current +release (ignored if no appId is given). The current release is usually also the latest, but can be +manually pinned using https://github.com/balena-io-projects/staged-releases . #### --splash-image, -s <splashImage.png> diff --git a/lib/actions/logs.ts b/lib/actions/logs.ts index f553a189..28d21a3a 100644 --- a/lib/actions/logs.ts +++ b/lib/actions/logs.ts @@ -91,7 +91,6 @@ export const logs: CommandDefinition< 'Only show system logs. This can be used in combination with --service.', }, ], - permission: 'user', primary: true, async action(params, options, done) { normalizeUuidProp(params); @@ -101,7 +100,9 @@ export const logs: CommandDefinition< '../utils/device/logs' ); const { validateIPAddress } = await import('../utils/validation'); - const { exitWithExpectedError } = await import('../utils/patterns'); + const { exitIfNotLoggedIn, exitWithExpectedError } = await import( + '../utils/patterns' + ); const Logger = await import('../utils/logger'); const logger = new Logger(); @@ -153,6 +154,7 @@ export const logs: CommandDefinition< options.service, ); } else { + exitIfNotLoggedIn(); if (options.tail) { return balena.logs .subscribe(params.uuidOrDevice, { count: 100 }) diff --git a/lib/actions/ssh.ts b/lib/actions/ssh.ts index 709428cf..eb18a3c8 100644 --- a/lib/actions/ssh.ts +++ b/lib/actions/ssh.ts @@ -275,7 +275,6 @@ export const ssh: CommandDefinition< installed in your shell environment. For more information (including Windows support) please check: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md#additional-dependencies`, - permission: 'user', options: [ { signature: 'port', @@ -304,6 +303,7 @@ export const ssh: CommandDefinition< const hasbin = require('hasbin'); const { getSubShellCommand } = await import('../utils/helpers'); const { child_process } = await import('mz'); + const { exitIfNotLoggedIn } = await import('../utils/patterns'); const { exitWithExpectedError, selectFromList } = await import( '../utils/patterns' @@ -366,6 +366,7 @@ export const ssh: CommandDefinition< switch (paramChecks.target) { case SSHTarget.APPLICATION: + exitIfNotLoggedIn(); // Here what we want to do is fetch all device which // are part of this application, and online try { @@ -395,6 +396,7 @@ export const ssh: CommandDefinition< throw e; } case SSHTarget.DEVICE: + exitIfNotLoggedIn(); // We want to do two things here; firstly, check // that the device exists and is accessible, and // also convert a short uuid to a long one if