services/agent/internal/server: check for socket file path length
test/modules/shell: shorten the path to the dir holding agent sockets

A long socket path is rejected when trying to listen. The error is
murky, and it's not immediately clear to the client what's wrong. This
change adds an explicit check in the agent to ensure the socket path is
of an acceptable length, and return an informative error if not.

One of the places where the socket path occasionally ends up being too
long is in integration tests. This change shaves off ~20 characters to
help keep it short.

Change-Id: I60c25c9a14ad0f8c7e81c5f5a5abbc090ab7f7e2
diff --git a/test/modules/shell.go b/test/modules/shell.go
index 4b3400e..c4dae02 100644
--- a/test/modules/shell.go
+++ b/test/modules/shell.go
@@ -229,7 +229,7 @@
 	sh.ctx = ctx
 	sh.logger = ctx
 
-	if sh.tempCredDir, err = ioutil.TempDir("", "shell_credentials-"); err != nil {
+	if sh.tempCredDir, err = ioutil.TempDir("", "sh_creds"); err != nil {
 		return nil, err
 	}
 	if sh.agent, err = keymgr.NewLocalAgent(sh.tempCredDir, nil); err != nil {
@@ -282,7 +282,7 @@
 	return fd, nil
 }
 
-// NewCustomCredentials creates a new Principal for StartWithOpts..
+// NewCustomCredentials creates a new Principal for StartWithOpts.
 // Returns nil if the shell is not managing principals.
 func (sh *Shell) NewCustomCredentials() (cred *CustomCredentials, err error) {
 	// Create child principal.
@@ -293,7 +293,7 @@
 	if err != nil {
 		return nil, err
 	}
-	dir, err := ioutil.TempDir(sh.tempCredDir, "agent")
+	dir, err := ioutil.TempDir(sh.tempCredDir, "a")
 	if err != nil {
 		return nil, err
 	}