mirror of https://gogs.blitter.com/RLabs/xs
Resynced w/master
Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
commit
09055dffe6
62
Makefile
62
Makefile
|
@ -26,12 +26,23 @@ BUILDOPTS :=$(BUILDOPTS)"$(GOBUILDOPTS) -ldflags \"-X main.version=$(VERSION)$(M
|
|||
#endif
|
||||
|
||||
SUBPKGS = logger spinsult xsnet
|
||||
TOOLS = xspasswd xs xsd
|
||||
TOOLS = xs xsd
|
||||
SUBDIRS = $(LIBS) $(TOOLS)
|
||||
|
||||
ifeq ($(GOOS),)
|
||||
GOOS=$(shell go env GOOS)
|
||||
endif
|
||||
|
||||
ifeq ($(GOOS),windows)
|
||||
ifeq ($(MSYSTEM),MSYS)
|
||||
WIN_MSYS=1
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
INSTPREFIX = /usr/local
|
||||
|
||||
all: common client server passwd
|
||||
all: common client server
|
||||
|
||||
clean:
|
||||
@echo "Make: $(MAKE)"
|
||||
|
@ -60,21 +71,12 @@ client: common
|
|||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C xs
|
||||
|
||||
|
||||
ifeq ($(MSYSTEM),)
|
||||
ifneq ($(GOOS),windows)
|
||||
server: common
|
||||
ifeq ($(MSYSTEM),MSYS)
|
||||
echo "Build of xsd server for Windows not yet supported"
|
||||
else
|
||||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C xsd
|
||||
else
|
||||
echo "Cross-build of xsd server for Windows not yet supported"
|
||||
endif
|
||||
else
|
||||
server: common
|
||||
echo "xsd server not (yet) supported on Windows"
|
||||
endif
|
||||
|
||||
|
||||
passwd: common
|
||||
$(MAKE) BUILDOPTS=$(BUILDOPTS) -C xspasswd
|
||||
|
||||
vis:
|
||||
@which go-callvis >/dev/null 2>&1; \
|
||||
|
@ -83,38 +85,30 @@ vis:
|
|||
else \
|
||||
$(MAKE) -C xs vis;\
|
||||
$(MAKE) -C xsd vis;\
|
||||
$(MAKE) -C xspasswd vis; \
|
||||
fi
|
||||
|
||||
lint:
|
||||
$(MAKE) -C xspasswd lint
|
||||
$(MAKE) -C xsd lint
|
||||
$(MAKE) -C xs lint
|
||||
|
||||
reinstall: uninstall install
|
||||
|
||||
install:
|
||||
cp xs/xs $(INSTPREFIX)/bin
|
||||
ifeq ($(MSYSTEM),)
|
||||
ifneq ($(GOOS),windows)
|
||||
cp xsd/xsd xspasswd/xspasswd $(INSTPREFIX)/sbin
|
||||
else
|
||||
mv $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/_xs
|
||||
echo "WIN_MSYS:" $(WIN_MSYS)
|
||||
ifdef WIN_MSYS
|
||||
cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xs
|
||||
echo "Cross-build of xsd server for Windows not yet supported"
|
||||
endif
|
||||
cp xs/mintty_wrapper.sh $(INSTPREFIX)/bin/xc
|
||||
cp xs/xs $(INSTPREFIX)/bin/_xs
|
||||
cp xs/xs $(INSTPREFIX)/bin/_xc
|
||||
echo "Install of xsd server for Windows not yet supported"
|
||||
else
|
||||
echo "Cross-build of xsd server for Windows not yet supported"
|
||||
endif
|
||||
cp xs/xs $(INSTPREFIX)/bin
|
||||
cd $(INSTPREFIX)/bin && ln -s xs xc && cd -
|
||||
|
||||
endif
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/xc $(INSTPREFIX)/bin/_xs
|
||||
ifeq ($(MSYSTEM),)
|
||||
ifneq ($(GOOS),windows)
|
||||
rm -f $(INSTPREFIX)/sbin/xsd $(INSTPREFIX)/sbin/xspasswd
|
||||
else
|
||||
endif
|
||||
else
|
||||
rm -f $(INSTPREFIX)/bin/xs $(INSTPREFIX)/bin/xc \
|
||||
$(INSTPREFIX)/bin/_xs $(INSTPREFIX)/bin/_xc
|
||||
ifndef $(WIN_MSYS)
|
||||
rm -f $(INSTPREFIX)/sbin/xsd
|
||||
endif
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
## The Makefile(s) to build require GNU make (gmake).
|
||||
## Please install and invoke build via:
|
||||
## $ gmake <targets>
|
||||
## eg.,
|
||||
## $ gmake clean all
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
[![GoDoc](https://godoc.org/blitter.com/go/xs?status.svg)](https://godoc.org/blitter.com/go/xs)
|
||||
|
||||
|
||||
# XS
|
||||
--
|
||||
|
||||
|
@ -198,3 +197,9 @@ Example, tunnelling ssh through xs
|
|||
* [client side, term A] ```$ xs -T=6002:7002 user@server```
|
||||
* [client side, term B] ```$ ssh user@localhost -p 6002```
|
||||
|
||||
|
||||
### Building for FreeBSD
|
||||
|
||||
The Makefile(s) to build require GNU make (gmake).
|
||||
Please install and invoke build via:
|
||||
```$ gmake clean all```
|
||||
|
|
|
@ -37,7 +37,7 @@ func MakeRaw(fd uintptr) (*State, error) {
|
|||
|
||||
// GetState returns the current state of a terminal which may be useful to
|
||||
// restore the terminal after a signal.
|
||||
func GetState(fd int) (*State, error) {
|
||||
func GetState(fd uintptr) (*State, error) {
|
||||
return &State{}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,12 @@ cleanup() {
|
|||
stty sane
|
||||
}
|
||||
|
||||
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
|
||||
|
||||
if [ ${1}x == "-hx" ]; then
|
||||
./hkexsh -h
|
||||
_${me} -h
|
||||
else
|
||||
stty -echo raw icrnl
|
||||
./hkexsh $@
|
||||
_${me} $@
|
||||
fi
|
||||
|
||||
|
|
20
xs/xs.go
20
xs/xs.go
|
@ -722,7 +722,10 @@ func main() {
|
|||
|
||||
// Find out what program we are (shell or copier)
|
||||
myPath := strings.Split(os.Args[0], string(os.PathSeparator))
|
||||
if myPath[len(myPath)-1] != "xc" && myPath[len(myPath)-1] != "xc.exe" {
|
||||
if myPath[len(myPath)-1] != "xc" &&
|
||||
myPath[len(myPath)-1] != "_xc" &&
|
||||
myPath[len(myPath)-1] != "xc.exe" &&
|
||||
myPath[len(myPath)-1] != "_xc.exe" {
|
||||
// xs accepts a command (-x) but not
|
||||
// a srcpath (-r) or dstpath (-t)
|
||||
flag.StringVar(&cmdStr, "x", "", "run <`command`> (if not specified, run interactive shell)")
|
||||
|
@ -766,7 +769,7 @@ func main() {
|
|||
var uname string
|
||||
if remoteUser == "" {
|
||||
u, _ := user.Current() // nolint: gosec
|
||||
uname = u.Username
|
||||
uname = localUserName(u)
|
||||
} else {
|
||||
uname = remoteUser
|
||||
}
|
||||
|
@ -1040,6 +1043,19 @@ func main() {
|
|||
exitWithStatus(int(rec.Status()))
|
||||
}
|
||||
|
||||
// currentUser returns the current username minus any OS-specific prefixes
|
||||
// such as MS Windows workgroup prefixes (eg. workgroup\user).
|
||||
func localUserName(u *user.User) string {
|
||||
if u == nil {
|
||||
log.Fatal("null User?!")
|
||||
}
|
||||
|
||||
// WinAPI: username may have CIFS prefix %USERDOMAIN%\
|
||||
userspec := strings.Split(u.Username, `\`)
|
||||
username := userspec[len(userspec)-1]
|
||||
return username
|
||||
}
|
||||
|
||||
func restoreTermState(oldState *xs.State) {
|
||||
_ = xs.Restore(os.Stdin.Fd(), oldState) // nolint: errcheck,gosec
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue