M3 Security Fixes for Pass 40

This commit is contained in:
Mark Gregory
2026-09-17 13:22:35 +01:00
parent 34c3460760
commit a9b63e43b3
28 changed files with 80 additions and 116 deletions
@@ -12,9 +12,13 @@ use Modules\M3\Services\PostgresProgramBridge;
class userControlController extends Controller
{
private const AUTH_FAILURE_MESSAGE = 'Could not connect due to wrong user or password.';
private const DATABASE_NOT_FOUND_MESSAGE = 'Database not found. Try WRKRDBDIRE to check.';
private const CONNECTION_ERROR_PREFIX = 'Could not connect. Error: ';
private const PROGRAM_ERROR_PREFIX = 'Error calling program. Code: ';
private const MESSAGE_SEPARATOR = ' Msg: ';
public static function index(Request $request)
@@ -193,7 +197,6 @@ class userControlController extends Controller
}
}
// Add LIB
// $result = $conn->CLCommand('ADDLIBLE LIB(MPDAT10)');
@@ -209,11 +212,9 @@ class userControlController extends Controller
// Add Delivery Note Param
// $params[] = $conn->AddParameterPackDec('in', 11, 0, 'ParamIn','','00000087125');
// Start Time Tracking
// $start = microtime(true);
// Config::get('eproconf.misc.PGM1'), Config::get('eproconf.misc.libname4')
// ICM700C EWOBJTST ICM700C ICM700CSBM
$result = $conn->PgmCall('ICMCHGPRF', 'EWOBJ', $params, [], []);
@@ -254,12 +255,10 @@ class userControlController extends Controller
$pGMERRORS = '';
// echo "B3<br>";
// connect to toolkit using DB2 credentials (can also leave blank for default authority)
try {
$conn = app(PostgresProgramBridge::class);
// echo "B4<br>";
} catch (\Throwable $e) {
$code = $e->getCode();
$msg = $e->getMessage();
@@ -279,12 +278,10 @@ class userControlController extends Controller
}
}
// $params[] = $conn->AddParameterChar('in', 10, 'userid','USRPRF',$request->USERID);
// $params[] = $conn->AddParameterChar('in', 9, 'sts','STATUS','*ENABLED');
// $params[] = $conn->AddParameterChar('in', 4, 'pwdexp','PWDEXP','*NO');
$result = $conn->CLCommand('QSYS/CHGUSRPRF USRPRF(' . $request->R428US_PWD . ') PASSWORD(' . $request->NEW_PASSWORD . ') STATUS(*ENABLED) PWDEXP(*NO)');
// echo "<script>alert('After CHGUSRPRF');</script>";
if (! $result) {
$pGMERRORS = self::PROGRAM_ERROR_PREFIX . $conn->getErrorCode() . self::MESSAGE_SEPARATOR . $conn->getErrorMsg();
@@ -299,6 +296,7 @@ class userControlController extends Controller
}
}
private static function programBridgeConnectionError(\Throwable $exception): string
{
$code = (int) $exception->getCode();
@@ -309,5 +307,4 @@ class userControlController extends Controller
default => 'error profile5',
};
}
}