Add COMMAND env variable support for shell command
This commit is contained in:
@@ -14,6 +14,8 @@ RUN apk add --no-cache ca-certificates
|
|||||||
|
|
||||||
COPY --from=builder /app/sshserver /usr/local/bin/sshserver
|
COPY --from=builder /app/sshserver /usr/local/bin/sshserver
|
||||||
|
|
||||||
|
ENV COMMAND /app/tui
|
||||||
|
|
||||||
EXPOSE 22
|
EXPOSE 22
|
||||||
|
|
||||||
CMD ["/usr/local/bin/sshserver"]
|
CMD ["/usr/local/bin/sshserver"]
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
services:
|
|
||||||
ssh-server:
|
|
||||||
image: ssh-server
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- "22:22"
|
|
||||||
volumes:
|
|
||||||
- ../tui:/app/tui:ro
|
|
||||||
cap_add:
|
|
||||||
- SYS_CHROOT
|
|
||||||
restart: unless-stopped
|
|
||||||
6
main.go
6
main.go
@@ -81,7 +81,11 @@ func handleChannel(channel ssh.Channel, requests <-chan *ssh.Request) {
|
|||||||
req.Reply(true, nil)
|
req.Reply(true, nil)
|
||||||
case "shell":
|
case "shell":
|
||||||
req.Reply(true, nil)
|
req.Reply(true, nil)
|
||||||
cmd := exec.Command("/app/tui")
|
command := os.Getenv("COMMAND")
|
||||||
|
if command == "" {
|
||||||
|
command = "/app/tui"
|
||||||
|
}
|
||||||
|
cmd := exec.Command(command)
|
||||||
cmd.Env = []string{"PATH=/bin"}
|
cmd.Env = []string{"PATH=/bin"}
|
||||||
cmd.Dir = "/"
|
cmd.Dir = "/"
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
Reference in New Issue
Block a user