get_user_name(); $payload = ["ChangePassword" => [ 'email_address' => $user, 'old_password' => $curpass, 'new_password' => $newpass, ]]; $decoded = appcd_request($payload); if (!is_array($decoded) || !$decoded['Ok']) { /*rcube::raise_error([ 'code' => 600, 'file' => __FILE__, 'line' => __LINE__, 'message' => "Password plugin: API error response ($responseBody)", ], true, false); */ return [ 'code' => PASSWORD_ERROR, 'message' => 'Backend says: ' . $decoded['Error']['msg'], ]; } return PASSWORD_SUCCESS; } } function appcd_request(array $request, float $timeout = 30.0): ?array { $socketPath = '/var/run/enhance/unpriv.sock'; $errno = 0; $errstr = ''; $fp = @stream_socket_client( 'unix://' . $socketPath, $errno, $errstr, $timeout ); if (!$fp) { throw new RuntimeException("Failed to connect to appcd: $errstr ($errno)"); } fwrite($fp, json_encode($request, JSON_UNESCAPED_SLASHES) . "\n"); $responseLine = fgets($fp); fclose($fp); if ($responseLine === false) { return null; } $decoded = json_decode(trim($responseLine), true); if (!is_array($decoded)) { throw new RuntimeException("Invalid JSON from appcd: $responseLine"); } return $decoded; }