UseModWiki | RecentChanges | Preferences

UseModWikiDocumentation: Functions - ConfigVariables - UseConfig

 1 = use config file,    0 = do not look for config

The config file is at $DataDir/config

Used by DoWikiRequest

Help! I tried the setting given above, but I accidentally found out wiki is actually using the default settings in the wiki.pl file. Since I thought I had disabled a bunch of stuff (using the $DataDir/config file), this could be dangerous. How can I make wiki read the config file & disregard the "default" configuration in the wiki.pl file?



Check for permissions and ownership (I am assuming you are on Apache on *NIX, but should apply for MS as well) -- DavidCollantes

DUH! Thanks for the quick shakkabukku.

the spiritual kick to the head that makes things clear :-]


Isn't it risky to save the config-file in $DataDir?
So everybody who guess my DataDir can read my config with his webbrowser and he can read the Admin-Pass. With Admin-Pass he can change unchangeble pages too... I tried to move DataDir to an directory protected by a .htaccess-file, but it didn`t work.

Answer: Protecting DataDir

It is possible to protect the DataDir with a .htaccess file. Here are instructions on how to do this with Apache.

In your Apache configuration file (found at /etc/httpd/httpd.conf on Mac & several unix systems), you need to make sure that the AllowOverride? variable is set to allow the .htaccess file to control your website's access options.

The default setting is to not allow the .htaccess file to control any access options. In the http.conf file, the first Directory configuration ruleset probably looks like this:

# First, we configure the "default" to be a very restrictive set of 
# permissions. 
<Directory />
    Options FollowSymLinks
    AllowOverride None

The "AllowOverride? None" line causes Apache to ignore the .htaccess file for all sites hosted on your server.

After the first Directory ruleset (pasted above), you should find configuration options for your site. For example, if your website lives in a directory called /www, look for the following line:

<Directory "/www">

This marks the beginning of the set of rules that Apache uses to govern the site found in /www. Be sure that AllowOverride? is set to "Limit" for this directory. My rules are pasted below (minus comments).

<Directory "/www">
    Options Indexes FollowSymLinks MultiViews ExecCGI
    AllowOverride Limit
    Order allow,deny
    Allow from all

Cool. Now you need to make a .htaccess file in your DataDir. Mine looks like this.

<limit GET>
   order deny,allow
   deny from all

The only thing left to do is restart Apache. You can do this by typing in the following line:

 sudo apachectl restart

These instructions assume you are running the Apache webserver on some kind of Unix system. Hope this helps! -raj

I had some trouble with this, too. The docs may have mentioned that I shold put the config file in the data dir, and I'd missed it... anyway, I think it would be good to raise an error if the config file cannot be found--otherwise, there's no way of knowing... Here is a patch to do that:

    if ($UseConfig) {
	    if (-f $ConfigFile?) {
	        $ConfigError? = '';
	        if (!do $ConfigFile?) {   # Some error occurred
	            $ConfigError? = $@;
	            if ($ConfigError? eq '') {
	                # Unfortunately, if the last expr returns 0, one will get a false
	                # error above.  To remain compatible with existing installs the
	                # wiki must not report an error unless there is error text in $@.
	                # (Errors in "use strict" may not have error text.)
	                # Uncomment the line below if you want to catch use strict errors.
	                #$ConfigError? = T('Unknown Error (no error text)');

	    else {
	    	require Carp;
        	croak("I could not find config file '$ConfigFile?'");

This is in the DoWikiRequest subroutine. The only thing I'm changing is that in the original, there was one if statement, "if ($UseConfig &&-f $ConfigFile?)"... and I am nesting one condition within another... and in this way allowing for the else statement if it simply cannot be found.

-- ChrisBurbridge

UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited October 8, 2006 4:44 pm by MarkusLude (diff)