php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21625 --with-config-file-scan-dir
Submitted: 2003-01-13 17:10 UTC Modified: 2003-01-26 10:41 UTC
From: oden dot eriksson at linux-mandrake dot com Assigned: iliaa (profile)
Status: Closed Package: PHP options/info functions
PHP Version: 4.3.0 OS: Mandrake Linux 9.0/Cooker
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: oden dot eriksson at linux-mandrake dot com
New email:
PHP Version: OS:

 

 [2003-01-13 17:10 UTC] oden dot eriksson at linux-mandrake dot com
Hi.

This "--with-config-file-scan-dir=/etc/php" is wierd. When compiled as in Mandrake Linux 9.0/Cooker the included files from /etc/php/ is randomly listed when viewed in phpinfo(). Here's an example:

This phpinfo.html file was generated from a build from source: http://d-srv.com/Cooker/PRE/phpinfo.html

This phpinfo.html file was generated from a RPM build as in/for Mandrake Linux 9.0/Cooker: http://d-srv.com/Cooker/phpinfo.html

Also I noticed that php scans recursivly in this /etc/php/ directory which is not very nice (or maybe it's per design?).

Chears.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-13 19:03 UTC] sniper@php.net
What do you mean with 'randomly listed' ?
Listed in random order or only some files are listed..?

 [2003-01-13 19:42 UTC] jmdault at mandrakesoft dot com
php_ini.c uses readdir, which gives all the files on the directory, *but
in the order of the filesystem*. ie, it's acting like "ls -U", instead
of just "ls".

The problem is that there is no way of knowing which file will be loaded
first and which one will be loaded last, with causes problems with the
way Mandrake loads extensions, as we create ini files in the format
16_dba.ini ... 52_xslt.ini. Those files contain the "extention =3D"
directive, so that modules can be loaded in the right order.

For tricky extensions, like recode (who has to be loaded first), apc and
pspell (who have to be loaded last), we need to be able to control the
load order of the ini files.

I enclose a small hack I made using scandir and alphasort. It should
work on BSD and Linux systems, maybe on other platforms, so we should
use ifdefines on platforms that do not support it.

Regards,

Jean-Michel Dault
MandrakeSoft Apache/PHP packager
 [2003-01-13 19:46 UTC] jmdault at mandrakesoft dot com
Is there a way to cleanly add a patch to bugs.php.net? 

I e-mailed it to sniper and oden, but anyways, here it is. Hope it's readable...

--- php-4.3.0/main/php_ini.c.orig       2003-01-13 18:17:18.000000000 -0400
+++ php-4.3.0/main/php_ini.c    2003-01-13 19:03:23.000000000 -0400
@@ -30,6 +30,9 @@
 #include "zend_highlight.h"
 #include "SAPI.h"
 #include "php_main.h"
+#include <sys/types.h>
+#include <sys/dir.h>
+extern  int alphasort();
=20
 #ifndef S_ISREG
 #define S_ISREG(mode)   (((mode) & S_IFMT) =3D=3D S_IFREG)
@@ -232,6 +235,8 @@
        zend_file_handle fh;
        DIR *dirp =3D NULL;
        struct dirent *dir_entry;
+       struct dirent **inifiles;
+       int inicount,i;
        struct stat sb;
        char ini_file[MAXPATHLEN];
        char *p;
@@ -400,10 +405,11 @@
                dirp =3D VCWD_OPENDIR(PHP_CONFIG_FILE_SCAN_DIR);
                if (dirp) {
                        fh.type =3D ZEND_HANDLE_FP;
-                       while ((dir_entry =3D readdir(dirp)) !=3D NULL) {
+                       inicount =3D scandir(PHP_CONFIG_FILE_SCAN_DIR, &inifiles, NULL, alphaso=
rt);
+                       for(i=3D1;i<inicount+1;++i) {
                                /* check for a .ini extension */
-                               if ((p =3D strrchr(dir_entry->d_name,'.')) && strcmp(p,".ini")) contin=
ue;
-                               snprintf(ini_file, MAXPATHLEN, "%s%c%s", PHP_CONFIG_FILE_SCAN_DIR, DEF=
AULT_SLASH, dir_entry->d_name);
+                               if ((p =3D strrchr(inifiles[i-1]->d_name,'.')) && strcmp(p,".ini")) co=
ntinue;
+                               snprintf(ini_file, MAXPATHLEN, "%s%c%s", PHP_CONFIG_FILE_SCAN_DIR, DEF=
AULT_SLASH, inifiles[i-1]->d_name);
                                if (VCWD_STAT(ini_file, &sb) =3D=3D 0) {
                                        if (S_ISREG(sb.st_mode)) {
                                                if ((fh.handle.fp =3D VCWD_FOPEN(ini_file, "r"))) {
 [2003-01-14 00:43 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
 [2003-01-14 00:44 UTC] derick@php.net
oops, sorry
 [2003-01-25 15:15 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2003-01-25 17:53 UTC] shane@php.net
This patch has broken the windows builds.
 [2003-01-26 10:41 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jun 03 20:01:26 2020 UTC