v0.43.1
This commit is contained in:
1 parent
5b6d4a7903
commit
4d1087e357
160 files changed
+2407
-1933
No files matched your search
@@ -18,8 +18,6 @@ import (
|
||||
|
||||
const defaultEnvFile = "/etc/rustproxy/docker-agent.env"
|
||||
|
||||
// requestedEnvFile is handled before other flags so CLI calls can load the same
|
||||
// configuration as systemd. Both --env-file=X and --env-file X are supported.
|
||||
func requestedEnvFile(args []string) (string, error) {
|
||||
path := defaultEnvFile
|
||||
for i := 0; i < len(args); i++ {
|
||||
@@ -39,7 +37,6 @@ func requestedEnvFile(args []string) (string, error) {
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// Read a restricted, plain KEY=VALUE EnvironmentFile. Never execute it as shell.
|
||||
func readEnvironmentFile(path string) (map[string]string, error) {
|
||||
result := make(map[string]string)
|
||||
f, err := os.Open(path)
|
||||
@@ -91,7 +88,6 @@ func makeToken() (string, error) {
|
||||
}
|
||||
|
||||
func provisionToken(path string, rotate bool) (string, bool, error) {
|
||||
// Reject symlinks, devices and directories before opening anything.
|
||||
stat, err := os.Lstat(path)
|
||||
var raw []byte
|
||||
if err == nil {
|
||||
@@ -130,7 +126,6 @@ func provisionToken(path string, rotate bool) (string, bool, error) {
|
||||
"RUSTPROXY_DOCKER_AGENT_LISTEN=0.0.0.0:9876\n" +
|
||||
"RUSTPROXY_DOCKER_AGENT_TLS=true\n")
|
||||
}
|
||||
// Preserve non-secret settings/comments, remove duplicate token assignments.
|
||||
lines := strings.Split(strings.TrimRight(string(raw), "\n"), "\n")
|
||||
filtered := make([]string, 0, len(lines)+1)
|
||||
for _, line := range lines {
|
||||
@@ -148,8 +143,6 @@ func provisionToken(path string, rotate bool) (string, bool, error) {
|
||||
return token, true, nil
|
||||
}
|
||||
|
||||
// Generated keys must be readable by the unprivileged systemd service even
|
||||
// when 'init' is invoked via sudo during DEB/RPM or manual installation.
|
||||
func setServiceCertificateOwnership(certFile, keyFile string) error {
|
||||
if os.Geteuid() != 0 {
|
||||
return nil
|
||||
@@ -157,7 +150,7 @@ func setServiceCertificateOwnership(certFile, keyFile string) error {
|
||||
serviceUser, err := user.Lookup("rustproxy-docker-agent")
|
||||
if err != nil {
|
||||
return nil
|
||||
} // Standalone CLI; warn operators to run init as service user.
|
||||
}
|
||||
uid, err := strconv.Atoi(serviceUser.Uid)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -172,7 +165,6 @@ func setServiceCertificateOwnership(certFile, keyFile string) error {
|
||||
if err := os.Chown(certFile, uid, gid); err != nil {
|
||||
return err
|
||||
}
|
||||
// Parent generated via atomicWrite must also be traversable by the service.
|
||||
dir := filepath.Dir(keyFile)
|
||||
if dir == filepath.Dir(certFile) {
|
||||
if err := os.Chown(dir, uid, gid); err != nil {
|
||||
@@ -274,5 +266,3 @@ func printAgentInfo(w io.Writer, cfg config, envFile string, showToken, asJSON b
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Compile-time reference: readCertificate returns an x509 parsed certificate.
|
||||
Reference in new issue
Block a user