From 880ba4090cd8af757f17604af3284afab6fd198c Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 31 Jul 2007 21:38:03 +0000 Subject: * dropped support for CSV databases, as they are simply not good enough * added support for db-user and db-passwd: + the mysql backend will now ask for the password upon connect + you can specify the db-user and db-passwd via slxsettings (so you never have to enter it manually afterwards) * slxsettings now checks db-type against an explicit pattern to avoid problems caused by typos git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1295 95ad53e4-c205-0410-b2fa-d234c58c8868 --- bin/slxsettings | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/slxsettings b/bin/slxsettings index e6daf0cf..907f6f60 100755 --- a/bin/slxsettings +++ b/bin/slxsettings @@ -58,8 +58,17 @@ if ($versionReq) { exit 1; } +if ($> != 0) { + die _tr("Sorry, this script can only be executed by the superuser!\n"); +} + openslxInit() or pod2usage(2); +# some settings must match a certain pattern: +my %configPattern = ( + 'db-type' => '(SQLite|mysql)', +); + # the remaining cmdline arguments are set or reset actions, each followed # by a single argument: while (scalar @ARGV) { @@ -89,6 +98,11 @@ while (scalar @ARGV) { # fetch current content of local settings file... my $fileName = "$openslxConfig{'config-path'}/settings"; +if (!-e $fileName) { + # create empty default settings file with tight mode (root-only access) + # [I know this isn't *secure* as such, but it's still better than nothing] + slxsystem("touch $fileName && chmod 0600 $fileName"); +} my $configObj = Config::General->new( -ConfigFile => $fileName, -SplitDelimiter => '\s*=\s*', @@ -109,6 +123,12 @@ foreach my $key (keys %givenSettings) { if ($key =~ m{^(base-path|config-path)$}) { die _tr("option '%s' is fixed!", $key); } + if (exists $configPattern{$key} && $value !~ m{$configPattern{$key}}) { + die _tr( + "option '%s' must match pattern '%s'!", $key, $configPattern{$key} + ); + } + vlog(0, _tr("setting %s to '%s'", $key, $value)) unless $quiet; my $externalKey = externalKeyFor($key); if (!exists $settings{$externalKey} || $settings{$externalKey} ne $value) { @@ -162,8 +182,13 @@ if (!keys %changed) { my @extSettings = grep { !exists $cmdlineConfig{$_} } keys %openslxConfig; foreach my $key (sort @extSettings) { next if $key =~ m[^(base-path|config-path)$]; - my $val = $openslxConfig{$key} || ''; - print qq[\t$key='$val'\n]; + my $val = $openslxConfig{$key}; + if (defined $val) { + print qq[\t$key='$val'\n]; + } + else { + print qq[\t$key=\n]; + } } } @@ -280,9 +305,9 @@ Default is $SLX_DB_SPEC (usually empty as it will be built automatically). =item B<< db-type= >> -Sets the type of database to connect to (CSV, SQLite, mysql, ...). +Sets the type of database to connect to (SQLite, mysql, ...). -Default $SLX_DB_TYPE (usually C). +Default $SLX_DB_TYPE (usually C). =item B<< locale= >> -- cgit v1.2.3-55-g7522