/[smeserver]/rpms/e-smith-lib/sme9/e-smith-lib-2.4.0.set-secret_password-creation.patch
ViewVC logotype

Annotation of /rpms/e-smith-lib/sme9/e-smith-lib-2.4.0.set-secret_password-creation.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Thu Jun 25 15:51:01 2015 UTC (9 years, 5 months ago) by stephdl
Branch: MAIN
CVS Tags: e-smith-lib-2_4_0-17_el6_sme, e-smith-lib-2_4_0-18_el6_sme, e-smith-lib-2_4_0-15_el6_sme, e-smith-lib-2_4_0-16_el6_sme, HEAD
* Thu Jun 18 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 2.4.0-15.sme
- Added a password creation (set_secret) [SME : 8943]
- code from Charlie Brady <charlieb-contribs-bugzilla@budge.apana.org.au>

1 stephdl 1.1 diff -Nur e-smith-lib-2.4.0.old.8943/root/usr/share/perl5/vendor_perl/esmith/util.pm e-smith-lib-2.4.0.8943/root/usr/share/perl5/vendor_perl/esmith/util.pm
2     --- e-smith-lib-2.4.0.old.8943/root/usr/share/perl5/vendor_perl/esmith/util.pm 2015-06-18 21:51:44.062723966 +0200
3     +++ e-smith-lib-2.4.0.8943/root/usr/share/perl5/vendor_perl/esmith/util.pm 2015-06-22 03:04:11.449937443 +0200
4     @@ -21,7 +21,7 @@
5     use File::Basename;
6     use File::stat;
7     use FileHandle;
8     -
9     +use Data::UUID;
10     =pod
11    
12     =head1 NAME
13     @@ -901,6 +901,55 @@
14    
15     =pod
16    
17     +=head2 set_secret()
18     +
19     +Shortcut method to create and set a password property on a record without having to extract the record first.
20     +
21     +The password creation is based on an UID of 64 bits (Data::UUID). If the optional type option is passed,
22     +it will be used to create the record if it does not already exist. Otherwise, a default 'service' type
23     +will be used to create the record.
24     +
25     +The $DB is expected to be an already open esmith::DB object, so that an open DB in the caller can be re-used.
26     +Therefore in a migrate fragment you could just use $DB.
27     +
28     + esmith::util::set_secret($DB, '$key','$property'[,type=>'$type']);
29     +
30     +For example in /etc/e-smith/db/configuration/migrate/90roundcube
31     + {
32     + esmith::util::set_secret($DB, 'foo','DbPassword',type=>'service');
33     + }
34     +
35     +The password will be generated to the property 'DbPassword' in the 'foo' key.
36     +
37     +If you want to change the database then you must open another esmith::DB objet
38     + {
39     + my $database = esmith::ConfigDB->open('accounts') or
40     + die esmith::DB->error;
41     + esmith::util::set_secret($database, 'foo','DbPassword',type=>'user');
42     + }
43     +
44     +=cut
45     +
46     +sub set_secret
47     +
48     +{
49     + my ($db, $key, $prop, %options) = @_;
50     + %options = (type => 'service', %options);
51     +
52     + my $record = $db->get($key) ||
53     + $db->new_record($key, \%options) or
54     + die "Error creating new record";
55     +
56     + return if $db->get_prop($key,$prop);
57     +
58     + $record->merge_props(%options, $prop =>
59     + Data::UUID->new->create_b64());
60     +}
61     +
62     +
63     +
64     +=pod
65     +
66     =head1 HIGH LEVEL PASSWORD UTILITIES
67    
68     High-level password-changing utilities. These utilities
69     @@ -1324,6 +1373,7 @@
70     return 1;
71     }
72    
73     +
74     =head1 AUTHOR
75    
76     Mitel Networks Corp.

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed