gates / gates (push) Successful in 31s
- clear_hold: a fifth verb in the closed operator-action list; lifts a hold of any reason in the RUNNING controller (memory + settings.json together), forgets the update's held flag, drops a waiting put-back from the app-stop marker (copy kept). Refused on a bad name or no hold. No new event type. - --clear-restore-hold asks the running controller over <data dir>/ctl/hold.sock (unix, 0600, peer uid checked, no TCP); edits settings.json only when no controller answers, and says so (in-guest restart). - R-1340: the operator's HELD STOPPED mail is built from the hold record (restore kind, mixed cause, failed put-back step, database replay or not, kept copy) — never the option-C database story by default. - R-1341: the OOM WARN line once per new kill (container, start time, kill count); event unchanged.
35 lines
968 B
Go
35 lines
968 B
Go
//go:build linux
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// holdCtlPeerAllowed (R-1343) admits a peer on the hold socket only when its uid equals this process's (SO_PEERCRED).
|
|
// The socket's 0600 mode in a 0700 directory already says so; this is the second lock on the same door.
|
|
func holdCtlPeerAllowed(conn net.Conn) (bool, string) {
|
|
uc, ok := conn.(*net.UnixConn)
|
|
if !ok {
|
|
return false, "not a unix-socket peer"
|
|
}
|
|
raw, err := uc.SyscallConn()
|
|
if err != nil {
|
|
return false, "the peer's identity could not be read"
|
|
}
|
|
var cred *syscall.Ucred
|
|
var cerr error
|
|
if err := raw.Control(func(fd uintptr) {
|
|
cred, cerr = syscall.GetsockoptUcred(int(fd), syscall.SOL_SOCKET, syscall.SO_PEERCRED)
|
|
}); err != nil || cerr != nil || cred == nil {
|
|
return false, "the peer's identity could not be read"
|
|
}
|
|
if int(cred.Uid) != os.Geteuid() {
|
|
return false, fmt.Sprintf("the peer's uid %d is not this controller's", cred.Uid)
|
|
}
|
|
return true, ""
|
|
}
|