fix: harden operations and configuration recovery
This commit is contained in:
+4
-5
@@ -2,7 +2,6 @@
|
||||
package apt
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -15,6 +14,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"proxyctl/internal/execsafe"
|
||||
"proxyctl/internal/profile"
|
||||
"proxyctl/internal/securefs"
|
||||
"proxyctl/internal/target"
|
||||
@@ -77,7 +77,7 @@ type Runner interface {
|
||||
|
||||
type systemRunner struct{}
|
||||
|
||||
func (systemRunner) LookPath(name string) (string, error) { return exec.LookPath(name) }
|
||||
func (systemRunner) LookPath(name string) (string, error) { return execsafe.LookPath(name) }
|
||||
func (systemRunner) Output(ctx context.Context, name string, args ...string) ([]byte, error) {
|
||||
return exec.CommandContext(ctx, name, args...).Output()
|
||||
}
|
||||
@@ -435,9 +435,8 @@ func aptQuote(value string) string {
|
||||
|
||||
func parseConfiguration(data []byte) map[string]string {
|
||||
settings := make(map[string]string)
|
||||
scanner := bufio.NewScanner(strings.NewReader(string(data)))
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
for _, raw := range strings.Split(string(data), "\n") {
|
||||
line := strings.TrimSpace(raw)
|
||||
if line == "" || strings.HasPrefix(line, "//") || strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user