12 years, 3 months ago
(2012-02-08 16:27:21 UTC)
#5
PTAL
https://codereview.appspot.com/5647047/diff/6001/charm/bundle.go
File charm/bundle.go (right):
https://codereview.appspot.com/5647047/diff/6001/charm/bundle.go#newcode201
charm/bundle.go:201: err = os.MkdirAll(path, mode & 0777)
On 2012/02/08 09:56:56, rog wrote:
> do we care about interaction with umask here?
No, not here. This is the bundle content. If we want to alter the mode, we
should do at packing time. I'm happy to be more specific for the moment.
> in general i'm not sure about the file modes here (what do "group" permissions
> mean when the group owner of the file isn't defined?) i'd be happy if we
> continued to use 0755, or we could just copy the user mode bits to other and
This would give owner permission for everybody. I don't think we want that.
> group: mode&7 | mode&7<<3 | mode&7<<6
This isn't doing what you say it is.
> i think the permissions in the zip file (execute bits aside) are much more
> likely to be a reflection of some dubious umask on the charm creator's side
than
> a deliberate decision.
Yeah, probably. I've changed the bundling side to use fixed permissions.
https://codereview.appspot.com/5647047/diff/6001/charm/bundle.go#newcode222
charm/bundle.go:222: if err != nil || strings.HasPrefix(reltarget, "..") {
On 2012/02/08 09:56:56, rog wrote:
> i'm not sure the logic of the previous three lines is correct.
>
> 1) you're doing the join even when the target is already absolute (i think you
> should check for target[0] == '/').
> 2) it allows absolute symlinks that happen to point into the charm directory.
> 3) it can disallow a symlink that points at a file name beginning with two
dots,
> which should be allowed.
(1) Good catch, thanks.
(2) Not really. It's broken due to 1.
(3) That was conscious, but was silly. Will fix.
https://codereview.appspot.com/5647047/diff/6001/charm/bundle.go#newcode225
charm/bundle.go:225: return os.Symlink(string(data), path)
On 2012/02/08 09:56:56, rog wrote:
> s/string(data)/target/
Will do.
https://codereview.appspot.com/5647047/diff/6001/charm/bundle.go#newcode228
charm/bundle.go:228: f, err := os.OpenFile(path,
os.O_CREATE|os.O_EXCL|os.O_WRONLY, mode & 0777)
On 2012/02/08 09:56:56, rog wrote:
> the same considerations about file mode apply here.
Ditto.
https://codereview.appspot.com/5647047/diff/6001/charm/bundle_test.go
File charm/bundle_test.go (right):
https://codereview.appspot.com/5647047/diff/6001/charm/bundle_test.go#newcode115
charm/bundle_test.go:115: err := os.Symlink("../../target",
filepath.Join(charmDir, "hooks", "badlink"))
On 2012/02/08 09:56:56, rog wrote:
> we should have a test with an absolute link.
Will do.
Issue 5647047: charm: fix symlink and file mode when bundling/expanding
Created 12 years, 3 months ago by niemeyer
Modified 6 months, 1 week ago
Reviewers: mp+91960_code.launchpad.net, kapil.foss, gustavo_niemeyer.net
Base URL:
Comments: 21