Browse Source

Merge pull request #11420 from estesp/reexec-path-fix

Fix relative path execution of docker daemon in reexec.Self()
Jessie Frazelle 10 năm trước cách đây
mục cha
commit
f41ba82eb9
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 7 1
      pkg/reexec/reexec.go

+ 7 - 1
pkg/reexec/reexec.go

@@ -35,8 +35,14 @@ func Self() string {
 	name := os.Args[0]
 	if filepath.Base(name) == name {
 		if lp, err := exec.LookPath(name); err == nil {
-			name = lp
+			return lp
 		}
 	}
+	// handle conversion of relative paths to absolute
+	if absName, err := filepath.Abs(name); err == nil {
+		return absName
+	}
+	// if we coudn't get absolute name, return original
+	// (NOTE: Go only errors on Abs() if os.Getwd fails)
 	return name
 }