diff options
-rw-r--r-- | Makefile.am | 21 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | perl/Wallet/Config.pm | 30 | ||||
-rwxr-xr-x | perl/t/config.t | 46 |
4 files changed, 82 insertions, 19 deletions
diff --git a/Makefile.am b/Makefile.am index 389c1b7..a59c119 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,16 +18,17 @@ EXTRA_DIST = LICENSE autogen client/wallet.pod config/allow-extract \ perl/Wallet/Config.pm perl/Wallet/Database.pm \ perl/Wallet/Object/Base.pm perl/Wallet/Object/Keytab.pm \ perl/Wallet/Schema.pm perl/Wallet/Server.pm perl/t/acl.t \ - perl/t/admin.t perl/t/data/README perl/t/data/keytab-fake \ - perl/t/data/keytab.conf perl/t/data/netdb.conf \ - perl/t/data/netdb-fake perl/t/init.t perl/t/keytab.t \ - perl/t/lib/Util.pm perl/t/object.t perl/t/pod.t perl/t/schema.t \ - perl/t/server.t perl/t/verifier-netdb.t perl/t/verifier.t \ - tests/TESTS tests/data/README tests/data/allow-extract \ - tests/data/cmd-fake tests/data/fake-data tests/data/fake-kadmin \ - tests/data/fake-keytab tests/data/fake-keytab-2 \ - tests/data/fake-keytab-merge tests/data/fake-keytab-old \ - tests/data/fake-srvtab tests/data/wallet.conf tests/libtest.sh + perl/t/admin.t perl/t/config.t perl/t/data/README \ + perl/t/data/keytab-fake perl/t/data/keytab.conf \ + perl/t/data/netdb.conf perl/t/data/netdb-fake perl/t/init.t \ + perl/t/keytab.t perl/t/lib/Util.pm perl/t/object.t perl/t/pod.t \ + perl/t/schema.t perl/t/server.t perl/t/verifier-netdb.t \ + perl/t/verifier.t tests/TESTS tests/data/README \ + tests/data/allow-extract tests/data/cmd-fake tests/data/fake-data \ + tests/data/fake-kadmin tests/data/fake-keytab \ + tests/data/fake-keytab-2 tests/data/fake-keytab-merge \ + tests/data/fake-keytab-old tests/data/fake-srvtab \ + tests/data/wallet.conf tests/libtest.sh noinst_LIBRARIES = portable/libportable.a util/libutil.a portable_libportable_a_SOURCES = portable/dummy.c @@ -4,6 +4,10 @@ wallet 0.8 (unreleased) Fix the wallet client to use check instead of exists. + Wallet::Config and hence the wallet server now checks for the + environment variable WALLET_CONFIG and loads configuration from the + file specified there instead of /etc/wallet/wallet.conf if it is set. + wallet 0.7 (2008-02-08) Add new exists and autocreate wallet server interfaces. The first diff --git a/perl/Wallet/Config.pm b/perl/Wallet/Config.pm index 47a45df..735e799 100644 --- a/perl/Wallet/Config.pm +++ b/perl/Wallet/Config.pm @@ -15,10 +15,10 @@ use vars qw($PATH $VERSION); # This version should be increased on any code change to this module. Always # use two digits for the minor version with a leading zero if necessary so # that it will sort properly. -$VERSION = '0.02'; +$VERSION = '0.03'; # Path to the config file to load. -$PATH = '/etc/wallet/wallet.conf'; +$PATH = $ENV{WALLET_CONFIG} || '/etc/wallet/wallet.conf'; =head1 NAME @@ -46,11 +46,12 @@ Wallet::Config - Configuration handling for the wallet server =head1 DESCRIPTION Wallet::Config encapsulates all of the site-specific configuration for the -wallet server. It is implemented as a Perl class that declares and sets the -defaults for various configuration variables and then, if it exists, loads -the file F</etc/wallet/wallet.conf>. That file should contain any -site-specific overrides to the defaults, and at least some parameters must -be set. +wallet server. It is implemented as a Perl class that declares and sets +the defaults for various configuration variables and then, if it exists, +loads the file specified by the WALLET_CONFIG environment variable or +F</etc/wallet/wallet.conf> if that environment variable isn't set. That +file should contain any site-specific overrides to the defaults, and at +least some parameters must be set. This file must be valid Perl. To set a variable, use the syntax: @@ -560,6 +561,17 @@ keytab objects for particular principals have fully-qualified hostnames: Objects that aren't of type C<keytab> or which aren't for a host-based key have no naming requirements enforced. +=head1 ENVIRONMENT + +=over 4 + +=item WALLET_CONFIG + +If this environment variable is set, it is taken to be the path to the +wallet configuration file to load instead of F</etc/wallet/wallet.conf>. + +=back + =cut # Now, load the configuration file so that it can override the defaults. @@ -574,8 +586,8 @@ __END__ DBI(3), Wallet::Object::Keytab(3), Wallet::Server(3), wallet-backend(8) -This module is part of the wallet system. The current version is available -from L<http://www.eyrie.org/~eagle/software/wallet/>. +This module is part of the wallet system. The current version is +available from L<http://www.eyrie.org/~eagle/software/wallet/>. =head1 AUTHOR diff --git a/perl/t/config.t b/perl/t/config.t new file mode 100755 index 0000000..0d159dc --- /dev/null +++ b/perl/t/config.t @@ -0,0 +1,46 @@ +#!/usr/bin/perl -w +# $Id$ +# +# t/config.t -- Tests for the wallet server configuration. +# +# Written by Russ Allbery <rra@stanford.edu> +# Copyright 2008 Board of Trustees, Leland Stanford Jr. University +# +# See LICENSE for licensing terms. + +use Test::More tests => 7; + +# Silence warnings since we're not using use. +package Wallet::Config; +our $DB_DRIVER; +our $KEYTAB_AFS_KASETKEY; +our $KEYTAB_FLAGS; +our $KEYTAB_KADMIN; +package main; + +# Load with a nonexistent file. +$ENV{WALLET_CONFIG} = '/path/to/nonexistent/file'; +eval { require Wallet::Config }; +is ($@, '', 'Loading Wallet::Config with nonexistent config file works'); +is ($Wallet::Config::KEYTAB_FLAGS, '-clearpolicy', + ' and KEYTAB_FLAGS is correct'); +is ($Wallet::Config::KEYTAB_KADMIN, 'kadmin', + ' and KEYTAB_KADMIN is correct'); +is ($Wallet::Config::KEYTAB_AFS_KASETKEY, 'kasetkey', + ' and KEYTAB_AFS_KASETKEY is correct'); +is ($Wallet::Config::DB_DRIVER, undef, ' and DB_DRIVER is unset'); + +# Create a configuration file with a single setting. +open (CONFIG, '>', 'test-wallet.conf') + or die "$0: cannot create test-wallet.conf: $!\n"; +print CONFIG '$DB_DRIVER = "mysql";', "\n"; +print CONFIG "1;\n"; +close CONFIG; +$ENV{WALLET_CONFIG} = './test-wallet.conf'; + +# Reload the module and be sure it picks up that configuration file. +delete $INC{'Wallet/Config.pm'}; +eval { require Wallet::Config }; +is ($@, '', 'Loading Wallet::Config with new config file works'); +is ($Wallet::Config::DB_DRIVER, 'mysql', ' and now DB_DRIVER is set'); +unlink 'test-wallet.conf'; |