--- /dev/null
+#!/usr/bin/env perl
+
+use File::Which;
+use App::EzPz::UserStore;
+use strictures 1;
+
+die "Usage: ezpz-admin-repl ezmlm-bindir htpasswd-file"
+ unless @ARGV == 2;
+
+{
+ package Eval::WithLexicals::Scratchpad;
+
+ use vars qw($users);
+
+ $users = App::EzPz::UserStore->new(
+ ezmlm_bindir => $ARGV[0],
+ htpasswd_file => $ARGV[1],
+ );
+}
+
+do +which('tinyrepl');
+
+exit 0;
--- /dev/null
+package App::EzPz::User;
+
+use Authen::Htpasswd::User;
+use Moo;
+
+has _htpasswd_user => (
+ is => 'ro', init_arg => 'htpasswd_user', required => 1,
+ handles => [ qw(username password check_password) ],
+);
+
+around BUILDARGS => sub {
+ my ($orig, $self) = (shift, shift);
+ my $args = $self->$orig(@_);
+ $args->{htpasswd_user} ||=
+ Authen::Htpasswd::User->new(
+ delete @{$args}{qw(username password)}
+ );
+ return $args
+};
+
+1;
--- /dev/null
+package App::EzPz::UserStore;
+
+use App::EzPz::User;
+use Scalar::Util 'blessed';
+use Authen::Htpasswd;
+use Moo;
+
+has ezmlm_bindir => (is => 'ro', required => 1);
+
+has htpasswd_file => (is => 'ro', required => 1);
+
+has _htpasswd => (is => 'lazy');
+
+sub _build__htpasswd {
+ my ($self) = @_;
+ return Authen::Htpasswd->new($self->htpasswd_file);
+}
+
+sub all {
+ my ($self) = @_;
+ return map $self->_inflate_user($_), $self->_htpasswd->all_users;
+}
+
+sub get {
+ my ($self, $name) = @_;
+ if (my $htp_user = $self->_htpasswd->lookup_user($name)) {
+ return $self->_inflate_user($htp_user);
+ } else {
+ return undef;
+ }
+}
+
+sub add {
+ my ($self, $user) = @_;
+ unless (blessed($user)) {
+ $user = App::EzPz::User->new($user);
+ }
+ my $htp_file = $self->_htpasswd;
+ my $htp_user = $user->_htpasswd_user;
+ $htp_file->add_user($htp_user);
+ $htp_user->file($htp_file);
+ return $user;
+}
+
+sub remove {
+ my ($self, $user) = @_;
+ $self->_htpasswd->remove_user($user->_htpasswd_user);
+ return $user;
+}
+
+sub _inflate_user {
+ my ($self, $htp_user) = @_;
+ return App::EzPz::User->new(
+ htpasswd_user => $htp_user,
+ );
+}
+
+sub check_password {
+ my ($self, $name, $password) = @_;
+ return unless my $user = $self->get($name);
+ return $user->check_password($password);
+}
+
+1;