+{
+ my $file = shift;
+
+ my $config = parse_config($file);
+
+ $config->{'errors'} = parse_config($config->{'error_file'});
+ $config->{'templates'} = parse_config($config->{'template_file'});
+
+ # Check if we have to parse the user config file
+
+ if($ENV{'REMOTE_USER'} && $config->{'userconf_file'} && -f $config->{'userconf_file'})
+ {
+ my $userconf = parse_config($config->{'userconf_file'});
+
+ # Parse aliases (we use references, so we won't get a memory
+ # problem so soon...)
+
+ foreach my $user(keys(%$userconf))
+ {
+ if(my $aliases = $userconf->{$user}->{'aliases'})
+ {
+ foreach my $alias(parse_line('\s+',0,$aliases))
+ {
+ $userconf->{$alias} = $userconf->{$user} unless($userconf->{$alias});
+ }
+ }
+ }
+
+ if($userconf->{$ENV{'REMOTE_USER'}})
+ {
+ # The current HTTP Auth user has got an individual configuration
+ # Overwrite the default values
+
+ my $new_conf = $userconf->{$ENV{'REMOTE_USER'}};
+
+ $config->{'fileroot'} = $new_conf->{'fileroot'} if($new_conf->{'fileroot'});
+ $config->{'httproot'} = $new_conf->{'httproot'} if($new_conf->{'httproot'});
+ $config->{'startdir'} = $new_conf->{'startdir'} if($new_conf->{'startdir'});
+
+ $config->{'forbidden'} = $new_conf->{'forbidden'} if(defined $new_conf->{'forbidden'});
+ $config->{'disable_commands'} = $new_conf->{'disable_commands'} if(defined $new_conf->{'disable_commands'});
+
+ $config->{'hide_dot_files'} = $new_conf->{'hide_dot_files'} if(defined $new_conf->{'hide_dot_files'});
+
+ $config->{'user_config'} = 1;
+ }
+ }
+
+ # Parse list of forbidden files
+
+ if($config->{'forbidden'})
+ {
+ my @files;
+
+ foreach my $file(parse_line('\s+',0,$config->{'forbidden'}))
+ {
+ $file =~ tr!\\!/!;
+
+ $file = '/'.$file unless($file =~ m!^/!);
+ $file =~ s!/+$!!g;
+
+ push(@files,$file);
+ }
+
+ $config->{'forbidden'} = \@files;
+ }
+ else
+ {
+ $config->{'forbidden'} = [];
+ }
+
+ # Parse list of disabled commands (we need some universal code!)
+
+ if($config->{'disable_commands'})
+ {
+ my @commands;
+
+ foreach my $command(parse_line('\s+',0,$config->{'disable_commands'}))
+ {
+ push(@commands,$command) unless(substr($command,0,1) eq '@');
+
+ if(exists($disable_dependency{$command}) && $disable_dependency{$command})
+ {
+ if(ref($disable_dependency{$command}) eq 'ARRAY')
+ {
+ push(@commands,@{$disable_dependency{$command}});
+ }
+ else
+ {
+ push(@commands,$disable_dependency{$command});
+ }
+ }
+ }
+
+ $config->{'disable_commands'} = \@commands;
+ }
+ else
+ {
+ $config->{'disable_commands'} = [];
+ }
+
+ return $config;
+}
+
+# parse_config()
+#
+# Parse a configuration file
+#
+# Params: Path to configuration file
+#
+# Return: Configuration (Hash Reference)
+
+sub parse_config($)