Skip to content

Commit

Permalink
fix(lk): correct cfg file permission check and bin name (#385)
Browse files Browse the repository at this point in the history
* fix(lk): correct cfg file permission check and bin name

* revert(lk): keep existing cfg permission check

* chore(lk): make unexpected cfg permissions a warning instead of error
  • Loading branch information
rektdeckard authored Aug 15, 2024
1 parent d2e3f27 commit 245fd68
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ GOBIN=$(shell go env GOBIN)
endif

cli: check_lfs
go build -ldflags "-w -s" -o bin/lk ./cmd/lk
GOOS=linux GOARCH=amd64 go build -o bin/lk-linux ./cmd/lk
GOOS=darwin GOARCH=arm64 go build -ldflags "-w -s" -o bin/lk ./cmd/lk
GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o bin/lk-linux ./cmd/lk
GOOS=windows GOARCH=amd64 go build -ldflags "-w -s" -o bin/lk.exe ./cmd/lk


install: cli
cp bin/lk $(GOBIN)/
Expand Down
2 changes: 1 addition & 1 deletion cmd/lk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func main() {
}

func checkForLegacyName() {
if !strings.HasSuffix(os.Args[0], "lk") {
if !(strings.HasSuffix(os.Args[0], "lk") || strings.HasSuffix(os.Args[0], "lk.exe")) {
fmt.Fprintf(
os.Stderr,
"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DEPRECATION NOTICE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"+
Expand Down
4 changes: 3 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ func LoadOrCreate() (*CLIConfig, error) {
} else if err != nil {
return nil, err
} else if s.Mode().Perm()&0077 != 0 {
return nil, fmt.Errorf("config file %s should be 0600", configPath)
// because this file contains private keys, warn that
// only the owner should have permission to access it
fmt.Fprintf(os.Stderr, "WARNING: config file %s should have permissions %o\n", configPath, 0600)
}

content, err := os.ReadFile(configPath)
Expand Down

0 comments on commit 245fd68

Please sign in to comment.