PHP: open_basedir restriction in effect

Elektronik- och mekanikrelaterad mjukvara/litteratur. (T.ex schema-CAD, simulering, böcker, manualer mm. OS-problem hör inte hit!)
bos
Inlägg: 2308
Blev medlem: 24 februari 2007, 23:29:15
Kontakt:

PHP: open_basedir restriction in effect

Inlägg av bos »

Igår skapade jag på webhotellet en ny subdomän och dit kopierade jag hela filträdet för den nuvarande hemsidan (för att på så sätt kunna jobba "ostört" med utvecklingen). Allt funkade prima.

Tills idag. När jag försöker komma åt http://new.grastorpsik.se/ får jag det här:
Warning: main(): open_basedir restriction in effect. File(../includes/session.php) is not within the allowed path(s): (/usr/local/psa/home/vhosts/grastorpsik.se/subdomains/new/httpdocs:/tmp) in /usr/local/psa/home/vhosts/grastorpsik.se/subdomains/new/httpdocs/admin/articles.php on line 14

Warning: main(../includes/session.php): failed to open stream: Operation not permitted in /usr/local/psa/home/vhosts/grastorpsik.se/subdomains/new/httpdocs/admin/articles.php on line 14

Warning: main(): open_basedir restriction in effect. File(../includes/session.php) is not within the allowed path(s): (/usr/local/psa/home/vhosts/grastorpsik.se/subdomains/new/httpdocs:/tmp) in /usr/local/psa/home/vhosts/grastorpsik.se/subdomains/new/httpdocs/admin/articles.php on line 14

Warning: main(../includes/session.php): failed to open stream: Operation not permitted in /usr/local/psa/home/vhosts/grastorpsik.se/subdomains/new/httpdocs/admin/articles.php on line 14

Fatal error: main(): Failed opening required '../includes/session.php' (include_path='.:/usr/local/psa/apache/share/pear') in /usr/local/psa/home/vhosts/grastorpsik.se/subdomains/new/httpdocs/admin/articles.php on line 14
Jag har inte ändrat en rad kod i articles.php sen igår. articles.php anropas från /admin/index.php, och om jag stoppar alla include-rader som finns - i articles.php - i index.php och kommenterar bort dem i article.php, så funkar det.

Men jag kaninte ungå att undra, vad var det som gick sönder? http://se.php.net/manual/en/features.sa ... ctions.php gör mig inte klokare, snarare mer förvirrad och irriterad.
Muppis
Inlägg: 275
Blev medlem: 15 februari 2007, 10:26:28
Ort: Halmstad

Inlägg av Muppis »

Detta är texten som förklarar open_basedir. Saxat ifrån http://se.php.net/manual/en/features.safe-mode.php

Ditt webbhotell borde erbjuda lite felsökning och avhjälpning, verkar vara ett fel ifrån deras sida då http://new.grastorpsik.se/includes/session.php går att nå.
open_basedir string

Limit the files that can be opened by PHP to the specified directory-tree, including the file itself. This directive is NOT affected by whether Safe Mode is turned On or Off.

When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to open it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. If the file doesn't exist then the symlink couldn't be resolved and the filename is compared to (a resolved) open_basedir .

The special value . indicates that the working directory of the script will be used as the base-directory. This is, however, a little dangerous as the working directory of the script can easily be changed with chdir().

In httpd.conf, open_basedir can be turned off (e.g. for some virtual hosts) the same way as any other configuration directive with "php_admin_value open_basedir none".

Under Windows, separate the directories with a semicolon. On all other systems, separate the directories with a colon. As an Apache module, open_basedir paths from parent directories are now automatically inherited.

The restriction specified with open_basedir is actually a prefix, not a directory name. This means that "open_basedir = /dir/incl" also allows access to "/dir/include" and "/dir/incls" if they exist. When you want to restrict access to only the specified directory, end with a slash. For example: "open_basedir = /dir/incl/"

The default is to allow all files to be opened.
bos
Inlägg: 2308
Blev medlem: 24 februari 2007, 23:29:15
Kontakt:

Inlägg av bos »

Webhotellet hjälpte mig nu med problemet. Felet var att jag hade en relativ sökväg i include(), och supporten berättade för mig att när man använder nästlade includes så är det ursprungsdokumentet som bestämmer vilken den relativa pathen ska vara. Den inre include-filen gav en relativ path som gick utanför filträdet, och då sket sig allt.
Skriv svar