82355

PHP open_basedir with UNC path

Question:

Running PHP 5.3.1 on a Windows server, I have to modify a PHP script to access XML files on a network share. For various reasons the files cannot be placed on the PHP server, and I am not allowed to create a mapped drive on the PHP server so I have to modify the open_basedir parameter in PHP.ini to include the UNC path to the share, e.g.:

open_basedir = "E:\inetpub\;E:\DB_HubDataFiles\;\\stdmfps01\inter-departements$\CVSC-CDT-Estimation-Cedule\"

However when I try to access files on the share I get the "open_basedir restriction in effect" error. I am trying to access the files as follows:

$jobfilename = "//stdmfps01/inter-departements$/CVSC-CDT-Estimation-Cedule/" .$job . ".xml"; if (file_exists($jobfilename)) { $jobxml = simplexml_load_file($jobfilename); etc...

I have been assured that it is not a problem of rights, and anyway the error indicates a problem with open_basedir. So my questions are:

<ol><li>does open_basedir handle UNC paths under Windows (I have seen conflicting statements about this)?</li> <li>if so is there some problem with my syntax?</li> <li>do I have other options than using open_basedir?</li> </ol>

Thanks.

Answer1:

Anyway, here's what ended up working for me, even if I am not totally clear why:

In php.ini changed the open_basedir parameter to use the IP address instead of the server name, and used the parent directory of the directory where my files are located, instead of the directory itself:

\\\nnn.nnn.nnn.nnn\inter-departements$\

instead of:

\\servername\inter-departements$\CVSC-CDT-Estimation-Cedule\

In the PHP script used the IP address as well:

$jobfile = "//nnn.nnn.nnn.nnn/inter-departements$/CVSC-CDT-Estimation-Cedule/" . ($jobid) . ".xml";

Answer2:

This worked for me: Replace the backslashes with slashes

open_basedir = "E:\inetpub\;E:\DB_HubDataFiles\;//stdmfps01/inter-departements$/CVSC-CDT-Estimation-Cedule/"

Recommend

  • RegEx to split string based on operators and retain operator in answer
  • MYSQL, using unique table names VS using ids
  • Element style not allowed as child of element body in this context ( not validating)
  • Working with Bluetooth in android kernel development linux
  • View Animation (Resizing a Ball)
  • Connect my Activity, Service and BroadcastListener
  • How can using cooperative groups feature of CUDA in windows
  • Python multiprocessing: understanding logic behind `chunksize`
  • python multiprocess update dictionary synchronously
  • tag partial tree vs full trunk in svn
  • pushd \\\\network\\path returns CMD does not support UNC paths as current directories
  • Convenient access to members of raw pointers?
  • How to get the computer name using the IP Address [closed]
  • Can't create a file in C:\\inetpub\\wwwroot programmatically
  • transparent access to files on Samba shares on Linux et al. using C++ IO streams
  • Threads have almost no overhead; processes have considerable overhead. What does it mean? [closed]
  • How can my Java program be used to open a file when the file is double clicked? [closed]
  • How to really understand robocopy return code of 2
  • Transfer data from Windows Service to Console Application repeatedly
  • Inter change blue and red channels in bitmap in android
  • How can I get a list of all open named pipes in Windows and avoiding possible exceptions?
  • Need to find Default Web Site's Home Directory in IIS
  • Chaining multiple async functions in Swift
  • How to get minimal absolute path from relative path without any permission checks?
  • Enabling domxml in php
  • Change of MySQL database location not working
  • Changing MySQL charset to UTF8 on linux so it will work with JDBC
  • Cannot get the UserManager class
  • Unable to decode certificate at client new X509Certificate2()
  • Install PHP intl extension on MacOS
  • Needing to do .toArray() to get output of mongodb .find() on key name not value
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • ORA-29908: missing primary invocation for ancillary operator
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Buffer size for converting unsigned long to string
  • Hits per day in Google Big Query
  • How to get Windows thread pool to call class member function?