Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -13,7 +13,7 @@ import ( |
| 13 | 13 |
"github.com/docker/docker/api/client" |
| 14 | 14 |
"github.com/docker/docker/dockerversion" |
| 15 | 15 |
flag "github.com/docker/docker/pkg/mflag" |
| 16 |
- "github.com/docker/docker/reexec" |
|
| 16 |
+ "github.com/docker/docker/pkg/reexec" |
|
| 17 | 17 |
"github.com/docker/docker/utils" |
| 18 | 18 |
) |
| 19 | 19 |
|
| ... | ... |
@@ -22,7 +22,7 @@ import ( |
| 22 | 22 |
"github.com/docker/docker/image" |
| 23 | 23 |
"github.com/docker/docker/nat" |
| 24 | 24 |
"github.com/docker/docker/pkg/ioutils" |
| 25 |
- "github.com/docker/docker/reexec" |
|
| 25 |
+ "github.com/docker/docker/pkg/reexec" |
|
| 26 | 26 |
"github.com/docker/docker/runconfig" |
| 27 | 27 |
"github.com/docker/docker/utils" |
| 28 | 28 |
) |
| 0 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,5 @@ |
| 0 |
+## reexec |
|
| 1 |
+ |
|
| 2 |
+The `reexec` package facilitates the busybox style reexec of the docker binary that we require because |
|
| 3 |
+of the forking limitations of using Go. Handlers can be registered with a name and the argv 0 of |
|
| 4 |
+the exec of the binary will be used to find and execute custom init paths. |
| 0 | 5 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,45 @@ |
| 0 |
+package reexec |
|
| 1 |
+ |
|
| 2 |
+import ( |
|
| 3 |
+ "fmt" |
|
| 4 |
+ "os" |
|
| 5 |
+ "os/exec" |
|
| 6 |
+ "path/filepath" |
|
| 7 |
+) |
|
| 8 |
+ |
|
| 9 |
+var registeredInitializers = make(map[string]func()) |
|
| 10 |
+ |
|
| 11 |
+// Register adds an initialization func under the specified name |
|
| 12 |
+func Register(name string, initializer func()) {
|
|
| 13 |
+ if _, exists := registeredInitializers[name]; exists {
|
|
| 14 |
+ panic(fmt.Sprintf("reexec func already registred under name %q", name))
|
|
| 15 |
+ } |
|
| 16 |
+ |
|
| 17 |
+ registeredInitializers[name] = initializer |
|
| 18 |
+} |
|
| 19 |
+ |
|
| 20 |
+// Init is called as the first part of the exec process and returns true if an |
|
| 21 |
+// initialization function was called. |
|
| 22 |
+func Init() bool {
|
|
| 23 |
+ initializer, exists := registeredInitializers[os.Args[0]] |
|
| 24 |
+ if exists {
|
|
| 25 |
+ initializer() |
|
| 26 |
+ |
|
| 27 |
+ return true |
|
| 28 |
+ } |
|
| 29 |
+ |
|
| 30 |
+ return false |
|
| 31 |
+} |
|
| 32 |
+ |
|
| 33 |
+// Self returns the path to the current processes binary |
|
| 34 |
+func Self() string {
|
|
| 35 |
+ name := os.Args[0] |
|
| 36 |
+ |
|
| 37 |
+ if filepath.Base(name) == name {
|
|
| 38 |
+ if lp, err := exec.LookPath(name); err == nil {
|
|
| 39 |
+ name = lp |
|
| 40 |
+ } |
|
| 41 |
+ } |
|
| 42 |
+ |
|
| 43 |
+ return name |
|
| 44 |
+} |
| 0 | 45 |
deleted file mode 100644 |
| ... | ... |
@@ -1,5 +0,0 @@ |
| 1 |
-## reexec |
|
| 2 |
- |
|
| 3 |
-The `reexec` package facilitates the busybox style reexec of the docker binary that we require because |
|
| 4 |
-of the forking limitations of using Go. Handlers can be registered with a name and the argv 0 of |
|
| 5 |
-the exec of the binary will be used to find and execute custom init paths. |
| 6 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,45 +0,0 @@ |
| 1 |
-package reexec |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "fmt" |
|
| 5 |
- "os" |
|
| 6 |
- "os/exec" |
|
| 7 |
- "path/filepath" |
|
| 8 |
-) |
|
| 9 |
- |
|
| 10 |
-var registeredInitializers = make(map[string]func()) |
|
| 11 |
- |
|
| 12 |
-// Register adds an initialization func under the specified name |
|
| 13 |
-func Register(name string, initializer func()) {
|
|
| 14 |
- if _, exists := registeredInitializers[name]; exists {
|
|
| 15 |
- panic(fmt.Sprintf("reexec func already registred under name %q", name))
|
|
| 16 |
- } |
|
| 17 |
- |
|
| 18 |
- registeredInitializers[name] = initializer |
|
| 19 |
-} |
|
| 20 |
- |
|
| 21 |
-// Init is called as the first part of the exec process and returns true if an |
|
| 22 |
-// initialization function was called. |
|
| 23 |
-func Init() bool {
|
|
| 24 |
- initializer, exists := registeredInitializers[os.Args[0]] |
|
| 25 |
- if exists {
|
|
| 26 |
- initializer() |
|
| 27 |
- |
|
| 28 |
- return true |
|
| 29 |
- } |
|
| 30 |
- |
|
| 31 |
- return false |
|
| 32 |
-} |
|
| 33 |
- |
|
| 34 |
-// Self returns the path to the current processes binary |
|
| 35 |
-func Self() string {
|
|
| 36 |
- name := os.Args[0] |
|
| 37 |
- |
|
| 38 |
- if filepath.Base(name) == name {
|
|
| 39 |
- if lp, err := exec.LookPath(name); err == nil {
|
|
| 40 |
- name = lp |
|
| 41 |
- } |
|
| 42 |
- } |
|
| 43 |
- |
|
| 44 |
- return name |
|
| 45 |
-} |