Fix js build

This commit is contained in:
Viktor Liu
2025-10-02 15:59:17 +02:00
parent 66483ab48d
commit b3c7b3c7b2
5 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
//go:build js
package server
import (
"errors"
"os/exec"
"os/user"
"github.com/gliderlabs/ssh"
)
var errNotSupported = errors.New("SSH server command execution not supported on WASM/JS platform")
// createSuCommand is not supported on JS/WASM
func (s *Server) createSuCommand(_ ssh.Session, _ *user.User, _ bool) (*exec.Cmd, error) {
return nil, errNotSupported
}
// createExecutorCommand is not supported on JS/WASM
func (s *Server) createExecutorCommand(_ ssh.Session, _ *user.User, _ bool) (*exec.Cmd, error) {
return nil, errNotSupported
}
// prepareCommandEnv is not supported on JS/WASM
func (s *Server) prepareCommandEnv(_ *user.User, _ ssh.Session) []string {
return nil
}
// setupProcessGroup is not supported on JS/WASM
func (s *Server) setupProcessGroup(_ *exec.Cmd) {
}
// killProcessGroup is not supported on JS/WASM
func (s *Server) killProcessGroup(_ *exec.Cmd) {
}

View File

@@ -0,0 +1,22 @@
//go:build js
package server
import (
"fmt"
"github.com/gliderlabs/ssh"
log "github.com/sirupsen/logrus"
)
// handlePty is not supported on JS/WASM
func (s *Server) handlePty(logger *log.Entry, session ssh.Session, _ PrivilegeCheckResult, _ ssh.Pty, _ <-chan ssh.Window) bool {
errorMsg := "PTY sessions are not supported on WASM/JS platform\n"
if _, err := fmt.Fprint(session.Stderr(), errorMsg); err != nil {
logger.Debugf(errWriteSession, err)
}
if err := session.Exit(1); err != nil {
logger.Debugf(errExitSession, err)
}
return false
}

View File

@@ -0,0 +1,12 @@
//go:build js
package server
import (
"os/user"
)
// parseUserCredentials is not supported on JS/WASM
func (s *Server) parseUserCredentials(_ *user.User) (uint32, uint32, []uint32, error) {
return 0, 0, nil, errNotSupported
}

View File

@@ -0,0 +1,8 @@
//go:build js
package server
// validateUsername is not supported on JS/WASM
func validateUsername(_ string) error {
return errNotSupported
}

View File

@@ -0,0 +1,8 @@
//go:build js
package server
// enableUserSwitching is not supported on JS/WASM
func enableUserSwitching() error {
return errNotSupported
}