Update acl if they already exists, or create a default role if role.ser doesn't exists

This commit is contained in:
Daniel Berteaud 2013-09-26 19:57:24 +02:00
parent 5a10c7d865
commit faf021bf08

View File

@ -41,16 +41,28 @@ unlink(</var/cache/ajaxplorer/i18n/*.ser>);
foreach my $user (($a->users),$a->get('admin')){
my $name = $user->key;
my $data;
mkpath('/var/lib/ajaxplorer/plugins/auth.serial/' . $name);
chmod 0770, "/var/lib/ajaxplorer/plugins/auth.serial/$name";
chown '0', '102', "/var/lib/ajaxplorer/plugins/auth.serial/$name";
if (-s "/var/lib/ajaxplorer/plugins/auth.serial/$name/role.ser"){
open RROLE, "/var/lib/ajaxplorer/plugins/auth.serial/$name/role.ser";
my $data = <RROLE>;
$data = <RROLE>;
close RROLE;
$data = unserialize($data);
delete $data->{"\0*\0acls"} if (defined $data->{"\0*\0acls"});
}
# No role yet ? lets create it
else{
$data->{"\0*\0groupPath"} = undef;
$data->{"\0*\0autoApplies"} = [];
$data->{"\0*\0parameters"} = [];
$data->{"\0*\0roleLabel"} = undef;
$data->{"\0*\0actions"} = [];
$data->{"\0*\0roleId"} = "AJXP_USR_/$name";
$data = bless $data, 'PHP::Serialization::Object::AJXP_Role';
}
# In any case, re-compute the effective permissions
foreach my $share ($a->get_all_by_prop(type => 'share')){
my $sharename = $share->key;
my $access = $share->prop('Ajaxplorer') || 'disabled';
@ -78,7 +90,6 @@ foreach my $user (($a->users),$a->get('admin')){
print WROLE serialize($data);
close WROLE;
}
}
my $ajxp = $c->get('ajaxplorer') || die "Couldn't find ajaxplorer entry in ConfigDB\n";
my $homedir = $ajxp->prop('HomeDir') || 'none';