fix(chv): cell 不再把 /run/chv 的组改回 root
chv-cell 每次跑 cell 都 _ensure_bind_source(BROKER_DIR, uid=0, gid=0),把 /run/chv 的组改回 root,抹掉 tmpfiles 的 chv-browser 组;之后 chv-browser 重启时 os.remove(browser.sock) 报 Permission denied、无限 crash-loop(构建 #8 客机 62 次重启才 被发现,03:42 驱动两次跑 cell 正好在补丁后、重启前)。改:组 改取 chv-browser 的 gid(不存在回落 0);serve() 删 socket 失败时报错说清修法,不再只剩裸 traceback。
This commit is contained in:
1 parent
0bfb00ab1b
commit
435664925e
3 files changed
+105
-3
No files matched your search
@@ -550,12 +550,27 @@ def handle_request(agent, req):
|
||||
"unmount_full/ping)" % (op,)}
|
||||
|
||||
|
||||
def _remove_stale_socket(sock_path):
|
||||
"""删掉上次残留的 socket。删不掉时不静默吞掉:目录权限不对
|
||||
(/run/chv 须是 0775 root:chv-browser)就会无限 crash-loop,
|
||||
报错必须说清修法(2026-11-08 构建 #8 live 实证:cell 曾把组
|
||||
改回 root,服务 62 次重启才被发现)。"""
|
||||
if not os.path.exists(sock_path):
|
||||
return
|
||||
try:
|
||||
os.remove(sock_path)
|
||||
except PermissionError:
|
||||
raise PermissionError(
|
||||
"删不掉旧 socket %s:/run/chv 须是 0775 root:chv-browser "
|
||||
"(tmpfiles.d/chv.conf),且跑 cell 不可把它 chown 回 "
|
||||
"root:root" % sock_path)
|
||||
|
||||
|
||||
def serve(sock_path=BROWSER_SOCK, shots_dir=SHOTS_DIR,
|
||||
profile_dir=None, cdp_port=None):
|
||||
"""监听 Unix socket,逐连接处理。socket 0600(只给属主 +
|
||||
broker 的 root 连)。建不起来即抛错,不要静默带病跑。"""
|
||||
if os.path.exists(sock_path):
|
||||
os.remove(sock_path)
|
||||
_remove_stale_socket(sock_path)
|
||||
os.makedirs(os.path.dirname(sock_path), exist_ok=True)
|
||||
srv = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
srv.bind(sock_path)
|
||||
|
||||
Reference in new issue
Block a user