Ignore:
Timestamp:
03/12/18 14:22:15 (7 years ago)
Author:
Edwin Eefting <edwin@datux.nl>
Branches:
master, perl-5.22
Children:
fdfd619
Parents:
1051986
Message:

flush nscd cache when modifying users

Location:
npl/fileserver/smb-ldap-tool/modified
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • npl/fileserver/smb-ldap-tool/modified/smbldap-groupdel

    r1051986 r3187b26  
    5757group_del($dn);
    5858
    59 my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
    60 
    61 if ($nscd_status == 0) {
    62   system "/etc/init.d/nscd restart > /dev/null 2>&1";
    63 }
     59# my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
     60#
     61# if ($nscd_status == 0) {
     62#   system "/etc/init.d/nscd restart > /dev/null 2>&1";
     63# }
     64system "nscd -i passwd; nscd -i group";
    6465
    6566#if (defined($dn_line = get_group_dn($_groupName))) {
  • npl/fileserver/smb-ldap-tool/modified/smbldap-groupmod

    r1051986 r3187b26  
    4848  print "  -r   group-rid\n";
    4949  print "  -s   group-sid\n";
    50   print "  -t   group-type\n"; 
     50  print "  -t   group-type\n";
    5151  print "  -x   delete members (comma delimted)\n";
    5252  print "  -?   show this help message\n";
     
    6666my $newname = $Options{'n'};
    6767
    68 my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
    69 
    70 if ($nscd_status == 0) {
    71   system "/etc/init.d/nscd restart > /dev/null 2>&1";
    72 }
     68# my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
     69#
     70# if ($nscd_status == 0) {
     71#   system "/etc/init.d/nscd restart > /dev/null 2>&1";
     72# }
     73system "nscd -i passwd; nscd -i group";
    7374
    7475my $gid = getgrnam($groupName);
     
    223224}
    224225
    225 $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
    226 
    227 if ($nscd_status == 0) {
    228   system "/etc/init.d/nscd restart > /dev/null 2>&1";
    229 }
     226# $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
     227#
     228# if ($nscd_status == 0) {
     229#   system "/etc/init.d/nscd restart > /dev/null 2>&1";
     230# }
     231system "nscd -i passwd; nscd -i group";
    230232
    231233# take down session
  • npl/fileserver/smb-ldap-tool/modified/smbldap-useradd

    r1051986 r3187b26  
    149149
    150150my $userUidNumber = $Options{'u'};
    151 if (!defined($userUidNumber)) { 
     151if (!defined($userUidNumber)) {
    152152  $userUidNumber=get_next_id($config{usersdn},"uidNumber");
    153153} elsif (getpwuid($userUidNumber)) {
     
    158158  system "/etc/init.d/nscd start > /dev/null 2>&1";
    159159}
     160system "nscd -i passwd; nscd -i group";
    160161
    161162my $createGroup = 0;
    162163my $userGidNumber = $Options{'g'};
    163 # gid not specified ? 
     164# gid not specified ?
    164165if (!defined($userGidNumber)) {
    165166  # windows machine => $config{defaultComputerGid}
     
    252253# MACHINE ACCOUNT
    253254if (defined($Options{'w'}) or defined($Options{'i'})) {
    254    
     255
    255256  # if Options{'i'} and username does not end with $ caracter => we add it
    256257  if ( $Options{'i'} and !($userName =~ m/\$$/) ) {
     
    270271    system "stty -echo";
    271272    print "New password : ";
    272     chomp($pass=<STDIN>); 
     273    chomp($pass=<STDIN>);
    273274    print "\n";
    274275    system "stty echo";
     
    345346        my $OX_TZ = "Europe/Amsterdam";
    346347        my $WRITE_GLOBAL_ADDR = "TRUE";
    347        
     348
    348349  my $GROUPWARE_SERVER="none";
    349350  if (defined($Options{'W'}))
     
    388389$add->code && warn "failed to add entry: ", $add->error ;
    389390
    390 my $add2 = $ldap_master->add ("ou=addr,uid=$userName,$config{usersdn}", attr => [   'objectclass' => ['top','organizationalUnit'], 'ou'   => "addr" ] );   
     391my $add2 = $ldap_master->add ("ou=addr,uid=$userName,$config{usersdn}", attr => [   'objectclass' => ['top','organizationalUnit'], 'ou'   => "addr" ] );
    391392
    392393my $add3 = $ldap_master->modify ("cn=AddressAdmins,o=AddressBook,$config{suffix}",add => { member  => "uid=$userName,$config{usersdn}" });
    393394    $add3->code && warn "failed to add entry: ", $add3->error ;
    394                                                                                                                                                                                                                                                                                                                            
     395
    395396
    396397#if ($createGroup) {
     
    416417      system "chown -R $userUidNumber:$userGidNumber $userHomeDirectory 2>/dev/null";
    417418      if (defined $config{userHomeDirectoryMode}) {
    418         system "chmod $config{userHomeDirectoryMode} $userHomeDirectory 2>/dev/null"; 
     419        system "chmod $config{userHomeDirectoryMode} $userHomeDirectory 2>/dev/null";
    419420      } else {
    420         system "chmod 700 $userHomeDirectory 2>/dev/null"; 
     421        system "chmod 700 $userHomeDirectory 2>/dev/null";
    421422      }
    422423    }
     
    498499                                                   ]
    499500                                      );
    500        
     501
    501502    $modify->code && die "failed to add entry: ", $modify->error ;
    502503
  • npl/fileserver/smb-ldap-tool/modified/smbldap-userdel

    r1051986 r3187b26  
    105105  system "/etc/init.d/nscd restart > /dev/null 2>&1";
    106106}
     107system "nscd -i passwd; nscd -i group";
    107108
    108109$ldap_master->unbind;           # take down session
  • npl/fileserver/smb-ldap-tool/modified/smbldap-usermod

    r1051986 r3187b26  
    113113  my $valpwdcanchange = 0;
    114114  my $valpwdmustchange = $winmagic;
    115   my $valpwdlastset = 0; 
     115  my $valpwdlastset = 0;
    116116  my $valacctflags = "[UX]";
    117117  my $user_entry=read_user_entry($user);
     
    143143  if (defined($Options{'o'})) {
    144144    $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
    145        
     145
    146146    if ($nscd_status == 0) {
    147147      system "/etc/init.d/nscd stop > /dev/null 2>&1";
     
    152152        system "/etc/init.d/nscd start > /dev/null 2>&1";
    153153      }
     154      system "nscd -i passwd; nscd -i group";
    154155
    155156      print "$0: uid number $tmp exists\n";
     
    219220}
    220221
    221 if (defined($tmp = $Options{'N'})) { 
     222if (defined($tmp = $Options{'N'})) {
    222223  push(@mods, 'cn' => $tmp);
    223224}
     
    227228  push(@mods, 'givenName' => $tmp);
    228229}
    229  
    230 if (defined($tmp = $Options{'S'})) { 
     230
     231if (defined($tmp = $Options{'S'})) {
    231232  push(@mods, 'sn' => $tmp);
    232233}
     
    580581  system "/etc/init.d/nscd restart > /dev/null 2>&1";
    581582}
     583system "nscd -i passwd; nscd -i group";
    582584
    583585if (defined($Options{'P'})) {
  • npl/fileserver/smb-ldap-tool/modified/smbldap_tools.pm

    r1051986 r3187b26  
    241241        undef $smbconf{$parameter_smb};
    242242  }
    243  
     243
    244244}
    245245
     
    287287                                                                         # debug => 0xffff,
    288288                                                                        );
    289                                                                        
     289
    290290        if ($ldap_master)
    291291        {
     
    542542                                                                                  ]
    543543                                                                );
    544        
     544
    545545        $add->code && warn "failed to add entry: ", $add->error ;
    546546        sleep($wait);
     
    564564        $name =~ s/.$//s;
    565565
    566         my ($lmpassword,$ntpassword) = ntlmgen $name;   
     566        my ($lmpassword,$ntpassword) = ntlmgen $name;
    567567        my $modify = $ldap->modify ( "uid=$user,$config{computersdn}",
    568568                                                                                changes => [
     
    581581                                                                                                   ]
    582582                                                                          );
    583        
     583
    584584        $modify->code && die "failed to add entry: ", $modify->error ;
    585585
     
    594594        if (!defined(get_group_dn($group))) {
    595595          print "$0: group \"$group\" doesn't exist\n";
    596           exit (6); 
     596          exit (6);
    597597        }
    598598        if (!defined($dn_line)) {
     
    666666  }
    667667
    668  
     668
    669669sub add_grouplist_user
    670670{
     
    683683        my $dn_line;
    684684        my $dn = get_dn_from_line($dn_line);
    685        
     685
    686686        if (!defined($dn_line = get_user_dn($user))) {
    687687          print "$0: user $user doesn't exist\n";
     
    725725  {
    726726        my ($gname, $gid, $force) = @_;
    727         my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
    728         if ($nscd_status == 0) {
    729           system "/etc/init.d/nscd stop > /dev/null 2>&1";
    730         }
     727        # my $nscd_status = system "/etc/init.d/nscd status >/dev/null 2>&1";
     728        # if ($nscd_status == 0) {
     729        #   system "/etc/init.d/nscd stop > /dev/null 2>&1";
     730        # }
    731731        if (!defined($gid)) {
    732732          #while (defined(getgrgid($config{GID_START}))) {
     
    742742          }
    743743        }
    744         if ($nscd_status == 0) {
    745           system "/etc/init.d/nscd start > /dev/null 2>&1";
    746         }
     744        # if ($nscd_status == 0) {
     745          # system "/etc/init.d/nscd start > /dev/null 2>&1";
     746          system "nscd -i passwd; nscd -i group";
     747        # }
    747748        my $modify = $ldap->add ( "cn=$gname,$config{groupsdn}",
    748749                                                                         attrs => [
     
    752753                                                                                          ]
    753754                                                                   );
    754        
     755
    755756        $modify->code && die "failed to add entry: ", $modify->error ;
    756757        return $gid;
     
    10781079        }
    10791080        my $entry = $next_uid_mesg->entry(0);
    1080            
     1081
    10811082        $nextuid = $entry->get_value($attribute);
    10821083        my $modify=$ldap->modify( "$config{sambaUnixIdPooldn}",
     
    11031104
    11041105sub utf8Encode {
    1105   my $arg = shift; 
     1106  my $arg = shift;
    11061107
    11071108  return to_utf8(
     
    11181119                                   -charset => 'ISO-8859-1',
    11191120                                  );
    1120 }   
     1121}
    11211122
    112211231;
    1123 
Note: See TracChangeset for help on using the changeset viewer.