Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> fopen() - Operation not permitted
artur9010
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 5.08.2015

Ostrzeżenie: (0%)
-----


Witam, chce "podmienić" wszystkie exec() które nie wymagają użycia tej funkcji (czyli np. exec('cat plik')wink.gif na fopen, niestety pojawia się tutaj drobny problem ponieważ nie mogę otworzyć tego pliku.

Kod z fopen:
  1. [root@alarmpi ~]# php -r 'fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r");'
  2. PHP Warning: fopen(): open_basedir restriction in effect. File(/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/) in Command line code on line 1
  3. PHP Warning: fopen(/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq): failed to open stream: Operation not permitted in Command line code on line 1


Kod z exec:
  1. exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $freqArray);
  2. $freq = $freqArray[0]/1000;


Wersja php:
  1. [root@alarmpi /]# php -v
  2. PHP 5.6.11 (cli) (built: Jul 10 2015 10:16:21)
  3. Copyright (c) 1997-2015 The PHP Group
  4. Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies


Ten sam błąd pojawia się przy file, file_get_contents i każdej innej funkcji która operuje na plikach.

Ten post edytował artur9010 5.08.2015, 14:39:56
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
kartin
post
Post #2





Grupa: Zarejestrowani
Postów: 246
Pomógł: 79
Dołączył: 25.05.2010

Ostrzeżenie: (0%)
-----


Co konkretnie jest niejasne w komunikacie błędu?
Cytat
open_basedir restriction in effect. File(/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/) in Command line code on line 1


Jeśli chcesz rozszerzyć dozwolone katalogi to szukaj w configu Apache
Kod
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/"
i dopisz kolejny katalog.

Ostatecznie możesz też usunąć ograniczenie, ale to jest bardzo zły pomysł.
Kod
php_admin_value open_basedir none


Po wprowadzeniu zmiana nie zapomnij o restarcie Apache.


--------------------
Jeśli ten post pomógł to kliknij przycisk po lewej stronie.
Nie pomagam przez PW, GG, e-mail, faks, telegram, znaki dymne, ...
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 10:00