From 08ecf5255c7aad0a16eb5860ead5f5618abc89a9 Mon Sep 17 00:00:00 2001 From: Q Date: Mon, 15 May 2023 11:30:03 +0800 Subject: [PATCH] fix non-root android & compile with golang 1.20.4 --- build.sh | 9 ++++++--- sshd.go | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index c98d169..233e920 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,10 @@ set -x # ECHO on #go get github.com/google/shlex github.com/gliderlabs/ssh export GOPROXY=https://goproxy.cn go get -export CGO_ENABLED=0 GOOS=linux GOARCH=arm64 ;go build -trimpath -ldflags "-s -w -buildid=" -o sshd-${GOOS}-$GOARCH -export CGO_ENABLED=0 GOOS=linux GOARCH=arm ;go build -trimpath -ldflags "-s -w -buildid=" -o sshd-${GOOS}-$GOARCH -export CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ;go build -trimpath -ldflags "-s -w -buildid=" -o sshd-${GOOS}-$GOARCH +export BUILD_COMMAND='go build -trimpath -ldflags "-s -w -buildid=" -buildvcs=false -o' +#golang 1.20 -buildvcs=false + +export CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ;eval $BUILD_COMMAND sshd-$GOOS-$GOARCH +export CGO_ENABLED=0 GOOS=linux GOARCH=arm ;eval $BUILD_COMMAND sshd-$GOOS-$GOARCH +export CGO_ENABLED=0 GOOS=linux GOARCH=arm64 ;eval $BUILD_COMMAND sshd-$GOOS-$GOARCH \ No newline at end of file diff --git a/sshd.go b/sshd.go index 164adea..95a6e26 100644 --- a/sshd.go +++ b/sshd.go @@ -25,8 +25,8 @@ func main() { _, err := os.Stat(scmd) if os.IsNotExist(err) { scmd="/data/data/com.termux/files/usr/bin/bash" - _, err := os.Stat(scmd) - if os.IsNotExist(err) { + _, err := os.Open(scmd)//fix os.Stat(scmd) + if err != nil { scmd="/system/bin/sh" }