@@ -343,6 +343,14 @@ var ring1Cmd = &cobra.Command{
343
343
}
344
344
}
345
345
346
+ // We deliberately do not bind mount `/etc/resolv.conf`, but instead place a copy
347
+ // so that users in the workspace can modify the file.
348
+ err = copyResolvConf (ring2Root )
349
+ if err != nil {
350
+ log .WithError (err ).Error ("cannot copy resolv.conf" )
351
+ return
352
+ }
353
+
346
354
env := make ([]string , 0 , len (os .Environ ()))
347
355
for _ , e := range os .Environ () {
348
356
if strings .HasPrefix (e , "WORKSPACEKIT_" ) {
@@ -565,7 +573,9 @@ var (
565
573
"/dev" ,
566
574
"/etc/hosts" ,
567
575
"/etc/hostname" ,
568
- "/etc/resolv.conf" ,
576
+ }
577
+ rejectMountPaths = map [string ]struct {}{
578
+ "/etc/resolv.conf" : {},
569
579
}
570
580
)
571
581
@@ -613,6 +623,11 @@ func findBindMountCandidates(procMounts io.Reader, readlink func(path string) (d
613
623
continue
614
624
}
615
625
626
+ // reject known paths
627
+ if _ , ok := rejectMountPaths [path ]; ok {
628
+ continue
629
+ }
630
+
616
631
// test remaining candidates if they're a Kubernetes configMap or secret
617
632
ln , err := readlink (filepath .Join (path , "..data" ))
618
633
if err != nil {
@@ -627,6 +642,34 @@ func findBindMountCandidates(procMounts io.Reader, readlink func(path string) (d
627
642
return mounts , scanner .Err ()
628
643
}
629
644
645
+ // copyResolvConf copies /etc/resolv.conf to <ring2root>/etc/resolv.conf
646
+ func copyResolvConf (ring2root string ) error {
647
+ fn := "/etc/resolv.conf"
648
+ stat , err := os .Stat (fn )
649
+ if err != nil {
650
+ return err
651
+ }
652
+
653
+ org , err := os .Open (fn )
654
+ if err != nil {
655
+ return err
656
+ }
657
+ defer org .Close ()
658
+
659
+ dst , err := os .OpenFile (filepath .Join (ring2root , fn ), os .O_CREATE | os .O_TRUNC | os .O_WRONLY , stat .Mode ())
660
+ if err != nil {
661
+ return err
662
+ }
663
+ defer dst .Close ()
664
+
665
+ _ , err = io .Copy (dst , org )
666
+ if err != nil {
667
+ return err
668
+ }
669
+
670
+ return nil
671
+ }
672
+
630
673
func receiveSeccmpFd (conn * net.UnixConn ) (libseccomp.ScmpFd , error ) {
631
674
buf := make ([]byte , unix .CmsgSpace (4 ))
632
675
0 commit comments