Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
| ... | ... |
@@ -476,19 +476,17 @@ func (b *buildFile) CmdVolume(args string) error {
|
| 476 | 476 |
|
| 477 | 477 |
func (b *buildFile) checkPathForAddition(orig string) error {
|
| 478 | 478 |
origPath := path.Join(b.contextPath, orig) |
| 479 |
- if p, err := filepath.EvalSymlinks(origPath); err != nil {
|
|
| 479 |
+ origPath, err := filepath.EvalSymlinks(origPath) |
|
| 480 |
+ if err != nil {
|
|
| 480 | 481 |
if os.IsNotExist(err) {
|
| 481 | 482 |
return fmt.Errorf("%s: no such file or directory", orig)
|
| 482 | 483 |
} |
| 483 | 484 |
return err |
| 484 |
- } else {
|
|
| 485 |
- origPath = p |
|
| 486 | 485 |
} |
| 487 | 486 |
if !strings.HasPrefix(origPath, b.contextPath) {
|
| 488 | 487 |
return fmt.Errorf("Forbidden path outside the build context: %s (%s)", orig, origPath)
|
| 489 | 488 |
} |
| 490 |
- _, err := os.Stat(origPath) |
|
| 491 |
- if err != nil {
|
|
| 489 |
+ if _, err := os.Stat(origPath); err != nil {
|
|
| 492 | 490 |
if os.IsNotExist(err) {
|
| 493 | 491 |
return fmt.Errorf("%s: no such file or directory", orig)
|
| 494 | 492 |
} |
| ... | ... |
@@ -910,7 +910,8 @@ func (container *Container) initializeNetworking() error {
|
| 910 | 910 |
container.HostsPath = hostsPath |
| 911 | 911 |
|
| 912 | 912 |
return ioutil.WriteFile(container.HostsPath, content, 0644) |
| 913 |
- } else if container.hostConfig.NetworkMode.IsContainer() {
|
|
| 913 |
+ } |
|
| 914 |
+ if container.hostConfig.NetworkMode.IsContainer() {
|
|
| 914 | 915 |
// we need to get the hosts files from the container to join |
| 915 | 916 |
nc, err := container.getNetworkedContainer() |
| 916 | 917 |
if err != nil {
|
| ... | ... |
@@ -920,16 +921,16 @@ func (container *Container) initializeNetworking() error {
|
| 920 | 920 |
container.ResolvConfPath = nc.ResolvConfPath |
| 921 | 921 |
container.Config.Hostname = nc.Config.Hostname |
| 922 | 922 |
container.Config.Domainname = nc.Config.Domainname |
| 923 |
- } else if container.daemon.config.DisableNetwork {
|
|
| 923 |
+ return nil |
|
| 924 |
+ } |
|
| 925 |
+ if container.daemon.config.DisableNetwork {
|
|
| 924 | 926 |
container.Config.NetworkDisabled = true |
| 925 | 927 |
return container.buildHostnameAndHostsFiles("127.0.1.1")
|
| 926 |
- } else {
|
|
| 927 |
- if err := container.allocateNetwork(); err != nil {
|
|
| 928 |
- return err |
|
| 929 |
- } |
|
| 930 |
- return container.buildHostnameAndHostsFiles(container.NetworkSettings.IPAddress) |
|
| 931 | 928 |
} |
| 932 |
- return nil |
|
| 929 |
+ if err := container.allocateNetwork(); err != nil {
|
|
| 930 |
+ return err |
|
| 931 |
+ } |
|
| 932 |
+ return container.buildHostnameAndHostsFiles(container.NetworkSettings.IPAddress) |
|
| 933 | 933 |
} |
| 934 | 934 |
|
| 935 | 935 |
// Make sure the config is compatible with the current kernel |