容器里的治理进程以固定非 root 用户运行,agent 原先只接受与自身同 uid 的连接, socket 挂进容器后一律被拒(peer uid is not allowed)。新增 --allow-peer-uid, 默认仍只允许同 uid,放行清单只能由部署参数给出,避免"挂上就能连"。
This commit is contained in:
@@ -49,7 +49,10 @@ type Config struct {
|
||||
Project string
|
||||
Writers string
|
||||
NonWriters string
|
||||
MaxDuration time.Duration
|
||||
// AllowedPeerUIDs 是除"与 agent 同 uid"之外额外放行的连接方 uid。
|
||||
// 默认空:只允许同 uid。容器里固定以某个 uid 运行时,由部署参数显式列出。
|
||||
AllowedPeerUIDs []uint32
|
||||
MaxDuration time.Duration
|
||||
// StopGrace bounds the graceful stop of one operation: SIGTERM first (the
|
||||
// child aborts the maintenance window and restores writers), then SIGKILL
|
||||
// only after this grace period. It must exceed the child's own restore budget.
|
||||
@@ -214,7 +217,11 @@ func (a *Agent) Serve(ctx context.Context) error {
|
||||
|
||||
func (a *Agent) handle(ctx context.Context, conn net.Conn) {
|
||||
defer conn.Close()
|
||||
if err := peerAllowed(conn); err != nil {
|
||||
allowed := make(map[uint32]bool, len(a.config.AllowedPeerUIDs))
|
||||
for _, uid := range a.config.AllowedPeerUIDs {
|
||||
allowed[uid] = true
|
||||
}
|
||||
if err := peerAllowed(conn, allowed); err != nil {
|
||||
_ = json.NewEncoder(conn).Encode(response{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user