Merge lp:~chipaca/snappy/exec-self into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by John Lenton
Status: Rejected
Rejected by: Sergio Schvezov
Proposed branch: lp:~chipaca/snappy/exec-self
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~chipaca/snappy/click-manifest-full-name
Diff against target: 73 lines (+1/-44)
2 files modified
snappy/click.go (+1/-28)
snappy/click_test.go (+0/-16)
To merge this branch: bzr merge lp:~chipaca/snappy/exec-self
Reviewer Review Type Date Requested Status
Sergio Schvezov Disapprove
Review via email: mp+256564@code.launchpad.net

Commit message

Exec self instead of looking for 'snappy' in the path when unpacking via drop privs.

To post a comment you must log in.
lp:~chipaca/snappy/exec-self updated
381. By John Lenton

spurious println

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

This breaks u-d-f or webdm

review: Disapprove

Unmerged revisions

381. By John Lenton

spurious println

380. By John Lenton

exec self for unpack helper

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy/click.go'
2--- snappy/click.go 2015-04-16 19:59:43 +0000
3+++ snappy/click.go 2015-04-16 19:59:43 +0000
4@@ -630,21 +630,6 @@
5 return nil
6 }
7
8-// takes a name and PATH (colon separated) and returns the full qualified path
9-func findBinaryInPath(name, path string) string {
10- for _, entry := range strings.Split(path, ":") {
11- fname := filepath.Join(entry, name)
12- if st, err := os.Stat(fname); err == nil {
13- // check for any x bit
14- if st.Mode()&0111 != 0 {
15- return fname
16- }
17- }
18- }
19-
20- return ""
21-}
22-
23 // unpackWithDropPrivs is a helper that will unapck the ClickDeb content
24 // into the target dir and drop privs when doing this.
25 //
26@@ -656,19 +641,7 @@
27 return d.Unpack(instDir)
28 }
29
30- // find priv helper executable
31- privHelper := ""
32- for _, path := range []string{"PATH", "GOPATH"} {
33- privHelper = findBinaryInPath("snappy", os.Getenv(path))
34- if privHelper != "" {
35- break
36- }
37- }
38- if privHelper == "" {
39- return ErrUnpackHelperNotFound
40- }
41-
42- cmd := exec.Command(privHelper, "internal-unpack", d.Name(), instDir, globalRootDir)
43+ cmd := exec.Command(os.Args[0], "internal-unpack", d.Name(), instDir, globalRootDir)
44 cmd.Stdout = os.Stdout
45 cmd.Stderr = os.Stderr
46 if err := cmd.Run(); err != nil {
47
48=== modified file 'snappy/click_test.go'
49--- snappy/click_test.go 2015-04-16 19:59:43 +0000
50+++ snappy/click_test.go 2015-04-16 19:59:43 +0000
51@@ -739,22 +739,6 @@
52
53 }
54
55-func (s *SnapTestSuite) TestFindBinaryInPath(c *C) {
56- fakeBinDir := c.MkDir()
57- runMePath := filepath.Join(fakeBinDir, "runme")
58- err := ioutil.WriteFile(runMePath, []byte(""), 0755)
59- c.Assert(err, IsNil)
60-
61- p := filepath.Join(fakeBinDir, "not-executable")
62- err = ioutil.WriteFile(p, []byte(""), 0644)
63- c.Assert(err, IsNil)
64-
65- fakePATH := fmt.Sprintf("/some/dir:%s", fakeBinDir)
66- c.Assert(findBinaryInPath("runme", fakePATH), Equals, runMePath)
67- c.Assert(findBinaryInPath("no-such-binary-nowhere", fakePATH), Equals, "")
68- c.Assert(findBinaryInPath("not-executable", fakePATH), Equals, "")
69-}
70-
71 func (s *SnapTestSuite) TestLocalSnapInstallRunHooks(c *C) {
72 // we can not strip the global rootdir for the hook tests
73 stripGlobalRootDir = func(s string) string { return s }

Subscribers

People subscribed via source and target branches