php / php/php-src

Closing PDO descriptors for child processes

オープン
#20,084 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Extension: pdo (core) Feature Status: Needs Triage
主要言語
C
スター
40.4k
フォーク
8.2k
平均マージ
2日 13時間
マージ済み PR(30日)
96

説明

Description

At least on Unix systems, whenever PHP creates a child process, whether through conventional means like shell_exec(), passthru(), or proc_open(), or through stuff like pcntl_fork(), the child process inherits all of the open file descriptors, including any open authenticated PDO database connections.

This is generally not desirable. Even in contexts where it's not a security concern, two processes should not share one connection to a database because the first one to use it will mess it up for the other one.

In other languages, this is avoided by calling something like:

fcntl( fd, F_SETFD, F_CLOEXEC );

on the database's file handle. But PHP doesn't provide this functionality (that I'm aware of) without exotic extensions and even if it did, there's no way (that I'm aware of) to get at the system file descriptor corresponding to a PDO connection.

Would it be possible/reasonable to add something to PDO::setAttribute() that would, when invoked, set that flag on the underlying descriptor where it is applicable?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

PDO::setAttribute() と、issue で挙げられている Unix プロセスパスである shell_exec()、passthru()、proc_open()、pcntl_fork() から始めます。PDO 接続がどのようにディスクリプタを公開または継承するかを確認し、要求された動作に対するカバレッジを定義します。対応する設定によって、該当する場合に継承が防止されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
c, php
領域
backend, databases
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。