File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
components/workspacekit/cmd Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -695,22 +695,27 @@ func makeHostnameLocal(ring2root string) error {
695695 if err != nil {
696696 return err
697697 }
698- b , err := ioutil .ReadFile (path )
698+ b , err := os .ReadFile (path )
699699 if err != nil {
700700 return err
701701 }
702702 bStr := string (b )
703703 lines := strings .Split (bStr , "\n " )
704- for i , line := range lines {
704+ newLines := []string {}
705+ for _ , line := range lines {
705706 fields := strings .Fields (line )
706707 if len (fields ) != 2 {
708+ newLines = append (newLines , line )
709+ continue
710+ }
711+ if len (net .ParseIP (fields [0 ])) != net .IPv4len {
707712 continue
708713 }
709714 if fields [1 ] == hostname {
710- lines [ i ] = "127.0.0.1 " + hostname
715+ newLines = append ( newLines , "127.0.0.1 " + hostname )
711716 }
712717 }
713- return ioutil .WriteFile (path , []byte (strings .Join (lines , "\n " )), stat .Mode ())
718+ return os .WriteFile (path , []byte (strings .Join (newLines , "\n " )), stat .Mode ())
714719}
715720
716721func receiveSeccmpFd (conn * net.UnixConn ) (libseccomp.ScmpFd , error ) {
You can’t perform that action at this time.
0 commit comments