SVN: toys/rsget.pl/RSGet/Main.pm

sparky sparky at pld-linux.org
Mon Oct 12 00:08:31 CEST 2009


Author: sparky
Date: Mon Oct 12 00:08:30 2009
New Revision: 10757

Modified:
   toys/rsget.pl/RSGet/Main.pm
Log:
- check user settings


Modified: toys/rsget.pl/RSGet/Main.pm
==============================================================================
--- toys/rsget.pl/RSGet/Main.pm	(original)
+++ toys/rsget.pl/RSGet/Main.pm	Mon Oct 12 00:08:30 2009
@@ -55,7 +55,7 @@
 	set_rev $main_rev;
 
 	print_help() if $help;
-	check_settings();
+	check_settings( \%main::settings );
 
 	$SIG{CHLD} = "IGNORE";
 	maybe_update( $argv );
@@ -128,9 +128,11 @@
 
 sub check_settings
 {
+	my $settings = shift;
+	my $user = shift;
 	my $die = 0;
-	foreach my $s ( sort keys %main::settings ) {
-		my $v = $main::settings{ $s };
+	foreach my $s ( sort keys %$settings ) {
+		my $v = $settings->{ $s };
 		my $def = $main::def_settings{ $s };
 		unless ( $def ) {
 			warn "There is no setting '$s' -- defined in $v->[1].\n";
@@ -145,6 +147,11 @@
 				next;
 			}
 		}
+		if ( $user and not $def->{user} ) {
+			warn "Setting '$s' is global, users cannot have it set -- defined in $v->[1].\n";
+			$die = 1;
+			next;
+		}
 	}
 	die "ERROR: Found invalid settings.\n" if $die;
 }
@@ -194,14 +201,19 @@
 		} elsif ( /^\s*([a-z_]+)\s*=\s*(.*?)\s*$/ ) {
 			die "User not defined, at user config file, line ($line):\n$_\n"
 				unless $user;
-			$usettings{ $user }->{$1} = [ $2, "user config file, line $line" ];
+			$usettings{ $user }->{$1} = [ $2, "user config file, section [$user], line $line" ];
 			next;
 		}
 		warn "Incorrect config line: $_\n";
 	}
 	close F_IN;
 
-
+	foreach my $user ( sort keys %usettings ) {
+		eval {
+			check_settings( $usettings{ $user }, $user );
+		}
+	}
+	die $@ if $@;
 }
 
 sub set_interfaces


More information about the pld-cvs-commit mailing list