Bug 1380794 - mysql LOAD DATA LOCAL INFILE fails when PHP's open_basedir is set
Summary: mysql LOAD DATA LOCAL INFILE fails when PHP's open_basedir is set
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: php
Version: 6.8
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Remi Collet
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-09-30 14:45 UTC by David Mulford
Modified: 2021-01-14 09:24 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-07 22:17:40 UTC
Target Upstream Version:


Attachments (Terms of Use)
.tar.xz file containing three files used to reproduce the issue (600 bytes, application/x-gzip)
2016-09-30 14:45 UTC, David Mulford
no flags Details


Links
System ID Private Priority Status Summary Last Updated
PHP Bug Tracker 62889 0 None None None 2016-09-30 14:45:01 UTC
PHP Bug Tracker 68077 0 None None None 2016-10-03 06:39:10 UTC

Description David Mulford 2016-09-30 14:45:02 UTC
Created attachment 1206308 [details]
.tar.xz file containing three files used to reproduce the issue

Description of problem:
Trying to use LOAD DATA LOCAL INFILE fails when PHP's open_basedir setting is non-empty. More details in this PHP bug: https://bugs.php.net/bug.php?id=62889

Version-Release number of selected component (if applicable):
php54-2.0-1.el6.x86_64
mysql-server-5.1.73-7.el6.x86_64
php54-php-mysqlnd-5.4.40-4.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Setup mysql and install php with mysqlnd drivers
2. Create a table in the "test" database using the attached create-rhel-tables.sql
3. Set open_basedir in /opt/rh/php54/root/etc/php.ini
4. Edit the attached sample.php to look at the open_basedir value set in step #3
5. Run the attached sample.php with `php sample.php`

Actual results:
The query fails with error 1148 "The used command is not allowed with this MySQL version"

Expected results:
The query is executed and runs as expected, affecting 3 rows.

Additional info:
Using the LOAD DATA LOCAL INFILE from the mysql command line tool works. This also works if the open_basedir setting in PHP is disabled.

The second comment of the linked PHP bug lists a workaround that doesn't work. According to PHP's documentation on PDO::MYSQL_ATTR_READ_DEFAULT_GROUP [1], this option is not read when using mysqlnd.

[1] http://php.net/manual/en/ref.pdo-mysql.php

Comment 3 Remi Collet 2016-10-03 05:51:40 UTC
I can reproduce with 5.4 and 5.5

$ scl enable php54 bash
$ php sample.php 
Query run successfully. 2 rows affected
$ php -d open_basedir=/home sample.php 
Query failed: ERRNO=(1148) The used command is not allowed with this MySQL version
$ php -d open_basedir=/tmp sample.php 
Query failed: ERRNO=(1148) The used command is not allowed with this MySQL version

$ scl enable php55 bash
$ php sample.php 
Query run successfully. 2 rows affected
$ php -d open_basedir=/home sample.php 
Query failed: ERRNO=(1148) The used command is not allowed with this MySQL version
$ php -d open_basedir=/tmp sample.php 
Query failed: ERRNO=(1148) The used command is not allowed with this MySQL version

Newer versions work as expected

$ scl enable rh-php56 bash
$ php sample.php 
Query run successfully. 2 rows affected
$ php -d open_basedir=/home sample.php 
Query run successfully. 2 rows affected
$ php -d open_basedir=/tmp sample.php 
Query failed: ERRNO=(2000) open_basedir restriction in effect. Unable to open file

$ scl enable rh-php70 bash
$ php sample.php 
Query run successfully. 2 rows affected
$ php -d open_basedir=/home sample.php 
Query run successfully. 2 rows affected
$ php -d open_basedir=/tmp sample.php 
Query failed: ERRNO=(2000) open_basedir restriction in effect. Unable to open file

Comment 8 Chris Williams 2017-06-07 22:17:40 UTC
Red Hat Enterprise Linux 6 transitioned to the Production 3 Phase on May 10, 2017.  During the Production 3 Phase, Critical impact Security Advisories (RHSAs) and selected Urgent Priority Bug Fix Advisories (RHBAs) may be released as they become available.

The official life cycle policy can be reviewed here:

http://redhat.com/rhel/lifecycle

This issue does not appear to meet the inclusion criteria for the Production Phase 3 and will be marked as CLOSED/WONTFIX. If this remains a critical requirement, please contact Red Hat Customer Support to request a re-evaluation of the issue, citing a clear business justification.  Red Hat Customer Support can be contacted via the Red Hat Customer Portal at the following URL:

https://access.redhat.com


Note You need to log in before you can comment on or make changes to this bug.