瀏覽代碼

Bug 677774 - DS fails to start after reboot

https://bugzilla.redhat.com/show_bug.cgi?id=677774
Resolves: bug 677774
Bug Description: DS fails to start after reboot
Reviewed by: nkinder (Thanks!)
Branch: master
Fix Description: Added a new configure switch --with-tmpfiles-d - this is the
path to the tmpfiles.d directory.  If this is set, ds create/update/migration
will create the appropriate instance specific tmpfiles.d file.
Platforms tested: Fedora 15 x86_64
Flag Day: no
Doc impact: no
Rich Megginson 14 年之前
父節點
當前提交
1b5ff01a85
共有 10 個文件被更改,包括 844 次插入788 次删除
  1. 2 0
      Makefile.am
  2. 4 1
      Makefile.in
  3. 2 2
      aclocal.m4
  4. 0 6
      config.h.in
  5. 580 398
      configure
  6. 19 0
      configure.ac
  7. 75 2
      ldap/admin/src/scripts/DSCreate.pm.in
  8. 7 0
      ldap/admin/src/scripts/DSMigration.pm.in
  9. 3 1
      ldap/admin/src/scripts/DSUpdate.pm.in
  10. 152 378
      ltmain.sh

+ 2 - 0
Makefile.am

@@ -1389,6 +1389,7 @@ fixupcmd = sed \
 	-e 's,@defaultgroup\@,$(defaultgroup),g' \
 	-e 's,@with_fhs_opt\@,@with_fhs_opt@,g' \
 	-e 's,@with_selinux\@,@with_selinux@,g' \
+	-e 's,@with_tmpfiles_d\@,@with_tmpfiles_d@,g' \
 	-e 's,@perlexec\@,@perlexec@,g' \
 	-e 's,@sttyexec\@,@sttyexec@,g' \
 	-e 's,@initconfigdir\@,$(initconfigdir),g'\
@@ -1451,6 +1452,7 @@ fixupcmd = sed \
 	-e 's,@defaultgroup\@,$(defaultgroup),g' \
 	-e 's,@with_fhs_opt\@,@with_fhs_opt@,g' \
 	-e 's,@with_selinux\@,@with_selinux@,g' \
+	-e 's,@with_tmpfiles_d\@,@with_tmpfiles_d@,g' \
 	-e 's,@perlexec\@,@perlexec@,g' \
 	-e 's,@sttyexec\@,@sttyexec@,g' \
 	-e 's,@initconfigdir\@,$(initconfigdir),g' \

+ 4 - 1
Makefile.in

@@ -1112,7 +1112,6 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
 PACKAGE_NAME = @PACKAGE_NAME@
 PACKAGE_STRING = @PACKAGE_STRING@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
 PKG_CONFIG = @PKG_CONFIG@
@@ -1192,6 +1191,7 @@ libdir = @libdir@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
 mandir = @mandir@
 mibdir = $(datadir)@mibdir@
 mkdir_p = @mkdir_p@
@@ -1247,6 +1247,7 @@ updatedir = $(datadir)@updatedir@
 vendor = @vendor@
 with_fhs_opt = @with_fhs_opt@
 with_selinux = @with_selinux@
+with_tmpfiles_d = @with_tmpfiles_d@
 
 # look for included m4 files in the ./m4/ directory
 ACLOCAL_AMFLAGS = -I m4
@@ -2471,6 +2472,7 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
 @BUNDLE_FALSE@	-e 's,@defaultgroup\@,$(defaultgroup),g' \
 @BUNDLE_FALSE@	-e 's,@with_fhs_opt\@,@with_fhs_opt@,g' \
 @BUNDLE_FALSE@	-e 's,@with_selinux\@,@with_selinux@,g' \
+@BUNDLE_FALSE@	-e 's,@with_tmpfiles_d\@,@with_tmpfiles_d@,g' \
 @BUNDLE_FALSE@	-e 's,@perlexec\@,@perlexec@,g' \
 @BUNDLE_FALSE@	-e 's,@sttyexec\@,@sttyexec@,g' \
 @BUNDLE_FALSE@	-e 's,@initconfigdir\@,$(initconfigdir),g' \
@@ -2543,6 +2545,7 @@ rsearch_bin_LDADD = $(NSPR_LINK) $(NSS_LINK) $(LDAPSDK_LINK) $(SASL_LINK) $(LIBS
 @BUNDLE_TRUE@	-e 's,@defaultgroup\@,$(defaultgroup),g' \
 @BUNDLE_TRUE@	-e 's,@with_fhs_opt\@,@with_fhs_opt@,g' \
 @BUNDLE_TRUE@	-e 's,@with_selinux\@,@with_selinux@,g' \
+@BUNDLE_TRUE@	-e 's,@with_tmpfiles_d\@,@with_tmpfiles_d@,g' \
 @BUNDLE_TRUE@	-e 's,@perlexec\@,@perlexec@,g' \
 @BUNDLE_TRUE@	-e 's,@sttyexec\@,@sttyexec@,g' \
 @BUNDLE_TRUE@	-e 's,@initconfigdir\@,$(initconfigdir),g'\

+ 2 - 2
aclocal.m4

@@ -13,8 +13,8 @@
 
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.66],,
-[m4_warning([this file was generated for autoconf 2.66.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
+[m4_warning([this file was generated for autoconf 2.63.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically `autoreconf'.])])

+ 0 - 6
config.h.in

@@ -245,9 +245,6 @@
    */
 #undef HAVE_SYS_NDIR_H
 
-/* Define to 1 if you have the <sys/param.h> header file. */
-#undef HAVE_SYS_PARAM_H
-
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
 
@@ -364,9 +361,6 @@
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 

文件差異過大導致無法顯示
+ 580 - 398
configure


+ 19 - 0
configure.ac

@@ -292,6 +292,25 @@ schemadir=/$PACKAGE_NAME/schema
 defaultuser=nobody
 defaultgroup=nobody
 
+if test -z "$with_tmpfiles_d" ; then
+   if test -d $sysconfdir/tmpfiles.d ; then
+      with_tmpfiles_d='$(sysconfdir)/tmpfiles.d'
+   fi
+fi
+AC_MSG_CHECKING(for --with-tmpfiles-d)
+AC_ARG_WITH(tmpfiles-d,
+   AS_HELP_STRING([--with-tmpfiles-d=PATH],
+                  [system uses tmpfiles.d to handle temp files/dirs (default: $with_tmpfiles_d)])
+)
+if test "$with_tmpfiles_d" = yes ; then
+  AC_MSG_ERROR([You must specify --with-tmpfiles-d=/full/path/to/tmpfiles.d directory])
+elif test "$with_tmpfiles_d" = no ; then
+  with_tmpfiles_d=
+else
+  AC_MSG_RESULT([$with_tmpfiles_d])
+fi
+AC_SUBST(with_tmpfiles_d)
+
 AC_SUBST(configdir)
 AC_SUBST(sampledatadir)
 AC_SUBST(propertydir)

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

@@ -64,8 +64,10 @@ use Mozilla::LDAP::LDIF;
 
 use Exporter;
 @ISA       = qw(Exporter);
-@EXPORT    = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeOtherConfigFiles installSchema updateSelinuxPolicy);
-@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts makeOtherConfigFiles installSchema updateSelinuxPolicy);
+@EXPORT    = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts
+                makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD);
+@EXPORT_OK = qw(createDSInstance removeDSInstance setDefaults createInstanceScripts
+                makeOtherConfigFiles installSchema updateSelinuxPolicy updateTmpfilesDotD);
 
 use strict;
 
@@ -987,6 +989,62 @@ sub updateSelinuxPolicy {
     }
 }
 
+sub updateTmpfilesDotD {
+    my $inf = shift;
+    my $dir = "@with_tmpfiles_d@";
+
+    # if tmpfiles.d is not available, do nothing
+    if ($dir and -d $dir) {
+        my $filename = "$dir/@package_name@-$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);
+            }
+            # 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
+                }
+            }
+
+            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, "$filename exists - skipping\n");
+        }
+    } else {
+        debug(3, "no tmpfiles.d - skipping\n");
+    }
+
+    return ();
+}
+
 sub createDSInstance {
     my $inf = shift;
     my @errs;
@@ -1025,6 +1083,10 @@ sub createDSInstance {
 
     updateSelinuxPolicy($inf);
 
+    if (@errs = updateTmpfilesDotD($inf)) {
+        return @errs;
+    }
+
     if (@errs = startServer($inf)) {
         return @errs;
     }
@@ -1191,6 +1253,17 @@ sub removeDSInstance {
         }
     }
 
+    my $tmpfilesdir = "@with_tmpfiles_d@";
+    my $tmpfilesname = "$tmpfilesdir/@package_name@-$inst";
+    if ($tmpfilesdir and -d $tmpfilesdir and -f $tmpfilesname) {
+        my $rc = unlink($tmpfilesname);
+        if ( 0 == $rc )
+        {
+            push @errs, [ 'error_removing_path', $tmpfilesname, $! ];
+            debug(1, "Warning: $tmpfilesname was not removed. Error: $!\n");
+        }
+    }
+
     # remove the selinux label from the ports if needed
     if ("@with_selinux@") {
         foreach my $port (@{$entry->{"nsslapd-port"}}) 

+ 7 - 0
ldap/admin/src/scripts/DSMigration.pm.in

@@ -1153,6 +1153,13 @@ sub migrateDS {
 	# ensure any selinux relabeling gets done if needed
         DSCreate::updateSelinuxPolicy($inf);
 
+	# do the tmpfiles.d stuff
+        @errs = DSCreate::updateTmpfilesDotD($inf);
+        if (@errs) {
+            $mig->msg(@errs);
+            goto cleanup;
+        }
+
         # finally, start the server
         if ($mig->{start_servers}) {
             $inf->{slapd}->{start_server} = 1;

+ 3 - 1
ldap/admin/src/scripts/DSUpdate.pm.in

@@ -47,7 +47,7 @@ package DSUpdate;
 use DSUtil;
 use Inf;
 use FileConn;
-use DSCreate qw(setDefaults createInstanceScripts makeOtherConfigFiles updateSelinuxPolicy);
+use DSCreate qw(setDefaults createInstanceScripts makeOtherConfigFiles updateSelinuxPolicy updateTmpfilesDotD);
 
 use File::Basename qw(basename dirname);
 
@@ -408,6 +408,8 @@ sub updateDSInstance {
 
     updateSelinuxPolicy($inf);
 
+    push @errs, updateTmpfilesDotD($inf);
+
     return @errs;
 }
 

文件差異過大導致無法顯示
+ 152 - 378
ltmain.sh


部分文件因文件數量過多而無法顯示