>From 42d1548c7a15408f49bf0e7fc804ecddf1601e27 Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Thu, 1 Oct 2009 15:56:20 -0600
Subject: [PATCH] more updates - add missing rundir - remove ldapiautodnsuffix
 Some older releases did not have nsslapd-rundir - upgrading from
 those releases will cause the server not to start - we must add
 nsslapd-rundir if it is missing
 We also got rid of nsslapd-ldapiautodnsuffix, so remove that from
 the config - it doesn't hurt anything to leave it, but the error
 message is annoying
 I also added back a mostly truncated version of 28pilot.ldif because
 some apps still use pilotObject - those apps should change to
 use a different objectclass ASAP.

---
 Makefile.am                                 |    3 +
 Makefile.in                                 |    3 +
 ldap/admin/src/scripts/10delautodnsuffix.pl |   23 +++++++++++
 ldap/admin/src/scripts/10fixrundir.pl       |   28 +++++++++++++
 ldap/schema/28pilot.ldif                    |   56 +++++++++++++++++++++++++++
 ldap/servers/slapd/main.c                   |    2 +-
 6 files changed, 114 insertions(+), 1 deletions(-)
 create mode 100644 ldap/admin/src/scripts/10delautodnsuffix.pl
 create mode 100644 ldap/admin/src/scripts/10fixrundir.pl
 create mode 100644 ldap/schema/28pilot.ldif

diff --git a/Makefile.am b/Makefile.am
index b8724ca..c34e6fe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -246,6 +246,7 @@ schema_DATA = $(srcdir)/ldap/schema/00core.ldif \
 	$(srcdir)/ldap/schema/10rfc2307.ldif \
 	$(srcdir)/ldap/schema/20subscriber.ldif \
 	$(srcdir)/ldap/schema/25java-object.ldif \
+	$(srcdir)/ldap/schema/28pilot.ldif \
 	$(srcdir)/ldap/schema/30ns-common.ldif \
 	$(srcdir)/ldap/schema/50ns-admin.ldif \
 	$(srcdir)/ldap/schema/50ns-certificate.ldif \
@@ -394,6 +395,8 @@ dist_man_MANS = man/man1/dbscan.1 \
 #------------------------
 update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/exampleupdate.ldif \
+	ldap/admin/src/scripts/10delautodnsuffix.pl \
+	ldap/admin/src/scripts/10fixrundir.pl \
 	ldap/admin/src/scripts/50addchainingsaslpwroles.ldif \
 	ldap/admin/src/scripts/50memberofindex.ldif \
 	ldap/admin/src/scripts/50bitstringsyntaxplugin.ldif \
diff --git a/Makefile.in b/Makefile.in
index 49cde44..4de1cfe 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1291,6 +1291,7 @@ schema_DATA = $(srcdir)/ldap/schema/00core.ldif \
 	$(srcdir)/ldap/schema/10rfc2307.ldif \
 	$(srcdir)/ldap/schema/20subscriber.ldif \
 	$(srcdir)/ldap/schema/25java-object.ldif \
+	$(srcdir)/ldap/schema/28pilot.ldif \
 	$(srcdir)/ldap/schema/30ns-common.ldif \
 	$(srcdir)/ldap/schema/50ns-admin.ldif \
 	$(srcdir)/ldap/schema/50ns-certificate.ldif \
@@ -1441,6 +1442,8 @@ dist_man_MANS = man/man1/dbscan.1 \
 #------------------------
 update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/exampleupdate.ldif \
+	ldap/admin/src/scripts/10delautodnsuffix.pl \
+	ldap/admin/src/scripts/10fixrundir.pl \
 	ldap/admin/src/scripts/50addchainingsaslpwroles.ldif \
 	ldap/admin/src/scripts/50memberofindex.ldif \
 	ldap/admin/src/scripts/50bitstringsyntaxplugin.ldif \
diff --git a/ldap/admin/src/scripts/10delautodnsuffix.pl b/ldap/admin/src/scripts/10delautodnsuffix.pl
new file mode 100644
index 0000000..548a2d1
--- /dev/null
+++ b/ldap/admin/src/scripts/10delautodnsuffix.pl
@@ -0,0 +1,23 @@
+use Mozilla::LDAP::Conn;
+use Mozilla::LDAP::Utils qw(normalizeDN);
+use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn);
+
+sub runinst {
+    my ($inf, $inst, $dseldif, $conn) = @_;
+
+    my @errs;
+
+    # see if nsslapd-ldapiautodnsuffix is defined
+    my $ent = $conn->search("cn=config", "base", "(objectclass=*)");
+    if (!$ent) {
+        return ('error_finding_config_entry', 'cn=config', $conn->getErrorString());
+    }
+
+    if ($ent->getValues('nsslapd-ldapiautodnsuffix')) {
+        $ent->remove('nsslapd-ldapiautodnsuffix');
+        $conn->update($ent);
+        # ignore errors - cn=config attr deletion not allowed over ldap
+    }
+
+    return ();
+}
diff --git a/ldap/admin/src/scripts/10fixrundir.pl b/ldap/admin/src/scripts/10fixrundir.pl
new file mode 100644
index 0000000..a1e7524
--- /dev/null
+++ b/ldap/admin/src/scripts/10fixrundir.pl
@@ -0,0 +1,28 @@
+use Mozilla::LDAP::Conn;
+use Mozilla::LDAP::Utils qw(normalizeDN);
+use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn);
+
+sub runinst {
+    my ($inf, $inst, $dseldif, $conn) = @_;
+
+    my @errs;
+
+    # see if nsslapd-rundir is defined
+    my $ent = $conn->search("cn=config", "base", "(objectclass=*)");
+    if (!$ent) {
+        return ('error_finding_config_entry', 'cn=config', $conn->getErrorString());
+    }
+
+    if (!$ent->getValues('nsslapd-rundir')) {
+        $ent->setValues('nsslapd-rundir', $inf->{slapd}->{run_dir});
+        # mark as modified so update will use a replace instead of an add
+        $ent->attrModified('nsslapd-rundir');
+        $conn->update($ent);
+        my $rc = $conn->getErrorCode();
+        if ($rc) {
+            return ('error_updating_entry', 'cn=config', $conn->getErrorString());
+        }
+    }
+
+    return ();
+}
diff --git a/ldap/schema/28pilot.ldif b/ldap/schema/28pilot.ldif
new file mode 100644
index 0000000..aeaac85
--- /dev/null
+++ b/ldap/schema/28pilot.ldif
@@ -0,0 +1,56 @@
+#
+# BEGIN COPYRIGHT BLOCK
+# This Program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 2 of the License.
+# 
+# This Program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along with
+# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA.
+# 
+# In addition, as a special exception, Red Hat, Inc. gives You the additional
+# right to link the code of this Program with code not covered under the GNU
+# General Public License ("Non-GPL Code") and to distribute linked combinations
+# including the two, subject to the limitations in this paragraph. Non-GPL Code
+# permitted under this exception must only link to the code of this Program
+# through those well defined interfaces identified in the file named EXCEPTION
+# found in the source code files (the "Approved Interfaces"). The files of
+# Non-GPL Code may instantiate templates or use macros or inline functions from
+# the Approved Interfaces without causing the resulting work to be covered by
+# the GNU General Public License. Only Red Hat, Inc. may make changes or
+# additions to the list of Approved Interfaces. You must obey the GNU General
+# Public License in all respects for all of the Program code and other code used
+# in conjunction with the Program except the Non-GPL Code covered by this
+# exception. If you modify this file, you may extend this exception to your
+# version of the file, but you are not obligated to do so. If you do not wish to
+# provide this exception without modification, you must delete this exception
+# statement from your version and license this file solely under the GPL without
+# exception. 
+# 
+# 
+# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
+# Copyright (C) 2005 Red Hat, Inc.
+# All rights reserved.
+# END COPYRIGHT BLOCK
+#
+# This is deprecated and will be removed ASAP.  Some applications still
+# use the pilotObject objectclass, but nothing else, so the contents
+# of this file have been removed except for that definition.  Applications
+# must migrate away from the use of this objectclass.
+# The objectclass also uses the attribute type ditRedirect, which is not
+# used or defined anywhere else.
+# The other attributes are defined in other standard schema like the
+# inetorgperson schema, et. al.
+#
+# Schema from the pilot RFCs, especially RFC 1274, that is no longer 
+# recommended by Netscape for use in new deployments.  Please be aware
+# that future RFCs that succeed RFC 1274 may deprecate some or all of
+# these attribute types and classes.
+#
+dn: cn=schema
+attributeTypes: ( 0.9.2342.19200300.100.1.54 NAME 'ditRedirect' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 X-ORIGIN 'RFC 1274' )
+objectClasses: ( 0.9.2342.19200300.100.4.3 NAME 'pilotObject' DESC 'Standard LDAP objectclass' SUP top MAY ( audio $ dITRedirect $ info $ jpegPhoto $ lastModifiedBy $ lastModifiedTime $ manager $ photo $ uniqueIdentifier ) X-ORIGIN 'RFC 1274' )
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 33e6e11..1d820f3 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -999,7 +999,7 @@ main( int argc, char **argv)
 
 		/* Ensure that we can read from and write to our rundir */
 		if (access(rundir, R_OK | W_OK)) {
-			LDAPDebug(LDAP_DEBUG_ANY, "Unable to access nsslapd-rundir: %s\n",
+			LDAPDebug(LDAP_DEBUG_ANY, "Unable to access " CONFIG_RUNDIR_ATTRIBUTE ": %s\n",
 				slapd_system_strerror(errno), 0, 0);
 			LDAPDebug(LDAP_DEBUG_ANY, "Ensure that user \"%s\" has read and write "
 				"permissions on %s\n",
-- 
1.5.5.6

