@@ -257,9 +257,10 @@ type UnixSocketConfig struct {
257257 // not set, defaults to the directory chosen by os.MkdirTemp.
258258 TempDir string
259259
260- // The directory to create Unix sockets in. Internally managed by go-plugin
261- // and deleted when the plugin is killed.
262- directory string
260+ // The directory to create Unix sockets in. Internally created and managed
261+ // by go-plugin and deleted when the plugin is killed. Will be created
262+ // inside TempDir if specified.
263+ socketDir string
263264}
264265
265266// ReattachConfig is used to configure a client to reattach to an
@@ -465,7 +466,7 @@ func (c *Client) Kill() {
465466 c .l .Lock ()
466467 runner := c .runner
467468 addr := c .address
468- hostSocketDir := c .unixSocketCfg .directory
469+ hostSocketDir := c .unixSocketCfg .socketDir
469470 c .l .Unlock ()
470471
471472 // If there is no runner or ID, there is nothing to kill.
@@ -660,22 +661,22 @@ func (c *Client) Start() (addr net.Addr, err error) {
660661 var runner runner.Runner
661662 switch {
662663 case c .config .RunnerFunc != nil :
663- c .unixSocketCfg .directory , err = os .MkdirTemp (c .unixSocketCfg .TempDir , "plugin-dir" )
664+ c .unixSocketCfg .socketDir , err = os .MkdirTemp (c .unixSocketCfg .TempDir , "plugin-dir" )
664665 if err != nil {
665666 return nil , err
666667 }
667668 // os.MkdirTemp creates folders with 0o700, so if we have a group
668669 // configured we need to make it group-writable.
669670 if c .unixSocketCfg .Group != "" {
670- err = setGroupWritable (c .unixSocketCfg .directory , c .unixSocketCfg .Group , 0o770 )
671+ err = setGroupWritable (c .unixSocketCfg .socketDir , c .unixSocketCfg .Group , 0o770 )
671672 if err != nil {
672673 return nil , err
673674 }
674675 }
675- cmd .Env = append (cmd .Env , fmt .Sprintf ("%s=%s" , EnvUnixSocketDir , c .unixSocketCfg .directory ))
676- c .logger .Trace ("created temporary directory for unix sockets" , "dir" , c .unixSocketCfg .directory )
676+ cmd .Env = append (cmd .Env , fmt .Sprintf ("%s=%s" , EnvUnixSocketDir , c .unixSocketCfg .socketDir ))
677+ c .logger .Trace ("created temporary directory for unix sockets" , "dir" , c .unixSocketCfg .socketDir )
677678
678- runner , err = c .config .RunnerFunc (c .logger , cmd , c .unixSocketCfg .directory )
679+ runner , err = c .config .RunnerFunc (c .logger , cmd , c .unixSocketCfg .socketDir )
679680 if err != nil {
680681 return nil , err
681682 }
0 commit comments