diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2011-01-05 15:50:25 +0100 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2011-01-05 15:50:25 +0100 |
commit | cbcd00f3a96af5213c2ce7ad4d49a84a80f42f72 (patch) | |
tree | 9f1a9111b9ca32b06ff327bdea73156c2d56090d /fripost-passwd | |
parent | 3cfc25a53829c3121e7ca8190bc8de72e3d7f051 (diff) |
Add fripost-passwd
Diffstat (limited to 'fripost-passwd')
-rwxr-xr-x | fripost-passwd | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/fripost-passwd b/fripost-passwd new file mode 100755 index 0000000..ad835b0 --- /dev/null +++ b/fripost-passwd @@ -0,0 +1,75 @@ +#!/usr/bin/perl + +use 5.010_000; +use warnings; +use strict; + +=head1 NAME + +fripost-passwd - Change password of user + +=cut + +use FindBin qw($Bin); +use lib "$Bin/lib"; + +our $VERSION = '0.01'; + +use Fripost::Password; +use Fripost::Prompt; +use Fripost::Schema; +use Getopt::Long; +use YAML::Syck; + +my $username = $ARGV[0]; +$username //= prompt_username(); +my $password = prompt_password(); + +# Show the information that will be inserted +say "Password: $password"; +say "Salted MD5: " . smd5($password); + +## Get command line options +our $conf = LoadFile('default.yml'); + +GetOptions( + 'dbi_dsn' => \$conf->{dbi_dsn}, + 'admuser=s' => \$conf->{admuser}, + 'admpass=s' => \$conf->{admpass}, + 'pretend' => \$conf->{pretend}, +) or die "Unable to get command line options."; + +if ($conf->{pretend}) { + say "Nothing to do since we are pretending..."; + exit 0; +} + +# Connect to the database +my $schema = Fripost::Schema->connect( + $conf->{dbi_dsn}, $conf->{admuser}, $conf->{admpass}, {} #\%dbi_params +); + +my $row = $schema->resultset('Mailbox')->find($username); + +$row->password(smd5($password)); + +$row->update; + +say "Updated password for $username."; + +# TODO: ändra changedate vid varje insert + +=head1 AUTHOR + +Stefan Kangas C<< <skangas at skangas.se> >> + +=head1 COPYRIGHT + +Copyright 2010 Stefan Kangas. + +=head1 LICENSE + +This program is free software; you can redistribute it and/or modify it +under the same terms as perl itself. + +=cut |