<?php
declare(strict_types=1);
// Root-authorized PID112175 only, never emit or persist source env/cmdline.
$pid=112175;$root='/tmp/zhct-dm-poc-20260928.fcpiiN/store';$runner=$argv[1]??'';
if(!preg_match('#^/tmp/cdx-nfl-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),$root)===false)exit(79);
$allow=['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=[];$raw=file_get_contents('/proc/'.$pid.'/environ');if(!is_string($raw))exit(80);
foreach(explode(chr(0),$raw)as $entry){$pair=explode('=',$entry,2);if(count($pair)===2&&in_array($pair[0],$allow,true))$env[$pair[0]]=$pair[1];}
unset($raw,$cmd,$entry,$pair);
foreach(['POC_HOST','POC_PORT','POC_SCHEMA','POC_USER','POC_PASSWORD']as $key)if(!isset($env[$key])||$env[$key]==='')exit(81);
if($env['POC_HOST']!=='127.0.0.1'||$env['POC_PORT']!=='5237'||$env['POC_SCHEMA']!=='ZHCT_APP'||($env['POC_EXTERNAL_STUBS']??'')!=='1'||($env['POC_REAL_QUEUE']??'0')!=='0')exit(82);
$env['LR_ROOT']=$root;
$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);unset($env);if(!is_resource($proc))exit(83);exit(proc_close($proc));
