<?php
declare(strict_types=1);
// Explicit Root scope: PID112175 only. Never log or persist source env/cmdline.
$pid=112175;$expectedRoot='/tmp/zhct-dm-poc-20260928.fcpiiN/store';
$runner=$argv[1]??'';
if(!preg_match('#^/tmp/cdx-nf5-C-20261011\.[A-Za-z0-9]+/runner\.php$#D',$runner)||!is_file($runner))exit(78);
$cmd=file_get_contents('/proc/'.$pid.'/cmdline');
if(!is_string($cmd)||strpos(str_replace(chr(0),' ',$cmd),$expectedRoot)===false)exit(79);
$allowed=['POC_HOST','POC_PORT','POC_SCHEMA','POC_USER','POC_PASSWORD','POC_DIALECT','POC_EXTERNAL_STUBS','POC_REAL_QUEUE','PATH','LANG','LC_ALL','LC_CTYPE','TZ','NLS_LANG','DM_CHARSET','DM_SVC_PATH','DM_HOME','LD_LIBRARY_PATH'];
$env=[];$bytes=file_get_contents('/proc/'.$pid.'/environ');
foreach(explode(chr(0),$bytes)as $item){$parts=explode('=',$item,2);if(count($parts)===2&&in_array($parts[0],$allowed,true))$env[$parts[0]]=$parts[1];}
unset($bytes,$cmd,$item,$parts);
foreach(['POC_HOST','POC_PORT','POC_SCHEMA','POC_USER','POC_PASSWORD']as $key)if(!isset($env[$key])||$env[$key]==='')exit(80);
if(($env['POC_EXTERNAL_STUBS']??'')!=='1'||($env['POC_REAL_QUEUE']??'0')!=='0')exit(81);
$env['NF_LANE']='C';$env['NF_PHASE']='execute';$env['NF_ROOT']=$expectedRoot;
$php='/www/server/php/73/bin/php';
$child=escapeshellarg($php).' -c /www/server/php/73/etc/php-cli.ini -d extension=/home/dmdba/dmdbms/drivers/php_pdo/libphp73_dm.so -d extension=/home/dmdba/dmdbms/drivers/php_pdo/php73_pdo_dm.so '.escapeshellarg($runner);
$proc=proc_open($child,[0=>STDIN,1=>STDOUT,2=>STDERR],$pipes,null,$env);
if(!is_resource($proc))exit(82);
exit(proc_close($proc));
