This commit is contained in:
Russ Magee 2019-07-11 10:12:38 -07:00
parent 2087aab2d5
commit 06854f7a03
7 changed files with 31 additions and 15 deletions

View File

@ -4,8 +4,10 @@
MAKEOPTS = $(MAKEOPTS) MAKEOPTS = $(MAKEOPTS)
#endif #endif
GIT_COMMIT := $(shell git rev-list -1 HEAD)
VERSION := 0.8.4
#ifeq ($(BUILDOPTS),) #ifeq ($(BUILDOPTS),)
BUILDOPTS = $(BUILDOPTS) BUILDOPTS :=$(BUILDOPTS)" -ldflags \"-X main.version=$(VERSION) -X main.gitCommit=$(GIT_COMMIT)\""
#endif #endif
SUBPKGS = logger spinsult hkexnet SUBPKGS = logger spinsult hkexnet
@ -24,27 +26,28 @@ clean:
subpkgs: subpkgs:
for d in $(SUBPKGS); do\ for d in $(SUBPKGS); do\
$(MAKE) -C $$d all;\ $(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
done done
tools: tools:
for d in $(TOOLS); do\ for d in $(TOOLS); do\
$(MAKE) -C $$d all;\ $(MAKE) BUILDOPTS=$(BUILDOPTS) -C $$d all;\
done done
common: common:
go build .
go install . go install .
client: common client: common
$(MAKE) -C hkexsh $(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexsh
ifeq ($(MSYSTEM),) ifeq ($(MSYSTEM),)
ifneq ($(GOOS),windows) ifneq ($(GOOS),windows)
server: common server: common
$(MAKE) -C hkexshd $(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexshd
else else
echo "Cross-build of hkexshd server for Windows not yet supported" echo "Cross-build of hkexshd server for Windows not yet supported"
endif endif
@ -55,7 +58,7 @@ endif
passwd: common passwd: common
$(MAKE) -C hkexpasswd $(MAKE) BUILDOPTS=$(BUILDOPTS) -C hkexpasswd
vis: vis:
@which go-callvis >/dev/null 2>&1; \ @which go-callvis >/dev/null 2>&1; \

View File

@ -8,6 +8,3 @@
package hkexsh package hkexsh
// common constants for the HKExSh // common constants for the HKExSh
// Version string returned by tools
const Version = "0.8.4 (NO WARRANTY)"

View File

@ -4,7 +4,7 @@ EXTPKGS = bytes,errors,flag,fmt,internal,io,log,net,os,path,runtime,time,strings
EXE = $(notdir $(shell pwd)) EXE = $(notdir $(shell pwd))
all: all:
go build . go build $(BUILDOPTS) .
clean: clean:
$(RM) $(EXE) $(EXE).exe $(RM) $(EXE) $(EXE).exe

View File

@ -21,17 +21,29 @@ import (
"github.com/jameskeane/bcrypt" "github.com/jameskeane/bcrypt"
) )
var (
version string
gitCommit string
)
// nolint: gocyclo // nolint: gocyclo
func main() { func main() {
var vopt bool
var pfName string var pfName string
var newpw string var newpw string
var confirmpw string var confirmpw string
var userName string var userName string
flag.BoolVar(&vopt, "v", false, "show version")
flag.StringVar(&userName, "u", "", "username") flag.StringVar(&userName, "u", "", "username")
flag.StringVar(&pfName, "f", "/etc/hkexsh.passwd", "passwd file") flag.StringVar(&pfName, "f", "/etc/hkexsh.passwd", "passwd file")
flag.Parse() flag.Parse()
if vopt {
fmt.Printf("version %s (%s)\n", version, gitCommit)
os.Exit(0)
}
var uname string var uname string
if len(userName) == 0 { if len(userName) == 0 {
log.Println("specify username with -u") log.Println("specify username with -u")

View File

@ -4,6 +4,7 @@ EXTPKGS = bytes,errors,flag,fmt,internal,io,log,net,os,path,runtime,time,strings
EXE = $(notdir $(shell pwd)) EXE = $(notdir $(shell pwd))
all: all:
echo "BUILDOPTS:" $(BUILDOPTS)
go build $(BUILDOPTS) . go build $(BUILDOPTS) .
clean: clean:

View File

@ -41,6 +41,9 @@ import (
) )
var ( var (
version string
gitCommit string // set in -ldflags by build
// wg controls when the goroutines handling client I/O complete // wg controls when the goroutines handling client I/O complete
wg sync.WaitGroup wg sync.WaitGroup
// Log defaults to regular syslog output (no -d) // Log defaults to regular syslog output (no -d)
@ -592,7 +595,6 @@ func sendSessionParams(conn io.Writer /* *hkexnet.Conn*/, rec *hkexsh.Session) (
// TODO: reduce gocyclo // TODO: reduce gocyclo
func main() { func main() {
version := hkexsh.Version
var vopt bool var vopt bool
var gopt bool //login via password, asking server to generate authToken var gopt bool //login via password, asking server to generate authToken
var dbg bool var dbg bool
@ -723,7 +725,7 @@ func main() {
} }
if vopt { if vopt {
fmt.Printf("version v%s\n", version) fmt.Printf("version %s (%s)\n", version, gitCommit)
exitWithStatus(0) exitWithStatus(0)
} }

View File

@ -35,6 +35,9 @@ import (
) )
var ( var (
version string
gitCommit string // set in -ldflags by build
// Log - syslog output (with no -d) // Log - syslog output (with no -d)
Log *logger.Writer Log *logger.Writer
) )
@ -401,8 +404,6 @@ func GenAuthToken(who string, connhost string) string {
// Compare to 'serverp.go' in this directory to see the equivalence. // Compare to 'serverp.go' in this directory to see the equivalence.
// TODO: reduce gocyclo // TODO: reduce gocyclo
func main() { func main() {
version := hkexsh.Version
var vopt bool var vopt bool
var chaffEnabled bool var chaffEnabled bool
var chaffFreqMin uint var chaffFreqMin uint
@ -421,7 +422,7 @@ func main() {
flag.Parse() flag.Parse()
if vopt { if vopt {
fmt.Printf("version v%s\n", version) fmt.Printf("version %s (%s)\n", version, gitCommit)
os.Exit(0) os.Exit(0)
} }