From 29b3215d65d9083b66f4a4e7ef926f7d18d483c7 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 3 Oct 2013 09:48:37 +0200 Subject: [PATCH] Automatically set email and display names for users --- root/etc/e-smith/events/actions/ajaxplorer-user-rights | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/root/etc/e-smith/events/actions/ajaxplorer-user-rights b/root/etc/e-smith/events/actions/ajaxplorer-user-rights index 25ddb19..124825d 100644 --- a/root/etc/e-smith/events/actions/ajaxplorer-user-rights +++ b/root/etc/e-smith/events/actions/ajaxplorer-user-rights @@ -29,6 +29,8 @@ use PHP::Serialization qw(serialize unserialize); my $c = esmith::ConfigDB->open_ro; my $a = esmith::AccountsDB->open_ro; +my $domain = $c->get('DomainName')->value; + # Remove all the permissions unlink(); @@ -41,6 +43,8 @@ unlink(); foreach my $user (($a->users),$a->get('admin')){ my $name = $user->key; + my $first = $user->prop('FirstName') || ''; + my $last = $user->prop('LastName') || $name; my $data; mkpath('/var/lib/ajaxplorer/plugins/auth.serial/' . $name); chmod 0770, "/var/lib/ajaxplorer/plugins/auth.serial/$name"; @@ -56,7 +60,6 @@ foreach my $user (($a->users),$a->get('admin')){ else{ $data->{"\0*\0groupPath"} = undef; $data->{"\0*\0autoApplies"} = []; - $data->{"\0*\0parameters"} = []; $data->{"\0*\0roleLabel"} = undef; $data->{"\0*\0actions"} = []; $data->{"\0*\0roleId"} = "AJXP_USR_/$name"; @@ -85,6 +88,14 @@ foreach my $user (($a->users),$a->get('admin')){ $data->{"\0*\0acls"}->{$sharename} = 'rw' if ( $_ eq $name ); } } + # As we're here, lets update the email address and the display name + # First, delete parameter if it's an array (meaning it's empty + delete $data->{"\0*\0parameters"} unless( + defined $data->{"\0*\0parameters"}->{'AJXP_REPO_SCOPE_ALL'}->{'core.conf'}->{'email'} || + defined $data->{"\0*\0parameters"}->{'AJXP_REPO_SCOPE_ALL'}->{'core.conf'}->{'USER_DISPLAY_NAME'} + ); + $data->{"\0*\0parameters"}->{'AJXP_REPO_SCOPE_ALL'}->{'core.conf'}->{'email'} = "$name\@$domain"; + $data->{"\0*\0parameters"}->{'AJXP_REPO_SCOPE_ALL'}->{'core.conf'}->{'USER_DISPLAY_NAME'} = "$first $last"; open WROLE, '+>', "/var/lib/ajaxplorer/plugins/auth.serial/$name/role.ser"; print WROLE serialize($data);