fix(apiserver): carry exec_user on job submit so jobs don't run as nobody (bug-1500)

modelJobToSubmit built the C job_startinfo_t without setting execuser, so the
controller forwarded a NULL execuser in the startjob request and the worker
ran every job as "nobody". Now the submit carries the resolved exec user: an
explicit exec_user wins, otherwise the job runs as the submitting user.

- add resolveExecUser() (plain-Go, unit-testable) + TestResolveExecUser
- set si.execuser in modelJobToSubmit, free it in freeJobSubmit

Note: deploying this exposed an ASAN heap-use-after-free in the apiserver's
submit/notification path (strncpy reading freed memory); the fix is committed
but needs the memory-lifecycle investigation before it can ship safely.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
lei.chen 2026-08-04 07:37:48 +00:00
parent ee7dee0ed4
commit 5b47ee603f
8 changed files with 1138 additions and 379 deletions

View file

@ -14719,5 +14719,24 @@
"related_bugs": [],
"occurrences": 1,
"last_seen": "2026-08-03"
},
{
"id": "bug-1500",
"timestamp": "2026-08-04",
"error_message": "OpenBSD r1 (172.31.1.99) frpc \u7a7f\u900f\u96a7\u9053\u4f7f\u7528\u4e00\u6bb5\u65f6\u95f4\u540e\u9759\u9ed8\u65ad\u8054: \u516c\u7f51\u8fde 49.233.89.147:60023 \u62a5 ECONNREFUSED (\u5feb\u901f\u62d2\u7edd\u975e\u8d85\u65f6), frpc \u670d\u52a1\u72b6\u6001 OK \u8fdb\u7a0b\u5b58\u6d3b, \u53ea\u6709\u91cd\u542f frpc \u624d\u80fd\u6062\u590d",
"file": "/etc/frp/frpc.toml (frpc 0.69.1 / OpenBSD 7.9) + frps 0.69.1 \u65e5\u5fd7\u5206\u6790",
"root_cause": "OpenBSD \u4f4d\u4e8e\u8fd0\u8425\u5546 CGNAT \u540e (3 \u5468\u516c\u7f51\u51fa\u53e3 IP \u6362 10+ \u4e2a: 114.244.x/114.246.x/114.254.x/124.64.x/221.216.x; 7 \u5929 2088 \u8fde\u63a5\u88ab keepalive \u8d85\u65f6\u6740)\u3002frpc 0.69.1 \u63a7\u5236\u8fde\u63a5\u88ab\u7f51\u7edc\u9759\u9ed8\u6740\u6389\u540e, \u9677\u5165\u81ea\u6211\u7ef4\u6301\u7684\u91cd\u8fde\u6b7b\u5faa\u73af: \u6bcf ~30s \u91cd\u65b0 login (server \u8bb0\u5f55 replaced by client) \u4f46\u4ece\u4e0d\u91cd\u65b0\u6ce8\u518c proxy (\u5faa\u73af\u671f\u95f4\u65e0 'new proxy' \u4e8b\u4ef6), 60023 \u7aef\u53e3\u4e00\u76f4\u65e0\u76d1\u542c -> \u7528\u6237\u8fde\u63a5\u88ab\u62d2\u3002\u5faa\u73af\u8de8\u591a\u5929\u4e0d\u81ea\u6108 (2026-08-01 16:52 ~ 08-03 13:41, \u8de8 3 \u4e2a\u51fa\u53e3 IP, 3000+ logins, \u4ec5 1 \u6b21 new proxy), \u53ea\u6709\u91cd\u542f\u8fdb\u7a0b (\u65b0 run id) \u80fd\u6253\u65ad\u3002\u6b63\u5e38\u573a\u666f (\u6bcf\u665a 03:31 CGNAT \u56de\u6536) \u80fd 13-60s \u81ea\u6108, \u8bf4\u660e\u662f\u91cd\u8fde\u8def\u5f84\u4e0a\u7684 bug \u800c\u975e\u7eaf\u7f51\u7edc\u95ee\u9898\u3002server frps \u7a33\u5b9a\u8fd0\u884c 3 \u5468, \u6392\u9664\u670d\u52a1\u7aef",
"fix": "\u4e34\u65f6\u6b62\u8840: \u90e8\u7f72\u770b\u95e8\u72d7 /tmp/frpc_watchdog.sh (\u6bcf 30s \u63a2\u6d4b 60023, \u8fde\u7eed DOWN 3 \u6b21\u81ea\u52a8 doas /etc/rc.d/frpc restart, 300s \u9632\u6296); \u5ba2\u6237\u7aef\u5f00 debug \u65e5\u5fd7 /home/dankeer/frpc.log\u3002\u6839\u6cbb\u5019\u9009: \u5347\u7ea7 frp \u67e5\u91cd\u8fde\u5faa\u73af\u4fee\u590d / KCP/QUIC \u4f20\u8f93 / \u9759\u6001 IP \u6216\u975e CGNAT \u7f51\u7edc",
"tags": [
"frpc",
"openbsd",
"cgnat",
"reconnect-loop",
"frp-0.69.1",
"tunnel-dead"
],
"related_bugs": [],
"occurrences": 3,
"last_seen": "2026-08-04"
}
]