aboutsummaryrefslogtreecommitdiffstats
path: root/mkpeople
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-02-23 16:52:41 +0000
committerNicolas Vigier <boklm@mageia.org>2013-02-23 16:52:41 +0000
commited68e7e9eaa2060405e8f5969c056de80f90eb2f (patch)
treef2245b5998e237b9b9af566561b5e6f19ced23a0 /mkpeople
parentdf2b45d64d24ff050a86ad292c86459e2c1a019d (diff)
downloadmgapeople-ed68e7e9eaa2060405e8f5969c056de80f90eb2f.tar
mgapeople-ed68e7e9eaa2060405e8f5969c056de80f90eb2f.tar.gz
mgapeople-ed68e7e9eaa2060405e8f5969c056de80f90eb2f.tar.bz2
mgapeople-ed68e7e9eaa2060405e8f5969c056de80f90eb2f.tar.xz
mgapeople-ed68e7e9eaa2060405e8f5969c056de80f90eb2f.zip
Add maintdb infos on user pages
Diffstat (limited to 'mkpeople')
-rwxr-xr-xmkpeople53
1 files changed, 36 insertions, 17 deletions
diff --git a/mkpeople b/mkpeople
index cd21239..1cc4c7f 100755
--- a/mkpeople
+++ b/mkpeople
@@ -5,13 +5,26 @@ use Template;
use Net::LDAP;
use File::Slurp;
use YAML qw/LoadFile/;
+use LWP::UserAgent;
my $config_file = '/etc/mgapeople.conf';
my $config = LoadFile($ENV{MGAPEOPLE_CONF} ? $ENV{MGAPEOPLE_CONF} : $config_file);
+my %maintdb;
my %groups;
my %users;
+sub loadmaintdb {
+ return unless $config->{maintdburl};
+ my $ua = LWP::UserAgent->new;
+ my $r = $ua->get($config->{maintdburl});
+ return unless $r->is_success;
+ for my $line (split /^/, $r->decoded_content) {
+ my ($pkg, $user) = split ' ', $line;
+ push @{$maintdb{$user}}, $pkg;
+ }
+}
+
sub loaduser {
my ($ldap, $user) = @_;
my $m = $ldap->search(
@@ -56,19 +69,21 @@ sub output_users {
});
for my $user (keys %users) {
my $vars = {
- config => $config,
- user => $user,
- users => \%users,
- groups => \%groups,
+ config => $config,
+ user => $user,
+ users => \%users,
+ groups => \%groups,
+ maintdb => \%maintdb,
};
my $uid = $users{$user}->{uid}->[0];
$template->process("user.$extension", $vars, "$uid.$extension");
}
my $vars = {
- config => $config,
- users => \%users,
- groups => \%groups,
+ config => $config,
+ users => \%users,
+ groups => \%groups,
+ maintdb => \%maintdb,
};
$template->process("userindex.$extension", $vars, "index.$extension");
}
@@ -81,19 +96,21 @@ sub output_groups {
});
for my $group (keys %groups) {
my $vars = {
- config => $config,
- group => $group,
- users => \%users,
- groups => \%groups,
+ config => $config,
+ group => $group,
+ users => \%users,
+ groups => \%groups,
+ maintdb => \%maintdb,
};
my $cn = $groups{$group}->{cn}->[0];
$template->process("group.$extension", $vars, "$cn.$extension");
}
my $vars = {
- config => $config,
- users => \%users,
- groups => \%groups,
+ config => $config,
+ users => \%users,
+ groups => \%groups,
+ maintdb => \%maintdb,
};
$template->process("groupindex.$extension", $vars, "index.$extension");
}
@@ -105,9 +122,10 @@ sub output_index {
OUTPUT_PATH => "$config->{output_dir}",
});
my $vars = {
- config => $config,
- users => \%users,
- groups => \%groups,
+ config => $config,
+ users => \%users,
+ groups => \%groups,
+ maintdb => \%maintdb,
};
$template->process("index.$extension", $vars, "index.$extension");
}
@@ -120,6 +138,7 @@ $m = $ldap->start_tls(verify => 'none');
die $m->error if $m->is_error;
$m = $ldap->bind($config->{binddn}, password => $bindpw);
die $m->error if $m->is_error;
+loadmaintdb;
loadgroups($ldap);
output_users('html');
output_groups('html');