mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Fix some linter errors
This commit is contained in:
parent
2127f1b210
commit
417d7e4743
6 changed files with 66 additions and 65 deletions
|
@ -14,7 +14,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkAndCreateInstanceLock(path, name string) (pid int32, err error) {
|
func checkAndCreateInstanceLock(path, name string) (pid int32, err error) {
|
||||||
|
|
||||||
lockFilePath := filepath.Join(dataRoot.Path, path, fmt.Sprintf("%s-lock.pid", name))
|
lockFilePath := filepath.Join(dataRoot.Path, path, fmt.Sprintf("%s-lock.pid", name))
|
||||||
|
|
||||||
// read current pid file
|
// read current pid file
|
||||||
|
@ -86,7 +85,7 @@ func createInstanceLock(lockFilePath string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create lock file
|
// create lock file
|
||||||
err = ioutil.WriteFile(lockFilePath, []byte(fmt.Sprintf("%d", os.Getpid())), 0666)
|
err = ioutil.WriteFile(lockFilePath, []byte(fmt.Sprintf("%d", os.Getpid())), 0666) //nolint:gosec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ func getPmStartLogFile(ext string) *os.File {
|
||||||
}, info.Version(), ext)
|
}, info.Version(), ext)
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:deadcode,unused // false positive on linux, currently used by windows only
|
//nolint:unused // false positive on linux, currently used by windows only
|
||||||
func logControlError(cErr error) {
|
func logControlError(cErr error) {
|
||||||
// check if error present
|
// check if error present
|
||||||
if cErr == nil {
|
if cErr == nil {
|
||||||
|
|
|
@ -19,8 +19,8 @@ var recoverIPTablesCmd = &cobra.Command{
|
||||||
// we don't get the errno of the actual error and need to parse the
|
// we don't get the errno of the actual error and need to parse the
|
||||||
// output instead. Make sure it's always english by setting LC_ALL=C
|
// output instead. Make sure it's always english by setting LC_ALL=C
|
||||||
currentLocale := os.Getenv("LC_ALL")
|
currentLocale := os.Getenv("LC_ALL")
|
||||||
os.Setenv("LC_ALL", "C") // nolint:errcheck - we tried at least ...
|
os.Setenv("LC_ALL", "C")
|
||||||
defer os.Setenv("LC_ALL", currentLocale) // nolint:errcheck
|
defer os.Setenv("LC_ALL", currentLocale)
|
||||||
|
|
||||||
err := interception.DeactivateNfqueueFirewall()
|
err := interception.DeactivateNfqueueFirewall()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -33,17 +33,17 @@ var (
|
||||||
childIsRunning = abool.NewBool(false)
|
childIsRunning = abool.NewBool(false)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options for starting component
|
// Options for starting component.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Name string
|
Name string
|
||||||
Identifier string // component identifier
|
Identifier string // component identifier
|
||||||
|
ShortIdentifier string // populated automatically
|
||||||
LockPathPrefix string
|
LockPathPrefix string
|
||||||
PIDFile bool
|
PIDFile bool
|
||||||
ShortIdentifier string // populated automatically
|
SuppressArgs bool // do not use any args
|
||||||
SuppressArgs bool // do not use any args
|
AllowDownload bool // allow download of component if it is not yet available
|
||||||
AllowDownload bool // allow download of component if it is not yet available
|
AllowHidingWindow bool // allow hiding the window of the subprocess
|
||||||
AllowHidingWindow bool // allow hiding the window of the subprocess
|
NoOutput bool // do not use stdout/err if logging to file is available (did not fail to open log file)
|
||||||
NoOutput bool // do not use stdout/err if logging to file is available (did not fail to open log file)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -313,7 +313,7 @@ func execute(opts *Options, args []string) (cont bool, err error) {
|
||||||
log.Printf("starting %s %s\n", binPath, strings.Join(args, " "))
|
log.Printf("starting %s %s\n", binPath, strings.Join(args, " "))
|
||||||
|
|
||||||
// create command
|
// create command
|
||||||
exc := exec.Command(binPath, args...) //nolint:gosec // everything is okay
|
exc := exec.Command(binPath, args...)
|
||||||
|
|
||||||
if !runningInConsole && opts.AllowHidingWindow {
|
if !runningInConsole && opts.AllowHidingWindow {
|
||||||
// Windows only:
|
// Windows only:
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
var (
|
var (
|
||||||
startupComplete = make(chan struct{}) // signal that the start procedure completed (is never closed, just signaled once)
|
startupComplete = make(chan struct{}) // signal that the start procedure completed (is never closed, just signaled once)
|
||||||
shuttingDown = make(chan struct{}) // signal that we are shutting down (will be closed, may not be closed directly, use initiateShutdown)
|
shuttingDown = make(chan struct{}) // signal that we are shutting down (will be closed, may not be closed directly, use initiateShutdown)
|
||||||
//nolint:deadcode,unused // false positive on linux, currently used by windows only
|
//nolint:unused // false positive on linux, currently used by windows only
|
||||||
shutdownError error // protected by shutdownLock
|
shutdownError error // protected by shutdownLock
|
||||||
shutdownLock sync.Mutex
|
shutdownLock sync.Mutex
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,62 +12,64 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var showShortVersion bool
|
var (
|
||||||
var showAllVersions bool
|
showShortVersion bool
|
||||||
var versionCmd = &cobra.Command{
|
showAllVersions bool
|
||||||
Use: "version",
|
versionCmd = &cobra.Command{
|
||||||
Short: "Display various portmaster versions",
|
Use: "version",
|
||||||
Args: cobra.NoArgs,
|
Short: "Display various portmaster versions",
|
||||||
PersistentPreRunE: func(*cobra.Command, []string) error {
|
Args: cobra.NoArgs,
|
||||||
if showAllVersions {
|
PersistentPreRunE: func(*cobra.Command, []string) error {
|
||||||
// If we are going to show all component versions,
|
if showAllVersions {
|
||||||
// we need the registry to be configured.
|
// If we are going to show all component versions,
|
||||||
if err := configureRegistry(false); err != nil {
|
// we need the registry to be configured.
|
||||||
return err
|
if err := configureRegistry(false); err != nil {
|
||||||
}
|
return err
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
RunE: func(*cobra.Command, []string) error {
|
|
||||||
if !showAllVersions {
|
|
||||||
if showShortVersion {
|
|
||||||
fmt.Println(info.Version())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(info.FullVersion())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("portmaster-start %s\n\n", info.Version())
|
|
||||||
fmt.Printf("Assets:\n")
|
|
||||||
|
|
||||||
all := registry.Export()
|
|
||||||
keys := make([]string, 0, len(all))
|
|
||||||
for identifier := range all {
|
|
||||||
keys = append(keys, identifier)
|
|
||||||
}
|
|
||||||
sort.Strings(keys)
|
|
||||||
|
|
||||||
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
|
|
||||||
for _, identifier := range keys {
|
|
||||||
res := all[identifier]
|
|
||||||
|
|
||||||
if showShortVersion {
|
|
||||||
// in "short" mode, skip all resources that are irrelevant on that platform
|
|
||||||
if !strings.HasPrefix(identifier, "all") && !strings.HasPrefix(identifier, runtime.GOOS) {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(tw, " %s\t%s\n", identifier, res.SelectedVersion.VersionNumber)
|
return nil
|
||||||
}
|
},
|
||||||
tw.Flush()
|
RunE: func(*cobra.Command, []string) error {
|
||||||
|
if !showAllVersions {
|
||||||
|
if showShortVersion {
|
||||||
|
fmt.Println(info.Version())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
fmt.Println(info.FullVersion())
|
||||||
},
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Printf("portmaster-start %s\n\n", info.Version())
|
||||||
|
fmt.Printf("Assets:\n")
|
||||||
|
|
||||||
|
all := registry.Export()
|
||||||
|
keys := make([]string, 0, len(all))
|
||||||
|
for identifier := range all {
|
||||||
|
keys = append(keys, identifier)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
|
||||||
|
for _, identifier := range keys {
|
||||||
|
res := all[identifier]
|
||||||
|
|
||||||
|
if showShortVersion {
|
||||||
|
// in "short" mode, skip all resources that are irrelevant on that platform
|
||||||
|
if !strings.HasPrefix(identifier, "all") && !strings.HasPrefix(identifier, runtime.GOOS) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(tw, " %s\t%s\n", identifier, res.SelectedVersion.VersionNumber)
|
||||||
|
}
|
||||||
|
tw.Flush()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flags := versionCmd.Flags()
|
flags := versionCmd.Flags()
|
||||||
|
|
Loading…
Add table
Reference in a new issue