shared.pm
branchfoerste-hhsp
changeset 75 63b7c7fcd0cb
parent 48 36aca6fb0ab8
equal deleted inserted replaced
74:b82a656f784e 75:63b7c7fcd0cb
    12 use Net::LDAP::Entry;
    12 use Net::LDAP::Entry;
    13 
    13 
    14 #use Cyrus::IMAP::Admin;
    14 #use Cyrus::IMAP::Admin;
    15 use Text::Wrap;
    15 use Text::Wrap;
    16 use password;
    16 use password;
       
    17 use Common;
    17 
    18 
    18 my $Cf;
    19 my $Cf;
    19 my ( $ldap, $ubase, $abase );
    20 my ( $ldap, $ubase, $abase );
    20 my ($imap);
    21 my ($imap);
    21 END { $imap and $imap = undef; }
    22 END { $imap and $imap = undef; }
   202 
   203 
   203             $e->replace( (AT_PRIMARYADDRESS) => $Cf->primary );
   204             $e->replace( (AT_PRIMARYADDRESS) => $Cf->primary );
   204             $modified++;
   205             $modified++;
   205         }
   206         }
   206 
   207 
   207         if ( my $pw = _mkpw( $Cf->password ) ) {
   208         if ( my $pw = Common::mkpw( $Cf->password ) ) {
   208             $e->replace( userPassword => $pw );
   209             $e->replace( userPassword => $pw );
   209             $modified++;
   210             $modified++;
   210         }
   211         }
   211 
   212 
   212         #if ($Cf->internal ne ":") {
   213         #if ($Cf->internal ne ":") {
   296     my %x;
   297     my %x;
   297     @x{@_} = ();
   298     @x{@_} = ();
   298     return keys %x;
   299     return keys %x;
   299 }
   300 }
   300 
   301 
   301 {
       
   302     my @pw;
       
   303 
       
   304     sub _mkpw($) {
       
   305         my $in = $_[0];
       
   306 
       
   307         return $in unless $in and $in eq "{pwgen}";
       
   308 
       
   309         if ( !@pw ) {
       
   310             chomp( @pw = `pwgen 8 10 2>/dev/null|| mkpasswd` );
       
   311             die "pwgen/mkpasswd: $!" if $?;
       
   312         }
       
   313         return shift @pw;
       
   314 
       
   315     }
       
   316 }
       
   317 
       
   318 1;
   302 1;
   319 
   303 
   320 # vim:sts=4 sw=4 aw ai sm nohlsearch:
   304 # vim:sts=4 sw=4 aw ai sm nohlsearch: