/usr/share/perl5/EBox/CloudSync/Slave.pm is in zentyal-users 2.3.15+quantal1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | # Copyright (C) 2012 eBox Technologies S.L.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package EBox::CloudSync::Slave;
use strict;
use warnings;
use base 'EBox::UsersAndGroups::Slave';
use EBox::Global;
use EBox::Exceptions::External;
use Error qw(:try);
use MIME::Base64;
sub new
{
my ($class, $host, $port, $cert) = @_;
my $self = $class->SUPER::new(name => 'zentyal-cloud');
bless($self, $class);
return $self;
}
sub _addUser
{
my ($self, $user, $pass) = @_;
my $users = EBox::Global->modInstance('users');
return if ($user->baseDn() ne $users->usersDn());
# refresh user info to avoid cache problems with passwords:
$user = $users->user($user->name());
my @passwords = map { encode_base64($_) } @{$user->passwordHashes()};
my $userinfo = {
name => $user->get('uid'),
firstname => $user->get('givenName'),
lastname => $user->get('sn'),
description => ($user->get('description') or ''),
uid => $user->get('uidNumber'),
gid => $user->get('gidNumber'),
passwords => \@passwords,
};
my $uid = $user->get('uid');
$self->RESTClient->POST("/v1/users/users/$uid", $userinfo);
return 0;
}
sub _modifyUser
{
my ($self, $user, $pass) = @_;
my $users = EBox::Global->modInstance('users');
return if ($user->baseDn() ne $users->usersDn());
# refresh user info to avoid cache problems with passwords:
$user = $users->user($user->name());
my @passwords = map { encode_base64($_) } @{$user->passwordHashes()};
my $userinfo = {
firstname => $user->get('givenName'),
lastname => $user->get('sn'),
description => ($user->get('description') or ''),
passwords => \@passwords,
};
my $uid = $user->get('uid');
$self->RESTClient->PUT("/v1/users/users/$uid", $userinfo);
return 0;
}
sub _delUser
{
my ($self, $user) = @_;
my $users = EBox::Global->modInstance('users');
return if ($user->baseDn() ne $users->usersDn());
my $uid = $user->get('uid');
$self->RESTClient->DELETE("/v1/users/users/$uid");
return 0;
}
sub _addGroup
{
my ($self, $group) = @_;
my $users = EBox::Global->modInstance('users');
return if ($group->baseDn() ne $users->groupsDn());
my $groupinfo = {
name => $group->name(),
gid => $group->get('gidNumber'),
description => ($group->get('description') or ''),
};
my $name = $group->name();
$self->RESTClient->POST("/v1/users/groups/$name", $groupinfo);
return 0;
}
sub _modifyGroup
{
my ($self, $group) = @_;
my $users = EBox::Global->modInstance('users');
return if ($group->baseDn() ne $users->groupsDn());
my @members = map { $_->name() } @{$group->users()};
my $groupinfo = {
name => $group->name(),
gid => $group->get('gidNumber'),
description => ($group->get('description') or ''),
members => \@members,
};
my $name = $group->get('cn');
$self->RESTClient->PUT("/v1/users/groups/$name", $groupinfo);
return 0;
}
sub _delGroup
{
my ($self, $group) = @_;
my $users = EBox::Global->modInstance('users');
return if ($users->baseDn() ne $users->groupsDn());
my $name = $group->get('cn');
$self->RESTClient->DELETE("/v1/users/groups/$name");
return 0;
}
sub RESTClient
{
my $rs = new EBox::Global->modInstance('remoteservices');
return $rs->REST();
}
1;
|