Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configuration dirs #77

Open
mfn opened this issue Dec 6, 2014 · 5 comments
Open

Add support for configuration dirs #77

mfn opened this issue Dec 6, 2014 · 5 comments

Comments

@mfn
Copy link

mfn commented Dec 6, 2014

PHP has a setting, which set by default on e.g. Debian/Ubuntu, to load additional configuration files.

Looking at the output of iniscan scan --help I don't see an easy way to mimic this behavior quickly.

Suggestion: let --path also accept a directory by automatically reading all *.ini files in there; that's how PHP itself works

Another observation / suggestion:
Since providing a file/dir (=path) is essentially the required thing to perform anything useful I would suggest to simply drop --path option and use Symfonys arguments which don't require that prefix, effectively turning

iniscan scan --path foo.ini into iniscan scan foo.ini

This would also allow it easier to specify multiple filers, e.g. iniscan scan /etc/php5/cli/conf.d/*.ini

@mfn mfn changed the title Add support for configuratin dirs Add support for configuration dirs Dec 6, 2014
@enygma
Copy link
Member

enygma commented Dec 7, 2014

Yeah, I agree - I think that's a good way to go with it. It does seem more like a primary thing to have rather than an "option" per se.

@enygma
Copy link
Member

enygma commented Aug 12, 2015

@mfn any chance you could whip this up in a PR? :) I think it'd be a great addition to the tool.

@mfn
Copy link
Author

mfn commented Nov 19, 2019

Issue not relevant to me anymore 🤷‍♀️ => closing

@mfn mfn closed this as completed Nov 19, 2019
@c33s
Copy link

c33s commented Nov 20, 2019

@mfn but maybe for others ;)

please reopen

@mfn mfn reopened this Nov 20, 2019
@noraj
Copy link

noraj commented Jun 16, 2022

The thing is for Apache HTTP Server for example you have an include statement like IncludeOptional conf-enabled/*.conf in apache2.conf but for PHP there is not such a thing. The fact the PHP will load ini files from the conf.d in addition to php.ini is not defined the the PHP configuration itself, there is no include statement in php.ini, it's defined during the PHP compilation with an option like --with-config-file-scan-dir=/etc/php5/$SAPI/conf.d. If running from the audited system directly there is maybe a way to find the value of this compilation flag to know where to read additional ini files but if running iniscan offline (extracting the /etc/php directory from the target and running iniscan on an audit machine) there is absolutely no way to automatically tell by reading php.ini if and where there are additional ini files. So I guess the only way to do it properly is by specifying the path manually. For example: iniscan scan --path /etc/php/8.1/apache2/apache2.conf --scan-dir /etc/php/8.1/apache2/conf.d.

Also it's important to note that ini files in conf.d can override configuration keys already present in php.ini, so to solve the config one has to take php.ini then append 10-mysqlnd.ini then append 20-curl.ini and so on alphabetically. When all the file are concatenated only the last key value must be taken into account.

TL;DR

Right now the workaround is: cat php.ini conf.d/*.ini > /tmp/php_concat.ini and then iniscan scan --path /tmp/php_concat.ini

Information about how php.ini loads extra files

[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.

; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
; 1. SAPI module specific location.
; 2. The PHPRC environment variable. (As of PHP 5.2.0)
; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0)
; 4. Current working directory (except CLI)
; 5. The web server's directory (for SAPI modules), or directory of PHP
; (otherwise in Windows)
; 6. The directory from the --with-config-file-path compile time option, or the
; Windows directory (usually C:\windows)
; See the PHP docs for more specific information.
; http://php.net/configuration.file

and also https://www.php.net/configuration.file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants