New issue
Advanced search Search tips

Issue 818869 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Feature



Sign in to add a comment

vsh: improve command parsing logic

Project Member Reported by vapier@chromium.org, Mar 5 2018

Issue description

vsh treats --command="..." as a shell string.  that's fine for a rough/first pass.  we should improve it so we can pass argv through sanely.

proposed change to the vsh UI to make it behave like `sudo`:
  vsh [options] [-- [ENV=VAR] [args]]

that means by default, the args are turned directly into an argv and exec-ed.  there is no shell indirection.  this allows us to very cleanly and precisely run commands with random args inside of the container.

sudo detects all args as env vars if it has an = in it and does no other validation.  that means you could pass in "invalid" values like:
  sudo 'X_@!()=foo' env | grep ^X_
  X_@!()=foo
but it would mean you couldn't run a program directly which has an "=" in it ...

i'd be fine if we wanted to restrict this at first to only allowing POSIX defined env vars:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
Environment variable names used by the utilities in the Shell and Utilities volume of POSIX.1-2008 consist solely of uppercase letters, digits, and the <underscore> ( '_' ) from the characters defined in Portable Character Set and do not begin with a digit.

overall, this means changing the vsh argv parsing slightly, but it would also mean changing the vsh.proto file to pass down any array of strings for the command instead of a plain string.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Mar 9 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform2/+/78d5a4618be9d3ac6bb5284220adbec58a5e1986

commit 78d5a4618be9d3ac6bb5284220adbec58a5e1986
Author: Stephen Barber <smbarber@chromium.org>
Date: Fri Mar 09 05:59:41 2018

vm_tools: vsh: exec target programs directly

BUG= chromium:818869 
TEST=vsh --cid=3 -- LXD_DIR=/mnt/stateful/lxd LXD_CONF=/mnt/stateful/lxd_conf lxc list

Change-Id: I1ff4319cd514b1ffb5319e2f1a8bac8b0f5af8a7
Reviewed-on: https://chromium-review.googlesource.com/954282
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>

[modify] https://crrev.com/78d5a4618be9d3ac6bb5284220adbec58a5e1986/vm_tools/vsh/vsh.cc
[modify] https://crrev.com/78d5a4618be9d3ac6bb5284220adbec58a5e1986/vm_tools/proto/vsh.proto
[modify] https://crrev.com/78d5a4618be9d3ac6bb5284220adbec58a5e1986/vm_tools/vsh/vshd.cc

Owner: smbar...@chromium.org
Status: Fixed (was: Available)

Sign in to add a comment