nx_portcheck.nx
buildroot/runtime/nx_portcheck.nx
about
nx_portcheck.nx -- R1 of the sovereign-:443 arc: a SOVEREIGN "what owns this port" inspector. The deploy team
(nx_hostctl/nx_aw_hostctl) can start/stop/swap named daemons but has NO way to answer "what process is bound to
:443" -- the never-brick prerequisite before a sovereign terminator can take :443 from DSM (operator: "build them
up if they lack the capability, rung by rung; dont use shell"). This reads /proc sovereignly (syscalls only, no
ss/lsof/netstat): /proc/net/tcp{,6} for a LISTEN socket on the target port -> its inode; then /proc/<pid>/fd via
getdents64 + readlinkat(__syscall 267) to find the owning pid; then /proc/<pid>/comm for the process name.
license_tier: ORIGINAL expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_os_introspect.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 10 | const PC_MAGIC_32768: i64 = 32768 |
| 11 | const PC_MAGIC_53991: i64 = 53991 |
| 13 | const PC_TCP_LISTEN: i64 = 0x0A |
| 14 | const PC_AT_FDCWD: i64 = 0 - 100 |
| 15 | const PC_SYS_READLINKAT: i64 = 267 // x86_64 readlinkat(dirfd, path, buf, bufsiz) |
| 245 | const PCL_EXIT_USAGE: i64 = 3 |
| 246 | const PCL_EXIT_OUTPUT: i64 = 4 |
| 247 | const PCL_INTEGER_BYTES: i64 = 21 |
| 248 | const PCL_I64_MIN: i64 = 0-9223372036854775807-1 |
functions
| 17 | func pc_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 18 | func pc_row(name: *u8, ok: i64) -> i64 { if ok == 1 { pc_w(" PASS " as *u8) } else { pc_w(" FAIL " as *u8) } pc_w(name); pc_w("\n" as *u8); return ok } |
| 19 | func pc_is_space(c: i64) -> i64 { if c == 32 { return 1 } if c == 9 { return 1 } return 0 } called by 1: pc_field |
| 20 | func pc_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 21 | func pc_puti(v: i64) -> i64 { var t: i64=v; if t<0 { sys_write(1,"-" as *u8,1); t=0-t } let tm: *u8=sys_mmap(24); var k: i64=0; if t==0 {tm[0]=48 as u8;k=1} while t>0 {tm[k]=(48+(t%10)) as u8;t=t/10;k=k+1} let b: *u8=sys_mmap(24); var j: i64=0; while j<k {b[j]=tm[k-1-j];j=j+1} sys_write(1,b,k); return 0 } |
| 24 | func pc_hex(buf: *u8, s: i64, e: i64) -> i64 called by 1: pc_scan_file |
| 37 | func pc_dec(buf: *u8, s: i64, e: i64) -> i64 |
| 44 | func pc_field(buf: *u8, lstart: i64, lend: i64, idx: i64, fs: *i64, fe: *i64) -> i64 |
| 58 | func pc_scan_file(path: *u8, port: i64) -> i64 |
| 89 | func pc_listener_inode(port: i64) -> i64 |
| 95 | func pc_readlink(path: *u8, out: *u8, cap: i64) -> i64 |
| 101 | func pc_str_all_digits(s: *u8) -> i64 { var i: i64 = 0; if s[0] == (0 as u8) { return 0 } while s[i] != (0 as u8) { let c: i64 = s[i] & 0xff; if c < 48 { return 0 } if c > 57 { return 0 } i = i + 1 } return 1 } |
| 102 | func pc_join(a: *u8, b: *u8, c: *u8, d: *u8, out: *u8) -> i64 called by 1: pc_pid_has_inode |
| 110 | func pc_join3(a: *u8, b: *u8, c: *u8, out: *u8) -> i64 |
| 118 | func pc_pid_has_inode(piddir: *u8, inode: i64) -> i64 called by 1: pc_inode_to_pid calls 11: sys_mmappc_join3sys_openat_rdsys_getdents64dirent_namepc_str_all_digits+5 |
| 149 | func pc_inode_to_pid(inode: i64) -> i64 called by 1: pc_legacy_gate calls 10: sys_openat_rdsys_mmapsys_getdents64dirent_namepc_str_all_digitspc_pid_has_inode+4 |
| 170 | func pc_pid_comm(pid: i64, out: *u8, cap: i64) -> i64 |
| 185 | func pc_legacy_gate() -> i64 |
| 251 | func pcl_raw(s: *u8, n: i64) -> i64 |
| 260 | func pcl_text(s: *u8) -> i64 { return pcl_raw(s,pc_strlen(s)) } |
| 261 | func pcl_number(value: i64) -> i64 |
| 270 | func pcl_equal(a: *u8, b: *u8) -> i64 called by 1: main |
| 274 | func pcl_status(status: i64) -> *u8 called by 1: pcl_emit |
| 280 | func pcl_stage(stage: i64) -> *u8 called by 1: pcl_emit |
| 290 | func pcl_refuse(code: *u8) -> i64 |
| 297 | func pcl_emit(port: i64, row_capacity: i64, read_capacity: i64, rows: *i64, addresses: *u8, st: *i64, begin: i64, end: i64) -> i64 |
| 332 | func pcl_listeners(argc: i64, argv: *i64) -> i64 |
| 360 | func main(argc: i64, argv: *i64) -> i64 |