ldap/admin/src/scripts/DSCreate.pm.in | 80 +++++++++++++++++-----------------
1 file changed, 41 insertions(+), 39 deletions(-)
New commits:
commit febd0dbeab80f12bed1109fcbb0a929f83addb2a
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Fri Mar 15 14:40:54 2013 -0400
Ticket 583 - dirsrv fails to start on reboot due to /var/run/dirsrv permissions
Bug Description: On Fedora, after a reboot the ownership/permissions can change
for /var/lock/dirsrv & /var/run/dirsrv. This is because we
were not removing the old /etc/tmpfiles.d/dirsrv-INSTANCE.conf
file. So if an existing tmpfile existed, it would not be updated
when creating a new instance.
Fix Description: When removing an instance, we were using the wrong tmpfile name -
it was missing ".conf" extension. This has been
corrected. Also,
when creating an instance, we now check for and delete the old
tmpfile.
https://fedorahosted.org/389/ticket/583
Reviewed by: nkinder(Thanks!)
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in
b/ldap/admin/src/scripts/DSCreate.pm.in
index fefb3dc..be2097a 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -1040,48 +1040,50 @@ sub updateTmpfilesDotD {
# if tmpfiles.d is not available, do nothing
if ($dir and -d $dir) {
my $filename =
"$dir/@package_name(a)-$inf->{slapd}->{ServerIdentifier}.conf";
- if (! -f $filename) {
- debug(3, "Creating $filename\n");
- my $username = "";
- my $groupname = "";
- my $conffile = "$inf->{slapd}->{config_dir}/dse.ldif";
- # use the owner:group from the dse.ldif for the instance
- if (-f $conffile) {
- my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
- $atime,$mtime,$ctime,$blksize,$blocks)
- = stat(_);
- $username = getpwuid($uid);
- if (!$username) {
- debug(1, "Error: could not get username from uid $uid\n");
- }
- $groupname = getgrgid($gid);
+ if (-f $filename) {
+ debug(3, "Removing the old tmpfile: $filename\n");
+ if (!unlink($filename)){
+ debug(1, "Can not delete old tmpfile $filename ($!)\n");
+ return();
}
- # else, see if we were passed in values to use
+ }
+ debug(3, "Creating $filename\n");
+ my $username = "";
+ my $groupname = "";
+ my $conffile = "$inf->{slapd}->{config_dir}/dse.ldif";
+ # use the owner:group from the dse.ldif for the instance
+ if (-f $conffile) {
+ my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+ $atime,$mtime,$ctime,$blksize,$blocks)
+ = stat(_);
+ $username = getpwuid($uid);
if (!$username) {
- $username = $inf->{General}->{SuiteSpotUserID};
- }
- if (!$groupname) {
- if (defined($inf->{General}->{SuiteSpotGroup})) {
- $groupname = $inf->{General}->{SuiteSpotGroup};
- } else { # $groupname
- $groupname = "-"; # use default
- }
+ debug(1, "Error: could not get username from uid $uid\n");
}
-
- my $parent = dirname($inf->{slapd}->{lock_dir});
- if (!open(DOTDFILE, ">$filename")) {
- return ( [ 'error_creating_file', $filename, $! ] );
+ $groupname = getgrgid($gid);
+ }
+ # else, see if we were passed in values to use
+ if (!$username) {
+ $username = $inf->{General}->{SuiteSpotUserID};
+ }
+ if (!$groupname) {
+ if (defined($inf->{General}->{SuiteSpotGroup})) {
+ $groupname = $inf->{General}->{SuiteSpotGroup};
+ } else { # $groupname
+ $groupname = "-"; # use default
}
- # Type Path Mode UID GID Age
- # d /var/run/user 0755 root root 10d
- # we don't use age
- print DOTDFILE "d $inf->{slapd}->{run_dir} 0770 $username
$groupname\n";
- print DOTDFILE "d $parent 0770 $username $groupname\n";
- print DOTDFILE "d $inf->{slapd}->{lock_dir} 0770 $username
$groupname\n";
- close DOTDFILE;
- } else {
- debug(3, "$filename exists - skipping\n");
}
+ my $parent = dirname($inf->{slapd}->{lock_dir});
+ if (!open(DOTDFILE, ">$filename")) {
+ return ( [ 'error_creating_file', $filename, $! ] );
+ }
+ # Type Path Mode UID GID Age
+ # d /var/run/user 0755 root root 10d
+ # we don't use age
+ print DOTDFILE "d $inf->{slapd}->{run_dir} 0770 $username
$groupname\n";
+ print DOTDFILE "d $parent 0770 $username $groupname\n";
+ print DOTDFILE "d $inf->{slapd}->{lock_dir} 0770 $username
$groupname\n";
+ close DOTDFILE;
} else {
debug(3, "no tmpfiles.d - skipping\n");
}
@@ -1381,8 +1383,8 @@ sub removeDSInstance {
}
my $tmpfilesdir = "@with_tmpfiles_d@";
- my $tmpfilesname = "$tmpfilesdir/@package_name@-$inst";
- if ($tmpfilesdir and -d $tmpfilesdir and -f $tmpfilesname) {
+ my $tmpfilesname = "$tmpfilesdir/@package_name(a)-$inst.conf";
+ if ($tmpfilesdir && -d $tmpfilesdir && -f $tmpfilesname) {
my $rc = unlink($tmpfilesname);
if ( 0 == $rc )
{