From 7ae509c9969c3076d9efe1686a6768deaa00ffea Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Fri, 23 Aug 2013 12:17:57 -0400 Subject: [PATCH] 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!) --- ldap/admin/src/scripts/DSCreate.pm.in | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in index be2097a..d0d0896 100644 --- a/ldap/admin/src/scripts/DSCreate.pm.in +++ b/ldap/admin/src/scripts/DSCreate.pm.in @@ -1264,7 +1264,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, $! ] ); @@ -1444,7 +1447,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"); -- 1.7.1