php / php/php-src

Closing PDO descriptors for child processes

Offen
#20,084 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Extension: pdo (core) Feature Status: Needs Triage
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

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?

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit PDO::setAttribute() und den im Issue genannten Unix-Prozesspfaden: shell_exec(), passthru(), proc_open() und pcntl_fork(). Ermittle, wie PDO-Verbindungen Deskriptoren offenlegen oder erben, und definiere die Abdeckung für das angeforderte Verhalten; fertig ist die Arbeit, wenn die unterstützte Einstellung die Vererbung verhindert, wo dies zutrifft.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
c, php
Bereich
backend, databases
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.