r35078 - in /trunk/libdbix-password-perl/debian: README.Debian changelog patches/02-config-file.patch
roam-guest at users.alioth.debian.org
roam-guest at users.alioth.debian.org
Sat May 9 13:02:08 UTC 2009
Author: roam-guest
Date: Sat May 9 13:02:03 2009
New Revision: 35078
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=35078
Log:
Document the clearConfig() and readConfig() functions.
Modified:
trunk/libdbix-password-perl/debian/README.Debian
trunk/libdbix-password-perl/debian/changelog
trunk/libdbix-password-perl/debian/patches/02-config-file.patch
Modified: trunk/libdbix-password-perl/debian/README.Debian
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-password-perl/debian/README.Debian?rev=35078&op=diff
==============================================================================
--- trunk/libdbix-password-perl/debian/README.Debian (original)
+++ trunk/libdbix-password-perl/debian/README.Debian Sat May 9 13:02:03 2009
@@ -7,6 +7,10 @@
'v.user':'username':passwd':'port':'dbase:'connect':'driver':'host'
+Your program may also read another config file; see the DBIx::Password
+documentation on the clearConfig() and readConfig() functions for
+more information.
+
IMPORTANT NOTE IF UPGRADING FROM VERSION =< 1.8-4
------------------------------------------------
Modified: trunk/libdbix-password-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-password-perl/debian/changelog?rev=35078&op=diff
==============================================================================
--- trunk/libdbix-password-perl/debian/changelog (original)
+++ trunk/libdbix-password-perl/debian/changelog Sat May 9 13:02:03 2009
@@ -18,6 +18,7 @@
- add the Homepage control field
* New upstream release.
* Allow the module to be loaded even without a config file.
+ * Break out the config file parsing into separate functions.
-- Peter Pentchev <roam at ringlet.net> Sat, 09 May 2009 12:54:32 +0300
Modified: trunk/libdbix-password-perl/debian/patches/02-config-file.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libdbix-password-perl/debian/patches/02-config-file.patch?rev=35078&op=diff
==============================================================================
--- trunk/libdbix-password-perl/debian/patches/02-config-file.patch (original)
+++ trunk/libdbix-password-perl/debian/patches/02-config-file.patch Sat May 9 13:02:03 2009
@@ -1,9 +1,12 @@
-Read the virtual user data from a configuration file instead of
-hard-coding it into the module.
+Add the readConfig($filename) function to read the virtual user data from
+a configuration file instead of hard-coding it into the module.
+Invoke readConfig('/etc/dbix-password.conf') at module load time so
+that all users may benefit from a system-wide config file.
+Add the clearConfig() function to start the configuration from scratch.
--- a/Password.pm
+++ b/Password.pm
-@@ -7,6 +7,50 @@
+@@ -7,6 +7,64 @@
my $virtual1 = {};
@@ -32,29 +35,50 @@
+# },
+#};
+
-+#Now let's fill %virtual1 with values
-+my $config = "/etc/dbix-password.conf";
++sub clearConfig()
++{
++ $virtual1 = {};
++ return 1;
++}
+
-+if (-r $config) {
-+ open (IN,$config) || die "Opening config file $config: $!";
++sub readConfig($)
++{
++ my ($config) = @_;
++ my $f;
++ my @user;
++
++ return undef unless -r $config;
++
++ open ($f, $config) || die "Opening config file $config: $!";
+
+ my @fields = qw(user username password port database connect driver
+host);
+
-+ while (<IN>) {
++ while (<$f>) {
+ next if /^(#.*)?$/; #skip comments and blanks
-+ my @user = m/:?'([^']*)':?/g;
-+ foreach (1 .. 7) { #write fields
++ @user = m/:?'([^']*)':?/g;
++ foreach (1 .. $#fields) { #write fields
+ $virtual1->{$user[0]}->{$fields[$_]} = $user[$_];
+ };
+ $virtual1->{$user[0]}->{attributes} ||= {};
+ }
-+ close IN;
++ close $f;
++ return $user[0];
+}
++
++#Now let's fill %virtual1 with values
++readConfig('/etc/dbix-password.conf');
my %driver_cache;
-@@ -94,11 +138,11 @@
+@@ -90,15 +148,18 @@
+ DBIx::Password::getDriver($user);
+ DBIx::Password::checkVirtualUser($user);
+
++ DBIx::Password::clearConfig();
++ DBIx::Password::readConfig("$ENV{HOME}/.my.secret.file");
++
+ =head1 DESCRIPTION
Don't you hate keeping track of database passwords and such throughout
your scripts? How about the problem of changing those passwords
@@ -70,12 +94,19 @@
You can add as many as you like.
I would recommend that if you are only using this with
-@@ -127,20 +171,6 @@
+@@ -125,21 +186,13 @@
+ This is a rewrite of the module Tangent::DB that I did
+ for slashcode.
- Hope you enjoy it.
+-Hope you enjoy it.
+-
+-=head1 INSTALL
++If your program does not need the system-wide information stored
++in the /etc/dbix-password.conf file, you may use the clearConfig()
++and readConfig() functions to get the data from another source.
++At any time, readConfig() may also be used to merge the data from
++another file into the currently-loaded configuration.
--=head1 INSTALL
--
-Basically:
-
-perl Makefile.PL
@@ -87,10 +118,10 @@
-make install
-
-Be sure to answer the questions as you make the module
--
++Hope you enjoy it.
+
=head1 HOME
- To find out more information look at: http://www.tangent.org/DBIx-Password/
--- a/README
+++ b/README
@@ -14,11 +14,10 @@
More information about the Pkg-perl-cvs-commits
mailing list