Changeset 1357
- Timestamp:
- 06/25/15 15:38:44 (9 years ago)
- Location:
- trunk/LATMOS-Accounts
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
r1317 r1357 898 898 return; 899 899 } 900 if ( $self->_create_c_object($srcobj->type, $srcobj->id, %data)) {900 if (my $res = $self->_create_c_object($srcobj->type, $srcobj->id, %data)) { 901 901 return 'CREATED' 902 902 } else { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Attributes.pm
r1332 r1357 223 223 $self->object->id, 224 224 ); 225 $self->base->log(LA_DEBUG, "Possible value for %s: %s", 226 $self->name, 227 join(', ', @possible) 228 ); 225 229 return; 226 230 } -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
r1351 r1357 79 79 my $pclass = $base->_load_obj_class($otype) or return; 80 80 my $newobj = "$pclass"->new($base, $id, @args) or return; 81 81 82 $newobj->{_base} = $base; 82 83 $newobj->{_type} = lc($otype); 83 84 $newobj->{_id} ||= $id; 85 84 86 return $newobj; 85 87 } -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix.pm
r1298 r1357 125 125 $self->{users}{$user}{shell} ||= ''; 126 126 $self->{users}{$user}{shell} =~ s/^-//; 127 $self->{users}{$user}{_id} = $user; 127 128 }, 128 129 ) or return; … … 137 138 $self->{groups}{$group}{$_} = shift(@ch); 138 139 } 140 $self->{groups}{$group}{_id} = $group; 139 141 140 142 # split user in the group … … 336 338 user => 'users', 337 339 group => 'groups', 338 }->{$otype} ;340 }->{$otype} or return; 339 341 my @obj = sort keys %{$self->{$internal_obj} || {} }; 340 342 for ($otype) { … … 355 357 }->{$otype}; 356 358 for ($otype) { 357 /^user$/ && !defined($data{uid}) && !defined($data{gid}) and return; 358 /^group$/ && !defined($data{gid}) and return; 359 } 360 361 if ($self->{$internal_obj}{$id}) { return }; 359 if (/^user$/ && (!defined($data{uid}) || !defined($data{gid}))) { 360 $self->log(LA_ERR, "uid or gid missing to create $otype"); 361 return; 362 } 363 if(/^group$/ && !defined($data{gid})) { 364 $self->log(LA_ERR, "uid or gid missing to create $otype"); 365 return; 366 } 367 } 368 369 if ($self->{$internal_obj}{$id}) { 370 $self->log(LA_ERR, "Object %s.%s already exists", $otype, $id); 371 return 372 } 373 362 374 $self->{$internal_obj}{$id} = { 363 375 account => $id, 364 376 uid => $data{uid}, 365 377 gid => $data{gid}, 366 }; 367 my $obj = $self->get_object($otype, $id) or return; 378 _id => $id, 379 }; 380 381 my $obj = $self->get_object($otype, $id) or do { 382 $self->log(LA_ERR, "Cannot find freshly create $otype $id"); 383 return; 384 }; 385 368 386 $obj->set_fields(%data) or return; 369 387 $obj -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix/Group.pm
r1071 r1357 58 58 sub new { 59 59 my ($class, $base, $id, @args) = @_; 60 # we profit of ref, quite easy 61 if (exists($base->{groups}{$id}) && $base->{groups}{$id}) {60 61 if (exists($base->{groups}{$id})) { 62 62 if ($base->{groups}{$id}{gid} < ($base->{min_gid} || 0)) { 63 $base->log(LA_DEBUG, "gid %d less than minimal %d", $base->{groups}{$id}{gid}, ($base->{min_gid} || 0)); 63 64 return; 64 65 } 65 66 return bless($base->{groups}{$id}, $class); 66 } else { return } 67 } 68 69 sub id { 70 $_[0]->{group_name} 67 } else { 68 $base->log(LA_ERR, "Cannot find group $id"); 69 return 70 } 71 71 } 72 72 … … 75 75 if ($field eq 'user_list') { 76 76 return [ keys %{ $self->{'users'} || {} } ]; 77 } elsif ($field eq 'g oup_name') {77 } elsif ($field eq 'group_name') { 78 78 return $self->id; 79 79 } … … 88 88 if (!(defined($data{$field}) && $data{$field} =~ /^\d+$/)) { 89 89 $self->base->log(LA_ERR, 90 "Invalid data for $field: " . ($data{$field} ||''));90 "Invalid Group data for $field: " . (defined($data{$field}) ? $data{$field} : '')); 91 91 return; 92 92 } -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Unix/User.pm
r1352 r1357 84 84 } 85 85 86 sub id {87 $_[0]->{account}88 }89 90 86 sub get_field { 91 87 my ($self, $field) = @_; … … 115 111 if(!(defined($data{$field}) && $data{$field} =~ /^\d+$/)) { 116 112 $self->base->log(LA_ERR, 117 "Invalid data for $field: " . ( $data{$field} || ''));113 "Invalid data for $field: " . (defined($data{$field}) ? $data{$field} : '(none)')); 118 114 return; 119 115 } -
trunk/LATMOS-Accounts/testdata/synchro/dest/group
r46 r1357 1 1 root:x:0: 2 test:x:4: -
trunk/LATMOS-Accounts/testdata/synchro/source/group
r46 r1357 1 1 root:x:0: 2 test1:x:1: 3 test2:x:2: 4 test3:x:3: 5 test4:x:4:
Note: See TracChangeset
for help on using the changeset viewer.