Skip to content

Commit

Permalink
--force-dangerous should be simply spelled --dangerous
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronis committed Sep 2, 2016
1 parent c1dd5a7 commit 9567c31
Show file tree
Hide file tree
Showing 40 changed files with 65 additions and 65 deletions.
12 changes: 6 additions & 6 deletions client/snap_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
)

type SnapOptions struct {
Channel string `json:"channel,omitempty"`
Revision string `json:"revision,omitempty"`
DevMode bool `json:"devmode,omitempty"`
JailMode bool `json:"jailmode,omitempty"`
ForceDangerous bool `json:"force-dangerous,omitempty"`
Channel string `json:"channel,omitempty"`
Revision string `json:"revision,omitempty"`
DevMode bool `json:"devmode,omitempty"`
JailMode bool `json:"jailmode,omitempty"`
Dangerous bool `json:"dangerous,omitempty"`
}

type actionData struct {
Expand Down Expand Up @@ -181,7 +181,7 @@ func sendSnapFile(snapPath string, snapFile *os.File, pw *io.PipeWriter, mw *mul
mw.WriteField("channel", action.Channel),
mw.WriteField("devmode", strconv.FormatBool(action.DevMode)),
mw.WriteField("jailmode", strconv.FormatBool(action.JailMode)),
mw.WriteField("force-dangerous", strconv.FormatBool(action.ForceDangerous)),
mw.WriteField("dangerous", strconv.FormatBool(action.Dangerous)),
}
for _, err := range errs {
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client/snap_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (cs *clientSuite) TestClientOpInstallPath(c *check.C) {

c.Assert(string(body), check.Matches, "(?s).*\r\nsnap-data\r\n.*")
c.Assert(string(body), check.Matches, "(?s).*Content-Disposition: form-data; name=\"action\"\r\n\r\ninstall\r\n.*")
c.Assert(string(body), check.Matches, "(?s).*Content-Disposition: form-data; name=\"force-dangerous\"\r\n\r\nfalse\r\n.*")
c.Assert(string(body), check.Matches, "(?s).*Content-Disposition: form-data; name=\"dangerous\"\r\n\r\nfalse\r\n.*")

c.Check(cs.req.Method, check.Equals, "POST")
c.Check(cs.req.URL.Path, check.Equals, fmt.Sprintf("/v2/snaps"))
Expand Down
4 changes: 2 additions & 2 deletions cmd/snap/cmd_snap_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ type cmdInstall struct {
modeMixin
Revision string `long:"revision" description:"Install the given revision of a snap, to which you must have developer access"`

ForceDangerous bool `long:"force-dangerous" description:"Install the given snap file even if there are no pre-acknowledged signatures for it, meaning it was not verified and could be dangerous"`
Dangerous bool `long:"dangerous" description:"Install the given snap file even if there are no pre-acknowledged signatures for it, meaning it was not verified and could be dangerous (--devmode implies this)"`

Positional struct {
Snap string `positional-arg-name:"<snap>"`
Expand All @@ -294,7 +294,7 @@ func (x *cmdInstall) Execute([]string) error {

cli := Client()
name := x.Positional.Snap
opts := &client.SnapOptions{Channel: x.Channel, DevMode: x.DevMode, JailMode: x.JailMode, Revision: x.Revision, ForceDangerous: x.ForceDangerous}
opts := &client.SnapOptions{Channel: x.Channel, DevMode: x.DevMode, JailMode: x.JailMode, Revision: x.Revision, Dangerous: x.Dangerous}
if strings.Contains(name, "/") || strings.HasSuffix(name, ".snap") || strings.Contains(name, ".snap.") {
installFromFile = true
changeID, err = cli.InstallPath(name, opts)
Expand Down
6 changes: 3 additions & 3 deletions cmd/snap/cmd_snap_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ func (s *SnapOpSuite) TestInstallPathDevMode(c *check.C) {
c.Check(s.srv.n, check.Equals, s.srv.total)
}

func (s *SnapOpSuite) TestInstallPathForceDangerous(c *check.C) {
func (s *SnapOpSuite) TestInstallPathDangerous(c *check.C) {
s.srv.checker = func(r *http.Request) {
c.Check(r.URL.Path, check.Equals, "/v2/snaps")
postData, err := ioutil.ReadAll(r.Body)
c.Assert(err, check.IsNil)
c.Assert(string(postData), check.Matches, "(?s).*\r\nsnap-data\r\n.*")
c.Assert(string(postData), check.Matches, "(?s).*Content-Disposition: form-data; name=\"action\"\r\n\r\ninstall\r\n.*")
c.Assert(string(postData), check.Matches, "(?s).*Content-Disposition: form-data; name=\"force-dangerous\"\r\n\r\ntrue\r\n.*")
c.Assert(string(postData), check.Matches, "(?s).*Content-Disposition: form-data; name=\"dangerous\"\r\n\r\ntrue\r\n.*")
}

snapBody := []byte("snap-data")
Expand All @@ -273,7 +273,7 @@ func (s *SnapOpSuite) TestInstallPathForceDangerous(c *check.C) {
err := ioutil.WriteFile(snapPath, snapBody, 0644)
c.Assert(err, check.IsNil)

rest, err := snap.Parser().ParseArgs([]string{"install", "--force-dangerous", snapPath})
rest, err := snap.Parser().ParseArgs([]string{"install", "--dangerous", snapPath})
c.Assert(err, check.IsNil)
c.Assert(rest, check.DeepEquals, []string{})
c.Check(s.Stdout(), check.Matches, `(?sm).*foo 1.0 from 'bar' installed`)
Expand Down
4 changes: 2 additions & 2 deletions daemon/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ func postSnaps(c *Command, r *http.Request, user *auth.UserState) Response {
if err != nil {
return BadRequest(err.Error())
}
dangerousOK := isTrue(form, "force-dangerous")
dangerousOK := isTrue(form, "dangerous")

if len(form.Value["action"]) > 0 && form.Value["action"][0] == "try" {
if len(form.Value["snap-path"]) == 0 {
Expand Down Expand Up @@ -1107,7 +1107,7 @@ out:
snapName = si.RealName
sideInfo = si
} else {
// potentially dangerous but force-dangerous was provided
// potentially dangerous but dangerous param was set
info, err := unsafeReadSnapInfo(tempPath)
if err != nil {
return InternalError("cannot read snap file: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions daemon/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ var sideLoadBodyWithoutDevMode = "" +
"\r\n" +
"xyzzy\r\n" +
"----hello--\r\n" +
"Content-Disposition: form-data; name=\"force-dangerous\"\r\n" +
"Content-Disposition: form-data; name=\"dangerous\"\r\n" +
"\r\n" +
"true\r\n" +
"----hello--\r\n" +
Expand Down Expand Up @@ -1364,7 +1364,7 @@ func (s *apiSuite) TestSideloadSnapDevMode(c *check.C) {
"\r\n" +
"true\r\n" +
"----hello--\r\n" +
"Content-Disposition: form-data; name=\"force-dangerous\"\r\n" +
"Content-Disposition: form-data; name=\"dangerous\"\r\n" +
"\r\n" +
"true\r\n" +
"----hello--\r\n"
Expand All @@ -1387,7 +1387,7 @@ func (s *apiSuite) TestSideloadSnapJailMode(c *check.C) {
"\r\n" +
"true\r\n" +
"----hello--\r\n" +
"Content-Disposition: form-data; name=\"force-dangerous\"\r\n" +
"Content-Disposition: form-data; name=\"dangerous\"\r\n" +
"\r\n" +
"true\r\n" +
"----hello--\r\n"
Expand All @@ -1412,7 +1412,7 @@ func (s *apiSuite) TestSideloadSnapJailModeAndDevmode(c *check.C) {
"\r\n" +
"true\r\n" +
"----hello--\r\n" +
"Content-Disposition: form-data; name=\"force-dangerous\"\r\n" +
"Content-Disposition: form-data; name=\"dangerous\"\r\n" +
"\r\n" +
"true\r\n" +
"----hello--\r\n"
Expand Down
2 changes: 1 addition & 1 deletion overlord/snapstate/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (b Backend) CurrentInfo(*snap.Info) {}

// OpenSnapFile opens a snap blob returning both a snap.Info completed
// with sideInfo (if not nil) and a corresponding snap.Container.
// Assumes the file was verified beforehand or the user asked for --force-dangerous.
// Assumes the file was verified beforehand or the user asked for --dangerous.
func OpenSnapFile(snapPath string, sideInfo *snap.SideInfo) (*snap.Info, snap.Container, error) {
snapf, err := snap.Open(snapPath)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion overlord/snapstate/backend/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

// SetupSnap does prepare and mount the snap for further processing.
func (b Backend) SetupSnap(snapFilePath string, sideInfo *snap.SideInfo, meter progress.Meter) error {
// This assumes that the snap was already verified or --force-dangerous was used.
// This assumes that the snap was already verified or --dangerous was used.

s, snapf, err := OpenSnapFile(snapFilePath, sideInfo)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion overlord/snapstate/check_snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var openSnapFile = backend.OpenSnapFile

// checkSnap ensures that the snap can be installed.
func checkSnap(st *state.State, snapFilePath string, curInfo *snap.Info, flags Flags) error {
// This assumes that the snap was already verified or --force-dangerous was used.
// This assumes that the snap was already verified or --dangerous was used.

s, _, err := openSnapFile(snapFilePath, nil)
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions tests/main/install-sideload/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ execute: |
echo "Sideloaded snap shows status"
expected="(?s)basic 1.0 installed\n\
.*"
snap install --force-dangerous ./basic_1.0_all.snap | grep -Pzq "$expected"
snap install --dangerous ./basic_1.0_all.snap | grep -Pzq "$expected"
echo "Sideloaded snap executes commands"
snap install --force-dangerous ./test-snapd-tools_1.0_all.snap
snap install --dangerous ./test-snapd-tools_1.0_all.snap
test-snapd-tools.success
[ "$(test-snapd-tools.echo Hello World)" = "Hello World" ]
echo "Sideload desktop snap"
snap install --force-dangerous ./basic-desktop_1.0_all.snap
snap install --dangerous ./basic-desktop_1.0_all.snap
expected="\[Desktop Entry\]\n\
Name=Echo\n\
Comment=It echos stuff\n\
Expand All @@ -33,26 +33,26 @@ execute: |
echo "Sideload devmode snap fails without flags"
expected="requires devmode or confinement override"
( snap install --force-dangerous ./basic-devmode_1.0_all.snap 2>&1 || true ) | grep -Pzq "$expected"
( snap install --dangerous ./basic-devmode_1.0_all.snap 2>&1 || true ) | grep -Pzq "$expected"
echo "Sideload devmode snap succeeds with --devmode"
expected="basic-devmode 1.0 installed"
snap install --force-dangerous --devmode ./basic-devmode_1.0_all.snap | grep -Pq "$expected"
snap install --dangerous --devmode ./basic-devmode_1.0_all.snap | grep -Pq "$expected"
expected="^basic-devmode +.* +devmode"
snap list | grep -Pq "$expected"
echo "Sideload devmode snap succeeds with --jailmode"
expected="basic-devmode 1.0 installed"
snap install --force-dangerous --jailmode ./basic-devmode_1.0_all.snap | grep -Pq "$expected"
snap install --dangerous --jailmode ./basic-devmode_1.0_all.snap | grep -Pq "$expected"
expected="^basic-devmode +.* +jailmode"
snap list | grep -Pq "$expected"
echo "Sideload devmode snap fails with both --devmode and --jailmode"
expected="cannot use devmode and jailmode flags together"
( snap install --force-dangerous --devmode --jailmode ./basic-devmode_1.0_all.snap 2>&1 || true ) | grep -Pzq "$expected"
( snap install --dangerous --devmode --jailmode ./basic-devmode_1.0_all.snap 2>&1 || true ) | grep -Pzq "$expected"
echo "Sideload a second time succeeds"
snap install --force-dangerous ./test-snapd-tools_1.0_all.snap
snap install --dangerous ./test-snapd-tools_1.0_all.snap
test-snapd-tools.success
# TODO: check we copy the data directory over
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-cli/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ environment:
prepare: |
echo "Given a snap with the $PLUG plug is installed"
snapbuild $TESTSLIB/snaps/$SNAP_NAME .
snap install --force-dangerous $SNAP_FILE
snap install --dangerous $SNAP_FILE
restore: |
rm -f $SNAP_FILE
Expand Down
4 changes: 2 additions & 2 deletions tests/main/interfaces-content/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ details: |
prepare: |
echo "Given a snap declaring a content sharing slot is installed"
snapbuild $TESTSLIB/snaps/content-slot .
snap install --force-dangerous ./content-slot_1.0_all.snap
snap install --dangerous ./content-slot_1.0_all.snap
echo "And a snap declaring a content sharing plug is installed"
snapbuild $TESTSLIB/snaps/content-plug .
snap install --force-dangerous ./content-plug_1.0_all.snap
snap install --dangerous ./content-plug_1.0_all.snap
execute: |
CONNECTED_PATTERN="content-slot:shared-content-slot +content-plug:shared-content-plug"
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-hardware-observe/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ summary: |
prepare: |
echo "Given a snap declaring a plug on the hardware-observe interface is installed"
snapbuild $TESTSLIB/snaps/hardware-observe-consumer .
snap install --force-dangerous hardware-observe-consumer_1.0_all.snap
snap install --dangerous hardware-observe-consumer_1.0_all.snap
restore: |
rm -f hardware-observe-consumer_1.0_all.snap hw.error
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-home/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ environment:
prepare: |
echo "Given a snap declaring the home plug is installed"
snapbuild $TESTSLIB/snaps/home-consumer .
snap install --force-dangerous $SNAP_FILE
snap install --dangerous $SNAP_FILE
echo "And there is a readable file in HOME"
echo ok > "$READABLE_FILE"
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-locale-control/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ summary: |
prepare: |
echo "Given a snap declaring a plug on the locale-control interface is installed"
snapbuild $TESTSLIB/snaps/locale-control-consumer .
snap install --force-dangerous locale-control-consumer_1.0_all.snap
snap install --dangerous locale-control-consumer_1.0_all.snap
cp /etc/default/locale locale.back
restore: |
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-log-observe/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ environment:
prepare: |
echo "Given a snap declaring the $PLUG plug is installed"
snapbuild $TESTSLIB/snaps/$SNAP_NAME .
snap install --force-dangerous $SNAP_FILE
snap install --dangerous $SNAP_FILE
restore: |
rm -f $SNAP_FILE
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-mount-observe/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ details: |
prepare: |
echo "Given a snap declaring a plug on the mount-observe interface is installed"
snapbuild $TESTSLIB/snaps/mount-observe-consumer .
snap install --force-dangerous mount-observe-consumer_1.0_all.snap
snap install --dangerous mount-observe-consumer_1.0_all.snap
restore: |
rm -f mount-observe-consumer_1.0_all.snap
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-network-bind/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ environment:
prepare: |
echo "Given a snap declaring the network-bind plug is installed"
snapbuild $TESTSLIB/snaps/$SNAP_NAME .
snap install --force-dangerous $SNAP_FILE
snap install --dangerous $SNAP_FILE
echo "Given the snap's service is listening"
while ! netstat -lnt | grep -Pq "tcp.*?:$PORT +.*?LISTEN\n*"; do sleep 0.5; done
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-network-control/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ environment:
prepare: |
echo "Given a snap declaring a plug on the network-control interface is installed"
snapbuild $TESTSLIB/snaps/network-control-consumer .
snap install --force-dangerous network-control-consumer_1.0_all.snap
snap install --dangerous network-control-consumer_1.0_all.snap
echo "And a network service is up"
printf "#!/bin/sh -e\nwhile true; do echo \"HTTP/1.1 200 OK\n\nok\n\" | nc -l -p $PORT -q 1; done" > $SERVICE_FILE
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-network-observe/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ environment:
prepare: |
echo "Given a snap declaring a plug on the network-observe interface is installed"
snapbuild $TESTSLIB/snaps/network-observe-consumer .
snap install --force-dangerous network-observe-consumer_1.0_all.snap
snap install --dangerous network-observe-consumer_1.0_all.snap
echo "And a network service is up"
printf "#!/bin/sh -e\nwhile true; do echo \"HTTP/1.1 200 OK\n\nok\n\" | nc -l -p $PORT -q 1; done" > $SERVICE_FILE
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-network/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ environment:
prepare: |
echo "Given a snap declaring the network plug is installed"
snapbuild $TESTSLIB/snaps/$SNAP_NAME .
snap install --force-dangerous $SNAP_FILE
snap install --dangerous $SNAP_FILE
echo "And a service is listening"
printf "#!/bin/sh -e\nwhile true; do echo \"HTTP/1.1 200 OK\n\nok\n\" | nc -l -p $PORT -q 1; done" > $SERVICE_FILE
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-process-control/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ summary: |
prepare: |
echo "Given a snap declaring a plug on the process-control interface is installed"
snapbuild $TESTSLIB/snaps/process-control-consumer .
snap install --force-dangerous process-control-consumer_1.0_all.snap
snap install --dangerous process-control-consumer_1.0_all.snap
restore: |
rm -f process-control-consumer_1.0_all.snap process-kill.error process-nice.error
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-snapd-control/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ details: |
prepare: |
echo "Given a snap declaring a plug on the snapd-control interface is installed"
snapbuild $TESTSLIB/snaps/snapd-control-consumer .
snap install --force-dangerous snapd-control-consumer_1.0_all.snap
snap install --dangerous snapd-control-consumer_1.0_all.snap
restore: |
rm -f snapd-control-consumer_1.0_all.snap snapd.error
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-system-observe/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ details: |
prepare: |
echo "Given a snap declaring a plug on the system-observe interface is installed"
snapbuild $TESTSLIB/snaps/system-observe-consumer .
snap install --force-dangerous system-observe-consumer_1.0_all.snap
snap install --dangerous system-observe-consumer_1.0_all.snap
restore: |
rm -f system-observe-consumer_1.0_all.snap
Expand Down
2 changes: 1 addition & 1 deletion tests/main/interfaces-udev/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ details: |
prepare: |
echo "Given a snap declaring a slot with associated udev rules is installed"
snapbuild $TESTSLIB/snaps/modem-manager-consumer .
snap install --force-dangerous modem-manager-consumer_1.0_all.snap
snap install --dangerous modem-manager-consumer_1.0_all.snap
restore: |
rm -f modem-manager-consumer_1.0_all.snap
Expand Down
2 changes: 1 addition & 1 deletion tests/main/op-remove-retry/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ execute: |
echo "Given a snap is installed"
snapbuild $TESTSLIB/snaps/test-snapd-tools .
snap install --force-dangerous test-snapd-tools_1.0_all.snap
snap install --dangerous test-snapd-tools_1.0_all.snap
echo "And its mount point is kept busy"
systemd-run --unit unmount-blocker $(which test-snapd-tools.block)
Expand Down
4 changes: 2 additions & 2 deletions tests/main/op-remove/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ execute: |
echo "Given two revisions of a snap have been installed"
snapbuild $TESTSLIB/snaps/basic .
snap install --force-dangerous basic_1.0_all.snap
snap install --force-dangerous basic_1.0_all.snap
snap install --dangerous basic_1.0_all.snap
snap install --dangerous basic_1.0_all.snap
echo "Then the two revisions are available on disk"
[ $(snap_revisions basic) = "2" ]
Expand Down
4 changes: 2 additions & 2 deletions tests/main/revert-sideload/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ restore: |
execute: |
echo Installing sideloaded snap
snap install --force-dangerous ./basic_1.0_all.snap
snap install --dangerous ./basic_1.0_all.snap
snap list | grep -Pzq "x1"
echo Installing new version of sideloaded snap
snap install --force-dangerous ./basic_1.0_all.snap
snap install --dangerous ./basic_1.0_all.snap
snap list | grep -Pzq "x2"
echo Reverting to the previous version
Expand Down
2 changes: 1 addition & 1 deletion tests/main/security-apparmor/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ summary: Check basic apparmor confinement rules.
prepare: |
echo "Given a basic snap is installed"
snapbuild $TESTSLIB/snaps/test-snapd-tools .
snap install --force-dangerous test-snapd-tools_1.0_all.snap
snap install --dangerous test-snapd-tools_1.0_all.snap
restore: |
rm -f test-snapd-tools_1.0_all.snap
Expand Down
Loading

0 comments on commit 9567c31

Please sign in to comment.