allow propagating custom exec-root (e.g. "/run/docker") to libnetwork-setkey#2248
allow propagating custom exec-root (e.g. "/run/docker") to libnetwork-setkey#2248ctelfer merged 1 commit intomoby:masterfrom
Conversation
|
@fcrisciani @ctelfer PTAL? |
| "io/ioutil" | ||
| "net" | ||
| "os" | ||
| "path/filepath" |
There was a problem hiding this comment.
Can you run goimport ? that will keep import lines in alphabetical order.
There was a problem hiding this comment.
Isnt this already alphabetical?
There was a problem hiding this comment.
Agree.. it's fine. goimports wouldn't group it differently and alphabetizes based on the whole string, not just the last part of the path.
There was a problem hiding this comment.
got carried away with last name filepath :)
ctelfer
left a comment
There was a problem hiding this comment.
Sorry for the delay. Actually looked at it last week, but wanted to give it a second look.
Overall: LGTM
I have some style suggestions (see comments) that could tighten it up a bit. But I'm not stuck on them. @fcrisciani is unavailable for a few weeks. Maybe @abhi or @mavenugo could give a look? I'd like to hear if they are good with the way that the execRoot is getting propagated. Again, I'm ok with it, but someone with more history may know something I'm not considering.
sandbox_externalkey_unix.go
Outdated
| execRoot = v | ||
| } | ||
| udsBase := filepath.Join(execRoot, "libnetwork") | ||
| c, err := net.Dial("unix", filepath.Join(udsBase, controllerID+".sock")) |
There was a problem hiding this comment.
maybe skip udsBase entirely and just do:
uds := filepath.Join(execRoot, "libnetwork", controllerID+".sock")
c, err := net.Dial("unix", uds)
?
I guess if we want to be even cleaner we could do it as:
const execSubdir = "libnetwork"
above and then
uds := filepath.Join(execRoot, execSubdir, controllerID+".sock")
c, err := net.Dial("unix", uds)
| } | ||
| uds := udsBase + c.id + ".sock" | ||
| uds := filepath.Join(udsBase, c.id+".sock") | ||
| l, err := net.Listen("unix", uds) |
There was a problem hiding this comment.
Similar: maybe just
uds := filepath.Join(execRoot, execSubdir, c.id+".sock")
?
There was a problem hiding this comment.
MkdirAll(udsBase) is needed
d8c55c0 to
9ac90d5
Compare
sandbox_externalkey_unix.go
Outdated
|
|
||
| c, err := net.Dial("unix", udsBase+controllerID+".sock") | ||
| execRoot := "/run/docker" | ||
| if v := os.Getenv("_LIBNETWORK_EXEC_ROOT"); v != "" { |
There was a problem hiding this comment.
On second thought, maybe the underscore prefix is not needed?
There was a problem hiding this comment.
the original intention was to make sure this variable should not be set by human users
There was a problem hiding this comment.
Agree that the '_' is not necessary. Doubt people will accidentally prefix an environment variable with LIBNETWORK_.
There was a problem hiding this comment.
removed the underscore prefix
9ac90d5 to
e42a8d9
Compare
|
@fcrisciani will be back next week. Would still like someone w/ more history in how Moby things are done to comment re: using the env variables to pass this info. So, this is for "rootless" containers right? (which I'm pretty excited to see happen) If the environment variable is always set by moby, (as your proposed moby patch would indicate), then if someone set it to try to hijack the path, the injected path would always get clobbered. So, should be safe. Hrm.... Would it be better or cleaner, perhaps, to pass the root directory as an optional 3rd parameter (4th in argument list) to "libnetwork-setkey" / |
|
Realized we definitely don't want a mandatory extra argument because that would break libnetwork integration w/ moby until moby accepted the moby change. Optional would still work, though. Passing via env does avoid changing the _windows.go code. (not that the change would be big... just another parameter to ignore) @abhi WDYT? |
Yes, but should be useful for "rootful"
Is there any attack flow? |
|
My apologies for not being clear. I was saying that I don't think there is an attack path. Once moby is upgraded there is no attack flow for certain. Your proposed moby patch always sets (overrides) the environment variable so there's no way for some pre-set value of the environment variable to redirect it. It just now occurred to me that there could be an attack flow if we merged the libnetwork change, and then vendored libnetwork into moby (say, because we want some other libnetwork feature/fix) before moby accepted the update to set This is probably not a real issue because injecting arbitrary environment variables into the |
Is |
|
That I couldn't say without looking. But what I was thinking was that when moby goes and |
sandbox_externalkey_unix.go
Outdated
| Key: key} | ||
|
|
||
| c, err := net.Dial("unix", udsBase+controllerID+".sock") | ||
| execRoot := "/run/docker" |
There was a problem hiding this comment.
can we make it as defultExecRoot constant variable instead of using like this ?
sandbox_externalkey_unix.go
Outdated
| } | ||
|
|
||
| func (c *controller) startExternalKeyListener() error { | ||
| execRoot := "/run/docker" |
There was a problem hiding this comment.
same as above comment. we can use constant
|
LGTM. Pls see if you can address one review comment that I have added. |
|
done |
e42a8d9 to
75565f3
Compare
|
Thanks. LGTM |
|
@ctelfer LGTY? ^^ |
|
Alright. Sorry this has taken so long. Have had trouble finding others w/ history on the integration side of this. Discussed this w/ @thaJeztah w.r.t. the moby integration and he said he definitely preferred not to pass that info around in an environment variable. So could we please consider passing that path as an argument instead? I can think of two ways this could work:
Anyway, sorry to stretch this out. What seems best from your standpoint, given that passing by environment would be frowned upon? Maybe you have alternative approaches? Thanks! |
75565f3 to
3c86b73
Compare
|
Added |
…-setkey
The docker daemon needs to be modified as follows:
diff --git a/daemon/oci_linux.go b/daemon/oci_linux.go
index 00ace320df..ea7daa72df 100644
--- a/daemon/oci_linux.go
+++ b/daemon/oci_linux.go
@@ -809,7 +809,7 @@ func (daemon *Daemon) createSpec(c *container.Container) (retSpec *specs.Spec, e
s.Hooks = &specs.Hooks{
Prestart: []specs.Hook{{
Path: target,
- Args: []string{"libnetwork-setkey", c.ID, daemon.netController.ID()},
+ Args: []string{"libnetwork-setkey", c.ID, daemon.netController.ID(), "-exec-root="+daemon.configStore.GetExecRoot()},
}},
}
}
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
3c86b73 to
03bbfad
Compare
|
Thanks @AkihiroSuda . LGTM |
|
Thanks again for your patience @AkihiroSuda ! Am looking forward to seeing this go into moby! |
|
Thanks! |
|
thanks, opened moby/moby#37850 |
part of moby/moby#37375 (in rootless mode, exec-root should be like
/run/user/4242/dockerrather than/run/docker)The docker daemon needs to be modified as follows:
Signed-off-by: Akihiro Suda suda.akihiro@lab.ntt.co.jp