Skip to content

Commit

Permalink
fix non-root android & compile with golang 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Q authored and Q committed May 15, 2023
1 parent bdaad33 commit 08ecf52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions sshd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down

0 comments on commit 08ecf52

Please sign in to comment.