Skip to content

Commit 225245f

Browse files
author
Brian McCallister
committed
Change Authn socket to Control socket
1 parent e18f786 commit 225245f

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

cmd/epithet-agent/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ func parse(un unmarshal, body []byte) (map[string]*config, error) {
7474
}
7575

7676
type config struct {
77-
CA string `json:"ca_url" yaml:"ca_url" toml:"ca_url"`
78-
AgentSock string `json:"agent_sock" yaml:"agent_sock" toml:"agent_sock"`
79-
AuthnSock string `json:"authn_sock" yaml:"authn_sock" toml:"authn_sock"`
80-
Name string
77+
CA string `json:"ca_url" yaml:"ca_url" toml:"ca_url"`
78+
AgentSock string `json:"agent_sock" yaml:"agent_sock" toml:"agent_sock"`
79+
ControlSock string `json:"control_sock" yaml:"control_sock" toml:"control_sock"`
80+
Name string
8181
}
8282

8383
func (c *config) init(name string) error {
@@ -87,8 +87,8 @@ func (c *config) init(name string) error {
8787
c.AgentSock = fmt.Sprintf("~/.epithet/%s.agent.sock", name)
8888
}
8989

90-
if c.AuthnSock == "" {
91-
c.AuthnSock = fmt.Sprintf("~/.epithet/%s.authn.sock", name)
90+
if c.ControlSock == "" {
91+
c.ControlSock = fmt.Sprintf("~/.epithet/%s.control.sock", name)
9292
}
9393

9494
_, err := url.Parse(c.CA)

cmd/epithet-agent/epithet-agent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ func run(cc *cobra.Command, args []string) error {
6767
a, err := agent.Start(
6868
caClient,
6969
agent.WithAgentSocketPath(cfg.AgentSock),
70-
agent.WithAuthnSocketPath(cfg.AuthnSock),
70+
agent.WithControlSocketPath(cfg.ControlSock),
7171
)
7272
if err != nil {
7373
return fmt.Errorf("unable to start agent %s: %w", name, err)
7474
}
75-
log.Infof("started agent [%s] [authn=%s] [agent=%s]", name, a.AuthnSocketPath(), a.AgentSocketPath())
75+
log.Infof("started agent [%s] [authn=%s] [agent=%s]", name, a.ControlSocketPath(), a.AgentSocketPath())
7676
defer a.Close()
7777
}
7878

pkg/agent/agent.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ type Agent struct {
3636
agentSocketPath string
3737
agentListener net.Listener
3838

39-
authnSocketPath string
40-
grpcServer *grpc.Server
39+
controlSocketPath string
40+
grpcServer *grpc.Server
4141

4242
publicKey sshcert.RawPublicKey
4343
privateKey sshcert.RawPrivateKey
@@ -100,10 +100,10 @@ func WithAgentSocketPath(path string) Option {
100100
})
101101
}
102102

103-
// WithAuthnSocketPath specifies the SSH_AUTH_SOCK path to create
104-
func WithAuthnSocketPath(path string) Option {
103+
// WithControlSocketPath specifies the control socket (API) for the agent
104+
func WithControlSocketPath(path string) Option {
105105
return optionFunc(func(a *Agent) error {
106-
a.authnSocketPath = path
106+
a.controlSocketPath = path
107107
return nil
108108
})
109109
}
@@ -227,24 +227,24 @@ func (a *Agent) listenAndServeAgent(listener net.Listener) {
227227
}
228228

229229
func (a *Agent) startAuthnListener() error {
230-
if a.authnSocketPath == "" {
230+
if a.controlSocketPath == "" {
231231
f, err := ioutil.TempFile("", "epithet-authn.*")
232232
if err != nil {
233233
a.Close()
234234
return fmt.Errorf("unable to create authn socket: %w", err)
235235
}
236-
a.authnSocketPath = f.Name()
236+
a.controlSocketPath = f.Name()
237237
f.Close()
238238
os.Remove(f.Name())
239239
}
240240

241-
authnListener, err := net.Listen("unix", a.authnSocketPath)
241+
authnListener, err := net.Listen("unix", a.controlSocketPath)
242242
if err != nil {
243243
a.Close()
244-
return fmt.Errorf("unable to listen on %s: %w", a.authnSocketPath, err)
244+
return fmt.Errorf("unable to listen on %s: %w", a.controlSocketPath, err)
245245
}
246246

247-
err = os.Chmod(a.authnSocketPath, 0600)
247+
err = os.Chmod(a.controlSocketPath, 0600)
248248
if err != nil {
249249
a.Close()
250250
return fmt.Errorf("unable to set permissions on authn socket: %w", err)
@@ -268,9 +268,9 @@ func (a *Agent) AgentSocketPath() string {
268268
return a.agentSocketPath
269269
}
270270

271-
// AuthnSocketPath returns the path for the SSH_AUTH_SOCKET
272-
func (a *Agent) AuthnSocketPath() string {
273-
return a.authnSocketPath
271+
// ControlSocketPath returns the path for the SSH_AUTH_SOCKET
272+
func (a *Agent) ControlSocketPath() string {
273+
return a.controlSocketPath
274274
}
275275

276276
// IsAgentStopped lets you test if an error indicates that the agent has been stopped

test/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func Test_EndToEnd(t *testing.T) {
5454
require.NoError(err)
5555
defer a.Close()
5656

57-
authnClient, err := rpc.NewClient(a.AuthnSocketPath())
57+
authnClient, err := rpc.NewClient(a.ControlSocketPath())
5858
require.NoError(err)
5959

6060
_, err = authnClient.Authenticate(context.Background(), &rpc.AuthnRequest{

0 commit comments

Comments
 (0)