Skip to content

Commit

Permalink
Merge pull request #26 from cfergeau/unsetenv
Browse files Browse the repository at this point in the history
hosts: Unset HOSTS_PATH from the environment
  • Loading branch information
praveenkumar authored Nov 26, 2021
2 parents e2d4733 + c61aaad commit a6203a5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/hosts/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hosts

import (
"fmt"
"os"
"regexp"
"runtime"
"sort"
Expand All @@ -27,6 +28,14 @@ type Hosts struct {
HostFilter func(string) bool
}

func init() {
// goodhosts unconditionnally uses this environment variable
// as an override for the hosts file to use. We don't want admin-helper
// to modify arbitrary file, so we have to unset it before calling into
// goodhosts.
os.Unsetenv("HOSTS_PATH")
}

func New() (*Hosts, error) {
file, err := hostsfile.NewHosts()
if err != nil {
Expand Down

0 comments on commit a6203a5

Please sign in to comment.