Browse Source

Ticket 47394 - remove-ds.pl should remove /var/lock/dirsrv

Bug Description:  Once a DS instance has been created, /var/lock/dirsrv, /var/lib/dirsrv, and /var/run/dirsrv
                  are owned by the user that was specified when the instance was created. Then remove this
                  single instance, and create a new instance that runs as a different user.  The install will fail.

Fix Description:  When removing the last instance on the machine, remove the /var/lock|run|lib/dirsrv/ directories.

https://fedorahosted.org/389/ticket/47394

Reviewed by: richm(Thanks!)
Mark Reynolds 12 years ago
parent
commit
56441c31d8
1 changed files with 12 additions and 2 deletions
  1. 12 2
      ldap/admin/src/scripts/DSCreate.pm.in

+ 12 - 2
ldap/admin/src/scripts/DSCreate.pm.in

@@ -1274,7 +1274,10 @@ sub removeDSInstance {
     my @errs;
 
     my $initconfig = "$initconfig_dir/@package_name@-$inst";
-
+    my $pkglockdir = "@localstatedir@/lock/@package_name@";
+    my $pkgrundir = "@localstatedir@/run/@package_name@";
+    my $pkglibdir = "@localstatedir@/lib/@package_name@";
+    
     # Get the configdir, rundir and product_name from the instance initconfig script.
     unless(open(INFILE, $initconfig)) {
         return ( [ 'error_no_such_instance', $instname, $! ] );
@@ -1454,7 +1457,14 @@ sub removeDSInstance {
 
     # update systemd files
     push @errs, updateSystemD();
-
+    
+    # remove /var/lock/dirsrv & /var/run/dirsrv if this was the last instance
+    if(!<$pkglockdir/*>){
+        rmdir $pkglockdir;
+        rmdir $pkgrundir;
+        rmdir $pkglibdir;
+    }
+    
     # if we got here, report success
     if (@errs) {
         debug(1, "Could not successfully remove $instname\n");