Skip to content

Commit

Permalink
fix: ensure /tmp exists to have a consistent dir structure
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
  • Loading branch information
89luca89 committed Nov 14, 2023
1 parent dfb455c commit 5390840
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/ssh/server/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ func (s *Server) handler(sess ssh.Session) {
ptyReq, winCh, isPty := sess.Pty()
cmd := s.getCommand(sess, isPty)
if ssh.AgentRequested(sess) {
// on some systems (like containers) /tmp may not exists, this ensures
// that we have a compliant directory structure
err := os.MkdirAll("/tmp", 0o777)
if err != nil {
s.exitWithError(sess, perrors.Wrap(err, "creating /tmp dir"))
return
}
l, err := ssh.NewAgentListener()
if err != nil {
s.exitWithError(sess, perrors.Wrap(err, "start agent"))
Expand Down

0 comments on commit 5390840

Please sign in to comment.