diff -Nru ebox-samba-2.0.11/ChangeLog ebox-samba-2.0.12/ChangeLog --- ebox-samba-2.0.11/ChangeLog 2011-06-01 10:57:50.000000000 +0000 +++ ebox-samba-2.0.12/ChangeLog 2011-06-25 10:44:08.000000000 +0000 @@ -1,3 +1,6 @@ +2.0.12 + + Now deleted users and groups are removed correctly from printers + permissions lists 2.0.11 + Fixed SQL in activity report section 2.0.10 diff -Nru ebox-samba-2.0.11/configure ebox-samba-2.0.12/configure --- ebox-samba-2.0.11/configure 2011-06-01 10:58:14.000000000 +0000 +++ ebox-samba-2.0.12/configure 2011-06-25 10:44:32.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.67 for EBox-samba 2.0.11. +# Generated by GNU Autoconf 2.67 for EBox-samba 2.0.12. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -548,8 +548,8 @@ # Identity of this package. PACKAGE_NAME='EBox-samba' PACKAGE_TARNAME='ebox-samba' -PACKAGE_VERSION='2.0.11' -PACKAGE_STRING='EBox-samba 2.0.11' +PACKAGE_VERSION='2.0.12' +PACKAGE_STRING='EBox-samba 2.0.12' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1198,7 +1198,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures EBox-samba 2.0.11 to adapt to many kinds of systems. +\`configure' configures EBox-samba 2.0.12 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1264,7 +1264,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of EBox-samba 2.0.11:";; + short | recursive ) echo "Configuration of EBox-samba 2.0.12:";; esac cat <<\_ACEOF @@ -1347,7 +1347,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -EBox-samba configure 2.0.11 +EBox-samba configure 2.0.12 generated by GNU Autoconf 2.67 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1364,7 +1364,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by EBox-samba $as_me 2.0.11, which was +It was created by EBox-samba $as_me 2.0.12, which was generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -2182,7 +2182,7 @@ # Define the identity of the package. PACKAGE='ebox-samba' - VERSION='2.0.11' + VERSION='2.0.12' cat >>confdefs.h <<_ACEOF @@ -3428,7 +3428,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by EBox-samba $as_me 2.0.11, which was +This file was extended by EBox-samba $as_me 2.0.12, which was generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3485,7 +3485,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -EBox-samba config.status 2.0.11 +EBox-samba config.status 2.0.12 configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" diff -Nru ebox-samba-2.0.11/configure.ac ebox-samba-2.0.12/configure.ac --- ebox-samba-2.0.11/configure.ac 2011-06-01 10:57:50.000000000 +0000 +++ ebox-samba-2.0.12/configure.ac 2011-06-25 10:44:08.000000000 +0000 @@ -1,4 +1,4 @@ -AC_INIT([EBox-samba], [2.0.11]) +AC_INIT([EBox-samba], [2.0.12]) AC_CONFIG_AUX_DIR([config]) AC_CONFIG_SRCDIR([src/EBox/Samba.pm]) diff -Nru ebox-samba-2.0.11/debian/changelog ebox-samba-2.0.12/debian/changelog --- ebox-samba-2.0.11/debian/changelog 2011-06-25 11:01:19.000000000 +0000 +++ ebox-samba-2.0.12/debian/changelog 2011-06-25 11:01:20.000000000 +0000 @@ -1,3 +1,9 @@ +ebox-samba (2.0.12) lucid; urgency=low + + * New upstream release + + -- José A. Calvo Sat, 25 Jun 2011 12:44:46 +0200 + ebox-samba (2.0.11) lucid; urgency=low * New upstream release diff -Nru ebox-samba-2.0.11/src/EBox/Samba.pm ebox-samba-2.0.12/src/EBox/Samba.pm --- ebox-samba-2.0.11/src/EBox/Samba.pm 2011-06-01 10:32:36.000000000 +0000 +++ ebox-samba-2.0.12/src/EBox/Samba.pm 2011-06-18 02:15:34.000000000 +0000 @@ -1071,7 +1071,7 @@ } } -sub _addUsersToPrinter # (printer, users) +sub _setPrinterUsers { my ($self, $printer, $users) = @_; @@ -1080,14 +1080,15 @@ return; } - for my $username (@{$users}) { - _checkUserExists($username); - } + my $usermod = EBox::Global->modInstance('users'); + my @okUsers = grep { + $usermod->userExists($_) + } @{ $users }; - $self->set_list("printers/$printer/users", "string", $users); + $self->set_list("printers/$printer/users", "string", \@okUsers); } -sub _addGroupsToPrinter # (printer, groups) +sub _setPrinterGroups { my ($self, $printer, $groups) = @_; @@ -1097,13 +1098,11 @@ } my $groupmod = EBox::Global->modInstance('users'); + my @okGroups = grep { + $groupmod->groupExists($_) + } @{ $groups }; - my @existingGroups; - for my $group (@{$groups}) { - push (@existingGroups, $group) if ($groupmod->groupExists($group)); - } - - $self->set_list("printers/$printer/groups", "string", $groups); + $self->set_list("printers/$printer/groups", "string", \@okGroups); } sub _printerUsers # (printer) @@ -1166,78 +1165,53 @@ return \@printers; } -sub setPrintersForUser # (user, printers) +sub setPrintersForUser { my ($self, $user, $newconf) = @_; + _checkUserExists($user); - my %currconf; - for my $conf (@{$self->_printersForUser($user)}) { - $currconf{$conf->{'name'}} = $conf->{'allowed'}; - } - my @changes; - for my $conf (@{$newconf}) { - if ($currconf{$conf->{'name'}} xor $conf->{'allowed'}) { - push (@changes, $conf); - } - } + my %newConf = map { + $_->{name} => $_->{allowed} + } @{ $newconf }; - for my $printer (@changes) { - my @users; - my $new = undef; - my $name = $printer->{'name'}; - if ($printer->{'allowed'}) { - @users = @{$self->_printerUsers($name)}; - next if (grep(/^$user$/, @users)); - push (@users, $user); - $new = 1; - } else { - my @ousers = @{$self->_printerUsers($name)}; - @users = grep (!/^$user$/, @ousers); - if (@users != @ousers) { - $new = 1; - } + my @printers = @{ $self->printers() }; + foreach my $printer (@printers) { + my @printerUsers = @{$self->_printerUsers($printer)}; + my $userAllowed = grep { $user eq $_ } @printerUsers; + my $allowed = exists $newConf{$printer} ? $newConf{$printer} : 0; + if ($allowed and (not $userAllowed)) { + push @printerUsers, $user; + $self->_setPrinterUsers($printer, \@printerUsers) + } elsif (not $allowed and $userAllowed) { + @printerUsers = grep { $user ne $_ } @printerUsers; + $self->_setPrinterUsers($printer, \@printerUsers) } - - $self->_addUsersToPrinter($name, \@users) if ($new); } } -sub setPrintersForGroup # (user, printers) +sub setPrintersForGroup { my ($self, $group, $newconf) = @_; _checkGroupExists($group); - my %currconf; - for my $conf (@{$self->_printersForGroup($group)}) { - $currconf{$conf->{'name'}} = $conf->{'allowed'}; - } - my @changes; - for my $conf (@{$newconf}) { - if ($currconf{$conf->{'name'}} xor $conf->{'allowed'}) { - push (@changes, $conf); + my %newConf = map { + $_->{name} => $_->{allowed} + } @{ $newconf }; + + my @printers = @{ $self->printers() }; + foreach my $printer (@printers) { + my @printerGroups = @{$self->_printerGroups($printer)}; + my $groupAllowed = grep { $group eq $_ } @printerGroups; + my $allowed = exists $newConf{$printer} ? $newConf{$printer} : 0; + if ($allowed and (not $groupAllowed)) { + push @printerGroups, $group; + $self->_setPrinterGroups($printer, \@printerGroups) + } elsif (not $allowed and $groupAllowed) { + @printerGroups = grep { $group ne $_ } @printerGroups; + $self->_setPrinterGroups($printer, \@printerGroups) } } - - for my $printer (@changes) { - my @groups; - my $new = undef; - my $name = $printer->{'name'}; - if ($printer->{'allowed'}) { - @groups = @{$self->_printerGroups($name)}; - next if (grep(/^$group$/, @groups)); - push (@groups, $group); - $new = 1; - } else { - my @ogroups = @{$self->_printerGroups($name)}; - @groups = grep (!/^$group$/, @ogroups); - if (@groups != @ogroups) { - $new = 1; - } - } - - $self->_addGroupsToPrinter($name, \@groups) if ($new); - } } sub delPrinter # (resource)